]> SALOME platform Git repositories - modules/superv.git/blobdiff - src/GraphBase/DataFlowBase_ComputingNode.cxx
Salome HOME
NRI : Merge from 1.2c.
[modules/superv.git] / src / GraphBase / DataFlowBase_ComputingNode.cxx
index ad86cd829d763a4421e3fdcc3af6a8fd405fdd2b..bb47f9ecf99c25da549dcd3bd622cb32105e8f23 100644 (file)
@@ -10,8 +10,8 @@
 //  $Header:
 
 using namespace std;
-#include <strstream>
-#include <iostream>
+//#include <sstream>
+//#include <iostream>
 
 #include "DataFlowBase_InLineNode.hxx"
 #include "DataFlowBase_LoopNode.hxx"
@@ -77,10 +77,7 @@ GraphBase::ComputingNode::ComputingNode() :
   _InNode = NULL ;
   _ThreadNo = pthread_self() ;
   _Name = NULL ;
-  cdebug << "GraphBase::Node::Node "  << this 
-          << " _Name "
-         << (void *) _Name << " " << _Name << " _Comment "
-         << (void *) _Comment << " "  << _Comment << " "  << endl ;
+  cdebug << "GraphBase::Node::Node "  << this << " "  << endl ;
 
 }
 
@@ -88,9 +85,10 @@ GraphBase::ComputingNode::ComputingNode( CORBA::ORB_ptr ORB ,
                                          SALOME_NamingService* ptrNamingService ,
                                          const char * aDataFlowName ,
                                          int * Graph_prof_debug ,
-                                         ostream * Graph_fdebug ) :
+                                         ofstream * Graph_fdebug ) :
   GraphBase::PortsOfNode::PortsOfNode( aDataFlowName ) {
 
+  MESSAGE( "GraphBase::ComputingNode::ComputingNode( " << aDataFlowName << " Graph_fdebug " << Graph_fdebug ) ;
   InitFields( _Kind ,
               _FirstCreation ,
               _LastModification ,
@@ -106,26 +104,30 @@ GraphBase::ComputingNode::ComputingNode( CORBA::ORB_ptr ORB ,
 
   _ORB = CORBA::ORB::_duplicate( ORB ) ;
   _NamingService = ptrNamingService ;
-  _Graph_prof_debug = Graph_prof_debug ;
-  _Graph_fdebug = Graph_fdebug ;
   _Node = SUPERV::CNode::_nil() ;
   _InNode = NULL ;
   _ThreadNo = pthread_self() ;
 
-  if ( aDataFlowName && strlen( aDataFlowName ) ) {
+  if ( aDataFlowName != NULLSTRING && strlen( aDataFlowName ) ) {
     _Name = new char[ strlen( aDataFlowName )+1 ] ;
     strcpy( _Name , aDataFlowName ) ;
   }
-  else
-    _Name = NULL ;
+  else {
+    _Name = NULLSTRING ;
+  }
   if ( Graph_prof_debug ) {
+//    MESSAGE( "GraphBase::ComputingNode::ComputingNode --> SetDebug" ) ;
+//    cout << "GraphBase::ComputingNode::ComputingNode --> SetDebug" << endl ;
+    _Graph_prof_debug = Graph_prof_debug ;
+    _Graph_fdebug = Graph_fdebug ;
     SetDebug( ORB , Graph_prof_debug , Graph_fdebug ) ;
-//    MESSAGE( "Invalid DataFlow Name." );
   }
+//  else {
+//    cout << "GraphBase::ComputingNode::ComputingNode NO SetDebug" << endl ;
+//  }
   cdebug << "GraphBase::ComputingNode::ComputingNode "  << this 
          << "' _Name "
-         << (void *) _Name << " '" << _Name << " _Comment "
-         << (void *) _Comment << " "  << _Comment << " "  << _FirstCreation
+         << (void *) _Name << " '" << _Name << " "  << _FirstCreation
          << " "  << _LastModification << endl ;
 }
 
@@ -143,13 +145,11 @@ GraphBase::ComputingNode::ComputingNode( CORBA::ORB_ptr ORB ,
                                          const long   X ,
                                          const long   Y ,
                                          int * Graph_prof_debug ,
-                                         ostream * Graph_fdebug ) :
+                                         ofstream * Graph_fdebug ) :
   GraphBase::PortsOfNode::PortsOfNode() {
 
   _ORB = CORBA::ORB::_duplicate( ORB ) ;
   _NamingService = ptrNamingService ;
-  _Graph_prof_debug = Graph_prof_debug ;
-  _Graph_fdebug = Graph_fdebug ;
   _Node = SUPERV::CNode::_nil() ;
   _InNode = NULL ;
   _ThreadNo = pthread_self() ;
@@ -166,7 +166,7 @@ GraphBase::ComputingNode::ComputingNode( CORBA::ORB_ptr ORB ,
   _FirstCreation.Month  = _LastModification.Month  = Tm->tm_mon + 1;
   _FirstCreation.Year   = _LastModification.Year   = Tm->tm_year + 1900; 
 
-  if ( NodeEditorRelease ) {
+  if ( NodeEditorRelease != NULLSTRING ) {
     _EditorRelease = new char[ strlen( NodeEditorRelease ) + 1 ] ;
     strcpy( _EditorRelease , NodeEditorRelease ) ;
   }
@@ -175,19 +175,21 @@ GraphBase::ComputingNode::ComputingNode( CORBA::ORB_ptr ORB ,
     strcpy( _EditorRelease , SuperVision_Version ) ;
   }
 
-  if ( NodeAuthor ) {
+  if ( NodeAuthor != NULLSTRING ) {
     _Author = new char[ strlen( NodeAuthor ) + 1 ] ;
     strcpy( _Author  , NodeAuthor ) ;
   }
-  else
+  else {
     _Author = NULLSTRING ;
+  }
 
-  if ( NodeComment  ) {
+  if ( NodeComment != NULLSTRING ) {
     _Comment = new char[ strlen( NodeComment ) + 1 ] ;
     strcpy( _Comment  , NodeComment ) ;
   }
-  else
+  else {
     _Comment = NULLSTRING ;
+  }
 
   _SubGraphNumber = 0 ;
   _HeadNode = false ;
@@ -204,20 +206,27 @@ GraphBase::ComputingNode::ComputingNode( CORBA::ORB_ptr ORB ,
   _X = X ;
   _Y = Y ;
 
-  if ( Graph_prof_debug )
-    SetDebug( ORB , Graph_prof_debug , Graph_fdebug ) ;
+//  MESSAGE( "GraphBase::ComputingNode::ComputingNode --> SetDebug " << Graph_prof_debug << " Graph_fdebug "
+//           << Graph_fdebug ) ;
+//  cout << "GraphBase::ComputingNode::ComputingNode --> SetDebug " << Graph_prof_debug << " Graph_fdebug "
+//       << Graph_fdebug << endl ;
+  _Graph_prof_debug = Graph_prof_debug ;
+  _Graph_fdebug = Graph_fdebug ;
+  SetDebug( ORB , Graph_prof_debug , Graph_fdebug ) ;
+//  MESSAGE( "GraphBase::ComputingNode::ComputingNode SetDebug Done " << Graph_prof_debug << " Graph_fdebug "
+//           << Graph_fdebug << " aService.ServiceName " << aService.ServiceName ) ;
+//  cout << "GraphBase::ComputingNode::ComputingNode SetDebug Done " << Graph_prof_debug << " Graph_fdebug "
+//       << Graph_fdebug << endl ;
+//  cout << "GraphBase::ComputingNode::ComputingNode(" << aService.ServiceName << "," << aNodeName << ","
+//       << akind << ")" << endl;
+  cdebug_in << "GraphBase::ComputingNode::ComputingNode(" << aService.ServiceName << "," << aNodeName << ","
+            << akind << ")" << endl;
+  
 
-    DefPortsOfNode( ORB , aService , NamePtr() , Kind() ,
-                    Graph_prof_debug , Graph_fdebug ) ;
+  DefPortsOfNode( ORB , aService , NamePtr() , Kind() , Graph_prof_debug , Graph_fdebug ) ;
 
-  cdebug_in << "GraphBase::ComputingNode::ComputingNode(" << aService.ServiceName << ","
-            << aNodeName << "," << akind
-            << "," << NodeComment << ")" << endl;
-  
   cdebug << "GraphBase::ComputingNode::ComputingNode "  << this 
-         << " _Name "
-         << (void *) _Name << " '" << _Name << "' _Comment "
-         << (void *) _Comment << " "  << _Comment << " " 
+         << " _Name " << (void *) _Name << " '" << _Name
          << " KindOfNode " << _Kind
          << " ServiceName " << ServiceName() << " In(" << ServiceInParameter().length()
          << ") Out(" << ServiceOutParameter().length() << ")" << endl ;
@@ -243,19 +252,21 @@ GraphBase::ComputingNode::~ComputingNode() {
 }
 
 bool GraphBase::ComputingNode::Name( const char * aName) {
+  cdebug_in << "GraphBase::ComputingNode::Name " << _Name << endl;
   if ( _Name ) {
     cdebug << "GraphBase::ComputingNode::ReName "  << _Name << " --> " << aName << endl ;
     delete [] _Name ;
   }
   _Name = new char[strlen(aName)+1] ;
   strcpy( _Name , aName ) ;
+  cdebug_out << "GraphBase::ComputingNode::Name " << _Name << endl;
   return true ;
 }
 
 SUPERV::SDate GraphBase::ComputingNode::FirstCreation () const {
-  cdebug << "GraphBase::ComputingNode::FirstCreation "
-         << "' _Name " << _Name << " "  << _FirstCreation << " "  
-         << _LastModification << endl ;
+//  cdebug << "GraphBase::ComputingNode::FirstCreation "
+//         << "' _Name " << _Name << " "  << _FirstCreation << " "  
+//         << _LastModification << endl ;
   return _FirstCreation;
 }
 
@@ -284,18 +295,20 @@ bool GraphBase::ComputingNode::EditorRelease(const char * c){
 }
 
 bool GraphBase::ComputingNode::Author(const char * a) {
+  cdebug_in << "GraphBase::ComputingNode::Author " << _Author << endl;
   if ( _Author && _Author != NULLSTRING )
     delete _Author;
   _Author = my_strdup(a);
+  cdebug_out << "GraphBase::ComputingNode::Author " << _Author << endl;
   return true ;
 }
 
 bool GraphBase::ComputingNode::Comment(const char *c) {
-  cdebug_in << "GraphBase::ComputingNode::Comment" << endl;
+  cdebug_in << "GraphBase::ComputingNode::Comment " << _Comment << endl;
   if ( _Comment != NULLSTRING )
     delete [] _Comment;
   _Comment = my_strdup(c);
-  cdebug_out << "GraphBase::ComputingNode::Comment" << endl;
+  cdebug_out << "GraphBase::ComputingNode::Comment " << _Comment << endl;
   return true ;
 }
 
@@ -597,7 +610,12 @@ bool GraphBase::ComputingNode::SaveXML( QDomDocument & Graph , QDomElement & inf
     QDomElement inParametertype = Graph.createElement("inParameter-type") ;
     // mpv: Linux 8.0 compiler compatibility
 //    aField = Graph.createTextNode( (char *)ServiceInParameter()[i].Parametertype ) ;
-    aField = Graph.createTextNode( strdup(ServiceInParameter()[i].Parametertype) ) ;
+    if ( strlen( ServiceInParameter()[i].Parametertype ) ) {
+      aField = Graph.createTextNode( strdup( ServiceInParameter()[i].Parametertype ) ) ;
+    }
+    else {
+      aField = Graph.createTextNode( "?" ) ;
+    }
     inParameter.appendChild(inParametertype) ;
     inParametertype.appendChild( aField ) ;
 //    f << Tabs << "                   <inParameter-name>"
@@ -606,7 +624,12 @@ bool GraphBase::ComputingNode::SaveXML( QDomDocument & Graph , QDomElement & inf
     QDomElement inParametername = Graph.createElement("inParameter-name") ;
     // mpv: Linux 8.0 compiler compatibility
 //    aField = Graph.createTextNode( (char *) ServiceInParameter()[i].Parametername ) ;
-    aField = Graph.createTextNode( strdup(ServiceInParameter()[i].Parametername) ) ;
+    if ( strlen( ServiceInParameter()[i].Parametername ) ) {
+      aField = Graph.createTextNode( strdup(ServiceInParameter()[i].Parametername) ) ;
+    }
+    else {
+      aField = Graph.createTextNode( "?" ) ;
+    }
     inParameter.appendChild(inParametername) ;
     inParametername.appendChild( aField ) ;
 //    f << Tabs << "           </inParameter>" << endl ;
@@ -625,7 +648,12 @@ bool GraphBase::ComputingNode::SaveXML( QDomDocument & Graph , QDomElement & inf
     QDomElement outParametertype = Graph.createElement("outParameter-type") ;
     // mpv: Linux 8.0 compiler compatibility
 //    aField = Graph.createTextNode( (char *) ServiceOutParameter()[i].Parametertype ) ;
-    aField = Graph.createTextNode( strdup(ServiceOutParameter()[i].Parametertype) ) ;
+    if ( strlen( ServiceOutParameter()[i].Parametertype ) ) {
+      aField = Graph.createTextNode( strdup(ServiceOutParameter()[i].Parametertype) ) ;
+    }
+    else {
+      aField = Graph.createTextNode( "?" ) ;
+    }
     outParameter.appendChild(outParametertype) ;
     outParametertype.appendChild( aField ) ;
 //    f << Tabs << "                   <outParameter-name>"
@@ -634,7 +662,12 @@ bool GraphBase::ComputingNode::SaveXML( QDomDocument & Graph , QDomElement & inf
     QDomElement outParametername = Graph.createElement("outParameter-name") ;
     // mpv: Linux 8.0 compiler compatibility
 //    aField = Graph.createTextNode( (char *) ServiceOutParameter()[i].Parametername ) ;
-    aField = Graph.createTextNode( strdup(ServiceOutParameter()[i].Parametername) ) ;
+    if ( strlen( ServiceOutParameter()[i].Parametername ) ) {
+      aField = Graph.createTextNode( strdup(ServiceOutParameter()[i].Parametername) ) ;
+    }
+    else {
+      aField = Graph.createTextNode( "?" ) ;
+    }
     outParameter.appendChild(outParametername) ;
     outParametername.appendChild( aField ) ;
 //    f << Tabs << "           </outParameter>" << endl ;
@@ -684,7 +717,7 @@ bool GraphBase::ComputingNode::SaveXML( QDomDocument & Graph , QDomElement & inf
     QDomElement PyFunction = Graph.createElement("PyFunction") ;
     PyFunctionlist.appendChild( PyFunction ) ;
     int j ;
-    for ( j = 0 ; j < (*PythonFunctions[i]).length() ; j++ ) {
+    for ( j = 0 ; j < (int ) (*PythonFunctions[i]).length() ; j++ ) {
       if ( j == 0 ) {
 //        if ( i == 0 ) {
 //          f << Tabs << "             <FuncName>" << FuncNames[i].c_str()
@@ -716,12 +749,12 @@ bool GraphBase::ComputingNode::SaveXML( QDomDocument & Graph , QDomElement & inf
 //       char * aCDATAChar = (char *) (*PythonFunctions[i])[j] ;
       char * aCDATAChar = strdup ((*PythonFunctions[i])[j]) ;
       int i ;
-      for ( i = 0 ; i < strlen( aCDATAChar ) ; i++ ) {
+      for ( i = 0 ; i < (int ) strlen( aCDATAChar ) ; i++ ) {
         if ( aCDATAChar[ i ] != ' ' ) {
           break ;
        }
       }
-      if ( i == strlen( aCDATAChar ) ) {
+      if ( i == (int ) strlen( aCDATAChar ) ) {
         aCDATA = Graph.createCDATASection( "?" ) ;
       }
       else {
@@ -820,13 +853,13 @@ bool GraphBase::ComputingNode::SavePY( ostream &f , const char * aGraphName ,
   else if ( IsComputingNode() ) {
     int i ;
     f << Name() << "_ServiceinParameter = []" << endl ;
-    for ( i = 0 ; i < ServiceInParameter().length() ; i++ ) {
+    for ( i = 0 ; i < (int ) ServiceInParameter().length() ; i++ ) {
       f << Name() << "_ServiceinParameter.append( SALOME_ModuleCatalog.ServicesParameter( '"
         << ServiceInParameter()[i].Parametertype << "' , '"
         << ServiceInParameter()[i].Parametername << "' ) )" << endl ;
     }
     f << Name() << "_ServiceoutParameter = []" << endl ;
-    for ( i = 0 ; i < ServiceOutParameter().length() ; i++ ) {
+    for ( i = 0 ; i < (int ) ServiceOutParameter().length() ; i++ ) {
       f << Name() << "_ServiceoutParameter.append( SALOME_ModuleCatalog.ServicesParameter( '"
         << ServiceOutParameter()[i].Parametertype << "' , '"
         << ServiceOutParameter()[i].Parametername << "' ) )" << endl ;
@@ -848,7 +881,7 @@ bool GraphBase::ComputingNode::SavePY( ostream &f , const char * aGraphName ,
     SUPERV::ListOfStrings aPyFunc ;
     if ( PythonFunctions.size() ) {
       aPyFunc = *PythonFunctions[0] ;
-      for ( i = 0 ; i < aPyFunc.length() ; i++ ) {
+      for ( i = 0 ; i < (int ) aPyFunc.length() ; i++ ) {
         f << "Py" << Name() << ".append( '" << aPyFunc[i] << "' )" << endl ;
       }
     }
@@ -876,11 +909,11 @@ bool GraphBase::ComputingNode::SavePY( ostream &f , const char * aGraphName ,
         SUPERV::ListOfStrings aPyMore = *PythonFunctions[1] ;
         SUPERV::ListOfStrings aPyNext = *PythonFunctions[2] ;
         f << "PyMore" << Name() << " = []" << endl ;
-        for ( i = 0 ; i < aPyMore.length() ; i++ ) {
+        for ( i = 0 ; i < (int ) aPyMore.length() ; i++ ) {
           f << "PyMore" << Name() << ".append( '" << aPyMore[i] << "' )" << endl ;
         }
         f << "PyNext" << Name() << " = []" << endl ;
-        for ( i = 0 ; i < aPyNext.length() ; i++ ) {
+        for ( i = 0 ; i < (int ) aPyNext.length() ; i++ ) {
           f << "PyNext" << Name() << ".append( '" << aPyNext[i] << "' )" << endl ;
         }
         f << Name() << "," << EndName << " = " << aGraphName << ".LNode( '"
@@ -904,7 +937,7 @@ bool GraphBase::ComputingNode::SavePY( ostream &f , const char * aGraphName ,
           << aCoupledNode->YCoordinate() << " )" << endl ;
         SUPERV::ListOfStrings aPyFunc = *aCoupledNode->PythonFunction() ;
         f << "Py" << aCoupledNode->Name() << " = []" << endl ;
-        for ( i = 0 ; i < aPyFunc.length() ; i++ ) {
+        for ( i = 0 ; i < (int ) aPyFunc.length() ; i++ ) {
           f << "Py" << aCoupledNode->Name() << ".append( '" << aPyFunc[i] << "' )"
             << endl ;
         }
@@ -926,6 +959,18 @@ bool GraphBase::ComputingNode::SavePY( ostream &f , const char * aGraphName ,
       }
       delete [] EndName ;
     }
+  }
+
+  f << Name() << ".SetName( '" << Name() << "' )" << endl ;
+  f << Name() << ".SetAuthor( '" << Author() << "' )" << endl ;
+  if ( IsFactoryNode() ) {
+    f << Name() << ".SetContainer( '" << Computer << "' )" << endl ;
+  }
+  f << Name() << ".SetComment( '" << Comment() << "' )" << endl ;
+  f << Name() << ".Coords( " << XCoordinate << " , " << YCoordinate << " )" << endl ;
+
+  if ( IsOneOfInLineNodes() ) {
+    int i ;
     for ( i = 0 ; i < GetNodeInPortsSize() ; i++ ) {
       const GraphBase::InPort * anInPort = GetNodeInPort(i) ;
       if ( anInPort->IsInLine() ) {
@@ -942,14 +987,6 @@ bool GraphBase::ComputingNode::SavePY( ostream &f , const char * aGraphName ,
     }
   }
 
-  f << Name() << ".SetName( '" << Name() << "' )" << endl ;
-  f << Name() << ".SetAuthor( '" << Author() << "' )" << endl ;
-  if ( IsFactoryNode() ) {
-    f << Name() << ".SetContainer( '" << Computer << "' )" << endl ;
-  }
-  f << Name() << ".SetComment( '" << Comment() << "' )" << endl ;
-  f << Name() << ".Coords( " << XCoordinate << " , " << YCoordinate << " )" << endl ;
-
 #if 0
   if ( IsLoopNode() || IsSwitchNode() ) {
     f << EndName << ".SetName( '" << CoupledNode
@@ -975,8 +1012,7 @@ bool GraphBase::ComputingNode::SavePY( ostream &f , const char * aGraphName ,
   return true ;
 }
 
-void GraphBase::ComputingNode::NodeInfo(ostrstream & s) const {
-  int i ;
+void GraphBase::ComputingNode::NodeInfo(ostream & s) const {
   s << *this ;
   ListPorts( s , true ) ;
   s << ends ;