Salome HOME
MacroNodes and omniORB4 porting and state of nodes when an other node has aborted
[modules/superv.git] / src / GraphExecutor / DataFlowExecutor_FiniteStateMachine.hxx
index f99c1914eef181fe93c073fad6d5b784551249f6..f03fbdf7bf99189a714d36ced803fb2697a63169 100644 (file)
@@ -45,6 +45,8 @@
 //#include CORBA_SERVER_HEADER(SUPERV)
 #include <SALOME_LifeCycleCORBA.hxx>
 
+class Graph_Impl ;
+
 namespace GraphBase {
   class Graph ;
 }
@@ -72,9 +74,9 @@ namespace GraphExecutor {
                         SuspendedErroredState,
                         ResumedSuccessedState ,
                         ResumedErroredState ,
-                            KilledSuccessedState ,
+                       KilledSuccessedState ,
                         KilledErroredState ,
-                            StoppedSuccessedState ,
+                       StoppedSuccessedState ,
                         StoppedErroredState ,
                         SuccessedState ,
                         ErroredState ,
@@ -83,48 +85,69 @@ namespace GraphExecutor {
                         StoppedState ,
                         SuspendedSuccessedToReStartState ,
                         SuspendedErroredToReStartState ,
-                        ReRunnedState ,
                         ReStartedState ,
+                       LoadingState,
                         NumberOfAutomatonStates } ;
 
-  enum NodeEvent { UndefinedEvent , NewThreadEvent ,
-                     SuspendEvent , ToResumeEvent  , ResumeEvent ,
-                     KillEvent , StopEvent ,
-                     ExecuteEvent , SuccessEvent , ErrorEvent ,
-                     ToReStartEvent , ReStartEvent , ReStartAndSuspendEvent ,
-                     EndExecuteEvent ,
-                   NoDataReadyEvent , SomeDataReadyEvent ,
-                   NotAllDataReadyEvent , AllDataReadyEvent ,
-                     ReadyEvent , SuspendedReadyEvent ,ResumedReadyEvent ,
-                     KilledReadyEvent , StoppedReadyEvent ,
-                   ExecutingEvent , SuspendedExecutingEvent ,
-                   ResumedExecutingEvent , KilledExecutingEvent ,
+  enum NodeEvent { UndefinedEvent , 
+                   NewThreadEvent ,        
+                   SuspendEvent , 
+                   ToResumeEvent  , 
+                   ResumeEvent ,
+                   KillEvent , 
+                   StopEvent ,
+                   ExecuteEvent , 
+                   SuccessEvent , 
+                   ErrorEvent ,
+                   ToReStartEvent , 
+                   ReStartEvent , 
+                   ReStartAndSuspendEvent ,
+                   EndExecuteEvent ,
+                   NoDataReadyEvent , 
+                   SomeDataReadyEvent ,
+                   NotAllDataReadyEvent , 
+                   AllDataReadyEvent ,
+                   ReadyEvent , 
+                   SuspendedReadyEvent ,
+                   ResumedReadyEvent ,
+                   KilledReadyEvent , 
+                   StoppedReadyEvent ,
+                   ExecutingEvent , 
+                   SuspendedExecutingEvent ,
+                   ResumedExecutingEvent , 
+                   KilledExecutingEvent ,
                    StoppedExecutingEvent ,
-                     SuccessedExecutingEvent , ErroredExecutingEvent ,
-                     SuspendedSuccessedEvent , SuspendedErroredEvent ,
-                     ResumedSuccessedEvent , ResumedErroredEvent ,
-                     KilledEvent , StoppedEvent ,
-                   ReStartedEvent , ReStartedAndSuspendEvent ,
-                     NumberOfEvents } ;
+                   SuccessedExecutingEvent , 
+                   ErroredExecutingEvent ,
+                   SuspendedSuccessedEvent , 
+                   SuspendedErroredEvent ,
+                   ResumedSuccessedEvent , 
+                   ResumedErroredEvent ,
+                   KilledEvent , 
+                   StoppedEvent ,
+                   ReStartedEvent , 
+                   ReStartedAndSuspendEvent ,
+                   NumberOfEvents } ;
 
   enum StateEventAction { ErrorAction ,
                           VoidAction ,
                           executeAction , // +- pthread_create
                           ExecuteAction , // +- pthread_create
-                            DataWaiting_SomeDataReadyAction ,
-                            DataUndef_NotAllDataReadyAction ,
-                            DataUndef_AllDataReadyAction ,
+                          DataWaiting_SomeDataReadyAction ,
+                          DataUndef_NotAllDataReadyAction ,
+                          DataUndef_AllDataReadyAction ,
                           DataReady_SuspendAction ,
                           SuspendedReady_ResumeAction ,
                           DataReady_KillAction ,
                           DataReady_StopAction ,
-                            DataReady_ExecuteAction ,
+                          DataReady_ExecuteAction ,
                           Executing_SuspendAction ,
                           SuspendedExecuting_ResumeAction ,
                           Executing_KillAction ,
                           Executing_StopAction ,
-                            Executing_SuccessAction ,
-                            Executing_ErrorAction ,
+                          Executing_SuccessAction ,
+//                          Executing_ErrorAction ,
+                          Errored_ExecutingAction ,
                           Successed_SuccessAction ,
                           Errored_ErrorAction ,
                           Successed_SuspendAction ,
@@ -135,10 +158,10 @@ namespace GraphExecutor {
                           Errored_KillAction ,
                           Successed_StopAction ,
                           Errored_StopAction ,
-                            SuspendedSuccessed_ReStartAction ,
-                            SuspendedErrored_ReStartAction ,
-                            SuspendedSuccessed_ReStartAndSuspendAction ,
-                            SuspendedErrored_ReStartAndSuspendAction ,
+                          SuspendedSuccessed_ReStartAction ,
+                          SuspendedErrored_ReStartAction ,
+                          SuspendedSuccessed_ReStartAndSuspendAction ,
+                          SuspendedErrored_ReStartAndSuspendAction ,
                           NumberOfActions } ;
 
   class FiniteStateMachine {
@@ -156,6 +179,8 @@ namespace GraphExecutor {
                                                   [ GraphExecutor::NumberOfEvents ] ;
 
       pthread_mutex_t            _MutexPythonWait ;
+      bool                       _MutexPythonLocked ;
+// Map between FuncName and corresponding Python Object Function
       map< string , PyObject * > _MapOfPyFunctions ;
       bool                       _PyInitModule ;
       int                        _ExecNumber ;
@@ -173,6 +198,8 @@ namespace GraphExecutor {
       pthread_cond_t    _JoinWait ;
       list< pthread_t > _ThreadList ;
 
+      Graph_Impl * _GraphImpl ;
+
     public :
 
       FiniteStateMachine() ;
@@ -180,11 +207,14 @@ namespace GraphExecutor {
 
       int ExecNumber() ;
       void Executed() ;
+      void PyInitModule(bool) ;
       bool PyInitModule() ;
       void PyLock() ;
       void PyUnLock() ;
+      void PyLockReset() ;
       bool PyFunction( const char * aPyFuncName , PyObject * aPyFunction ) ;
       PyObject * PyFunction( const char * aPyFuncName ) ;
+      bool ErasePyFunction( const char * aPyFuncName ) ;
 
 
       string DbgFileNumber() {
@@ -221,6 +251,11 @@ namespace GraphExecutor {
       const GraphExecutor::StateEventAction NextAction( const GraphExecutor::AutomatonState & aState ,
                                                         const GraphExecutor::NodeEvent & anEvent ) const {
             return _ActionTable[ aState ][ anEvent ] ; } ;
+
+    void GraphImpl( Graph_Impl * aGraphImpl ) {// For GraphMNode ...
+         _GraphImpl = aGraphImpl ; } ;
+    Graph_Impl * GraphImpl() {
+                 return _GraphImpl ; } ;
   };
 
 };