Salome HOME
Join modifications from BR_Dev_For_4_0 tag V4_1_1.
[modules/superv.git] / src / GraphBase / DataFlowBase_Graph.cxx
index 7b63c99cca6269f32c37453441e3abf52a48f512..e5d072362bdf6226a420d73676706e049f8d0b2c 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
 //
 //
 //
@@ -100,9 +100,9 @@ GraphBase::SNode * GraphBase::Graph::GetInfo() const {
   Info->theName = Name() ;
   Info->theKind = Kind() ;
   if ( IsDataStreamNode() ) {
-    long Timeout ;
+    CORBA::Long Timeout ;
     SUPERV::KindOfDataStreamTrace DataStreamTrace ;
-    double DeltaTime ;
+    CORBA::Double DeltaTime ;
     ((GraphBase::StreamGraph * ) this)->StreamParams( Timeout , DataStreamTrace , DeltaTime ) ;
     Info->theTimeout = Timeout ;
     Info->theDataStreamTrace = DataStreamTrace ;
@@ -241,9 +241,9 @@ GraphBase::ListOfSNodes * GraphBase::Graph::GetNodes() const {
           const GraphBase::InPort * anInPort ;
           anInPort = aCNode->GetNodeInPort( iostream ) ;
           if ( anInPort->IsDataStream() ) {
-            cdebug << "GraphBase::Graph::GetNodes In" << iostream << " " << aCNode->Name() << " " << anInPort->NodeName() << " " << anInPort->PortName()
-                   << endl ;
-            (*_list_nodes)[ind].theListOfInDataStreams[streamind].theDataStreamParameter.Parametertype = StringToDataStreamType( anInPort->PortType() ) ;
+            cdebug << "GraphBase::Graph::GetNodes In" << iostream << " " << aCNode->Name()
+                   << " " << anInPort->NodeName() << " " << anInPort->PortName() << endl;
+            (*_list_nodes)[ind].theListOfInDataStreams[streamind].theDataStreamParameter.Parametertype = CORBA::string_dup( anInPort->PortType() ) ;
             (*_list_nodes)[ind].theListOfInDataStreams[streamind].theDataStreamParameter.Parametername = CORBA::string_dup( anInPort->PortName() ) ;
             (*_list_nodes)[ind].theListOfInDataStreams[streamind].theDataStreamParameter.Parameterdependency = anInPort->Dependency() ;
             SUPERV::KindOfSchema        aKindOfSchema ;
@@ -278,7 +278,7 @@ GraphBase::ListOfSNodes * GraphBase::Graph::GetNodes() const {
           if ( anOutPort->IsDataStream() ) {
             cdebug << "GraphBase::Graph::GetNodes Out" << iostream << " " << aCNode->Name() << " " << anOutPort->NodeName() << " " << anOutPort->PortName() << " "
                    << endl ;
-            (*_list_nodes)[ind].theListOfOutDataStreams[streamind].theDataStreamParameter.Parametertype = StringToDataStreamType( anOutPort->PortType() ) ;
+            (*_list_nodes)[ind].theListOfOutDataStreams[streamind].theDataStreamParameter.Parametertype = CORBA::string_dup( anOutPort->PortType() ) ;
             (*_list_nodes)[ind].theListOfOutDataStreams[streamind].theDataStreamParameter.Parametername = CORBA::string_dup( anOutPort->PortName() ) ;
             (*_list_nodes)[ind].theListOfOutDataStreams[streamind].theDataStreamParameter.Parameterdependency = anOutPort->Dependency() ;
             long aNumberOfValues = ((GraphBase::OutDataStreamPort * ) anOutPort)->NumberOfValues() ;
@@ -1103,10 +1103,10 @@ bool GraphBase::Graph::AddLink( const char* FromNodeName ,
       CORBA::Any aValue ;
 //JR 29.09.2005 Debug for CEA : we do not do that for MacroNodes :
       if ( !fromNode->IsMacroNode() ) {
-        aValue <<= (long ) 1 ;
+        aValue <<= (CORBA::Long ) 1 ;
       }
       else {
-        aValue <<= (long ) 0 ;
+        aValue <<= (CORBA::Long ) 0 ;
       }
       fromPort->SetValue( aValue ) ;
     }
@@ -1188,6 +1188,9 @@ bool GraphBase::Graph::AddLink( GraphBase::ComputingNode *fromNode ,
       cdebug_out << "RemoveLink(AddLink) toPort->GetOutPort()->NodeName() RemoveLink Error." << endl ;
       return false ;
     }
+    if ( fromNode->IsGOTONode() && fromPort->IsGate() ) { // mkr : PAL12575
+      ((GraphBase::GOTONode * ) fromNode)->CoupledNode( (GraphBase::InLineNode * ) toNode ) ;
+    }
   }
 
   if ( !fromNode->IsDataFlowNode() && !fromNode->IsDataStreamNode() &&
@@ -1487,6 +1490,22 @@ bool GraphBase::Graph::RemoveLink( const char* FromNodeName ,
          }
           else {
             fromNode->RemoveLinkedNode( toNode ) ;
+           // mkr : PAL12575 -->
+           if ( fromNode->IsGOTONode() ) {
+             GraphBase::GOTONode * aGOTONode = (GraphBase::GOTONode * ) fromNode ;
+             if ( aGOTONode->CoupledNode() && strcmp( aGOTONode->CoupledNode()->Name(), toNode->Name() ) == 0 ) {
+               aGOTONode->CoupledNode(NULL);
+               aGOTONode->CoupledNodeName("");
+               
+               // set ExternConnected status for output data port of GoTo node
+               for ( int aPortId = 0 ; aPortId < fromNode->GetNodeOutPortsSize() ; aPortId++ ) {
+                 GraphBase::OutPort * anOutPort = fromNode->GetChangeNodeOutPort(aPortId) ;
+                 if ( anOutPort->IsNotConnected() && !anOutPort->IsGate() )
+                   anOutPort->PortStatus( ExternConnected ) ;
+               }
+             }
+           }
+           // mkr : PAL12575 <--
          }
         }
 //JR PAL7990 : a SwitchPort is an OutPort of a SwitchNode connected to a InGate Port
@@ -1579,7 +1598,7 @@ bool GraphBase::Graph::AddInputData( const char* ToNodeName ,
   bool isUnknown = false;
   switch (aValue.type()->kind()) {
     case CORBA::tk_string:
-      char * t;
+      const char * t;
       aValue >>= t;
       cdebug << t << " (string) " ;
       if ( !strcmp( t, "Unknown CORBA::Any Type" ) ) 
@@ -1592,9 +1611,9 @@ bool GraphBase::Graph::AddInputData( const char* ToNodeName ,
       cdebug << d << " (double) " ;
       break;
     case CORBA::tk_long:
-      long l;
+      CORBA::Long l;
       aValue >>= l;
-      cdebug << l << " (long) " ;
+      cdebug << l << " (CORBA::Long) " ;
       break;
     case CORBA::tk_objref:
       cdebug << "(object reference) " ;
@@ -1653,8 +1672,8 @@ bool GraphBase::Graph::AddInputData( const char* ToNodeName ,
   else {
     cdebug << "ERROR Node and/or Port not found : " << aNodeName << " " << aPortName << endl ;
   }
-  delete aNodeName ;
-  delete aPortName ;
+  delete [] aNodeName ;
+  delete [] aPortName ;
 
   cdebug_out << "GraphBase::Graph::AddInputData " << RetVal << endl;
   return RetVal ;
@@ -1669,7 +1688,7 @@ bool GraphBase::Graph::ChangeInputData( const char * ToNodeName ,
             << ToServiceParameterName << "' , Any " ;
   switch (aValue.type()->kind()) {
     case CORBA::tk_string:
-      char * t;
+      const char * t;
       aValue >>= t;
       cdebug << t << " (string) " ;
       break;
@@ -1679,9 +1698,9 @@ bool GraphBase::Graph::ChangeInputData( const char * ToNodeName ,
       cdebug << d << " (double) " ;
       break;
     case CORBA::tk_long:
-      long l;
+      CORBA::Long l;
       aValue >>= l;
-      cdebug << l << " (long) " ;
+      cdebug << l << " (CORBA::Long) " ;
       break;
     case CORBA::tk_objref:
       cdebug << "(object reference) " ;
@@ -1741,14 +1760,14 @@ bool GraphBase::Graph::AddInputData( const char* ToNodeName ,
       cdebug << t << " (string) " ;
       break;
     case CORBA::tk_double:
-      double d;
+      CORBA::Double d;
       theValue >>= d;
       cdebug << d << " (double) " ;
       break;
     case CORBA::tk_long:
-      long l;
+      CORBA::Long l;
       theValue >>= l;
-      cdebug << l << " (long) " ;
+      cdebug << l << " (CORBA::Long) " ;
       break;
     case CORBA::tk_objref:
       cdebug << "(object reference) " ;
@@ -2099,8 +2118,8 @@ bool GraphBase::Graph::CreateService() {
 //  DataService( _Orb , aService , InPortsKind , OutPortsKind , Graph_prof_debug() , Graph_fdebug() ) ;
   for ( i = 0 ; i < innbr ; i++ ) {
     if ( InPortsKind[ i ] == SUPERV::DataStreamParameter ) {
-      GraphBase::InDataStreamPort * anInPort = AddInDataStreamPort( aService.ServiceinParameter[ i ].Parametername ,
-                                                                    StringToDataStreamType( aService.ServiceinParameter[ i ].Parametertype ) ,
+      GraphBase::InDataStreamPort * anInPort = AddInDataStreamPort( aService.ServiceinParameter[ i ].Parametername,
+                                                                    aService.ServiceinParameter[ i ].Parametertype,
                                                                     InDataStreamDependency[ i ] ,
                                                                     SUPERV::DataStreamParameter ) ;
       anInPort->SetParams( InKindOfSchema[ i ] ,
@@ -2141,7 +2160,7 @@ bool GraphBase::Graph::CreateService() {
   for ( i = 0 ; i < outnbr ; i++ ) {
     if ( OutPortsKind[ i ] == SUPERV::DataStreamParameter ) {
       GraphBase::OutDataStreamPort * anOutPort = AddOutDataStreamPort( aService.ServiceoutParameter[ i ].Parametername ,
-                                                                       StringToDataStreamType( aService.ServiceoutParameter[ i ].Parametertype ) ,
+                                                                       aService.ServiceoutParameter[ i ].Parametertype ,
                                                                        OutDataStreamDependency[ i ] ,
                                                                        SUPERV::DataStreamParameter ) ;
       anOutPort->NumberOfValues( OutNumberOfValues[ i ] ) ;
@@ -2291,7 +2310,7 @@ bool GraphBase::Graph::InLineServices() {
        }
         else if ( aINode->GetChangeNodeInPort(j)->IsDataStream() ) {
           aService.ServiceinDataStreamParameter.length( InStreamService+1 ) ;
-          aService.ServiceinDataStreamParameter[InStreamService].Parametertype = StringToDataStreamType( aINode->GetChangeNodeInPort(j)->PortType() ) ;
+          aService.ServiceinDataStreamParameter[InStreamService].Parametertype = CORBA::string_dup( aINode->GetChangeNodeInPort(j)->PortType() ) ;
           aService.ServiceinDataStreamParameter[InStreamService].Parametername = CORBA::string_dup( aINode->GetChangeNodeInPort(j)->PortName() ) ;
           aService.ServiceinDataStreamParameter[InStreamService++].Parameterdependency = aINode->GetChangeNodeInPort(j)->Dependency() ;
           aINode->IncrDataStreamInPorts() ;
@@ -2334,7 +2353,7 @@ bool GraphBase::Graph::InLineServices() {
        }
         else if ( aINode->GetChangeNodeOutPort(j)->IsDataStream() ) {
           aService.ServiceoutDataStreamParameter.length( OutStreamService+1 ) ;
-          aService.ServiceoutDataStreamParameter[OutStreamService].Parametertype = StringToDataStreamType( aINode->GetChangeNodeOutPort(j)->PortType() ) ;
+          aService.ServiceoutDataStreamParameter[OutStreamService].Parametertype = CORBA::string_dup( aINode->GetChangeNodeOutPort(j)->PortType() ) ;
           aService.ServiceoutDataStreamParameter[OutStreamService].Parametername = CORBA::string_dup( aINode->GetChangeNodeOutPort(j)->PortName() ) ;
           aService.ServiceoutDataStreamParameter[OutStreamService++].Parameterdependency = aINode->GetChangeNodeOutPort(j)->Dependency() ;
           aINode->IncrDataStreamOutPorts() ;
@@ -2773,6 +2792,59 @@ bool GraphBase::Graph::Sort( int & SubStreamGraphsNumber ) {
   return true ;
 }
 
+// mkr : PAL12575
+bool GraphBase::Graph::ValidGOTO() {
+  cdebug_in << "GraphBase::Graph::ValidGOTO" << endl;
+  bool RetVal = true ;
+  int i, j ;
+  GraphBase::ComputingNode * aNode ;
+  for ( i = 0 ; i < GraphNodesSize() ; i++ ) {
+    aNode = GraphNodes( i ) ;
+    if ( aNode->IsGOTONode() ) {
+      GraphBase::GOTONode * aGoToNode = (GraphBase::GOTONode * ) aNode ;
+      GraphBase::InLineNode * aCoupledNode ;
+      aCoupledNode = (GraphBase::InLineNode * ) aGoToNode->CoupledNode() ;
+      if ( aCoupledNode ) {
+       ostringstream ErrorMessage ;
+       // 1. Check the number of ports (the number of OutPorts of a GOTONode and of InPorts of its linked
+       //    InLine node must be the same)
+       if ( aNode->GetNodeOutPortsSize() != aCoupledNode->GetNodeInPortsSize() ) {
+         cdebug << "GraphBase::Graph::ValidGOTO : Different ports number!" << endl ;
+         ReSetMessages() ;
+         ErrorMessage << "Different ports number : the number of OutPorts of a " << aNode->Name()
+                      << " node (GoTo node) and of InPorts of its linked " << aCoupledNode->Name()
+                      << " node (InLine node) must be the same!\n" ;
+         SetMessages( ErrorMessage.str() ) ;
+         RetVal = false ;
+       }
+       // 2. Check ports names (the names of OutPorts of a GOTONode and of InPorts of its linked
+       //    InLine node must be the same)
+       else {
+         for ( j = 0 ; j < aNode->GetNodeOutPortsSize() ; j++ ) {
+           GraphBase::OutPort * aBusParamOutPort = aNode->GetChangeNodeOutPort( j ) ;
+           if ( !aBusParamOutPort->IsGate() ) {
+             GraphBase::InPort * aBusParamChangeInPort = NULL ;
+             aBusParamChangeInPort = aCoupledNode->GetChangeInPort( aBusParamOutPort->PortName() ) ;
+             if ( !aBusParamChangeInPort ) {
+               cdebug << "GraphBase::Graph::ValidGOTO : Different names of ports!" << endl ;
+               ReSetMessages() ;
+               ErrorMessage << "Different names of ports : there is no input port of " << aCoupledNode->Name()
+                            << " node (InLine node) coupled to " << aBusParamOutPort->PortName() 
+                            << " output port of a " << aNode->Name()
+                            << " node (GoTo node)\n" ;
+               SetMessages( ErrorMessage.str() ) ;
+               RetVal = false ;
+             }
+           }
+         }
+       }
+      }
+    }
+  }
+  cdebug_out << "GraphBase::Graph::ValidGOTO RetVal " << RetVal << endl;
+  return RetVal ;
+}
+
 bool GraphBase::Graph::ValidLoops() const {
   cdebug_in << "GraphBase::Graph::ValidLoops" << endl;
   bool RetVal = true ;
@@ -3020,7 +3092,7 @@ bool GraphBase::Graph::DataServerNodes() const {
         const GraphBase::OutPort * anOutPort = aNode->GetNodeOutPort(j) ;
 //JR Debug 06.06.2005 : if it is not a Gate !
 //        if ( anOutPort->IsNotConnected() ) {
-        if ( anOutPort->IsNotConnected() && !anOutPort->IsGate() ) {
+        if ( anOutPort->IsNotConnected() && !anOutPort->IsGate() && !aNode->IsGOTONode() ) { // mkr : PAL12575
           cdebug << "Graph::DataServerNodes Add[Stream]LinkedNode for OutPort "
                  << aNode->Name() << "( " << anOutPort->PortName() << " , "
                  << anOutPort->PortStatus() << " )" << endl ;
@@ -3183,8 +3255,8 @@ const CORBA::Any GraphBase::Graph::PortInData( const char* ToNodeName ,
     cdebug << "GraphBase::Graph::PortInData " << ToNodeName << " "
            << ToServiceParameterName << " ERROR no Node" << endl ;
   }
-  delete theNode ;
-  delete aPort ;
+  delete [] theNode ;
+  delete [] aPort ;
 #if TracePortInOutData
   cdebug_out << "GraphBase::Graph::PortInData " << endl ;
 #endif
@@ -3235,8 +3307,8 @@ const CORBA::Any GraphBase::Graph::PortOutData( const char* FromNodeName ,
     cdebug << "GraphBase::Graph::PortOutData " << FromNodeName << " "
            << FromServiceParameterName << " ERROR no Node" << endl ;
   }
-  delete theNode ;
-  delete aPort ;
+  delete [] theNode ;
+  delete [] aPort ;
 #if TracePortInOutData
   cdebug_out << "GraphBase::Graph::PortOutData " << endl ;
 #endif