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