Salome HOME
SMH: 3.0.0 preparation = merged version (POLYWORK + RTVDEBUG01) + adopation for new GUI
[modules/superv.git] / src / GraphBase / DataFlowBase_EndOfSwitchNode.cxx
index dc3e23caf3f03db4bf23d536570d5f2b3bb8dc1d..867cafdad1e4f1047f4135e7985f8fa59ec38da8 100644 (file)
@@ -74,3 +74,49 @@ GraphBase::EndOfSwitchNode::~EndOfSwitchNode() {
 //    delete [] _Comment;
 }
 
+bool GraphBase::EndOfSwitchNode::DecrEndSwitchInPortLinked( GraphBase::InPort * anInPort ) {
+  bool RetVal = true ;
+//  if ( !anInPort->BranchOfSwitchLinked() ) {
+    RetVal = anInPort->BranchOfSwitchLinked( true ) ;
+//JR 16.02.2005 : except for DefaultPort
+    if ( !anInPort->IsGate() ) {
+      _EndSwitchInPortLinkedNumber -= 1 ;
+    }
+    cdebug << Name()
+           << "->EndOfSwitchNode::DecrEndSwitchInPortLinked EndSwitchInPortLinkedNumber "
+           << _EndSwitchInPortLinkedNumber << " InPort '" << anInPort->PortName() << "' of "
+           << anInPort->NodeName() << " RetVal " << RetVal << endl ;
+//  }
+//  else {
+//    cdebug << "EndOfSwitchNode::DecrEndSwitchInPortLinked EndSwitchInPortLinkedNumber "
+//           << _EndSwitchInPortLinkedNumber << " InPort " << anInPort->PortName()
+//           << " already done RetVal " << RetVal << endl ;
+//  }
+  return RetVal ;
+}
+
+bool GraphBase::EndOfSwitchNode::CheckEndSwitchInPortsLinked() {
+// Check that all inports of the EndSwitchNode will have a value only once
+  if ( _EndSwitchInPortLinkedNumber != 0 ) {
+    cdebug << Name()
+           << "->EndOfSwitchNode::CheckEndSwitchInPortsLinked EndSwitchInPortLinkedNumber "
+           << _EndSwitchInPortLinkedNumber << endl ;
+    if ( !SwitchWithGOTO() ) {
+      return false ; // Some InPort is not linked
+    }
+  }
+// Check that all inports of the EndSwitchNode are reachable in that branch(es)
+  int i ;
+  for ( i = 0 ; i < GetNodeInPortsSize()-1 ; i++ ) {
+    if ( !GetChangeNodeInPort( i )->IsDataStream() &&
+         !GetChangeNodeInPort( i )->BranchOfSwitchLinked() ) {
+      cdebug << Name() << "->EndOfSwitchNode::CheckEndSwitchInPortsLinked "
+             << GetNodeInPort( i )->PortName() << " have no link in that branch"
+             << endl ;
+      if ( !SwitchWithGOTO() ) {
+        return false ; // that InPort is not linked
+      }
+    }
+  }
+  return true ; // Ok : all InPorts are linked
+}