Salome HOME
Join modifications from BR_Dev_For_4_0 tag V4_1_1.
[modules/superv.git] / src / GraphBase / DataFlowBase_OutPort.cxx
index 751d0df64e5521396c976776d6b89294324d44d0..776bc747567201c6155de3c1e1fa0caa99c73dbc 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
 //
 //
 //
@@ -28,6 +28,7 @@
 
 using namespace std;
 #include "DataFlowBase_OutPort.hxx"
+#include "DataFlowBase_InPort.hxx"
 
 //GraphBase::OutPort::~OutPort() {
 // In GraphExecutor::OutPort
@@ -50,9 +51,9 @@ const GraphBase::InPort * GraphBase::OutPort::GetInPort(
   if ( index > 0 && index <= _InPortsSize ) {
     anInPort = _InPorts[ index-1 ] ;
     if ( anInPort != toPort ) {
-      cout << "GraphBase::OutPort::GetInPort inconsistency toPort "
-           << hex << (void *) toPort << " != anInPort " << (void *) anInPort
-           << dec << endl ;
+  //cout << "GraphBase::OutPort::GetInPort inconsistency toPort "
+//           << hex << (void *) toPort << " != anInPort " << (void *) anInPort
+//           << dec << endl ;
       anInPort = NULL ;
     }
   }
@@ -96,14 +97,43 @@ bool GraphBase::OutPort::AddInPortObjRef( GraphBase::InPort * toPort ,
   return true ;
 }
 
+bool GraphBase::OutPort::RemoveInPort() {
+  if ( _InPortsSize != 1 ) {
+    return false ;
+  }
+  int index = 1 ;
+  GraphBase::InPort * toPort = _InPorts[ index - 1 ] ;
+  _InPortsSize -= 1 ;
+  _InPorts.resize( _InPortsSize ) ;
+  _Links.resize( _InPortsSize ) ;
+  _MapOfInPorts.erase( toPort->NodePortName() ) ;
+  if ( _InPortsSize == 0 ) {
+    PortStatus(NotConnected ) ;
+    if ( IsSwitch() ) {
+      Kind( SUPERV::InLineParameter ) ;
+    }
+  }
+  if ( toPort->GetOutPort() ) {
+    toPort->RemoveOutPort( false ) ;
+  }
+  cdebug << "OutPort::RemoveInPort " << NodeName() << "( " << PortName() << " " << PortStatus()
+         << " " << Kind() << " ) _InPortsSize " << _InPortsSize << " --> "
+         << toPort->NodeName() << "( " << toPort->PortName() << " " << toPort->PortStatus()
+         << " " << toPort->Kind() << " )" << endl ;
+  return true ;
+}
+
 bool GraphBase::OutPort::RemoveInPort( GraphBase::InPort * toPort ) {
   int i ;
   int index = _MapOfInPorts[ toPort->NodePortName() ] ;
   if ( index <= 0 || index > _InPortsSize ) {
-    cdebug << "GraphBase::OutPort::RemoveInPort Error " << NodePortName()
-           << " --> " << toPort->NodePortName() << endl ;
+//JR NPAL14110 09.02.2007 : Not an error with MacroNodes ...
+    //JRcdebug << "GraphBase::OutPort::RemoveInPort Error " << NodeName() << "( " << PortName()<< " ) --> "
+    //JR       << toPort->NodeName() << "( " << toPort->PortName() << " )" << endl ;
     return false ;
   }
+  cdebug << "OutPort::RemoveInPort " << NodeName() << "(" << PortName() << ") --> "
+         << _InPorts[ index - 1 ]->NodeName() << "(" << _InPorts[ index - 1 ]->PortName() << ")" << endl ;
   _InPortsSize -= 1 ;
   for ( i = index - 1 ; i < _InPortsSize  ; i++ ) {
     _MapOfInPorts[ _InPorts[ i+1 ]->NodePortName() ] = i + 1 ;
@@ -115,8 +145,13 @@ bool GraphBase::OutPort::RemoveInPort( GraphBase::InPort * toPort ) {
   _MapOfInPorts.erase( toPort->NodePortName() ) ;
   if ( _InPortsSize == 0 ) {
     PortStatus(NotConnected ) ;
+    if ( IsSwitch() ) {
+      Kind( SUPERV::InLineParameter ) ;
+    }
+  }
+  if ( toPort->GetOutPort() ) {
+    toPort->RemoveOutPort( false ) ;
   }
-  toPort->RemoveOutPort() ;
   return true ;
 }
 
@@ -124,7 +159,7 @@ bool GraphBase::OutPort::ReNameInPort( const char* OldNodePortName ,
                                        const char* NewNodePortName ) {
   int index = _MapOfInPorts[ OldNodePortName ] ;
   if ( index <= 0 || index > _InPortsSize ) {
-    cdebug << "GraphBase::OutPort::ReNameLink Error " << OldNodePortName
+    cdebug << "GraphBase::OutPort::ReNameInPort Error in Node " << NodeName() << " " << OldNodePortName
            << " --> " << NewNodePortName << " index " << index << endl ;
     return false ;
   }
@@ -153,13 +188,10 @@ bool GraphBase::OutPort::RemoveLinks() {
 
 ostream & operator<< (ostream &f ,const GraphBase::OutPort &P)
 {
-  f << P.PortName() << ", " 
-    << "type : " << P.PortType() << ", " ;
- f << "kind "
-   << P.Kind() << ", ";
- f << "from "
-   << P.NodeName() << ", ";
-
+ f << P.PortName() << ", " << "type : " << P.PortType() << ", " ;
+ f << "kind " << P.Kind() << ", ";
+ f << "Status " << P.PortStatus() << ", ";
+ f << "from Node " << P.NodeName() << ", ";
   return f;
 }