Salome HOME
SMH: 3.0.0 preparation = merged version (POLYWORK + RTVDEBUG01) + adopation for new GUI
[modules/superv.git] / src / GraphBase / DataFlowBase_Graph.cxx
index 169fc9ab5d6ce63315c126fefdf90d2ad5cb79ec..ede3e29a5e901a71e62da9f91c407ed58dc86563 100644 (file)
@@ -140,36 +140,45 @@ GraphBase::ListOfSNodes * GraphBase::Graph::GetNodes() const {
            ( igoto == 1 && aCNode->IsGOTONode() ) ) {
         if ( aCNode->IsFactoryNode() ) {
           GraphBase::FactoryNode * aFNode = (GraphBase::FactoryNode * ) aCNode ;
-          (*_list_nodes)[ind].theComponentName = CORBA::string_dup( aFNode->ComponentName());
-          (*_list_nodes)[ind].theInterfaceName = CORBA::string_dup( aFNode->InterfaceName());
+//JR 24.02.2005 Memory Leak          (*_list_nodes)[ind].theComponentName = CORBA::string_dup( aFNode->ComponentName());
+          (*_list_nodes)[ind].theComponentName = string( aFNode->ComponentName());
+//JR 24.02.2005 Memory Leak          (*_list_nodes)[ind].theInterfaceName = CORBA::string_dup( aFNode->InterfaceName());
+          (*_list_nodes)[ind].theInterfaceName = string( aFNode->InterfaceName());
         }
         else {
-          (*_list_nodes)[ind].theComponentName = CORBA::string_dup( "" );
-          (*_list_nodes)[ind].theInterfaceName = CORBA::string_dup( "" );
+          (*_list_nodes)[ind].theComponentName = string( "" );
+          (*_list_nodes)[ind].theInterfaceName = string( "" );
         }
-        (*_list_nodes)[ind].theName = CORBA::string_dup( aCNode->Name() );
+//JR 24.02.2005 Memory Leak        (*_list_nodes)[ind].theName = CORBA::string_dup( aCNode->Name() );
+        (*_list_nodes)[ind].theName = string( aCNode->Name() );
         (*_list_nodes)[ind].theKind = aCNode->Kind();
         if ( aCNode->IsInLineNode() || aCNode->IsMacroNode() ) {
           GraphBase::InLineNode * aINode = (GraphBase::InLineNode * ) aCNode ;
           (*_list_nodes)[ind].theListOfFuncName.resize( 1 ) ;
-          (*_list_nodes)[ind].theListOfFuncName[0] = CORBA::string_dup( aINode->PyFuncName() ) ;
+//JR 24.02.2005 Memory Leak          (*_list_nodes)[ind].theListOfFuncName[0] = CORBA::string_dup( aINode->PyFuncName() ) ;
+          (*_list_nodes)[ind].theListOfFuncName[0] = string( aINode->PyFuncName() ) ;
           (*_list_nodes)[ind].theListOfPythonFunctions.resize( 1 ) ;
           (*_list_nodes)[ind].theListOfPythonFunctions[0] = aINode->PythonFunction() ;
         }
         if ( aCNode->IsGOTONode() ) {
           GraphBase::GOTONode * aGNode = (GraphBase::GOTONode * ) aCNode ;
           (*_list_nodes)[ind].theListOfFuncName.resize( 1 ) ;
-          (*_list_nodes)[ind].theListOfFuncName[0] = CORBA::string_dup( aGNode->PyFuncName() ) ;
+//JR 24.02.2005 Memory Leak          (*_list_nodes)[ind].theListOfFuncName[0] = CORBA::string_dup( aGNode->PyFuncName() ) ;
+          (*_list_nodes)[ind].theListOfFuncName[0] = string( aGNode->PyFuncName() ) ;
           (*_list_nodes)[ind].theListOfPythonFunctions.resize( 1 ) ;
           (*_list_nodes)[ind].theListOfPythonFunctions[0] = aGNode->PythonFunction() ;
         }
         if ( aCNode->IsLoopNode() ) {
           GraphBase::LoopNode * aLNode = (GraphBase::LoopNode * ) aCNode ;
-          (*_list_nodes)[ind].theCoupledNode = CORBA::string_dup( aLNode->CoupledNode()->Name() ) ;
+//JR 24.02.2005 Memory Leak          (*_list_nodes)[ind].theCoupledNode = CORBA::string_dup( aLNode->CoupledNode()->Name() ) ;
+          (*_list_nodes)[ind].theCoupledNode = string( aLNode->CoupledNode()->Name() ) ;
           (*_list_nodes)[ind].theListOfFuncName.resize( 3 ) ;
-          (*_list_nodes)[ind].theListOfFuncName[0] = CORBA::string_dup( aLNode->PyFuncName() ) ;
-          (*_list_nodes)[ind].theListOfFuncName[1] = CORBA::string_dup( aLNode->PyMoreName() ) ;
-          (*_list_nodes)[ind].theListOfFuncName[2] = CORBA::string_dup( aLNode->PyNextName() ) ;
+//JR 24.02.2005 Memory Leak          (*_list_nodes)[ind].theListOfFuncName[0] = CORBA::string_dup( aLNode->PyFuncName() ) ;
+          (*_list_nodes)[ind].theListOfFuncName[0] = string( aLNode->PyFuncName() ) ;
+//JR 24.02.2005 Memory Leak          (*_list_nodes)[ind].theListOfFuncName[1] = CORBA::string_dup( aLNode->PyMoreName() ) ;
+          (*_list_nodes)[ind].theListOfFuncName[1] = string( aLNode->PyMoreName() ) ;
+//JR 24.02.2005 Memory Leak          (*_list_nodes)[ind].theListOfFuncName[2] = CORBA::string_dup( aLNode->PyNextName() ) ;
+          (*_list_nodes)[ind].theListOfFuncName[2] = string( aLNode->PyNextName() ) ;
           (*_list_nodes)[ind].theListOfPythonFunctions.resize( 3 ) ;
           (*_list_nodes)[ind].theListOfPythonFunctions[0] = aLNode->PythonFunction() ;
           (*_list_nodes)[ind].theListOfPythonFunctions[1] = aLNode->MorePythonFunction() ;
@@ -177,38 +186,46 @@ GraphBase::ListOfSNodes * GraphBase::Graph::GetNodes() const {
         }
         else if ( aCNode->IsSwitchNode() ) {
           GraphBase::SwitchNode * aSNode = (GraphBase::SwitchNode * ) aCNode ;
-          (*_list_nodes)[ind].theCoupledNode = CORBA::string_dup( aSNode->CoupledNode()->Name() ) ;
+//JR 24.02.2005 Memory Leak          (*_list_nodes)[ind].theCoupledNode = CORBA::string_dup( aSNode->CoupledNode()->Name() ) ;
+          (*_list_nodes)[ind].theCoupledNode = string( aSNode->CoupledNode()->Name() ) ;
           (*_list_nodes)[ind].theListOfFuncName.resize( 1 ) ;
-          (*_list_nodes)[ind].theListOfFuncName[0] = CORBA::string_dup( aSNode->PyFuncName() ) ;
+//JR 24.02.2005 Memory Leak          (*_list_nodes)[ind].theListOfFuncName[0] = CORBA::string_dup( aSNode->PyFuncName() ) ;
+          (*_list_nodes)[ind].theListOfFuncName[0] = string( aSNode->PyFuncName() ) ;
           (*_list_nodes)[ind].theListOfPythonFunctions.resize( 1 ) ;
           (*_list_nodes)[ind].theListOfPythonFunctions[0] = aSNode->PythonFunction() ;
         }
         else if ( aCNode->IsEndLoopNode() ) {
           GraphBase::EndOfLoopNode * aELNode = (GraphBase::EndOfLoopNode * ) aCNode ;
-          (*_list_nodes)[ind].theCoupledNode = CORBA::string_dup( aELNode->CoupledNode()->Name() ) ;
+//JR 24.02.2005 Memory Leak          (*_list_nodes)[ind].theCoupledNode = CORBA::string_dup( aELNode->CoupledNode()->Name() ) ;
+          (*_list_nodes)[ind].theCoupledNode = string( aELNode->CoupledNode()->Name() ) ;
           (*_list_nodes)[ind].theListOfFuncName.resize( 1 ) ;
-          (*_list_nodes)[ind].theListOfFuncName[0] = CORBA::string_dup( aELNode->PyFuncName() ) ;
+//JR 24.02.2005 Memory Leak          (*_list_nodes)[ind].theListOfFuncName[0] = CORBA::string_dup( aELNode->PyFuncName() ) ;
+          (*_list_nodes)[ind].theListOfFuncName[0] = string( aELNode->PyFuncName() ) ;
           (*_list_nodes)[ind].theListOfPythonFunctions.resize( 1 ) ;
           (*_list_nodes)[ind].theListOfPythonFunctions[0] = aELNode->PythonFunction() ;
         }
         else if ( aCNode->IsEndSwitchNode() ) {
           GraphBase::EndOfSwitchNode * aESNode = (GraphBase::EndOfSwitchNode * ) aCNode ;
-          (*_list_nodes)[ind].theCoupledNode = CORBA::string_dup( aESNode->CoupledNode()->Name() ) ;
+//JR 24.02.2005 Memory Leak          (*_list_nodes)[ind].theCoupledNode = CORBA::string_dup( aESNode->CoupledNode()->Name() ) ;
+          (*_list_nodes)[ind].theCoupledNode = string( aESNode->CoupledNode()->Name() ) ;
           (*_list_nodes)[ind].theListOfFuncName.resize( 1 ) ;
-          (*_list_nodes)[ind].theListOfFuncName[0] = CORBA::string_dup( aESNode->PyFuncName() ) ;
+//JR 24.02.2005 Memory Leak          (*_list_nodes)[ind].theListOfFuncName[0] = CORBA::string_dup( aESNode->PyFuncName() ) ;
+          (*_list_nodes)[ind].theListOfFuncName[0] = string( aESNode->PyFuncName() ) ;
           (*_list_nodes)[ind].theListOfPythonFunctions.resize( 1 ) ;
           (*_list_nodes)[ind].theListOfPythonFunctions[0] = aESNode->PythonFunction() ;
         }
         else if ( aCNode->IsMacroNode() ) {
           GraphBase::Graph * aGraph = (GraphBase::Graph * ) aCNode ;
-          (*_list_nodes)[ind].theCoupledNode = CORBA::string_dup( aGraph->CoupledNode()->Name() ) ;
+//JR 24.02.2005 Memory Leak          (*_list_nodes)[ind].theCoupledNode = CORBA::string_dup( aGraph->CoupledNode()->Name() ) ;
+          (*_list_nodes)[ind].theCoupledNode = string( aGraph->CoupledNode()->Name() ) ;
           (*_list_nodes)[ind].theListOfFuncName.resize( 1 ) ;
-          (*_list_nodes)[ind].theListOfFuncName[0] = CORBA::string_dup( aGraph->PyFuncName() ) ;
+//JR 24.02.2005 Memory Leak          (*_list_nodes)[ind].theListOfFuncName[0] = CORBA::string_dup( aGraph->PyFuncName() ) ;
+          (*_list_nodes)[ind].theListOfFuncName[0] = string( aGraph->PyFuncName() ) ;
           (*_list_nodes)[ind].theListOfPythonFunctions.resize( 1 ) ;
           (*_list_nodes)[ind].theListOfPythonFunctions[0] = aGraph->PythonFunction() ;
         }
         else {
-          (*_list_nodes)[ind].theCoupledNode = CORBA::string_dup( "" ) ;
+          (*_list_nodes)[ind].theCoupledNode = string( "" ) ;
         }
 //        (*_list_nodes)[ind].theDataStreamInArgsNumber = aCNode->DataStreamInPortsNumber() ;
 //        (*_list_nodes)[ind].theDataStreamOutArgsNumber = aCNode->DataStreamOutPortsNumber() ;
@@ -322,16 +339,20 @@ GraphBase::ListOfSNodes * GraphBase::Graph::GetNodes() const {
         }
         (*_list_nodes)[ind].theFirstCreation = aCNode->FirstCreation();
         (*_list_nodes)[ind].theLastModification = aCNode->LastModification();
-        (*_list_nodes)[ind].theEditorRelease = CORBA::string_dup( aCNode->EditorRelease());
-        (*_list_nodes)[ind].theAuthor = CORBA::string_dup( aCNode->Author());
+//JR 24.02.2005 Memory Leak        (*_list_nodes)[ind].theEditorRelease = CORBA::string_dup( aCNode->EditorRelease());
+        (*_list_nodes)[ind].theEditorRelease = string( aCNode->EditorRelease());
+//JR 24.02.2005 Memory Leak        (*_list_nodes)[ind].theAuthor = CORBA::string_dup( aCNode->Author());
         if ( aCNode->IsFactoryNode() ) {
           GraphBase::FactoryNode * aFNode = (GraphBase::FactoryNode * ) aCNode ;
-          (*_list_nodes)[ind].theContainer = CORBA::string_dup( aFNode->Computer());
+//JR 24.02.2005 Memory Leak          (*_list_nodes)[ind].theContainer = CORBA::string_dup( aFNode->Computer());
+          (*_list_nodes)[ind].theContainer = string( aFNode->Computer());
         }
         else {
-          (*_list_nodes)[ind].theContainer = CORBA::string_dup( "" );
+//JR 24.02.2005 Memory Leak          (*_list_nodes)[ind].theContainer = CORBA::string_dup( "" );
+          (*_list_nodes)[ind].theContainer = string( "" );
         }
-        (*_list_nodes)[ind].theComment = CORBA::string_dup( aCNode->Comment());
+//JR 24.02.2005 Memory Leak        (*_list_nodes)[ind].theComment = CORBA::string_dup( aCNode->Comment());
+        (*_list_nodes)[ind].theComment = string( aCNode->Comment());
         (*_list_nodes)[ind].theCoords.theX = aCNode->XCoordinate();
         (*_list_nodes)[ind].theCoords.theY = aCNode->YCoordinate();
 #if 0
@@ -342,10 +363,14 @@ GraphBase::ListOfSNodes * GraphBase::Graph::GetNodes() const {
           if ( anInPort->IsBus() ) {
             nports += 1 ;
             (*_list_nodes)[ind].theListOfParameters.resize( nports ) ;
-            (*_list_nodes)[ind].theListOfParameters[ nports-1 ].theInParameter.Parametertype = CORBA::string_dup( anInPort->PortType() ) ;
-            (*_list_nodes)[ind].theListOfParameters[ nports-1 ].theInParameter.Parametername = CORBA::string_dup( anInPort->PortName() ) ;
-            (*_list_nodes)[ind].theListOfParameters[ nports-1 ].theOutParameter.Parametertype = CORBA::string_dup( aCNode->GetNodeOutPort( anInPort->PortIndex() )->PortType() ) ;
-            (*_list_nodes)[ind].theListOfParameters[ nports-1 ].theOutParameter.Parametername = CORBA::string_dup( aCNode->GetNodeOutPort( anInPort->PortIndex() )->PortName() ) ;
+//JR 24.02.2005 Memory Leak            (*_list_nodes)[ind].theListOfParameters[ nports-1 ].theInParameter.Parametertype = CORBA::string_dup( anInPort->PortType() ) ;
+            (*_list_nodes)[ind].theListOfParameters[ nports-1 ].theInParameter.Parametertype = string( anInPort->PortType() ) ;
+//JR 24.02.2005 Memory Leak            (*_list_nodes)[ind].theListOfParameters[ nports-1 ].theInParameter.Parametername = CORBA::string_dup( anInPort->PortName() ) ;
+            (*_list_nodes)[ind].theListOfParameters[ nports-1 ].theInParameter.Parametername = string( anInPort->PortName() ) ;
+//JR 24.02.2005 Memory Leak            (*_list_nodes)[ind].theListOfParameters[ nports-1 ].theOutParameter.Parametertype = CORBA::string_dup( aCNode->GetNodeOutPort( anInPort->PortIndex() )->PortType() ) ;
+            (*_list_nodes)[ind].theListOfParameters[ nports-1 ].theOutParameter.Parametertype = string( aCNode->GetNodeOutPort( anInPort->PortIndex() )->PortType() ) ;
+//JR 24.02.2005 Memory Leak            (*_list_nodes)[ind].theListOfParameters[ nports-1 ].theOutParameter.Parametername = CORBA::string_dup( aCNode->GetNodeOutPort( anInPort->PortIndex() )->PortName() ) ;
+            (*_list_nodes)[ind].theListOfParameters[ nports-1 ].theOutParameter.Parametername = string( aCNode->GetNodeOutPort( anInPort->PortIndex() )->PortName() ) ;
           }
         }
 #endif
@@ -367,30 +392,46 @@ GraphBase::ListOfSLinks * GraphBase::Graph::GetLinks(bool AllLinks ) const {
 // All the links from _LinksList are taken
 //  vector< InNode *> Nodes = InNodes() ;
 
+  cdebug_in << "Graph::GetLinks( " << AllLinks << " ) " << endl ;
   int ind = 0 ;
   int k ;
   for ( k = 0 ; k < GraphNodesSize() ; k++ ) {
     GraphBase::ComputingNode * fromNode = GraphNodes( k ) ;
+//    cdebug << "GraphBase::Graph::GetLinks k" << k << ". :" << fromNode->Name() << endl ;
     int i ;
     for ( i = 0 ; i < fromNode->GetNodeOutPortsSize() ; i++ ) {
       const GraphBase::OutPort* fromPort = fromNode->GetNodeOutPort( i ) ;
+//      cdebug << "GraphBase::Graph::GetLinks k" << k << ". :" << fromNode->Name()
+//             << " i" << i << ". : " << fromPort->PortName() << endl ;
       int j ;
       for ( j = 0 ; j < fromPort->InPortsSize() ; j++ ) {
         const GraphBase::InPort* toPort = fromPort->InPorts( j ) ;
+//        cdebug << "GraphBase::Graph::GetLinks k" << k << ". : fromNode " << fromNode << " = "
+//               << fromNode->Name() << " i" << i << ". : fromPort " << fromPort << " = "
+//               << fromPort->PortName() << " j" << j << ". : toPort " << toPort << " = "
+//               << toPort->NodeName() << "( " << toPort->PortName() << " )" << endl ;
         if ( toPort->IsPortConnected() ) {
 // Desole pour ce cast mais avec les maps difficile de faire const ...
-          const GraphBase::ComputingNode * toNode = ((GraphBase::Graph * ) this)->GetGraphNode( toPort->NodeName() ) ;
+//          const GraphBase::ComputingNode * toNode = ((GraphBase::Graph * ) this)->GetGraphNode( toPort->NodeName() ) ;
+//          cdebug << "GraphBase::Graph::GetLinks " << fromNode->Name() << " ("
+//                 << fromPort->PortName() << " ) IsPortConnected" << fromPort->IsPortConnected()
+//                 << " --> toNode " << toNode << " " << toPort->NodeName() << "( "
+//                 << toPort->PortName() << " ) " << " " << fromPort->InPortsSize() << " ports"
+//                 << endl ;
           if ( !(fromPort->IsLoop() && toPort->IsLoop() ) || AllLinks ) {
-            cdebug << "GraphBase::Graph::GetLinks " << fromNode->Name() << " ("
-                   << fromPort->PortName() << " ) IsPortConnected" << fromPort->IsPortConnected()
-                   << " --> " << toNode->Name() << "( " << toPort->PortName() << " ) "
-                   << " " << fromPort->InPortsSize() << " ports" << endl ;
+//            cdebug << "GraphBase::Graph::GetLinks " << fromNode->Name() << " ("
+//                   << fromPort->PortName() << " ) IsPortConnected" << fromPort->IsPortConnected()
+//                   << " --> " << toNode->Name() << "( " << toPort->PortName() << " ) "
+//                   << " " << fromPort->InPortsSize() << " ports" << endl ;
             _list_links->resize( ind+1 );
-            (*_list_links)[ind].FromNodeName = CORBA::string_dup( fromNode->Name() );
+//JR 23.02.2005 Memory Leak            (*_list_links)[ind].FromNodeName = CORBA::string_dup( fromNode->Name() );
+            (*_list_links)[ind].FromNodeName = string( fromNode->Name() );
             (*_list_links)[ind].FromServiceParameterName = fromPort->GetServicesParameter().Parametername;
-            (*_list_links)[ind].ToNodeName = CORBA::string_dup( toPort->NodeName() );
+//JR 23.02.2005 Memory Leak            (*_list_links)[ind].ToNodeName = CORBA::string_dup( toPort->NodeName() );
+            (*_list_links)[ind].ToNodeName = string( toPort->NodeName() );
             (*_list_links)[ind].ToServiceParameterName = toPort->GetServicesParameter().Parametername;
-            (*_list_links)[ind].aLinkValue = *fromPort->Value() ;
+//JR 30.03.2005            (*_list_links)[ind].aLinkValue = *fromPort->Value() ;
+            (*_list_links)[ind].aLinkValue = fromPort->Value() ;
             if ( toPort->IsEndSwitch() ) {
               (*_list_links)[ind++].aListOfCoords = *(fromPort->Coords()) ;
            }
@@ -400,15 +441,17 @@ GraphBase::ListOfSLinks * GraphBase::Graph::GetLinks(bool AllLinks ) const {
          }
        }
         else {
-          cdebug << "GraphBase::Graph::GetLinks " << fromNode->Name() << " "
-                 << fromPort->PortName() << " ) " << fromPort->PortStatus()
-                 << " --> " << toPort->NodeName() << "( " << toPort->PortName() << " ) "
-                 << " " << toPort->PortStatus() << " " << fromPort->InPortsSize() << " ports ignored" << endl ;
+//          cdebug << "GraphBase::Graph::GetLinks " << fromNode->Name() << " "
+//                 << fromPort->PortName() << " ) " << fromPort->PortStatus()
+//                 << " --> " << toPort->NodeName() << "( " << toPort->PortName() << " ) "
+//                 << " " << toPort->PortStatus() << " " << fromPort->InPortsSize()
+//                 << " ports ignored" << endl ;
        }
       }
     }
   }
 
+  cdebug_out << "Graph::GetLinks( " << AllLinks << " ) " << endl ;
   return _list_links;
 }
 
@@ -422,11 +465,14 @@ GraphBase::SLink * GraphBase::Graph::GetLink( GraphBase::ComputingNode * aNode ,
                                               GraphBase::InPort* toPort ) {
   GraphBase::SLink * _link =  new GraphBase::SLink ;
   GraphBase::OutPort* fromPort = toPort->GetOutPort() ;
-  _link->FromNodeName = CORBA::string_dup( fromPort->NodeName() );
+//JR 24.02.2005 Memory Leak  _link->FromNodeName = CORBA::string_dup( fromPort->NodeName() );
+  _link->FromNodeName = string( fromPort->NodeName() );
   _link->FromServiceParameterName = fromPort->GetServicesParameter().Parametername;
-  _link->ToNodeName = CORBA::string_dup( toPort->NodeName() );
+//JR 24.02.2005 Memory Leak  _link->ToNodeName = CORBA::string_dup( toPort->NodeName() );
+  _link->ToNodeName = string( toPort->NodeName() );
   _link->ToServiceParameterName = toPort->GetServicesParameter().Parametername;
-  CORBA::Any aSPValue = *fromPort->Value() ;
+//JR 30.03.2005  CORBA::Any aSPValue = *fromPort->Value() ;
+  CORBA::Any aSPValue = fromPort->Value() ;
   _link->aLinkValue = aSPValue;
   _link->aListOfCoords = *(toPort->Coords()) ;
   return _link;
@@ -450,12 +496,15 @@ GraphBase::ListOfSLinks * GraphBase::Graph::GetDatas() const {
 // input ports. Input(s) of a DataFlow match one or several output-virtual-dataport
         for ( j = 0 ; j < fromDataPort->InPortsSize() ; j++ ) {
           _list_datalinks->resize( ind+1 );
-          (*_list_datalinks)[ind].FromNodeName = CORBA::string_dup( aDataNode->Name() );
+//JR 24.02.2005 Memory Leak          (*_list_datalinks)[ind].FromNodeName = CORBA::string_dup( aDataNode->Name() );
+          (*_list_datalinks)[ind].FromNodeName = string( aDataNode->Name() );
           (*_list_datalinks)[ind].FromServiceParameterName = fromDataPort->GetServicesParameter().Parametername;
           const GraphBase::InPort* toPort = fromDataPort->InPorts( j ) ;
-          (*_list_datalinks)[ind].ToNodeName = CORBA::string_dup( toPort->NodeName() );
+//JR 24.02.2005 Memory Leak          (*_list_datalinks)[ind].ToNodeName = CORBA::string_dup( toPort->NodeName() );
+          (*_list_datalinks)[ind].ToNodeName = string( toPort->NodeName() );
           (*_list_datalinks)[ind].ToServiceParameterName = toPort->GetServicesParameter().Parametername;
-          CORBA::Any aSPValue = *fromDataPort->Value() ;
+//JR 30.03.2005          CORBA::Any aSPValue = *fromDataPort->Value() ;
+          CORBA::Any aSPValue = fromDataPort->Value() ;
           (*_list_datalinks)[ind].aLinkValue = aSPValue;
           (*_list_datalinks)[ind++].aListOfCoords = *(toPort->Coords()) ;
         }
@@ -463,27 +512,6 @@ GraphBase::ListOfSLinks * GraphBase::Graph::GetDatas() const {
     }
   }
 
-#if 0
-// Output(s) of a DataFlow match only one input-virtual-dataport
-  for ( i = 0 ; i < aDataNode->GetNodeOutDataNodePortsSize() ; i++ ) {
-    GraphBase::InPort* toDataPort = aDataNode->GetChangeNodeOutDataNodePort( i ) ;
-    const GraphBase::OutPort* fromPort = toDataPort->GetLink() ;
-    if ( fromPort->IsDataConnected() ) {
-      _list_datalinks->length( ind+1 );
-      _list_datalinks[ind].FromNodeName = CORBA::string_dup( fromPort->NodeName() );
-      _list_datalinks[ind].FromServiceParameterName = fromPort->GetServicesParameter().Parametername;
-      _list_datalinks[ind].ToNodeName = CORBA::string_dup( aDataNode->Name() );
-      _list_datalinks[ind].ToServiceParameterName = toDataPort->GetServicesParameter().Parametername;
-//      SALOME_SuperVisionBase::ServicesParameterValue aSPValue;
-          CORBA::Any aSPValue = *fromPort->Value() ;
-//      aSPValue.Value = CORBA::string_dup( fromPort->Value() );
-//      aSPValue.Kind = fromPort->Kind();
-      _list_datalinks[ind].aLinkValue = aSPValue;
-      _list_datalinks[ind++].aListOfCoords = toDataPort->Coords() ;
-    }
-  }
-#endif
-
   return _list_datalinks ;
 }
 
@@ -550,13 +578,24 @@ bool GraphBase::Graph::ReNameNode( const char* OldNodeName ,
 
       GraphBase::ComputingNode * aNode = GetChangeGraphNode( index ) ;
 // Update 'ToNode's Map from 'aNode'
-      cdebug << "Graph::ReNameNode " << aNode->Name() << " LinkedNodesSize "
+      cdebug << "Graph::ReNameNode " << aNode->Name() << " LinkedNodesSize "
              << aNode->LinkedNodesSize() << endl ;
       for ( i = 0 ; i < aNode->LinkedNodesSize() ; i++ ) {
         GraphBase::StreamNode * ToNode = aNode->LinkedNodes( i ) ;
         ToNode->ReNameLinkedFromNode( OldNodeName , NewNodeName ) ;
       }
-// Update 'FomNode's Map to 'aNode'
+// Rename in _MapOfLinkedNodes of 'FromNode'
+      cdebug << "Graph::ReNameNode " << aNode->Name() << " LinkedFromNodesSize : "
+             << aNode->LinkedFromNodesSize() << endl ;
+      for ( i = 0 ; i < aNode->LinkedFromNodesSize() ; i++ ) {
+        GraphBase::StreamNode * FromNode = aNode->LinkedFromNodes( i ) ;
+        if ( FromNode->GetLinkedNodeIndex( OldNodeName ) >= 0 ) {
+          FromNode->ReNameLinkedNode( OldNodeName , NewNodeName ) ;
+       }
+        else {
+          FromNode->ReNameStreamLinkedNode( OldNodeName , NewNodeName ) ;
+       }
+      }
 // Inports 'anInPort' of 'aNode'
       for ( i = aNode->GetNodeInPortsSize()-1 ; i >= 0 ; i-- ) {
         GraphBase::InPort * anInPort = aNode->GetChangeNodeInPort( i ) ;
@@ -583,14 +622,17 @@ bool GraphBase::Graph::ReNameNode( const char* OldNodeName ,
             else {
               FromNode = this ;
            }
-// Rename in _MapOfLinkedFromNodes of 'FromNode'
             cdebug << " fromConnected " << anOutPort->NodeName() << endl ;
+#if 0
+//JR 26.01.2005 : a same node may be renamed severeal times. So this is done above
+// Rename in _MapOfLinkedFromNodes of 'FromNode'
             if ( anInPort->IsDataStream() ) {
               FromNode->ReNameStreamLinkedNode( OldNodeName , NewNodeName ) ;
            }
             else {
               FromNode->ReNameLinkedNode( OldNodeName , NewNodeName ) ;
            }
+#endif
          }
           char* OldNodePortName = new char[ strlen( OldNodeName ) +
                                             strlen( aNode->GetChangeNodeInPort( i )->PortName() ) + 3 ] ;
@@ -616,6 +658,24 @@ bool GraphBase::Graph::ReNameNode( const char* OldNodeName ,
         }
       }
       RetVal = true ;
+// PAL8508
+//JR 02.02.2005 DEBUG : ReName in the CoupledNode was missing
+      if ( aNode->IsLoopNode() || aNode->IsEndLoopNode() ||
+           aNode->IsSwitchNode() || aNode->IsEndSwitchNode() ) {
+        GraphBase::GOTONode * theCoupledNode = NULL ;
+        theCoupledNode = (GraphBase::GOTONode * ) ((GraphBase::GOTONode * ) aNode)->CoupledNode() ;
+        theCoupledNode->CoupledNodeName( aNode->Name() ) ;
+      }
+      else if ( aNode->IsInLineNode() ) {
+        GraphBase::OutPort * anOutPort = aNode->GetNodeInGate()->GetOutPort() ;
+        if ( anOutPort ) {
+          GraphBase::ComputingNode * aLinkedNode ;
+          aLinkedNode = GetChangeGraphNode( anOutPort->NodeName() ) ;
+          if ( aLinkedNode->IsGOTONode() ) {
+            ((GraphBase::GOTONode * ) aLinkedNode)->CoupledNodeName( aNode->Name() ) ;
+         }
+       }
+      }
     }
     else {
       cdebug << "ERROR Node not found" << endl ;
@@ -650,6 +710,20 @@ bool GraphBase::Graph::RemoveNode( const char* aNodeName ) {
                << aNode->LinkedFromNodes( i )->Name() << endl ;
       }
     }
+//PAL8177-PAL8509
+//JR 24.03.2005 : Debug : CoupledNode field of GOTONodes was not erased
+    if ( aNode->IsInLineNode() ) {
+      GraphBase::OutPort * anOutPort = aNode->GetNodeInGate()->GetOutPort() ;
+      if ( anOutPort ) {
+        GraphBase::ComputingNode * aLinkedNode ;
+        aLinkedNode = GetChangeGraphNode( anOutPort->NodeName() ) ;
+        if ( aLinkedNode->IsGOTONode() ) {
+          cdebug << "Graph::RemoveNode erase CoupledNode " << aLinkedNode->Name() << endl ;
+          ((GraphBase::GOTONode * ) aLinkedNode)->CoupledNode( NULL ) ;
+          ((GraphBase::GOTONode * ) aLinkedNode)->CoupledNodeName( "" ) ;
+        }
+      }
+    }
     if ( !aNode->IsEndSwitchNode() ) {
       if ( aNode->GetNodeInPortsSize() ) {
         for ( i = aNode->GetNodeInPortsSize()-1 ; i >= 0 ; i-- ) {
@@ -730,7 +804,7 @@ bool GraphBase::Graph::RemoveNode( const char* aNodeName ) {
           int k ;
           for ( k = anOutPort->InPortsSize() - 1 ; k >= 0  ; k-- ) {
             GraphBase::InPort * anInPort = anOutPort->ChangeInPorts( k ) ;
-            if ( strcmp( anInPort->NodeName() , aNode->Name() ) == 0 ) {
+            if ( !strcmp( anInPort->NodeName() , aNode->Name() ) ) {
 // InPort of the EndSwitchNode
               cdebug << "       to InPort" << j << ". " << anInPort->NodeName() << "( "
                      << anInPort->PortName() << ") "
@@ -773,6 +847,8 @@ bool GraphBase::Graph::RemoveNode( const char* aNodeName ) {
           if ( !anInPort->IsExternConnected() ) {
             GraphBase::ComputingNode * ToNode = GetChangeGraphNode( anInPort->NodeName() ) ;
             RetVal = anInPort->RemoveOutPort() ;
+// JR 04.02.2005 : Bug if it is a link to an EndSwitchNode. The InPort may be multiple linked !!!
+// PAL7990
             if ( !RetVal ) {
               cdebug << "anOutPort->RemoveOutPort Error RetVal " << RetVal << endl ;
               break ;
@@ -795,6 +871,41 @@ bool GraphBase::Graph::RemoveNode( const char* aNodeName ) {
               cdebug << "anOutPort->RemoveInPort( anInPort ) Error RetVal " << RetVal << endl ;
               break ;
            }
+            if ( ToNode->IsEndSwitchNode() ) {
+              int i ;
+              int done = false ;
+              for ( i = 0 ; i < ToNode->LinkedFromNodesSize() ; i++ ) {
+                GraphBase::StreamNode * fromNode = ToNode->LinkedFromNodes( i ) ;
+// Not the node that we are deleting ... :
+                if ( strcmp( fromNode->Name() , aNode->Name() ) ) {
+                  int j ;
+                  for ( j = 0 ; j < fromNode->GetNodeOutPortsSize() ; j++ ) {
+                    GraphBase::OutPort * fromOutPort = fromNode->GetChangeNodeOutPort( j ) ;
+                    int k ;
+                    for ( k = 0 ; k < fromOutPort->InPortsSize() ; k++ ) {
+                      if ( strcmp( ToNode->Name() , fromOutPort->InPorts( k )->NodeName() ) == 0 ) {
+                        if ( strcmp( anInPort->PortName() , fromOutPort->InPorts( k )->PortName() ) == 0 ) {
+// Restore an OutPort in the InPort
+                          anInPort->ChangeOutPort( fromOutPort ) ;
+                          cdebug << "Graph::RemoveNode reestablish " << fromOutPort->NodeName() << "( "
+                                 << fromOutPort->PortName() << " ) in the InPort of EndSwitch : "
+                                 << ToNode->Name() << "( " << anInPort->PortName() << " )"
+                                 << anInPort->Kind() << " " << anInPort->PortStatus()  << endl;
+                          done = true ;
+                          break ;
+                       }
+                     }
+                   }
+                    if ( done ) {
+                      break ;
+                   }
+                 }
+                  if ( done ) {
+                    break ;
+                 }
+               }
+             }
+           }
           }
        }
         if ( !RetVal ) {
@@ -803,6 +914,9 @@ bool GraphBase::Graph::RemoveNode( const char* aNodeName ) {
        }
       }
     }
+    if ( aNode->LinkedNodesSize() || aNode->LinkedFromNodesSize() ) {
+      RetVal = 0 ;
+    }
     cdebug << "Graph::RemoveNode " << aNode->Name() << " : " << aNode->GetNodeInPortsSize()
            << " InPorts " << aNode->GetNodeOutPortsSize() << " OutPorts "
            << aNode->LinkedNodesSize() << " LinkedNodes " << aNode->LinkedFromNodesSize()
@@ -823,10 +937,11 @@ bool GraphBase::Graph::RemoveNode( const char* aNodeName ) {
       char * theCoupledNodeName = NULL ;
       int CoupledIndex = -1 ;
       if ( aNode->IsEndLoopNode() || aNode->IsEndSwitchNode() ) {
-        theCoupledNode = ((GraphBase::GOTONode * ) aNode)->CoupledNode() ;
         theCoupledNodeName = ((GraphBase::GOTONode * ) aNode)->CoupledNodeName() ;
-        CoupledIndex = GetGraphNodeIndex( theCoupledNode->Name() ) ;
+        theCoupledNode = ((GraphBase::GOTONode * ) aNode)->CoupledNode() ;
       }
+      cdebug << "Node" << index << " " << _GraphNodes[ index ]->Name() << " will be deleted"
+             << endl ;
       delete aNode ;
       _GraphNodesSize -= 1 ;
       for ( i = index ; i < _GraphNodesSize ; i++ ) {
@@ -835,8 +950,13 @@ bool GraphBase::Graph::RemoveNode( const char* aNodeName ) {
       }
       _GraphNodes.resize( _GraphNodesSize+1 ) ;
       _MapOfGraphNodes.erase( aNodeName ) ;
+// PAL8510
 // Delete of the LoopNode of that EndLoopNode or of the SwitchNode of that EndSwitchNode :
       if ( theCoupledNode ) {
+//JR 02.02.2005 DEBUG : CoupledIndex must be here after the delete of aNode (not before)
+        CoupledIndex = GetGraphNodeIndex( theCoupledNodeName ) ;
+        cdebug << "CoupledNode" << CoupledIndex << " " << _GraphNodes[ CoupledIndex ]->Name()
+               << " will be deleted" << endl ;
         delete theCoupledNode ;
         _GraphNodesSize -= 1 ;
         for ( i = CoupledIndex ; i < _GraphNodesSize ; i++ ) {
@@ -850,10 +970,24 @@ bool GraphBase::Graph::RemoveNode( const char* aNodeName ) {
     }
   }
   else {
-    cdebug << "Node not found ERROR " << index << endl ;
+    cdebug << "Graph::RemoveNode Node not found ERROR " << index << endl ;
   }
 
-  cdebug_out << "GraphBase::Graph::RemoveNode " << RetVal << endl;
+#if 1
+  cdebug << "Graph::RemoveNode " << _GraphNodesSize << " known nodes" << endl;
+  for ( i = 0 ; i < _GraphNodesSize ; i++ ) {
+    cdebug << "Node" << i << _GraphNodes[ i ]->Name() << endl ;
+  }
+  map< string , int >::iterator aMapOfGraphNodesIterator ;
+  i = 0 ;
+  for ( aMapOfGraphNodesIterator = _MapOfGraphNodes.begin() ;
+    aMapOfGraphNodesIterator != _MapOfGraphNodes.end() ; aMapOfGraphNodesIterator++ ) {
+    cdebug << "MapOfGraphNodes " << i++ << " " << aMapOfGraphNodesIterator->first << " --> "
+           << aMapOfGraphNodesIterator->second << " - 1" << endl ;
+  }
+#endif
+
+  cdebug_out << "Graph::RemoveNode " << RetVal << endl;
   return RetVal ;
 }
 
@@ -971,9 +1105,10 @@ bool GraphBase::Graph::AddLink( GraphBase::ComputingNode *fromNode ,
     return false ;
   }
 
-  cdebug_in << "GraphBase::Graph::AddLink(" << fromNode->Name() << "("
-            << fromPort->PortName() << " " << fromPort->PortStatus() << ") ---> " << toNode->Name() << "("
-            << toPort->PortName() << " " << toPort->PortStatus() << ") )" << endl;
+  cdebug_in << "Graph::AddLink( " << fromNode->Name() << "("
+            << fromPort->PortName() << " " << fromPort->PortStatus() << ") " << fromPort->Kind()
+            << " ---> " << toNode->Name() << "(" << toPort->PortName() << " " << toPort->PortStatus()
+            << ") " << toPort->Kind() << " )" << endl;
   if ( fromPort->IsDataConnected() || fromPort->IsExternConnected() ) {
     if ( !fromPort->RemoveInPort() ) { // There is only one ===> RemoveOutPort()
       cdebug_out << "GraphBase::Graph::AddLink(" << fromNode->Name() << "("
@@ -1028,15 +1163,39 @@ bool GraphBase::Graph::AddLink( GraphBase::ComputingNode *fromNode ,
         }
       }
     }
-    else if ( !toNode->IsEndSwitchNode() ||
-              ( toNode->IsEndSwitchNode() && toPort->IsGate() ) ) {
-      if ( !RemoveLink( fromNode->Name() , fromPort->PortName() ,
+//PAL8511
+// JR 17.01.2005 : toPort is already linked : RemoveLink
+    else if ( !toNode->IsEndSwitchNode() ) {
+//    else if ( !toNode->IsEndSwitchNode() ||
+//              ( toNode->IsEndSwitchNode() && toPort->IsGate() ) ) {
+//JR Debug : the fromPort was wrong !
+//      if ( !RemoveLink( fromNode->Name() , fromPort->PortName() ,
+      if ( !RemoveLink( toPort->GetOutPort()->NodeName() , toPort->GetOutPort()->PortName() ,
                         toNode->Name() , toPort->PortName() ) ) {
         cdebug << "RemoveLink(AddLink) toNode->IsEndSwitchNode Error." << endl ;
         cdebug_out << "GraphBase::Graph::AddLink" << endl;
         return false ;
       }
     }
+//PAL8511
+//JR Debug 15.02.2005 : Not multiple links in that case except if toPort is the DefaultPort
+    else if ( fromNode->IsSwitchNode() && toNode->IsEndSwitchNode() && !toPort->IsGate() ) {
+      cdebug << "fromNode->IsSwitchNode() && toNode->IsEndSwitchNode toPort(NotGate)Error."
+             << endl ;
+      cdebug_out << "GraphBase::Graph::AddLink" << endl;
+      return false ;
+    }
+  }
+//PAL7990
+//JR 24.03.2005 : No Link between OutPort of SwitchNode to InPort of EndSwitchNode except if
+// they have the same name for a special case :
+// Switch with no branch ==> Default is applied always : GraphSyrControl example
+  else if ( fromNode->IsSwitchNode() && !fromPort->IsGate() &&
+            toNode->IsEndSwitchNode() && !toPort->IsGate() &&
+            strcmp( fromPort->PortName() , toPort->PortName() ) ) {
+    cdebug << "fromNode->IsSwitchNode() && toNode->IsEndSwitchNode Error." << endl ;
+    cdebug_out << "GraphBase::Graph::AddLink" << endl;
+    return false ;
   }
   else if ( fromNode->IsGOTONode() && fromPort->InPortsSize() ) {
     if ( !RemoveLink( fromNode->Name() , fromPort->PortName() ,
@@ -1057,7 +1216,26 @@ bool GraphBase::Graph::AddLink( GraphBase::ComputingNode *fromNode ,
   }
 
 
-  if ( toNode->IsEndSwitchNode() && !toPort->IsGate() ) {
+// JR 12.01.2005 : an OutPort of a SwitchNode connected to a Gate can be connected only to Gate
+  if ( !toNode->IsDataFlowNode() && !toNode->IsDataStreamNode() &&
+       fromNode->IsSwitchNode() && fromPort->IsSwitch() && !toPort->IsGate() ) {
+    cdebug << "toPort->AddLink Error( fromPort->IsSwitch() && !toPort->IsGate())." << endl ;
+    cdebug_out << "GraphBase::Graph::AddLink 0" << endl;
+    return false ;
+  }
+//JR 11.02.2005 : SwitchNode(Default) may be only linked to EndSwitchNode(Default)
+//                SwitchNode(Param) may be linked to EndSwitchNode(Param)
+//                SwitchNode(Param-UserDefault) may be linked to EndSwitchNode(Default)
+  else if ( fromNode->IsSwitchNode() && toNode->IsEndSwitchNode() &&
+            !( ( fromPort->IsGate() && toPort->IsGate() ) ||
+               ( !fromPort->IsGate() ) ) ) {
+//               ( !fromPort->IsGate() && !toPort->IsGate() ) ) ) {
+    cdebug << "SwitchNode(Default) may be only linked to EndSwitchNode(Default) AddLink Error."
+           << endl ;
+    cdebug_out << "GraphBase::Graph::AddLink 0" << endl;
+    return false ;
+  }
+  else if ( toNode->IsEndSwitchNode() && !toPort->IsGate() ) {
 //    if ( !toPort->IsEndSwitch() || !fromPort->AddInPort( toPort ) ) {
     if ( !fromPort->AddInPort( toPort ) ) {
       cdebug << "toNode->IsEndSwitchNode() : !fromPort->AddInPort( toPort ) AddLink Error."
@@ -1069,12 +1247,6 @@ bool GraphBase::Graph::AddLink( GraphBase::ComputingNode *fromNode ,
       toPort->Kind( SUPERV::EndSwitchParameter ) ;
     }
   }
-// JR 12.01.2005 : an OutPort of a SwitchNode connected to a Gate can be connected only to Gate
-  else if ( fromNode->IsSwitchNode() && fromPort->IsSwitch() && !toPort->IsGate() ) {
-    cdebug << "toPort->AddLink Error( fromPort->IsSwitch() && !toPort->IsGate())." << endl ;
-    cdebug_out << "GraphBase::Graph::AddLink 0" << endl;
-    return false ;
-  }
   else if ( !fromPort->AddInPort( toPort ) ) { // --> MapOfInports in the OutPort
     cdebug << "!fromPort->AddLink Error." << endl ;
     cdebug_out << "GraphBase::Graph::AddLink 0" << endl;
@@ -1140,7 +1312,8 @@ bool GraphBase::Graph::AddLink( GraphBase::ComputingNode *fromNode ,
   }
   if ( fromNode->IsSwitchNode() ) {
     if ( !fromPort->IsDataStream() ) {
-      if ( fromPort->IsInLine() && toPort->IsGate() && !toNode->IsEndSwitchNode() ) {
+//JR 08.02.2005      if ( fromPort->IsInLine() && toPort->IsGate() && !toNode->IsEndSwitchNode() ) {
+      if ( fromPort->IsInLine() && toPort->IsGate() ) {
         fromPort->Kind( SUPERV::SwitchParameter ) ;
       }
       else if ( !fromPort->IsGate() && !toPort->IsGate() ){
@@ -1184,7 +1357,7 @@ bool GraphBase::Graph::RemoveLink( const char* FromNodeName ,
     if ( anInPort && ( anInPort->IsPortConnected() ||
                        anInPort->IsDataConnected() ||
                        anInPort->IsExternConnected() ) ) {
-// JR 13.01.2005 : Bug if it is a link to an EndSwitchNode. The OutPort may be an other one !!!
+// JR 13.01.2005 : DeBug : if it is a link to an EndSwitchNode. The OutPort may be an other one !!!
       GraphBase::ComputingNode * fromNode = GetChangeGraphNode( FromNodeName ) ;
       GraphBase::OutPort * anOutPort = NULL ;
       if ( toNode->IsEndSwitchNode() ) {
@@ -1206,10 +1379,17 @@ bool GraphBase::Graph::RemoveLink( const char* FromNodeName ,
             fromNode->RemoveLinkedNode( toNode ) ;
          }
         }
-        if ( fromNode->IsSwitchNode() && !anOutPort->IsGate() && !toNode->IsEndSwitchNode() ) {
-          anOutPort->Kind( SUPERV::InLineParameter ) ;
+//JR PAL7990 : a SwitchPort is an OutPort of a SwitchNode connected to a InGate Port
+//Debug : change the kind only if there is no other InGate connected to the OutPort
+        if ( fromNode->IsSwitchNode() && !anOutPort->IsGate() && anOutPort->InPortsSize() == 0 ) {
+          if ( !toNode->IsEndSwitchNode() ) {
+            anOutPort->Kind( SUPERV::InLineParameter ) ;
+         }
+          else if ( !anInPort->IsGate() ) {
+            anOutPort->Kind( SUPERV::InLineParameter ) ;
+         }
         }
-// JR 13.01.2005 : Bug if it is a link to an EndSwitchNode. The InPort may be linked !!!
+// JR 13.01.2005 : DeBug : if it is a link to an EndSwitchNode. The InPort may be multiple linked !!!
         if ( toNode->IsEndSwitchNode() ) {
           int i ;
           int done = false ;
@@ -1221,13 +1401,16 @@ bool GraphBase::Graph::RemoveLink( const char* FromNodeName ,
               int k ;
               for ( k = 0 ; k < fromOutPort->InPortsSize() ; k++ ) {
                 if ( strcmp( toNode->Name() , fromOutPort->InPorts( k )->NodeName() ) == 0 ) {
+                  if ( strcmp( anInPort->PortName() , fromOutPort->InPorts( k )->PortName() ) == 0 ) {
 // Restore an OutPort in the InPort
-                  anInPort->ChangeOutPort( fromOutPort ) ;
-                  cdebug << "Graph::RemoveLink reestablish " << fromOutPort->NodeName() << "( "
-                         << fromOutPort->PortName() << " ) in the InPort of EndSwitch : "
-                         << toNode->Name() << "( " << anInPort->PortName() << " )" << endl;
-                  done = true ;
-                  break ;
+                    anInPort->ChangeOutPort( fromOutPort ) ;
+                    cdebug << "Graph::RemoveLink reestablish " << fromOutPort->NodeName() << "( "
+                           << fromOutPort->PortName() << " ) in the InPort of EndSwitch : "
+                           << toNode->Name() << "( " << anInPort->PortName() << " )"
+                           << anInPort->Kind() << " " << anInPort->PortStatus() << endl;
+                    done = true ;
+                    break ;
+                 }
                }
              }
               if ( done ) {
@@ -1258,8 +1441,10 @@ bool GraphBase::Graph::GetLink(const char* ToNodeName ,
     GraphBase::InPort * anInPort = toNode->GetChangeInPort( ToServiceParameterName ) ;
     if ( anInPort && !anInPort->IsNotConnected() ) {
       GraphBase::OutPort * anOutPort = anInPort->GetOutPort() ;
-      *FromNodeName = my_strdup( anOutPort->NodeName() ) ;
-      *FromServiceParameterName = my_strdup( anOutPort->PortName() ) ;
+//JR 17.02.2005 Memory Leak      *FromNodeName = my_strdup( anOutPort->NodeName() ) ;
+      *FromNodeName = (char * ) anOutPort->NodeName() ;
+//JR 17.02.2005 Memory Leak      *FromServiceParameterName = my_strdup( anOutPort->PortName() ) ;
+      *FromServiceParameterName = (char * ) anOutPort->PortName() ;
       RetVal = true ;
     }
     else {
@@ -1405,7 +1590,7 @@ bool GraphBase::Graph::ChangeInputData( const char * ToNodeName ,
         RetVal = true ;
         fromPort->Value( aValue ) ;
         fromPort->PortStatus( DataConnected ) ;
-        toPort->State( SUPERV::ReadyState ) ;
+        toPort->PortState( SUPERV::ReadyState ) ;
       }
       else {
         cdebug << "ERROR ChangeInputData fromPort not found" << endl ;
@@ -1423,6 +1608,7 @@ bool GraphBase::Graph::ChangeInputData( const char * ToNodeName ,
   return RetVal ;
 }
 
+#if 0
 // To restore InputData in CreateService
 bool GraphBase::Graph::AddInputData( const char* ToNodeName ,
                                      const char* ToServiceParameterName ,
@@ -1486,6 +1672,7 @@ bool GraphBase::Graph::AddInputData( const char* ToNodeName ,
   cdebug_out << "GraphBase::Graph::AddInputData " << RetVal << endl;
   return RetVal ;
 }
+#endif
 
 bool GraphBase::Graph::AddOutputData( const char* FromNodeName ,
                                       const char* FromServiceParameterName ,
@@ -1503,8 +1690,8 @@ bool GraphBase::Graph::AddOutputData( const char* FromNodeName ,
 //    RetVal = AddLink( fromNode , fromPort ,
 //                      (GraphBase::ComputingNode * ) this , toDataNodePort ) ;
     anOutPort->Value( aValue ) ;
-    anOutPort->State(  SUPERV::ReadyState ) ;
-    anOutPort->Done( true ) ;
+    anOutPort->PortState(  SUPERV::ReadyState ) ;
+    anOutPort->PortDone( true ) ;
     cdebug << *anOutPort ;
 #ifdef _DEBUG_
     anOutPort->StringValue( *_fdebug ) ;
@@ -1519,6 +1706,8 @@ bool GraphBase::Graph::AddOutputData( const char* FromNodeName ,
   return RetVal ;
 }
 
+//JR This is used by StreamGraphs to list "CODES" and after that there is instances
+// for each Code (Nodes).
 map< string , GraphBase::Service * > GraphBase::Graph::MapOfServiceNames() {
                                            return _MapOfServiceNames ; }
 
@@ -1538,12 +1727,13 @@ bool GraphBase::Graph::SetServiceOfMap( GraphBase::Service * aService ) {
   return true ;
 }
 
-int GraphBase::Graph::GetServiceNameNumber( SALOME_ModuleCatalog::Service aService ) {
-  GraphBase::Service * theService = _MapOfServiceNames[ (char * ) aService.ServiceName ] ;
-  if ( theService == NULL ) {
-    return 1 ;
-  }
-  return theService->NewInstance() ;
+//PAL7961
+//JR Debug 25.03.2005 : with multiple instances et delete of instances, it was wrong
+//Bug created with the developpement of StreamGraphs
+int GraphBase::Graph::GetNewServiceInstanceNumber( char * aServiceName ) {
+  int InstanceNumber = _MapOfServiceInstanceNumber[ aServiceName ] + 1 ;
+  _MapOfServiceInstanceNumber[ aServiceName ] = InstanceNumber ;
+  return InstanceNumber ;
 }
 
 void GraphBase::Graph::SetGraphPorts() {
@@ -1552,7 +1742,7 @@ void GraphBase::Graph::SetGraphPorts() {
   for ( i = 0 ; i < GetNodeInDataNodePortsSize() ; i++ ) {
     GraphBase::OutPort * anOutPort = GetChangeNodeInDataNodePort( i ) ;
     cdebug << "SetGraphPorts Out" << i << " " << anOutPort->PortName() << " " << anOutPort->PortType()
-           << " " << anOutPort->Kind() << " " << anOutPort->PortStatus() << " " << anOutPort->State() << endl ;
+           << " " << anOutPort->Kind() << " " << anOutPort->PortStatus() << " " << anOutPort->PortState() << endl ;
     if ( !anOutPort->IsGate() ) {
       anOutPort->PortStatus( ExternConnected ) ;
     }
@@ -1560,7 +1750,7 @@ void GraphBase::Graph::SetGraphPorts() {
   for ( i = 0 ; i < GetNodeOutDataNodePortsSize() ; i++ ) {
     GraphBase::InPort * anInPort = GetChangeNodeOutDataNodePort( i ) ;
     cdebug << "SetGraphPorts In" << i << " " << anInPort->PortName() << " " << anInPort->PortType()
-           << " " << anInPort->Kind() << " " << anInPort->PortStatus() << " " << anInPort->State() << endl ;
+           << " " << anInPort->Kind() << " " << anInPort->PortStatus() << " " << anInPort->PortState() << endl ;
     if ( !anInPort->IsGate() ) {
       GraphBase::OutPort * anOutPort = anInPort->GetOutPort() ;
       anOutPort->PortStatus( ExternConnected ) ;
@@ -1591,7 +1781,8 @@ bool GraphBase::Graph::CreateService() {
 //  if ( GraphMacroLevel() == 0 ) {
     for ( dostore = 0 ; dostore <= 2 ; dostore++ ) {
       if ( dostore == 1 ) {
-        aService.ServiceName = Name() ;
+//JR 17.02.2005 Memory Leak        aService.ServiceName = Name() ;
+        aService.ServiceName = my_strdup( Name() ) ;
         aService.ServiceinParameter.length( 0 ) ;
         aService.ServiceinParameter.length( innbr ) ;
         aService.ServiceoutParameter.length( 0 ) ;
@@ -1606,6 +1797,7 @@ bool GraphBase::Graph::CreateService() {
         OutNumberOfValues.resize( outnbr ) ;
       }
       else if ( dostore == 2 ) {
+//JR Creation of the Service (and of the Ports) with GraphBase::DataNode::DataService :
         cdebug << "GraphBase::Graph::CreateService ->DataService innbr " << innbr
                << " instreamnbr " << instreamnbr << " outnbr " << outnbr
                << " outstreamnbr " << outstreamnbr << endl ;
@@ -1743,7 +1935,7 @@ bool GraphBase::Graph::CreateService() {
     }
 //  }
 
-#if 0
+#if 1
   cdebug << "DataFlowNode ServiceName " << aService.ServiceName << " InPorts " << innbr
          << " OutPorts " << outnbr << endl ;
   for ( i = 0 ; i < innbr ; i++ ) {
@@ -1849,7 +2041,9 @@ bool GraphBase::Graph::CreateService() {
       if ( !anInPort->IsGate() && anInPort->IsDataConnected() ) {
         if ( !AddInputData( anInPort->NodeName() ,
                             anInPort->PortName() ,
-                            anInPort->GetOutPort()->ValuePtr() ) ) {
+//JR 21.02.2005 Debug Memory leak :                            anInPort->GetOutPort()->ValuePtr() ) ) {
+//JR 30.03.2005                            *anInPort->GetOutPort()->Value() ) ) {
+                            anInPort->GetOutPort()->Value() ) ) {
           cdebug << "CreateService In" << j << " " << anInPort->NodeName() << "(" << anInPort->PortName() << ") "
                  << anInPort->PortStatus() << " --> AddInputData ERROR" << endl ;
           RetVal = false ;
@@ -1890,6 +2084,10 @@ bool GraphBase::Graph::CreateService() {
     }
   }
 
+#ifdef _DEBUG_
+  ListPorts( *_Graph_fdebug , 0 ) ;
+#endif
+
   cdebug_out << "GraphBase::Graph::CreateService " << RetVal << endl;
   return RetVal ;
 }
@@ -2016,6 +2214,10 @@ bool GraphBase::Graph::InLineServices() {
 }
 
 bool GraphBase::Graph::Sort( int & SubStreamGraphsNumber ) {
+#ifdef _DEBUG_
+  ListPorts( *_Graph_fdebug , 0 ) ;
+#endif
+
   int i ;
   int j ;
   int NotSortedNumber = GraphNodesSize() ;
@@ -2173,8 +2375,10 @@ bool GraphBase::Graph::Sort( int & SubStreamGraphsNumber ) {
       return false ; // Loop in the Graph
     }
 
+    cdebug << "Graph::Sort " << _NodesNumber[ 0 ] << " HeadNodes :" << endl ;
     for ( i= 0 ; i <= _NodesNumber[ 0 ] ; i++ ) {
       (_SortedNodes[ 0 ])[ i ]->HeadNode( true ) ;
+      cdebug << "            " << i << ". : " << (_SortedNodes[ 0 ])[ i ]->Name() << endl ;
     }
 
 // Give a subgraph/substreamgraph number > 0 to HeadNodes (level 0)
@@ -2430,12 +2634,32 @@ bool GraphBase::Graph::ValidLoops() const {
   return true ;
 }
 
+bool GraphBase::Graph::ValidSwitchs() const {
+  cdebug_in << "GraphBase::Graph::ValidSwitchs" << endl;
+
+  int i ;
+  GraphBase::ComputingNode * aNode ;
+  for ( i = 0 ; i < GraphNodesSize() ; i++ ) {
+    aNode = GraphNodes( i ) ;
+    if ( aNode->IsSwitchNode() ) {
+      GraphBase::SwitchNode * aSwitchNode = (GraphBase::SwitchNode * ) aNode ;
+      if ( !aSwitchNode->CheckSwitch() ) {
+        cdebug_out << "GraphBase::Graph::ValidSwitchs false aSwitchNode " << aSwitchNode->Name()
+                   << endl;
+        return false ;
+      }
+    }
+  }
+  cdebug_out << "GraphBase::Graph::ValidSwitchs true" << endl;
+  return true ;
+}
+
 // Controle de la coherence des noeuds de calcul
 // Enregistrement dans la liste des noeuds "tete" de graphe
 
 bool GraphBase::Graph::ComputingNodes() const {
   bool RetVal = true ;
-  cdebug << "GraphExecutor::GraphControl::ComputingNodes ()" << endl;
+  cdebug << "GraphExecutor::Graph::ComputingNodes ()" << endl;
 
 //  list<GraphEditor::Node *> aComputingNodesList = _G->ComputingNodesList() ;
 //  list<GraphEditor::Node *>::iterator aNode = aComputingNodesList.begin();
@@ -2447,6 +2671,8 @@ bool GraphBase::Graph::ComputingNodes() const {
   GraphBase::ComputingNode * aNode ;
   for ( i = 0 ; i < GraphNodesSize() ; i++ ) {
     aNode = GraphNodes( i ) ;
+    cdebug << "Graph::ComputingNodes " << i << ". " << aNode->Name() << " Head " << aNode->IsHeadNode()
+           << endl ;
     // Tous les ports d'entree de tous les noeuds de calcul sont bien connectes
     // Enregistrement eventuel dans la liste des noeuds "tete" de graphe
 //    if ((*aNode)->GetNodeInPortsSize() == 0)
@@ -2532,10 +2758,12 @@ bool GraphBase::Graph::LinkLoopNodes(bool & NewLink ) {
       GraphBase::GOTONode * aGOTONode = (GraphBase::GOTONode * ) aNode ;
       GraphBase::OutPort *anOutGate = aGOTONode->GetChangeNodeOutGate() ;
       if ( anOutGate->IsNotConnected() ) {
-       RetVal = aGOTONode->CoupledNode() != NULL;
-       if ( RetVal ) {
-         RetVal = AddLink( aGOTONode , anOutGate ,
-                       aGOTONode->CoupledNode() , aGOTONode->CoupledNode()->GetChangeNodeInGate() );
+       if ( aGOTONode->CoupledNode() ) {
+          cdebug << "Graph::LinkLoopNodes aNode " << aNode << " : " << aNode->Name()
+                 << aGOTONode->CoupledNode() << " : " << aGOTONode->CoupledNode()->Name()
+                 << endl ;
+         RetVal = AddLink( aGOTONode , anOutGate , aGOTONode->CoupledNode() ,
+                            aGOTONode->CoupledNode()->GetChangeNodeInGate() );
        // cdebug << "GraphBase::Graph::CreateService AddLink ERROR " << aGOTONode->Name() << "( "
        //        << anOutGate->PortName() << " ) --> " << aGOTONode->CoupledNode()->Name() << "( "
        //        << aGOTONode->CoupledNode()->GetChangeNodeInGate()->PortName() << " )" << endl ;
@@ -2689,7 +2917,7 @@ SUPERV::GraphState GraphBase::Graph::PortState(
       }
     }
     if ( anOutPort ) {
-      aRet = anOutPort->State() ;
+      aRet = anOutPort->PortState() ;
 //      cdebug << "GraphBase::Graph::PortState --> " << aRet << endl ;
     }
   }
@@ -2702,13 +2930,18 @@ SUPERV::GraphState GraphBase::Graph::PortState(
   return aRet ;
 }
 
-const CORBA::Any * GraphBase::Graph::PortInData( const char* ToNodeName ,
-                                                 const char* ToServiceParameterName ) {
-  const CORBA::Any * aRet = new CORBA::Any() ;
+#define TracePortInOutData 0
+//JR 30.03.2005const CORBA::Any * GraphBase::Graph::PortInData( const char* ToNodeName ,
+const CORBA::Any GraphBase::Graph::PortInData( const char* ToNodeName ,
+                                               const char* ToServiceParameterName ) {
+//JR 30.03.2005  const CORBA::Any * aRet = new CORBA::Any() ;
+  CORBA::Any aRet = CORBA::Any() ;
   char *theNode ;
   char *aPort ;
-//  cdebug_in << "GraphBase::Graph::PortInData " << ToNodeName << " "
-//            << ToServiceParameterName << endl ;
+#if TracePortInOutData
+  cdebug_in << "GraphBase::Graph::PortInData " << ToNodeName << " "
+            << ToServiceParameterName << endl ;
+#endif
   NodePort( ToNodeName , ToServiceParameterName , &theNode , &aPort ) ;
 
   GraphBase::ComputingNode * aNode = GetChangeGraphNode( theNode ) ;
@@ -2719,10 +2952,19 @@ const CORBA::Any * GraphBase::Graph::PortInData( const char* ToNodeName ,
     if ( anInPort ) {
       anOutPort = anInPort->GetOutPort() ;
       if ( anOutPort ) {
+#if TracePortInOutData
+        cdebug << "-->PortInData " << ToNodeName << " " << ToServiceParameterName << " "
+               << endl ;
+#endif
         aRet = anOutPort->Value() ;
+#if TracePortInOutData
+        cdebug << "<--PortInData " << ToNodeName << " " << ToServiceParameterName << " " ;
+        anOutPort->StringValue( *GraphBase::Base::_fdebug ) ;
+        cdebug << endl ;
         cdebug << "Graph::PortInData OutPort value " << anOutPort->NodeName() << "("
                << anOutPort->PortName() << ") --> InPort " << anInPort->NodeName()
                << "(" << anInPort->PortName() << ") " << anInPort->PortStatus() << endl ;
+#endif
       }
       else {
         cdebug << "Graph::PortInData GraphBase::Graph::PortInData " << ToNodeName << " "
@@ -2740,17 +2982,23 @@ const CORBA::Any * GraphBase::Graph::PortInData( const char* ToNodeName ,
   }
   delete theNode ;
   delete aPort ;
-//  cdebug_out << "GraphBase::Graph::PortInData " << endl ;
+#if TracePortInOutData
+  cdebug_out << "GraphBase::Graph::PortInData " << endl ;
+#endif
   return aRet ;
 }
 
-const CORBA::Any * GraphBase::Graph::PortOutData( const char* FromNodeName ,
-                                                  const char* FromServiceParameterName ) {
-  const CORBA::Any * aRet = new CORBA::Any() ;
+//JR 30.03.2005const CORBA::Any * GraphBase::Graph::PortOutData( const char* FromNodeName ,
+const CORBA::Any GraphBase::Graph::PortOutData( const char* FromNodeName ,
+                                                const char* FromServiceParameterName ) {
+//JR 30.03.2005  const CORBA::Any * aRet = new CORBA::Any() ;
+  CORBA::Any aRet = CORBA::Any() ;
   char *theNode ;
   char *aPort ;
-//  cdebug_in << "GraphBase::Graph::PortOutData " << FromNodeName << " "
-//            << FromServiceParameterName << endl ;
+#if TracePortInOutData
+  cdebug_in << "GraphBase::Graph::PortOutData " << FromNodeName << " "
+            << FromServiceParameterName << endl ;
+#endif
   NodePort( FromNodeName , FromServiceParameterName , &theNode , &aPort ) ;
 
   GraphBase::ComputingNode * aNode = GetChangeGraphNode( theNode ) ;
@@ -2759,7 +3007,16 @@ const CORBA::Any * GraphBase::Graph::PortOutData( const char* FromNodeName ,
     GraphBase::OutPort *anOutPort ;
     anOutPort = aNode->GetChangeOutPort( aPort );
     if ( anOutPort ) {
+#if TracePortInOutData
+      cdebug << "-->PortOutData " << FromNodeName << " " << FromServiceParameterName << " "
+             << endl ;
+#endif
       aRet = anOutPort->Value() ;
+#if TracePortInOutData
+      cdebug << "<--PortOutData " << FromNodeName << " " << FromServiceParameterName << " " ;
+      anOutPort->StringValue( *GraphBase::Base::_fdebug ) ;
+      cdebug << endl ;
+#endif
     }
     else {
       cdebug << "GraphBase::Graph::PortOutData " << FromNodeName << " "
@@ -2772,7 +3029,9 @@ const CORBA::Any * GraphBase::Graph::PortOutData( const char* FromNodeName ,
   }
   delete theNode ;
   delete aPort ;
-//  cdebug_out << "GraphBase::Graph::PortOutData " << endl ;
+#if TracePortInOutData
+  cdebug_out << "GraphBase::Graph::PortOutData " << endl ;
+#endif
   return aRet ;
 }
 
@@ -2822,6 +3081,6 @@ bool GraphBase::Graph::StartComponent(const int aThread ,
     }
   }
   */
-  cdebug_out << aThread << " GraphBase::Graph::StartComponent " << RetVal << endl;
+   cdebug_out << aThread << " GraphBase::Graph::StartComponent " << RetVal << endl;
   return RetVal ;
 }