]> SALOME platform Git repositories - modules/superv.git/blobdiff - src/Supervision/Graph_Impl.cxx
Salome HOME
Join modifications from BR_Dev_For_4_0 tag V4_1_1.
[modules/superv.git] / src / Supervision / Graph_Impl.cxx
index a00e43fd791c8bbf36ec48cacd66db7348d0173b..bbc0feca64336ecf870de88d2193f2b0efb15b24 100644 (file)
@@ -17,7 +17,7 @@
 //  License along with this library; if not, write to the Free Software 
 //  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA 
 // 
-//  See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org 
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
 //
 //
 //
@@ -401,9 +401,20 @@ SUPERV::CNode_ptr Graph_Impl::CNode( const SALOME_ModuleCatalog::Service &NodeSe
 SUPERV::FNode_ptr Graph_Impl::FNode( const char * NodeComponentName ,
                                      const char * NodeInterfaceName ,
                                      const SALOME_ModuleCatalog::Service &NodeService ,
-                                    bool isCimpl ) {
+                                    const SALOME_ModuleCatalog::ImplType ImplType ) {
   beginService( "Graph_Impl::FNode" );
   SUPERV::FNode_var iobject = SUPERV::FNode::_nil() ;
+  bool isCimpl = true;
+  switch (ImplType)
+  {
+  case SALOME_ModuleCatalog::PY:
+    isCimpl = false;
+    break;
+  case SALOME_ModuleCatalog::SO:
+  case SALOME_ModuleCatalog::EXE:
+  default:
+    ;
+  }
   if ( DataFlowEditor()->IsEditing() && !DataFlowEditor()->IsReadOnly() && !IsMacro() ) {
     FNode_Impl * myNode = new FNode_Impl( _Orb , _Poa , _ContId ,
                                           instanceName() , interfaceName() ,
@@ -516,12 +527,12 @@ SUPERV::LNode_ptr Graph_Impl::LNode( const char * InitName ,
       SALOME_ModuleCatalog::Service aVoidService = SALOME_ModuleCatalog::Service() ;
       char * anEndName ;
       if ( strlen( InitName ) ) {
-        anEndName = new char( 3 + strlen( InitName ) + 1 ) ;
+        anEndName = new char[ 3 + strlen( InitName ) + 1 ];
         strcpy( anEndName , "End" ) ;
         strcat( anEndName , InitName ) ;
       }
       else {
-        anEndName = new char( 3 + strlen( "Loop" ) + 1 ) ;
+        anEndName = new char[ 3 + strlen( "Loop" ) + 1 ];
         strcpy( anEndName , "EndLoop" ) ;
       }
       ELNode_Impl * myEndNode = new ELNode_Impl( _Orb , _Poa , _ContId ,
@@ -589,10 +600,11 @@ SUPERV::SNode_ptr Graph_Impl::SNode( const char * FuncName ,
       myEndNode->SetObjRef( SUPERV::ESNode::_duplicate( iendobject ) ) ;
       myNode->SetCoupled( myEndNode->BaseNode()->Name() ) ;
       myEndNode->SetCoupled( myNode->BaseNode()->Name() ) ;
-      if ( !Link( myNode->Port( "Default" ) , myEndNode->Port( "Default" ) ) ) {
-        iobject = SUPERV::SNode::_nil() ;
-        iendobject = SUPERV::ESNode::_nil() ;
-      }
+//JR NPAL14793 05.02.2007 : do not add that link
+//      if ( !Link( myNode->Port( "Default" ) , myEndNode->Port( "Default" ) ) ) {
+//        iobject = SUPERV::SNode::_nil() ;
+//        iendobject = SUPERV::ESNode::_nil() ;
+//      }
     }
   }
   anEndOfSwitch = SUPERV::ESNode::_duplicate( iendobject ) ;
@@ -812,6 +824,7 @@ SUPERV::Graph_var Graph_Impl::LoadDataFlows( GraphExecutor::DataFlow * aDataFlow
          GraphExecutor::DataFlow * aMacroGraphExecutor ;
          CreateExecutor( _Orb , instanceName() , aMacroGraphName , SUPERV::DataStreamGraph ,
                        dbgfile , &aMacroGraphExecutor );
+          theAutomaton->Executed() ; // Decrement _GraphExecutingNumber for MacroSubGraph
 
        // set GraphMacroLevel for Executor's graph
          GraphBase::Graph* aMacroGraphExe = aMacroGraphExecutor->Graph();
@@ -1743,16 +1756,16 @@ bool Graph_Impl::IsReadOnly() {
   return RetVal ;
 }
 
-long Graph_Impl::LevelMax() {
+CORBA::Long Graph_Impl::LevelMax() {
 //  beginService( "Graph_Impl::LevelMax" );
-  long RetVal = 0 ;
+  CORBA::Long RetVal = 0 ;
   if ( !IsMacro() ) {
     RetVal = DataFlowEditor()->LevelMax() ;
   }
 //  endService( "Graph_Impl::LevelMax" );
   return RetVal ;
 }
-SUPERV::ListOfNodes * Graph_Impl::LevelNodes(long aLevel ) {
+SUPERV::ListOfNodes * Graph_Impl::LevelNodes(CORBA::Long aLevel ) {
 //  beginService( "Graph_Impl::LevelNodes" );
   SUPERV::ListOfNodes_var RetVal = new SUPERV::ListOfNodes;
   if ( !IsMacro() ) {
@@ -1778,27 +1791,27 @@ SUPERV::ListOfNodes * Graph_Impl::LevelNodes(long aLevel ) {
 //  endService( "Graph_Impl::LevelNodes" );
   return ( RetVal._retn() ) ;
 }
-long Graph_Impl::ThreadsMax() {
+CORBA::Long Graph_Impl::ThreadsMax() {
 //  beginService( "Graph_Impl::ThreadsMax" );
-  long RetVal = 0 ;
+  CORBA::Long RetVal = 0 ;
   if ( !IsMacro() ) {
     RetVal =  DataFlowEditor()->ThreadsMax() ;
   }
 //  endService( "Graph_Impl::ThreadsMax" );
   return RetVal ;
 }
-long Graph_Impl::Threads() {
+CORBA::Long Graph_Impl::Threads() {
 //  beginService( "Node_Impl::Threads" );
-  long RetVal = false ;
+  CORBA::Long RetVal = false ;
   if ( !IsMacro() ) {
     RetVal = DataFlowExecutor()->Threads() ;
   }
 //  endService( "Node_Impl::Threads" );
   return RetVal ;
 }
-long Graph_Impl::SuspendedThreads() {
+CORBA::Long Graph_Impl::SuspendedThreads() {
 //  beginService( "Node_Impl::SuspendedThreads" );
-  long RetVal = false ;
+  CORBA::Long RetVal = false ;
   if ( !IsMacro() ) {
     RetVal = DataFlowExecutor()->SuspendedThreads() ;
   }
@@ -2021,9 +2034,9 @@ bool Graph_Impl::EventW( SUPERV::CNode_out aNode ,
   return RetVal ;
 }
 
-long Graph_Impl::EventQSize() {
+CORBA::Long Graph_Impl::EventQSize() {
 //  beginService( "Graph_Impl::EventQSize" );
-  long QSize = -1 ;
+  CORBA::Long QSize = -1 ;
   if ( pthread_mutex_lock( &_MutexExecutorWait ) ) {
     perror("pthread_mutex_lock _MutexExecutorWait") ;
     exit( 0 ) ;
@@ -2039,13 +2052,13 @@ long Graph_Impl::EventQSize() {
   return QSize ;
 }
 
-long Graph_Impl::LastLevelDone() {
+CORBA::Long Graph_Impl::LastLevelDone() {
 //  beginService( "Graph_Impl::LastLevelDone" );
   if ( pthread_mutex_lock( &_MutexExecutorWait ) ) {
     perror("pthread_mutex_lock _MutexExecutorWait") ;
     exit( 0 ) ;
   }
-  long RetVal = 0 ;
+  CORBA::Long RetVal = 0 ;
   if ( DataFlowExecutor() && !IsMacro() ) {
     RetVal = DataFlowExecutor()->LastLevelDone() ;
   }
@@ -2057,9 +2070,9 @@ long Graph_Impl::LastLevelDone() {
   return RetVal ;
 }
 
-long Graph_Impl::SubGraphsNumber() {
+CORBA::Long Graph_Impl::SubGraphsNumber() {
 //  beginService( "Graph_Impl::SubGraphsNumber" );
-  long RetVal = 0 ;
+  CORBA::Long RetVal = 0 ;
   if ( DataFlowEditor()->IsExecutable() && !IsMacro() ) {
     RetVal = DataFlowEditor()->SubGraphsNumber() ;
   }
@@ -2067,7 +2080,7 @@ long Graph_Impl::SubGraphsNumber() {
   return RetVal ;
 }
 
-SUPERV::ListOfNodes * Graph_Impl::SubGraphsNodes( const long aSubGraphNumber ) {
+SUPERV::ListOfNodes * Graph_Impl::SubGraphsNodes( CORBA::Long aSubGraphNumber ) {
   beginService( "Graph_Impl::SubGraphsNodes" );
   SUPERV::ListOfNodes_var RetVal = new SUPERV::ListOfNodes ;
   if ( DataFlowEditor()->IsEditing() && !IsMacro() ) {
@@ -2187,10 +2200,12 @@ bool Graph_Impl::Merge(const SUPERV::Graph_ptr aGraph , map< string , int > & aM
     if ( RetVal ) {
       for ( i = 0 ; i < (int ) aGraphNodes->FNodes.length() ; i++ ) {
         SUPERV::FNode_var aNode = (aGraphNodes->FNodes)[ i ] ;
+        SALOME_ModuleCatalog::ImplType implType = SALOME_ModuleCatalog::SO;
+        if (!aNode->IsCimpl()) implType = SALOME_ModuleCatalog::PY;
         SUPERV::FNode_ptr myNode = FNode( aNode->GetComponentName() ,
                                           aNode->GetInterfaceName() ,
                                           *(aNode->Service()) ,
-                                         aNode->IsCimpl() ) ; // mkr : PAL11273
+                                         implType ) ; // mkr : PAL11273
         if ( !CORBA::is_nil( myNode ) ) {
           myNode->SetName( aNode->Name() ) ;
           myNode->SetAuthor( aNode->Author() ) ;
@@ -2245,10 +2260,10 @@ bool Graph_Impl::Merge(const SUPERV::Graph_ptr aGraph , map< string , int > & aM
             SUPERV::ListOfStreamPorts myStreamPorts = *(aNode->StreamPorts()) ;
             for ( j = 0 ; j < (int ) myStreamPorts.length() ; j++ ) {
               if ( myStreamPorts[ j ]->IsInput() ) {
-                aPort = myNode->InStreamPort( myStreamPorts[ j ]->Name() , StringToDataStreamType( myStreamPorts[ j ]->Type() ) , myStreamPorts[ j ]->Dependency() ) ;
+                aPort = myNode->InStreamPort( myStreamPorts[ j ]->Name(), myStreamPorts[ j ]->Type(), myStreamPorts[ j ]->Dependency() ) ;
              }
               else {
-                aPort = myNode->OutStreamPort( myStreamPorts[ j ]->Name() , StringToDataStreamType( myStreamPorts[ j ]->Type() ) , myStreamPorts[ j ]->Dependency() ) ;
+                aPort = myNode->OutStreamPort( myStreamPorts[ j ]->Name(), myStreamPorts[ j ]->Type(), myStreamPorts[ j ]->Dependency() ) ;
              }
            }
          }
@@ -2287,10 +2302,10 @@ bool Graph_Impl::Merge(const SUPERV::Graph_ptr aGraph , map< string , int > & aM
             SUPERV::ListOfStreamPorts myStreamPorts = *(aNode->StreamPorts()) ;
             for ( j = 0 ; j < (int ) myStreamPorts.length() ; j++ ) {
               if ( myStreamPorts[ j ]->IsInput() ) {
-                aPort = myNode->InStreamPort( myStreamPorts[ j ]->Name() , StringToDataStreamType( myStreamPorts[ j ]->Type() ) , myStreamPorts[ j ]->Dependency() ) ;
+                aPort = myNode->InStreamPort( myStreamPorts[ j ]->Name(), myStreamPorts[ j ]->Type(), myStreamPorts[ j ]->Dependency() ) ;
              }
               else {
-                aPort = myNode->OutStreamPort( myStreamPorts[ j ]->Name() , StringToDataStreamType( myStreamPorts[ j ]->Type() ) , myStreamPorts[ j ]->Dependency() ) ;
+                aPort = myNode->OutStreamPort( myStreamPorts[ j ]->Name(), myStreamPorts[ j ]->Type(), myStreamPorts[ j ]->Dependency() ) ;
              }
            }
          }
@@ -2336,10 +2351,10 @@ bool Graph_Impl::Merge(const SUPERV::Graph_ptr aGraph , map< string , int > & aM
             SUPERV::ListOfStreamPorts myStreamPorts = *(aNode->StreamPorts()) ;
             for ( j = 0 ; j < (int ) myStreamPorts.length() ; j++ ) {
               if ( myStreamPorts[ j ]->IsInput() ) {
-                aPort = myNode->InStreamPort( myStreamPorts[ j ]->Name() , StringToDataStreamType( myStreamPorts[ j ]->Type() ) , myStreamPorts[ j ]->Dependency() ) ;
+                aPort = myNode->InStreamPort( myStreamPorts[ j ]->Name(), myStreamPorts[ j ]->Type(), myStreamPorts[ j ]->Dependency() ) ;
              }
               else {
-                aPort = myNode->OutStreamPort( myStreamPorts[ j ]->Name() , StringToDataStreamType( myStreamPorts[ j ]->Type() ) , myStreamPorts[ j ]->Dependency() ) ;
+                aPort = myNode->OutStreamPort( myStreamPorts[ j ]->Name(), myStreamPorts[ j ]->Type(), myStreamPorts[ j ]->Dependency() ) ;
              }
            }
          }
@@ -2355,10 +2370,10 @@ bool Graph_Impl::Merge(const SUPERV::Graph_ptr aGraph , map< string , int > & aM
             SUPERV::ListOfStreamPorts myStreamLoopPorts = *(myEndOfLoop->StreamPorts()) ;
             for ( j = 0 ; j < (int ) myStreamLoopPorts.length() ; j++ ) {
               if ( myStreamLoopPorts[ j ]->IsInput() ) {
-                aPort = myNode->InStreamPort( myStreamLoopPorts[ j ]->Name() , StringToDataStreamType( myStreamLoopPorts[ j ]->Type() ) , myStreamLoopPorts[ j ]->Dependency() ) ;
+                aPort = myNode->InStreamPort( myStreamLoopPorts[ j ]->Name(), myStreamLoopPorts[ j ]->Type(), myStreamLoopPorts[ j ]->Dependency() ) ;
              }
               else {
-                aPort = myNode->OutStreamPort( myStreamLoopPorts[ j ]->Name() , StringToDataStreamType( myStreamLoopPorts[ j ]->Type() ) , myStreamLoopPorts[ j ]->Dependency() ) ;
+                aPort = myNode->OutStreamPort( myStreamLoopPorts[ j ]->Name(), myStreamLoopPorts[ j ]->Type(), myStreamLoopPorts[ j ]->Dependency() ) ;
              }
            }
          }
@@ -2399,10 +2414,10 @@ bool Graph_Impl::Merge(const SUPERV::Graph_ptr aGraph , map< string , int > & aM
             SUPERV::ListOfStreamPorts myStreamPorts = *(aNode->StreamPorts()) ;
             for ( j = 0 ; j < (int ) myStreamPorts.length() ; j++ ) {
               if ( myStreamPorts[ j ]->IsInput() ) {
-                aPort = myNode->InStreamPort( myStreamPorts[ j ]->Name() , StringToDataStreamType( myStreamPorts[ j ]->Type() ) , myStreamPorts[ j ]->Dependency() ) ;
+                aPort = myNode->InStreamPort( myStreamPorts[ j ]->Name(), myStreamPorts[ j ]->Type(), myStreamPorts[ j ]->Dependency() ) ;
              }
               else {
-                aPort = myNode->OutStreamPort( myStreamPorts[ j ]->Name() , StringToDataStreamType( myStreamPorts[ j ]->Type() ) , myStreamPorts[ j ]->Dependency() ) ;
+                aPort = myNode->OutStreamPort( myStreamPorts[ j ]->Name(), myStreamPorts[ j ]->Type(), myStreamPorts[ j ]->Dependency() ) ;
              }
            }
          }
@@ -2428,10 +2443,10 @@ bool Graph_Impl::Merge(const SUPERV::Graph_ptr aGraph , map< string , int > & aM
             SUPERV::ListOfStreamPorts myStreamSwitchPorts = *(myEndOfSwitch->StreamPorts()) ;
             for ( j = 0 ; j < (int ) myStreamSwitchPorts.length() ; j++ ) {
               if ( myStreamSwitchPorts[ j ]->IsInput() ) {
-                aPort = anEndOfSwitch->InStreamPort( myStreamSwitchPorts[ j ]->Name() , StringToDataStreamType( myStreamSwitchPorts[ j ]->Type() ) , myStreamSwitchPorts[ j ]->Dependency() ) ; // mkr : IPAL11394 (add port to !EndSwitch! node)
+                aPort = anEndOfSwitch->InStreamPort( myStreamSwitchPorts[ j ]->Name(), myStreamSwitchPorts[ j ]->Type(), myStreamSwitchPorts[ j ]->Dependency() ) ; // mkr : IPAL11394 (add port to !EndSwitch! node)
              }
               else {
-                aPort = anEndOfSwitch->OutStreamPort( myStreamSwitchPorts[ j ]->Name() , StringToDataStreamType( myStreamSwitchPorts[ j ]->Type() ) , myStreamSwitchPorts[ j ]->Dependency() ) ; // mkr : IPAL11394 (add port to !EndSwitch! node)
+                aPort = anEndOfSwitch->OutStreamPort( myStreamSwitchPorts[ j ]->Name(), myStreamSwitchPorts[ j ]->Type(), myStreamSwitchPorts[ j ]->Dependency() ) ; // mkr : IPAL11394 (add port to !EndSwitch! node)
              }
            }
          }
@@ -2459,9 +2474,9 @@ bool Graph_Impl::Merge(const SUPERV::Graph_ptr aGraph , map< string , int > & aM
                                            DataFlowEditor()->Graph()->GetGraphNode( aMapOfNodes[ aLinkToNodeName->c_str() ] )->Name() ,
                                            InPort->Name() ) ;
         if ( RetVal ) {
-          int j ;
+          CORBA::Long j ;
           for ( j = 1 ; j <= aLink->CoordsSize() ; j++ ) {
-            long X , Y ;
+            CORBA::Long X , Y ;
             RetVal = aLink->Coords( j , X , Y ) ;
             if ( !RetVal )
               break ;
@@ -2552,3 +2567,27 @@ void Graph_Impl::Editing() {
   }
 }
 
+/**
+ * Returns the default name of container for C component
+ */
+char* Graph_Impl::DefaultCContainerName() {
+  return ( CORBA::string_dup( FACTORYSERVER ) );
+}
+
+/**
+ * Returns the default name of container for Python component
+ */
+char* Graph_Impl::DefaultPythonContainerName() {
+  return ( CORBA::string_dup( FACTORYSERVERPY ) );
+}
+
+/*! 
+ * Returns the last container name associated with theComponentName component
+ */ 
+char* Graph_Impl::ContainerNameForComponent( const char * theComponentName ) {
+  const char* aContainer = DataFlowEditor()->Graph()->RetrieveFromMapOfComponentNameContainer(theComponentName);
+  if ( aContainer )
+    return my_strdup(aContainer);
+  else
+    return "";
+}