From: rahuel Date: Thu, 13 Jan 2005 15:23:17 +0000 (+0000) Subject: Debug : an OutPort connected to a Gate may only be connected again to a Gate of an... X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=db3372f31bb4ed6990019abed1ea2ccf9fff2f98;p=modules%2Fsuperv.git Debug : an OutPort connected to a Gate may only be connected again to a Gate of an other node Debug : RemoveLink of a link to an EndSwitchNode was wrong --- diff --git a/src/GraphBase/DataFlowBase_Graph.cxx b/src/GraphBase/DataFlowBase_Graph.cxx index 1df1159..d72d31d 100644 --- a/src/GraphBase/DataFlowBase_Graph.cxx +++ b/src/GraphBase/DataFlowBase_Graph.cxx @@ -1069,6 +1069,12 @@ bool GraphBase::Graph::AddLink( GraphBase::ComputingNode *fromNode , toPort->Kind( SUPERV::EndSwitchParameter ) ; } } +// JR 12.01.2005 : an OutPort of a SwitchNode connected to a Gate can be connected only to Gate + else if ( fromNode->IsSwitchNode() && fromPort->IsSwitch() && !toPort->IsGate() ) { + cdebug << "toPort->AddLink Error( fromPort->IsSwitch() && !toPort->IsGate())." << endl ; + cdebug_out << "GraphBase::Graph::AddLink 0" << endl; + return false ; + } else if ( !fromPort->AddInPort( toPort ) ) { // --> MapOfInports in the OutPort cdebug << "!fromPort->AddLink Error." << endl ; cdebug_out << "GraphBase::Graph::AddLink 0" << endl; @@ -1178,11 +1184,19 @@ bool GraphBase::Graph::RemoveLink( const char* FromNodeName , if ( anInPort && ( anInPort->IsPortConnected() || anInPort->IsDataConnected() || anInPort->IsExternConnected() ) ) { - GraphBase::OutPort * anOutPort = anInPort->GetOutPort() ; - RetVal = anOutPort->RemoveInPort( anInPort ) ; // ==> : -// anInPort->RemoveOutPort() ; - const char * FromNodeName = anOutPort->NodeName() ; +// JR 13.01.2005 : Bug if it is a link to an EndSwitchNode. The OutPort may be an other one !!! GraphBase::ComputingNode * fromNode = GetChangeGraphNode( FromNodeName ) ; + GraphBase::OutPort * anOutPort = NULL ; + if ( toNode->IsEndSwitchNode() ) { + anOutPort = fromNode->GetChangeOutPort( FromServiceParameterName ) ; + RetVal = anOutPort->RemoveInPort( anInPort ) ; + } + else { + anOutPort = anInPort->GetOutPort() ; + RetVal = anOutPort->RemoveInPort( anInPort ) ; + } +// anInPort->RemoveOutPort() ; // Already done in RemoveInPort +// const char * FromNodeName = anOutPort->NodeName() ; if ( RetVal ) { if ( fromNode ) { if ( anInPort->IsDataStream() ) { @@ -1195,6 +1209,36 @@ bool GraphBase::Graph::RemoveLink( const char* FromNodeName , if ( fromNode->IsSwitchNode() && !anOutPort->IsGate() && !toNode->IsEndSwitchNode() ) { anOutPort->Kind( SUPERV::InLineParameter ) ; } +// JR 13.01.2005 : Bug if it is a link to an EndSwitchNode. The InPort may be linked !!! + if ( toNode->IsEndSwitchNode() ) { + int i ; + int done = false ; + for ( i = 0 ; i < toNode->LinkedFromNodesSize() ; i++ ) { + GraphBase::StreamNode * fromNode = toNode->LinkedFromNodes( i ) ; + int j ; + for ( j = 0 ; j < fromNode->GetNodeOutPortsSize() ; j++ ) { + GraphBase::OutPort * fromOutPort = fromNode->GetChangeNodeOutPort( j ) ; + int k ; + for ( k = 0 ; k < fromOutPort->InPortsSize() ; k++ ) { + if ( strcmp( toNode->Name() , fromOutPort->InPorts( k )->NodeName() ) == 0 ) { +// Restore an OutPort in the InPort + anInPort->ChangeOutPort( fromOutPort ) ; + cdebug << "Graph::RemoveLink reestablish " << fromOutPort->NodeName() << "( " + << fromOutPort->PortName() << " ) in the InPort of EndSwitch : " + << toNode->Name() << "( " << anInPort->PortName() << " )" << endl; + done = true ; + break ; + } + } + if ( done ) { + break ; + } + } + if ( done ) { + break ; + } + } + } } } }