Salome HOME
DCQ : Merge with Ecole_Ete_a6.
[modules/superv.git] / src / GraphExecutor / DataFlowExecutor_OutNode.hxx
1 //  SUPERV GraphExecutor : contains classes that permit execution of graphs and particularly the execution automaton
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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org 
21 //
22 //
23 //
24 //  File   : DataFlowBase_OutNode.hxx
25 //  Author : Jean Rahuel, CEA
26 //  Module : SUPERV
27 //  $Header:
28
29 #ifndef _DATAFLOWEXECUTOR_OUTNODE_HXX
30 #define _DATAFLOWEXECUTOR_OUTNODE_HXX
31
32 #include "SALOME_Component_i.hxx"
33
34 #include "DataFlowExecutor_InNode.hxx"
35
36 #include "DataFlowBase_StreamGraph.hxx"
37
38 namespace GraphExecutor {
39
40 //  class OutNode : public GraphBase::Graph {
41   class OutNode : public GraphBase::Base {
42
43     private :
44
45       GraphBase::StreamGraph * _StreamGraph ;
46       GraphBase::Graph       * _Graph ;
47
48       int  _Graph_prof_debug ;
49
50       bool                    _PyInitialized ;
51       bool                    _Valid ;
52       bool                    _Executable ;
53       SUPERV::AutomatonState  _State ;
54       SUPERV::ControlState    _ControlState ;
55       bool                    _Done ;
56
57       pthread_mutex_t                  _PyMutexWait ;
58       pthread_mutex_t                  _MutexWait ;
59       pthread_cond_t                   _EventWait ;
60       pthread_cond_t                   _JoinWait ;
61       bool                             _JustStarted ;
62       int                              _Threads ; // Number of threads
63       int                              _SuspendedThreads ;
64       list< char * >                   _EventNodes ;
65       list< GraphExecutor::NodeEvent > _Events ;
66       list< SUPERV::AutomatonState >   _States ;
67
68       bool Valid() ;
69       void UnValid() ;
70       bool Executable() ;
71
72       bool LoadNodes( const GraphBase::ListOfNodes &aNodes ) ;
73       bool LoadLinks( const GraphBase::ListOfLinks &aLinks ) ;
74       bool LoadDatas( const GraphBase::ListOfLinks &aDatas ) ;
75
76       CORBA::ORB_ptr _Orb ;
77
78     public :
79   
80       OutNode() ;
81       OutNode( CORBA::ORB_ptr ORB, SALOME_NamingService* ptrNamingService ,
82                const char *DataFlowName ,
83                const char * DebugFileName ,
84                const SUPERV::KindOfNode aKindOfNode );
85       OutNode( CORBA::ORB_ptr ORB, SALOME_NamingService* ptrNamingService ,
86                const SALOME_ModuleCatalog::Service& DataFlowService ,
87                const char *DataFlowComponentName ,
88                const char *DataFlowInterfaceName ,
89                const char *DataFlowName ,
90                const SUPERV::KindOfNode DataFlowkind ,
91                const SUPERV::SDate DataFlowFirstCreation ,
92                const SUPERV::SDate DataFlowLastModification ,
93                const char * DataFlowEditorRelease ,
94                const char * DataFlowAuthor ,
95                const char * DataFlowComputer ,
96                const char * DataFlowComment ,
97                const char * DebugFileName ) ;
98       virtual ~OutNode() ;
99
100       void Set_prof_debug( CORBA::ORB_ptr ORB , const char * DebugFileName ) ;
101       GraphBase::StreamGraph * StreamGraph() {
102                                return _StreamGraph ; } ;
103       GraphBase::StreamGraph * StreamGraph() const {
104                                return _StreamGraph ; } ;
105       GraphBase::Graph * Graph() {
106                          return _Graph ; } ;
107       GraphBase::Graph * Graph() const {
108                          return _Graph ; } ;
109
110       bool LoadDataFlow( const GraphBase::SGraph &aDataFlow ) ;
111       bool LoadXml( const char* myFileName ) ;
112       bool LoadInfo( const GraphBase::SNode &aDataFlowInfo ) ;
113
114       GraphExecutor::InNode * AddNode(
115                         const SALOME_ModuleCatalog::Service& NodeService ,
116                         GraphBase::ListOfFuncName aFuncName ,
117                         GraphBase::ListOfPythonFunctions aPythonFunction ,
118                         const char * NodeComponentName ,
119                         const char * NodeInterfaceName ,
120                         const char * NodeName ,
121                         const SUPERV::KindOfNode NodeKindOfNode = SUPERV::ComputingNode ,
122                         const SUPERV::SDate NodeFirstCreation = SUPERV::SDate() ,
123                         const SUPERV::SDate NodeLastModification = SUPERV::SDate() ,
124                         const char * NodeEditorRelease = NULLSTRING ,
125                         const char * NodeAuthor = NULLSTRING ,
126                         const char * NodeComputer = NULLSTRING ,
127                         const char * NodeComment = NULLSTRING ,
128                         const int NodeX = 0 ,
129                         const int NodeY = 0 ) ;
130
131       bool AddInputData( const char* ToNodeName1 ,
132                          const char* ToParameterName1 ,
133                          const char* ToNodeName2 ,
134                          const char* ToParameterName2 ) ;
135
136       bool IsValid() { if ( !_Valid )
137                          return Valid() ;
138                        return _Valid ; } ;
139       bool IsExecutable() { if ( !_Executable )
140                                 return Executable() ;
141                             return _Executable ; } ;
142
143       bool Run( const bool AndSuspend ) ;
144       bool Run( const char * aNodeName , const char * AtNodeName ,
145                 const bool AndSuspend ) ;
146
147       void PyInitialized( bool init ) {
148            _PyInitialized = init ; } ;
149       bool PyInitialized() {
150            return _PyInitialized ; } ;
151
152       void CheckAllDone() ;
153
154       void PThreadLock( pthread_mutex_t * aMutex , char * errmsg ) ;
155       void PThreadUnLock( pthread_mutex_t * aMutex , char * errmsg ) ;
156       void PyThreadLock() ;
157       void PyThreadUnLock() ;
158
159       void NewThread() ;
160       void ExitThread() ;
161       void SuspendThread() ;
162       void ResumeThread() ;
163       long Threads() { return _Threads ; } ;
164       long SuspendedThreads() { return _SuspendedThreads ; } ;
165       void JoinedWait() ;
166
167       pthread_t ThreadNo() {
168                 return _Graph->ThreadNo() ; } ;
169       long Thread( const char * NodeName ) ;
170
171       bool PushEvent( GraphExecutor::InNode * aNode ,
172                       GraphExecutor::NodeEvent anEvent ,
173                       SUPERV::AutomatonState aState ) ;
174       int GetListSize();
175       bool StateWait( SUPERV::GraphState aState ) ;
176       bool Event( char ** aNodeName ,
177                   SUPERV::GraphEvent & anEvent ,
178                   SUPERV::GraphState & aState ,
179                   bool WithWait ) ;
180       bool EventW( char ** aNodeName ,
181                    SUPERV::GraphEvent & anEvent ,
182                    SUPERV::GraphState & aState ) ;
183       bool EventWait( char ** aNodeName ,
184                       SUPERV::GraphEvent & anEvent ,
185                       SUPERV::GraphState & aState ) ;
186       long EventQSize() ;
187       void EventList() ;
188
189       void State(SUPERV::AutomatonState aState ) ;
190       const char * StateName(SUPERV::AutomatonState aState ) {
191              return theAutomaton->StateName( aState ) ; }
192
193       SUPERV::GraphState State() ;
194       SUPERV::GraphState State( const char * NodeName ) ;
195       SUPERV::GraphState State( const char * NodeName ,
196                                 const char * ServiceParameterName ) ;
197
198       SUPERV::GraphEvent AutomatonGraphEvent(GraphExecutor::NodeEvent anEvent) ;
199       SUPERV::GraphState AutomatonGraphState(SUPERV::AutomatonState anAutomatonState) ;
200
201       SUPERV::AutomatonState AutomatonState() ;
202       SUPERV::AutomatonState AutomatonState( const char * NodeName ) ;
203
204       SUPERV::ControlState ControlState() ;
205       SUPERV::ControlState ControlState( const char * aNodeName ) ;
206       void ControlClear() ;
207       void ControlClear( const char * aNodeName ) ;
208
209       bool ContainerKill() ;
210
211       bool Suspend() ;
212       bool Resume() ;
213       bool Kill() ;
214       bool Stop() ;
215       bool ReRun() ;
216       bool ReStart() ;
217
218       bool IsWaiting() ;
219       bool IsReady() ;
220       bool IsRunning() ;
221       void Done( bool aDone ) { _Done = aDone ; } ;
222       bool Done() { return _Done ; } ;
223       bool IsDone() ;
224       bool IsSuspended() ;
225       bool IsKilled() ;
226       bool IsStopped() ;
227       bool IsWaiting( const char * NodeName ) ;
228       bool IsReady( const char * NodeName ) ;
229       bool IsRunning( const char * NodeName ) ;
230       bool IsDone( const char * NodeName ) ;
231       bool IsSuspended( const char * NodeName ) ;
232       bool IsDone( const char * NodeName ,
233                    const char * ServiceParameterName ) ;
234       long LastLevelDone() ;
235
236       bool ReadyWait() ;
237       bool RunningWait() ;
238       bool DoneWait() ;
239       bool SuspendedWait() ;
240       bool ReadyWait( const char * NodeName ) ;
241       bool RunningWait( const char * NodeName ) ;
242       bool DoneWait( const char * NodeName ) ;
243       bool SuspendedWait( const char * NodeName ) ;
244
245       const CORBA::Any *GetInData( const char *ToNodeName ,
246                                    const char *ToParameterName ) ;
247       const CORBA::Any *GetOutData( const char *FromNodeName ,
248                                     const char *FromParameterName ) ;
249       const long CpuUsed() ;
250       const long CpuUsed( const char *aNodeName ) ;
251   };
252 };
253
254 #endif