]> SALOME platform Git repositories - modules/superv.git/blobdiff - src/Supervision/Graph_Impl.cxx
Salome HOME
NRI : Merge from 1.2c.
[modules/superv.git] / src / Supervision / Graph_Impl.cxx
index bfb13ce8b5c27b5f29c58dee5d30c7d2b449cf96..531b19fddec81dbf7ce643933ac3e6a93386278c 100644 (file)
 using namespace std;
 #include <stdio.h>
 #include <fstream>
-#include <strstream>
+//#include <sstream>
 #include <string>
 
-#include "utilities.h"
+//#include "utilities.h"
 
 #include "Graph_Impl.hxx"
 
@@ -84,16 +84,13 @@ Graph_Impl::Graph_Impl( CORBA::ORB_ptr orb ,
   _DebugFileName = new char[ strlen( dbgfile.c_str() )+1 ] ;
   strcpy( _DebugFileName , dbgfile.c_str() ) ;
 
-  _NamingService = new SALOME_NamingService(orb);
-//  _DataFlowEditor = new SALOME_DataFlowEditor_impl( NS ) ;
-  GraphEditor::DataFlow *  aDataFlowEditor = new GraphEditor::DataFlow(
-                                               _Orb , _NamingService ,
-                                               theDataFlowName ,
-                                               _DebugFileName ) ;
+  _NamingService = new SALOME_NamingService( orb ) ;
+  GraphEditor::DataFlow *  aDataFlowEditor = new GraphEditor::DataFlow( _Orb , _NamingService ,
+                                                                        theDataFlowName ,
+                                                                        _DebugFileName ) ;
   DataFlowEditor( aDataFlowEditor ) ;
   DataFlowEditor()->SetObjImpl( this ) ;
   _DataFlowExecutor = NULL ;
-//  _DataFlowDataNode = DataFlowEditor() ;
   delete [] theDataFlowName ;
   endService( "Graph_Impl::Graph_Impl" );
 }
@@ -257,8 +254,8 @@ SUPERV::CNode_ptr Graph_Impl::CNode(
     CNode_Impl * myNode = new CNode_Impl( _Orb , _Poa , _ContId ,
                                           instanceName() , interfaceName() ,
                                           DataFlowEditor() ,
-                                          NodeService , (char * ) NULL ,
-                                          SUPERV::ComputingNode , (char * ) NULL ) ;
+                                          NodeService , NULLSTRING ,
+                                          SUPERV::ComputingNode , NULLSTRING ) ;
     if ( myNode->DataFlowNode() ) {
       PortableServer::ObjectId * id = myNode->getId() ;
       CORBA::Object_var obj = _poa->id_to_reference(*id);
@@ -274,7 +271,7 @@ SUPERV::FNode_ptr Graph_Impl::FNode(
                         const char * NodeComponentName ,
                          const char * NodeInterfaceName ,
                          const SALOME_ModuleCatalog::Service &NodeService ) {
-  beginService( "Graph_Impl::Node" );
+  beginService( "Graph_Impl::FNode" );
   SUPERV::FNode_var iobject = SUPERV::FNode::_nil() ;
   if ( DataFlowEditor()->IsEditing() && !DataFlowEditor()->IsReadOnly() ) {
     FNode_Impl * myNode = new FNode_Impl( _Orb , _Poa , _ContId ,
@@ -290,7 +287,7 @@ SUPERV::FNode_ptr Graph_Impl::FNode(
       myNode->SetObjRef( SUPERV::FNode::_duplicate( iobject ) ) ;
     }
   }
-  endService( "Graph_Impl::Node" );
+  endService( "Graph_Impl::FNode" );
   return SUPERV::FNode::_duplicate( iobject ) ;
 }
 
@@ -438,17 +435,17 @@ SUPERV::SNode_ptr Graph_Impl::SNode(
       else {
         anEndName += "Switch" ;
       }
-      cout << "Graph_Impl::SNode anEndName " << (void *) FuncName << " " << FuncName
-           << " " << strlen(FuncName) << " " << (void *) anEndName.c_str() << " "
-           << anEndName.c_str() << endl ;
+//      cout << "Graph_Impl::SNode anEndName " << (void *) FuncName << " " << FuncName
+//           << " " << strlen(FuncName) << " " << (void *) anEndName.c_str() << " "
+//           << anEndName.c_str() << endl ;
       ESNode_Impl * myEndNode = new ESNode_Impl( _Orb , _Poa , _ContId ,
                                                instanceName() , interfaceName() ,
                                                DataFlowEditor() ,
                                                anEndName.c_str() ,
                                                SUPERV::EndSwitchNode ) ;
-      cout << "Graph_Impl::SNode returned anEndName " << (void *) FuncName << " "
-           << FuncName << " " << strlen(FuncName) << " " << (void *) anEndName.c_str()
-           << " " << anEndName.c_str() << endl ;
+//      cout << "Graph_Impl::SNode returned anEndName " << (void *) FuncName << " "
+//           << FuncName << " " << strlen(FuncName) << " " << (void *) anEndName.c_str()
+//           << " " << anEndName.c_str() << endl ;
       PortableServer::ObjectId * endid = myEndNode->getId() ;
       CORBA::Object_var endobj = _poa->id_to_reference(*endid);
       iendobject = SUPERV::ESNode::_narrow(endobj) ;
@@ -778,9 +775,16 @@ SUPERV::ListOfLinks * Graph_Impl::Links( GraphBase::ComputingNode * theNode ,
               if ( theNode == NULL ||
                    ( theNode != NULL && theNode->IsEndSwitchNode() &&
                      !strcmp( theNode->Name() , aNode->Name() ) ) ) {
-                if ( CORBA::is_nil( anOutPort->InPortObjRef( anInPort ) ) ) {
+                if ( anInPort->IsLoop() || anOutPort->IsLoop() ||
+                     ( aNode->IsEndLoopNode() && !strcmp( aNode->CoupledNode()->Name() ,
+                                                          anOutPort->NodeName() ) ) ) {
+                  MESSAGE( "Link " << anOutPort->NodeName() << "("
+                          << anOutPort->PortName() << ") --> " << aNode->Name() << "("
+                          << anInPort->PortName() << ")" << " ignored" ) ;
+               }
+                else if ( CORBA::is_nil( anOutPort->InPortObjRef( anInPort ) ) ) {
                   if ( begin ) {
-                    beginService( "Graph_Impl::ListOfLinks" );
+                    beginService( "Graph_Impl::Links" );
                     begin = false ;
                   }
                   GraphEditor::InNode * anOutNode = NULL ;
@@ -825,9 +829,16 @@ SUPERV::ListOfLinks * Graph_Impl::Links( GraphBase::ComputingNode * theNode ,
           if ( theNode || ( toNode->IsEndSwitchNode() && !aNode->IsSwitchNode() ) ) {
             if ( anInputParam == NULL ||
                  !strcmp( anInPort->PortName() , anInputParam ) ) {
-              if ( CORBA::is_nil( anOutPort->InPortObjRef( anInPort ) ) ) {
+              if ( anInPort->IsLoop() || anOutPort->IsLoop() ||
+                   ( toNode->IsEndLoopNode() && !strcmp( toNode->CoupledNode()->Name() ,
+                                                         anOutPort->NodeName() ) ) ) {
+                MESSAGE( "Link " << anOutPort->NodeName() << "("
+                        << anOutPort->PortName() << ") --> " << aNode->Name() << "("
+                        << anInPort->PortName() << ")" << " ignored" ) ;
+             }
+              else if ( CORBA::is_nil( anOutPort->InPortObjRef( anInPort ) ) ) {
                 if ( begin ) {
-                  beginService( "Graph_Impl::ListOfLinks" );
+                  beginService( "Graph_Impl::Links" );
                   begin = false ;
                 }
                 Link_Impl * myLink = new Link_Impl( _Orb , _Poa , _ContId ,
@@ -857,7 +868,7 @@ SUPERV::ListOfLinks * Graph_Impl::Links( GraphBase::ComputingNode * theNode ,
     }
   }
   if ( !begin ) {
-    endService( "Graph_Impl::ListOfLinks" );
+    endService( "Graph_Impl::Links" );
   }
   return ( RetVal._retn() ) ;
 }
@@ -930,7 +941,7 @@ SUPERV::ListOfNodes * Graph_Impl::LevelNodes(long aLevel ) {
   int i ;
   SUPERV::ListOfStrings_var Nodes = DataFlowEditor()->LevelNodes( aLevel ) ;
 //  RetVal->length( Nodes->length() );
-  for ( i = 0 ; i < Nodes->length() ; i++ ) {
+  for ( i = 0 ; i < (int ) Nodes->length() ; i++ ) {
 //    char * aNode = Nodes[ i ] ;
     GraphBase::ComputingNode * aNode = DataFlowEditor()->GetChangeGraphNode( Nodes[ i ] ) ;
     RetVal = SetNode( RetVal , aNode ) ;
@@ -1136,7 +1147,7 @@ bool Graph_Impl::Merge(const SUPERV::Graph_ptr aGraph ) {
 
     int i ;
     map< string , int > aMapOfNodes ;
-    for ( i = 0 ; i < aGraphNodes->CNodes.length() ; i++ ) {
+    for ( i = 0 ; i < (int ) aGraphNodes->CNodes.length() ; i++ ) {
       SUPERV::CNode_var aNode = (aGraphNodes->CNodes)[ i ] ;
       GraphEditor::InNode * myNode ;
       GraphBase::ListOfFuncName aFuncName = GraphBase::ListOfFuncName() ;
@@ -1144,7 +1155,7 @@ bool Graph_Impl::Merge(const SUPERV::Graph_ptr aGraph ) {
       myNode = DataFlowEditor()->AddNode( *(aNode->Service()) ,
                                           "" ,
                                           "" ,
-                                          NULL ,
+                                          NULLSTRING ,
                                           SUPERV::ComputingNode ,
                                           aFuncName ,
                                           aPythonFunction ,
@@ -1167,7 +1178,7 @@ bool Graph_Impl::Merge(const SUPERV::Graph_ptr aGraph ) {
         break ;
       }
     }
-    for ( i = 0 ; i < aGraphNodes->FNodes.length() ; i++ ) {
+    for ( i = 0 ; i < (int ) aGraphNodes->FNodes.length() ; i++ ) {
       SUPERV::FNode_var aNode = (aGraphNodes->FNodes)[ i ] ;
       GraphEditor::InNode * myNode ;
       GraphBase::ListOfFuncName aFuncName = GraphBase::ListOfFuncName() ;
@@ -1175,7 +1186,7 @@ bool Graph_Impl::Merge(const SUPERV::Graph_ptr aGraph ) {
       myNode = DataFlowEditor()->AddNode( *(aNode->Service()) ,
                                          aNode->GetComponentName() ,
                                          aNode->GetInterfaceName() ,
-                                         NULL ,
+                                         NULLSTRING ,
                                          SUPERV::ComputingNode ,
                                          aFuncName ,
                                          aPythonFunction ,
@@ -1199,7 +1210,7 @@ bool Graph_Impl::Merge(const SUPERV::Graph_ptr aGraph ) {
       }
     }
     if ( RetVal ) {
-      for ( i = 0 ; i < aGraphLinks->length() ; i++ ) {
+      for ( i = 0 ; i < (int ) aGraphLinks->length() ; i++ ) {
         SUPERV::Link_var aLink = (*aGraphLinks)[ i ] ;
         SUPERV::Port_var OutPort = aLink->OutPort() ;
         SUPERV::Port_var InPort = aLink->InPort() ;
@@ -1229,7 +1240,7 @@ bool Graph_Impl::Merge(const SUPERV::Graph_ptr aGraph ) {
        }
       }
       if ( RetVal ) {
-        for ( i = 0 ; i < aGraphPorts->length() ; i++ ) {
+        for ( i = 0 ; i < (int ) aGraphPorts->length() ; i++ ) {
           SUPERV::Port_var aPort = (*aGraphPorts)[ i ] ;
           if ( aPort->HasInput() ) {
             char * aNode = new char[ strlen( aPort->Name() + 1 ) ] ;