1 // SUPERV GraphBase : contains fondamental classes for Services, Input Ports, Output Ports Links and Nodes.
3 // Copyright (C) 2003 CEA/DEN, EDF R&D
7 // File : DataFlowBase_EndOfSwitchNode.cxx
8 // Author : Jean Rahuel, CEA
16 #include "DataFlowBase_EndOfSwitchNode.hxx"
18 GraphBase::EndOfSwitchNode::EndOfSwitchNode() :
19 GraphBase::GOTONode::GOTONode() {
21 cdebug << "GraphBase::EndOfSwitchNode::EndOfSwitchNode " << this
22 << " _Name " << (void *) Name() << " " << Name() << " _Comment "
23 << (void *) Comment() << " " << Comment() << " " << endl ;
27 GraphBase::EndOfSwitchNode::EndOfSwitchNode( CORBA::ORB_ptr ORB ,
28 SALOME_NamingService* ptrNamingService ,
29 const char * FuncName ,
30 const SUPERV::ListOfStrings & aPythonFunction ,
31 const char *NodeName ,
32 const SUPERV::KindOfNode akind ,
33 const SUPERV::SDate NodeFirstCreation ,
34 const SUPERV::SDate NodeLastModification ,
35 const char * NodeEditorRelease ,
36 const char * NodeAuthor ,
37 const char * NodeComment ,
38 const bool GeneratedName ,
41 int * Graph_prof_debug ,
42 ofstream * Graph_fdebug ) :
43 GraphBase::GOTONode::GOTONode( ORB , ptrNamingService , FuncName ,
45 NodeName , akind , NodeFirstCreation ,
46 NodeLastModification , NodeEditorRelease ,
47 NodeAuthor , NodeComment , GeneratedName ,
48 X , Y , Graph_prof_debug , Graph_fdebug ) {
50 cdebug_in << "GraphBase::EndOfSwitchNode::EndOfSwitchNode " << this
51 << "' _Name " << (void *) Name() << " '" << Name() << " _Comment "
52 << (void *) Comment() << " " << Comment() << " "
53 << " KindOfNode " << Kind() << " FuncName " << FuncName
54 << " ServiceName " << ServiceName() << " In("
55 << ServiceInParameter().length()
56 << ") Out(" << ServiceOutParameter().length() << ")" << endl ;
58 cdebug_out << "GraphBase::EndOfSwitchNode::EndOfSwitchNode" << endl;
61 GraphBase::EndOfSwitchNode::~EndOfSwitchNode() {
62 cdebug << "GraphBase::EndOfSwitchNode::~EndOfSwitchNode " << this
63 << " _Name " << (void *) Name() << " " << Name() << " _Comment "
64 << (void *) Comment() << " " << Comment() << " " << endl ;
65 // if ( _ComponentName != NULLSTRING )
66 // delete [] _ComponentName ;
68 // delete [] _EditorRelease ;
69 // if ( _Author != NULLSTRING )
70 // delete [] _Author ;
71 // if ( _Computer != FACTORYSERVER )
72 // delete [] _Computer;
73 // if ( _Comment != NULLSTRING )
74 // delete [] _Comment;
77 void GraphBase::EndOfSwitchNode::InitEndSwitchInPortLinked() { // without StreamInPorts
78 cdebug << "Base::EndOfSwitchNode::InitEndSwitchInPortLinked of " << Name() << endl ;
79 //JR 06.07.2005 : the InGatePort(Default) must also be counted (enhancement) ...
80 // _EndSwitchInPortLinkedNumber = GetNodeInPortsSize() - DataStreamInPortsNumber() - 1 ;
81 _EndSwitchInPortLinkedNumber = GetNodeInPortsSize() - DataStreamInPortsNumber() ;
82 _SwitchWithGOTO = false ;
84 //JR 06.07.2005 : the InGatePort must also be counted (enhancement) ...
85 // for ( i = 0 ; i < GetNodeInPortsSize()-1 ; i++ ) {
86 for ( i = 0 ; i < GetNodeInPortsSize() ; i++ ) {
87 GetChangeNodeInPort( i )->BranchOfSwitchLinked( false ) ;
91 bool GraphBase::EndOfSwitchNode::DecrEndSwitchInPortLinked( GraphBase::InPort * anInPort ,
92 string & anErrorMessage ) {
94 //JR 16.02.2005 : except for DefaultPort
95 //JR 06.07.2005 : the InGatePort must also be counted now (enhancement) ...
96 // if ( !anInPort->IsGate() ) {
97 if ( !anInPort->BranchOfSwitchLinked( true ) ) {
98 cdebug << Name() << "->DecrEndSwitchInPortLinked ERROR " << anInPort->NodeName() << "( "
99 << anInPort->PortName() << " ) was already linked in that branch." << endl ;
100 anErrorMessage = anErrorMessage + string( Name() ) + string( " The port " ) +
101 string( anInPort->NodeName() ) + string( "( " ) +
102 string( anInPort->PortName() ) +
103 string( " ) was already linked in that branch.\n" ) ;
106 _EndSwitchInPortLinkedNumber -= 1 ;
109 << "->EndOfSwitchNode::DecrEndSwitchInPortLinked EndSwitchInPortLinkedNumber "
110 << _EndSwitchInPortLinkedNumber << " InPort '" << anInPort->PortName() << "' of "
111 << anInPort->NodeName() << " RetVal " << RetVal << endl ;
115 bool GraphBase::EndOfSwitchNode::CheckEndSwitchInPortsLinked( string & anErrorMessage ) {
117 bool DefaultNotLinked = false ;
118 // Check that all inports of the EndSwitchNode are reachable in that branch(es)
120 //JR 06.07.2005 : the InGatePort must also be counted now (enhancement) ...
121 // for ( i = 0 ; i < GetNodeInPortsSize()-1 ; i++ ) {
122 for ( i = 0 ; i < GetNodeInPortsSize() ; i++ ) {
123 GraphBase::InPort * anInPort = GetChangeNodeInPort( i ) ;
124 if ( !anInPort->IsDataStream() && !anInPort->BranchOfSwitchLinked() ) {
125 cdebug << Name() << "->EndOfSwitchNode::CheckEndSwitchInPortsLinked "
126 << anInPort->PortName() << " have no link in that branch"
127 << " SwitchWithGOTO() " << SwitchWithGOTO() << endl ;
128 if ( !SwitchWithGOTO() ) {
129 anErrorMessage = anErrorMessage + string( Name() ) + string( "( " ) +
130 string( anInPort->PortName() ) +
131 string( " ) has no link from that branch.\n" ) ;
132 if ( anInPort->IsGate() ) {
133 DefaultNotLinked = true ;
136 RetVal = false ; // that InPort is not linked
141 // Check that all inports of the EndSwitchNode will have a value only once
142 if ( _EndSwitchInPortLinkedNumber != 0 ) {
144 << "->EndOfSwitchNode::CheckEndSwitchInPortsLinked EndSwitchInPortLinkedNumber "
145 << _EndSwitchInPortLinkedNumber << " SwitchWithGOTO() " << SwitchWithGOTO()
146 << " DefaultNotLinked " << DefaultNotLinked << endl ;
147 if ( !SwitchWithGOTO() ) {
148 if ( RetVal && _EndSwitchInPortLinkedNumber == 1 && DefaultNotLinked ) {
151 if ( _EndSwitchInPortLinkedNumber > 0 ) {
152 anErrorMessage = anErrorMessage + string( Name() ) +
153 string( " has some InPort(s) not linked.\n" ) ;
156 anErrorMessage = anErrorMessage + string( Name() ) +
157 string( " has some InPort(s) multiply linked.\n" ) ;
159 RetVal = false ; // Some InPort is not linked or multiply linked