Salome HOME
Join modifications from BR_Dev_For_4_0 tag V4_1_1.
[modules/superv.git] / src / Supervision / Graph_Impl.hxx
1 //  SUPERV Supervision : contains the implementation of interfaces of SuperVision described in SUPERV.idl
2 //
3 //  Copyright (C) 2003  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 //  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS 
5 // 
6 //  This library is free software; you can redistribute it and/or 
7 //  modify it under the terms of the GNU Lesser General Public 
8 //  License as published by the Free Software Foundation; either 
9 //  version 2.1 of the License. 
10 // 
11 //  This library is distributed in the hope that it will be useful, 
12 //  but WITHOUT ANY WARRANTY; without even the implied warranty of 
13 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU 
14 //  Lesser General Public License for more details. 
15 // 
16 //  You should have received a copy of the GNU Lesser General Public 
17 //  License along with this library; if not, write to the Free Software 
18 //  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA 
19 // 
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 //
22 //
23 //
24 //  File   : Graph_Impl.hxx
25 //  Author : Jean Rahuel
26 //  Module : SUPERV
27 //  $Header: 
28
29 #ifndef _GRAPH_IMPL_HXX_
30 #define _GRAPH_IMPL_HXX_
31
32 //#include <iostream.h>
33
34 #include "CORBA.h"
35
36 #include <SALOMEconfig.h>
37 #include "SALOME_Component_i.hxx"
38 #include "SALOME_LifeCycleCORBA.hxx"
39
40 #include "StreamLink_Impl.hxx"
41 #include "FNode_Impl.hxx"
42 #include "GNode_Impl.hxx"
43 #include "LNode_Impl.hxx"
44 #include "ELNode_Impl.hxx"
45 #include "SNode_Impl.hxx"
46 #include "ESNode_Impl.hxx"
47
48 #include "DataFlowEditor_DataFlow.hxx"
49 #include "DataFlowExecutor_DataFlow.hxx"
50
51 class Graph_Impl : public POA_SUPERV::Graph ,
52                    public GNode_Impl {
53   private:
54
55     CORBA::ORB_ptr             _Orb ;
56     PortableServer::POA_ptr    _Poa ;
57     PortableServer::ObjectId * _ContId ;
58
59     SALOME_NamingService *     _NamingService ;
60     char * _DebugFileName ;
61
62     pthread_mutex_t            _MutexExecutorWait ;
63 //    GraphExecutor::DataFlow *  _DataFlowExecutor ;
64
65     SUPERV::Graph_var          myServant; // mpv 23.12.2002: store servant of graph to get constant IOR
66
67   public:
68     Graph_Impl();
69     Graph_Impl( CORBA::ORB_ptr orb ,
70                 PortableServer::POA_ptr poa ,
71                 PortableServer::ObjectId * contId , 
72                 const char *instanceName ,
73                 const char *interfaceName ,
74                 const char *aDataFlowName ,
75                 const SUPERV::KindOfNode aKindOfNode ) ;
76     Graph_Impl( CORBA::ORB_ptr orb ,
77                 PortableServer::POA_ptr poa ,
78                 PortableServer::ObjectId * contId , 
79                 const char *instanceName ,
80                 const char *interfaceName ,
81                 GraphEditor::DataFlow * DataFlowEditor ,
82                 GraphEditor::InNode * DataFlowNode ) ;
83     virtual SUPERV::Graph_ptr Copy() ;
84
85     virtual ~Graph_Impl() ;
86     virtual void destroy() ;
87
88     void DebugFileName( char * aDebugFileName ) {
89          _DebugFileName = my_strdup( aDebugFileName ) ; } ;
90     char * DebugFileName() {
91            return _DebugFileName ; } ;
92
93     virtual char* getIOR();
94
95     virtual void ReadOnly() ;
96
97     virtual SUPERV::INode_ptr Node() ;
98
99 //    virtual char * DataFlowInfo() ;
100 //    virtual char * DataNodeInfo() ;
101 //    virtual char * NodeInfo( const char * aNodeName ) ;
102
103     virtual GraphBase::ListOfSGraphs * GetGraphs() ;
104
105     virtual bool LoadGraphs( GraphBase::ListOfSGraphs *aListOfGraphs ) ;
106     virtual bool Import(const char * aXmlFile ) ;
107
108     virtual bool Export(const char * aXmlFile ) ;
109
110     virtual char * SavePY( bool importSuperV ) ;
111
112     virtual SUPERV::CNode_ptr CNode(
113                           const SALOME_ModuleCatalog::Service &NodeService ) ;
114     virtual SUPERV::FNode_ptr FNode(
115                           const char * NodeComponentName ,
116                           const char * InterfaceName ,
117                           const SALOME_ModuleCatalog::Service &NodeService ,
118                           const SALOME_ModuleCatalog::ImplType ImplType ) ; // mkr : PAL11273 : C++ implementation by default
119     virtual SUPERV::INode_ptr INode(
120                           const char * FuncName ,
121                           const SUPERV::ListOfStrings & PythonFunction ) ;
122     virtual SUPERV::GNode_ptr GNode(
123                           const char * FuncName ,
124                           const SUPERV::ListOfStrings & PythonFunction ,
125                           const char * anInLineNode ) ;
126     virtual SUPERV::LNode_ptr LNode(
127                           const char * InitName ,
128                           const SUPERV::ListOfStrings & InitFunction ,
129                           const char * MoreName ,
130                           const SUPERV::ListOfStrings & MoreFunction ,
131                           const char * NextName ,
132                           const SUPERV::ListOfStrings & NextFunction ,
133                           SUPERV::INode_out anEndOfLoop ) ;
134     virtual SUPERV::SNode_ptr SNode(
135                           const char * FuncName ,
136                           const SUPERV::ListOfStrings & PythonFunction ,
137                           SUPERV::INode_out anEndOfSwitch ) ;
138
139     SUPERV::Graph_var LoadDataFlows( GraphEditor::DataFlow * aDataFlowEditor ,
140                                      GraphBase::ListOfSGraphs * aListOfDataFlows ,
141                                      int index ) ;
142     SUPERV::Graph_var LoadDataFlows( GraphExecutor::DataFlow * aDataFlowExecutor ,
143                                      GraphBase::ListOfSGraphs * aListOfDataFlows ,
144                                      int index ) ;
145     virtual SUPERV::Graph_ptr MNode( const char * aXmlFileName ) ;
146
147     virtual SUPERV::Graph_ptr MNode( GraphEditor::DataFlow * aDataFlowEditor ,
148                                      GraphBase::ListOfSGraphs * aListOfDataFlows ) ;
149
150     virtual SUPERV::Graph_ptr GraphMNode( SUPERV::Graph_ptr aGraph ) ;
151
152     virtual SUPERV::Graph_ptr FlowObjRef() ;
153
154     virtual SUPERV::StreamGraph_ptr StreamObjRef() ;
155
156     virtual SUPERV::CNode_ptr Node( const char * NodeName );
157
158     virtual SUPERV::Link_ptr Link( SUPERV::Port_ptr OutPort ,
159                                    SUPERV::Port_ptr InPort ) ;
160
161     virtual SUPERV::ListOfNodes_var SetNode( SUPERV::ListOfNodes_var RetVal ,
162                                                          GraphBase::ComputingNode * aNode ) ;
163     virtual SUPERV::ListOfNodes * Nodes() ;
164     virtual void SetNodeObjRef( GraphEditor::InNode * anInNode ) ;
165
166     virtual SUPERV::ListOfLinks * GLinks() ;
167     virtual SUPERV::ListOfLinks * Links( GraphBase::ComputingNode * aNode ,
168                                          const char * anInputParam ) ;
169
170     virtual Engines::Component_ptr ComponentRef( const char * aComputerContainer ,
171                                                  const char * aComponentName ) ;
172
173     virtual char * Messages() ;
174
175     virtual bool IsValid() ;
176     virtual bool IsExecutable() ;
177
178     virtual bool IsEditing() ;
179     virtual CORBA::Boolean IsExecuting() ;
180
181     virtual bool IsReadOnly() ;
182
183     virtual CORBA::Long LevelMax() ;
184     virtual SUPERV::ListOfNodes * LevelNodes(CORBA::Long aLevel ) ;
185     virtual CORBA::Long ThreadsMax() ;
186     virtual CORBA::Long Threads() ;
187     virtual CORBA::Long SuspendedThreads() ;
188
189     virtual bool Run() ;   // called on "Execute Graph" command
190     virtual bool Start() ; // called on "Execute Graph Step-by-Step" command
191  
192     virtual bool Begin() ;
193     virtual CORBA::Long LastLevelDone() ;
194
195     virtual bool EventNoW( SUPERV::CNode_out aNode ,
196                            SUPERV::GraphEvent & anEvent ,
197                            SUPERV::GraphState & aState ) ;
198     virtual bool Event( SUPERV::CNode_out aNode ,
199                         SUPERV::GraphEvent & anEvent ,
200                         SUPERV::GraphState & aState ) ;
201     virtual bool EventW( SUPERV::CNode_out aNode ,
202                          SUPERV::GraphEvent & anEvent ,
203                          SUPERV::GraphState & aState ) ;
204     virtual CORBA::Long EventQSize() ;
205
206     virtual CORBA::Long SubGraphsNumber() ;
207     virtual SUPERV::ListOfNodes * SubGraphsNodes( CORBA::Long aSubGraphNumber ) ;
208
209     virtual bool Merge(const SUPERV::Graph_ptr aGraph ) ;
210     virtual bool Merge(const SUPERV::Graph_ptr aGraph , map< string , int > & aMapOfNodes ) ;
211
212     virtual SUPERV::StreamGraph_ptr ToStreamGraph() ;
213
214     virtual void Editing(); // Destroy Executor and use only Editor and its data model
215   
216     virtual char* DefaultCContainerName() ;
217     virtual char* DefaultPythonContainerName() ;
218     virtual char* ContainerNameForComponent( const char * theComponentName) ;
219
220 private:
221     bool run( const bool andSuspend = false ); // Run() calls run( false ), Start() calls run( true );
222
223 };
224
225
226 #endif