Salome HOME
*** empty log message ***
[modules/superv.git] / src / Supervision / INode_Impl.cxx
index bbce38e53bde4fe331392daa8834a46848118a2c..9bda5bf95a52161f5dc552fa948597c76c08a98d 100644 (file)
@@ -177,80 +177,178 @@ char * INode_Impl::PyFuncName() {
   return CORBA::string_dup( DataFlowNode()->PyFuncName() ) ;
 }
 
-#if 0
-bool INode_Impl::BusPort( const char * InOutParameterName ,
-                         const char * InOutParameterType ,
-                        SUPERV::Port_out InputPort ,
-                        SUPERV::Port_out OutputPort ) {
-  return BusPorts( InOutParameterName , InOutParameterType ,
-                   InOutParameterName , InOutParameterType ,
-                   InputPort , OutputPort ) ;
+SUPERV::Port_ptr INode_Impl::InPort( const char *aParameterName ,
+                                     const char *aParameterType ) {
+  SUPERV::Port_ptr Inobject = SUPERV::Port::_nil() ;
+  SUPERV::Port_ptr Outobject = SUPERV::Port::_nil() ;
+  SUPERV::Port_ptr InEndobject = SUPERV::Port::_nil() ;
+  Port_Impl * myInPort = NULL ;
+  bool InPortCreated = false ;
+  MESSAGE( "CNode_Impl::InPort " << DataFlowNode()->Name() << "->AddInPort( " << aParameterName << " , "
+           << aParameterType << " )" ) ;
+  GraphBase::InPort * anInPort = DataFlowNode()->GetChangeInPort( aParameterName ) ;
+  if ( anInPort == NULL ) {
+    anInPort = DataFlowNode()->AddInPort( aParameterName , aParameterType , SUPERV::InLineParameter ) ;
+    InPortCreated = true ;
+  }
+  if ( anInPort ) {
+    Inobject = anInPort->ObjRef() ;
+    if ( CORBA::is_nil( Inobject ) ) {
+      myInPort = new Port_Impl( _Orb , _Poa , _ContId ,
+                                instanceName() , interfaceName() ,
+                                DataFlowEditor() ,
+                                DataFlowNode() ,
+                                (GraphBase::Port * ) anInPort ,
+                                true ) ;
+      if ( myInPort ) {
+        PortableServer::ObjectId * id = myInPort->getId() ;
+        CORBA::Object_var obj = _poa->id_to_reference(*id) ;
+        Inobject = SUPERV::Port::_narrow(obj) ;
+      }      
+    }
+  }
+
+  if ( !CORBA::is_nil( Inobject ) && InPortCreated &&
+       ( DataFlowNode()->IsLoopNode() || DataFlowNode()->IsEndLoopNode() ) ) {
+//         || DataFlowNode()->IsEndSwitchNode() ) ) {
+    Outobject = OutPort( aParameterName , aParameterType ) ;
+    if ( DataFlowNode()->IsLoopNode() ) {
+      LNode_Impl * myLoopNode = (LNode_Impl * ) this ;
+      InEndobject = myLoopNode->Coupled()->InPort( aParameterName , aParameterType ) ;
+      DataFlowEditor()->AddLink( Outobject->Node()->Name() , Outobject->Name() ,
+                                 InEndobject->Node()->Name() , InEndobject->Name() ) ;
+    }
+  }
+  DataFlowEditor()->UnValid() ;
+  return SUPERV::Port::_duplicate( Inobject ) ;
 }
 
-bool INode_Impl::BusPorts( const char * InputParameterName ,
-                          const char * InputParameterType ,
-                          const char * OutputParameterName ,
-                          const char * OutputParameterType ,
-                         SUPERV::Port_out InputPort ,
-                         SUPERV::Port_out OutputPort ) {
-  beginService( "INode_Impl::BusPorts" );
-  bool RetVal = false ;
-  Port_Impl * myInPort = NULL ;
+SUPERV::Port_ptr INode_Impl::OutPort( const char *aParameterName ,
+                                      const char *aParameterType ) {
   Port_Impl * myOutPort = NULL ;
-  SUPERV::Port_var Inobject = SUPERV::Port::_nil() ;
-  SUPERV::Port_var Outobject = SUPERV::Port::_nil() ;
-//  if ( DataFlowNode()->GetInPort( InputParameterName ) ||
-//       DataFlowNode()->GetOutPort( OutputParameterName ) ) {
-//  }
-//  else {
-    GraphBase::InPort * anInPort = DataFlowNode()->AddInPort( InputParameterName ,
-                                                             InputParameterType ) ;
-    if ( anInPort ) {
-      myInPort = new Port_Impl( _Orb , _Poa , _ContId ,
+  SUPERV::Port_ptr Outobject = SUPERV::Port::_nil() ;
+  MESSAGE( "CNode_Impl::OutPort " << DataFlowNode()->Name() << "->AddOutPort( " << aParameterName << " , "
+           << aParameterType << " )" ) ;
+  GraphBase::OutPort * anOutPort = DataFlowNode()->GetChangeOutPort( aParameterName ) ;
+  if ( anOutPort == NULL ) {
+    anOutPort = DataFlowNode()->AddOutPort( aParameterName , aParameterType , SUPERV::InLineParameter ) ;
+  }
+  if ( anOutPort ) {
+    Outobject = anOutPort->ObjRef() ;
+    if ( CORBA::is_nil( Outobject ) ) {
+      const CORBA::Any * anAny = anOutPort->Value() ;
+      myOutPort = new Port_Impl( _Orb , _Poa , _ContId ,
+                                 instanceName() , interfaceName() ,
+                                 DataFlowEditor() ,
+                                 DataFlowNode() ,
+                                 (GraphBase::Port * ) anOutPort ,
+                                 false ,
+                                 anAny ) ;
+      if ( myOutPort ) {
+        PortableServer::ObjectId * id = myOutPort->getId() ;
+        CORBA::Object_var obj = _poa->id_to_reference(*id) ;
+        Outobject = SUPERV::Port::_narrow(obj) ;
+      }
+    }
+  }
+  DataFlowEditor()->UnValid() ;
+  return SUPERV::Port::_duplicate( Outobject );
+}
+
+SUPERV::StreamPort_ptr INode_Impl::InStreamPort( const char *aParameterName ,
+                                                 const SALOME_ModuleCatalog::DataStreamType aParameterType ,
+                                                 const SALOME_ModuleCatalog::DataStreamDependency aDependency ) {
+  SUPERV::StreamPort_ptr Inobject = SUPERV::StreamPort::_nil() ;
+  if ( DataFlowEditor()->Graph()->IsDataStreamNode() ) {
+    StreamPort_Impl * myInStreamPort = NULL ;
+    bool InPortCreated = false ;
+    MESSAGE( "INode_Impl::InStreamPort " << DataFlowNode()->Name() << "->AddInPort( " << aParameterName << " , "
+             << aParameterType << " )" ) ;
+    GraphBase::InPort * anInPort = DataFlowNode()->GetChangeInPort( aParameterName ) ;
+    if ( anInPort && !anInPort->IsDataStream() ) {
+      MESSAGE( "INode_Impl::InStreamPort ERROR !IsDataStream " ) ;
+    }
+    else if ( DataFlowEditor()->Graph()->IsDataStreamNode() ) {
+      if ( anInPort == NULL ) {
+        anInPort = DataFlowNode()->ComputingNode()->AddInDataStreamPort( aParameterName , aParameterType , aDependency , SUPERV::DataStreamParameter ) ;
+        InPortCreated = true ;
+      }
+
+      if ( anInPort ) {
+        Inobject = SUPERV::StreamPort::_narrow( anInPort->ObjRef() ) ;
+        if ( CORBA::is_nil( Inobject ) ) {
+          myInStreamPort = new StreamPort_Impl( _Orb , _Poa , _ContId ,
                                 instanceName() , interfaceName() ,
                                 DataFlowEditor() ,
                                 DataFlowNode() ,
-//                                InputParameterName ) ;
                                 (GraphBase::Port * ) anInPort ,
                                 true ) ;
-      GraphBase::OutPort * anOutPort = DataFlowNode()->AddOutPort( OutputParameterName ,
-                                                                  OutputParameterType ) ;
-      if ( anOutPort ) {
-        const CORBA::Any * anAny = anOutPort->Value() ;
-        myOutPort = new Port_Impl( _Orb , _Poa , _ContId ,
-                                  instanceName() , interfaceName() ,
-                                  DataFlowEditor() ,
-                                  DataFlowNode() ,
-//                                  OutputParameterName ,
-                                  (GraphBase::Port * ) anOutPort ,
-                                  false ,
-                                  anAny ) ;
-        DataFlowNode()->InOutPort( anInPort , anOutPort ) ;
-        RetVal = true ;
+          if ( myInStreamPort ) {
+            PortableServer::ObjectId * id = myInStreamPort->getId() ;
+            CORBA::Object_var obj = _poa->id_to_reference(*id) ;
+            Inobject = SUPERV::StreamPort::_narrow(obj) ;
+            anInPort->ObjRef( SUPERV::StreamPort::_duplicate( Inobject ) ) ;
+         }
+       }
       }
     }
-//  }
-  if ( RetVal && myInPort && myOutPort ) {
-    if ( DataFlowNode()->CoupledNode() ) {
-      GraphBase::InPort * anInPort ;
-      anInPort = DataFlowNode()->CoupledNode()->AddInPort( OutputParameterName ,
-                                                          OutputParameterType ) ;
-      GraphBase::OutPort * anOutPort ;
-      anOutPort = DataFlowNode()->CoupledNode()->AddOutPort( InputParameterName ,
-                                                            InputParameterType ) ;
-      DataFlowNode()->CoupledNode()->InOutPort( anInPort , anOutPort ) ;
+
+//    if ( !CORBA::is_nil( Inobject ) && InPortCreated &&
+//         ( DataFlowNode()->IsLoopNode() || DataFlowNode()->IsEndLoopNode() ||
+//           DataFlowNode()->IsEndSwitchNode() ) ) {
+//      Outobject = OutPort( aParameterName , aParameterType ) ;
+//      if ( DataFlowNode()->IsLoopNode() ) {
+//        LNode_Impl * myLoopNode = (LNode_Impl * ) this ;
+//        InEndobject = myLoopNode->Coupled()->InPort( aParameterName , aParameterType ) ;
+//        DataFlowEditor()->AddLink( Outobject->Node()->Name() , Outobject->Name() ,
+//                                   InEndobject->Node()->Name() , InEndobject->Name() ) ;
+//      }
+//    }
+    DataFlowEditor()->UnValid() ;
+  }
+  return SUPERV::StreamPort::_duplicate( Inobject ) ;
+}
+
+SUPERV::StreamPort_ptr INode_Impl::OutStreamPort( const char * aParameterName ,
+                                                  const SALOME_ModuleCatalog::DataStreamType aParameterType ,
+                                                  const SALOME_ModuleCatalog::DataStreamDependency aDependency ) {
+  StreamPort_Impl * myOutStreamPort = NULL ;
+  SUPERV::StreamPort_ptr Outobject = SUPERV::StreamPort::_nil() ;
+  if ( DataFlowEditor()->Graph()->IsDataStreamNode() ) {
+    MESSAGE( "INode_Impl::OutStreamPort " << DataFlowNode()->Name() << "->AddOutPort( " << aParameterName << " , "
+             << aParameterType << " )" ) ;
+    GraphBase::OutPort * anOutPort = DataFlowNode()->GetChangeOutPort( aParameterName ) ;
+    if ( anOutPort && !anOutPort->IsDataStream() ) {
+      MESSAGE( "INode_Impl::OutStreamPort ERROR !IsDataStream " ) ;
+    }
+    else if ( DataFlowEditor()->Graph()->IsDataStreamNode() ) {
+      if ( anOutPort == NULL ) {
+        anOutPort = DataFlowNode()->ComputingNode()->AddOutDataStreamPort( aParameterName , aParameterType , aDependency , SUPERV::DataStreamParameter ) ;
+      }
+
+      if ( anOutPort ) {
+        Outobject = SUPERV::StreamPort::_narrow( anOutPort->ObjRef() ) ;
+        if ( CORBA::is_nil( Outobject ) ) {
+          const CORBA::Any * anAny = anOutPort->Value() ;
+          myOutStreamPort = new StreamPort_Impl( _Orb , _Poa , _ContId ,
+                                 instanceName() , interfaceName() ,
+                                 DataFlowEditor() ,
+                                 DataFlowNode() ,
+                                 (GraphBase::Port * ) anOutPort ,
+                                 false ,
+                                 anAny ) ;
+          if ( myOutStreamPort ) {
+            PortableServer::ObjectId * id = myOutStreamPort->getId() ;
+            CORBA::Object_var obj = _poa->id_to_reference(*id) ;
+            Outobject = SUPERV::StreamPort::_narrow(obj) ;
+            anOutPort->ObjRef( SUPERV::StreamPort::_duplicate( Outobject ) ) ;
+         }
+       }
+      }
     }
-    PortableServer::ObjectId * id = myInPort->getId() ;
-    CORBA::Object_var obj = _poa->id_to_reference(*id) ;
-    Inobject = SUPERV::Port::_narrow(obj) ;
-    InputPort = SUPERV::Port::_duplicate( Inobject ) ;
-    id = myOutPort->getId() ;
-    obj = _poa->id_to_reference(*id);
-    Outobject = SUPERV::Port::_narrow(obj) ;
-    OutputPort = SUPERV::Port::_duplicate( Outobject ) ;
+    DataFlowEditor()->UnValid() ;
   }
-  endService( "INode_Impl::BusPorts" );
-  return RetVal ;
+  return SUPERV::StreamPort::_duplicate( Outobject );
 }
-#endif
+