// delete [] _Comment;
}
-bool GraphBase::EndOfSwitchNode::DecrEndSwitchInPortLinked( GraphBase::InPort * anInPort ) {
+void GraphBase::EndOfSwitchNode::InitEndSwitchInPortLinked() { // without StreamInPorts
+ cdebug << "Base::EndOfSwitchNode::InitEndSwitchInPortLinked of " << Name() << endl ;
+//JR 06.07.2005 : the InGatePort(Default) must also be counted (enhancement) ...
+// _EndSwitchInPortLinkedNumber = GetNodeInPortsSize() - DataStreamInPortsNumber() - 1 ;
+ _EndSwitchInPortLinkedNumber = GetNodeInPortsSize() - DataStreamInPortsNumber() ;
+ _SwitchWithGOTO = false ;
+ int i ;
+//JR 06.07.2005 : the InGatePort must also be counted (enhancement) ...
+// for ( i = 0 ; i < GetNodeInPortsSize()-1 ; i++ ) {
+ for ( i = 0 ; i < GetNodeInPortsSize() ; i++ ) {
+ GetChangeNodeInPort( i )->BranchOfSwitchLinked( false ) ;
+ }
+}
+
+bool GraphBase::EndOfSwitchNode::DecrEndSwitchInPortLinked( GraphBase::InPort * anInPort ,
+ string & anErrorMessage ) {
bool RetVal = true ;
-// if ( !anInPort->BranchOfSwitchLinked() ) {
- RetVal = anInPort->BranchOfSwitchLinked( true ) ;
//JR 16.02.2005 : except for DefaultPort
- if ( !anInPort->IsGate() ) {
- _EndSwitchInPortLinkedNumber -= 1 ;
+//JR 06.07.2005 : the InGatePort must also be counted now (enhancement) ...
+// if ( !anInPort->IsGate() ) {
+ if ( !anInPort->BranchOfSwitchLinked( true ) ) {
+ cdebug << Name() << "->DecrEndSwitchInPortLinked ERROR " << anInPort->NodeName() << "( "
+ << anInPort->PortName() << " ) was already linked in that branch." << endl ;
+ anErrorMessage = anErrorMessage + string( Name() ) + string( " The port " ) +
+ string( anInPort->NodeName() ) + string( "( " ) +
+ string( anInPort->PortName() ) +
+ string( " ) was already linked in that branch.\n" ) ;
+ RetVal = false ;
}
- 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 ;
+ _EndSwitchInPortLinkedNumber -= 1 ;
// }
+ cdebug << Name()
+ << "->EndOfSwitchNode::DecrEndSwitchInPortLinked EndSwitchInPortLinkedNumber "
+ << _EndSwitchInPortLinkedNumber << " InPort '" << anInPort->PortName() << "' of "
+ << anInPort->NodeName() << " RetVal " << RetVal << endl ;
return RetVal ;
}
-bool GraphBase::EndOfSwitchNode::CheckEndSwitchInPortsLinked() {
+bool GraphBase::EndOfSwitchNode::CheckEndSwitchInPortsLinked( string & anErrorMessage ) {
+ bool RetVal = true ;
+ bool DefaultNotLinked = false ;
+// Check that all inports of the EndSwitchNode are reachable in that branch(es)
+ int i ;
+//JR 06.07.2005 : the InGatePort must also be counted now (enhancement) ...
+// for ( i = 0 ; i < GetNodeInPortsSize()-1 ; i++ ) {
+ for ( i = 0 ; i < GetNodeInPortsSize() ; i++ ) {
+ GraphBase::InPort * anInPort = GetChangeNodeInPort( i ) ;
+ if ( !anInPort->IsDataStream() && !anInPort->BranchOfSwitchLinked() ) {
+ cdebug << Name() << "->EndOfSwitchNode::CheckEndSwitchInPortsLinked "
+ << anInPort->PortName() << " have no link in that branch"
+ << " SwitchWithGOTO() " << SwitchWithGOTO() << endl ;
+ if ( !SwitchWithGOTO() ) {
+ anErrorMessage = anErrorMessage + string( Name() ) + string( "( " ) +
+ string( anInPort->PortName() ) +
+ string( " ) has no link from that branch.\n" ) ;
+ if ( anInPort->IsGate() ) {
+ DefaultNotLinked = true ;
+ }
+ else {
+ RetVal = false ; // that InPort is not linked
+ }
+ }
+ }
+ }
// Check that all inports of the EndSwitchNode will have a value only once
if ( _EndSwitchInPortLinkedNumber != 0 ) {
cdebug << Name()
<< "->EndOfSwitchNode::CheckEndSwitchInPortsLinked EndSwitchInPortLinkedNumber "
- << _EndSwitchInPortLinkedNumber << endl ;
+ << _EndSwitchInPortLinkedNumber << " SwitchWithGOTO() " << SwitchWithGOTO()
+ << " DefaultNotLinked " << DefaultNotLinked << 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
+ if ( RetVal && _EndSwitchInPortLinkedNumber == 1 && DefaultNotLinked ) {
+ }
+ else {
+ if ( _EndSwitchInPortLinkedNumber > 0 ) {
+ anErrorMessage = anErrorMessage + string( Name() ) +
+ string( " has some InPort(s) not linked.\n" ) ;
+ }
+ else {
+ anErrorMessage = anErrorMessage + string( Name() ) +
+ string( " has some InPort(s) multiply linked.\n" ) ;
+ }
+ RetVal = false ; // Some InPort is not linked or multiply linked
}
}
}
- return true ; // Ok : all InPorts are linked
+ return RetVal ;
}