1 // Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
22 // SUPERV GraphBase : contains fondamental classes for Services, Input Ports, Output Ports Links and Nodes.
23 // File : DataFlowBase_EndOfSwitchNode.cxx
24 // Author : Jean Rahuel, CEA
31 #include "DataFlowBase_EndOfSwitchNode.hxx"
33 GraphBase::EndOfSwitchNode::EndOfSwitchNode() :
34 GraphBase::GOTONode::GOTONode() {
36 cdebug << "GraphBase::EndOfSwitchNode::EndOfSwitchNode " << this
37 << " _Name " << (void *) Name() << " " << Name() << " _Comment "
38 << (void *) Comment() << " " << Comment() << " " << endl ;
42 GraphBase::EndOfSwitchNode::EndOfSwitchNode( CORBA::ORB_ptr ORB ,
43 SALOME_NamingService* ptrNamingService ,
44 const char * FuncName ,
45 const SUPERV::ListOfStrings & aPythonFunction ,
46 const char *NodeName ,
47 const SUPERV::KindOfNode akind ,
48 const SUPERV::SDate NodeFirstCreation ,
49 const SUPERV::SDate NodeLastModification ,
50 const char * NodeEditorRelease ,
51 const char * NodeAuthor ,
52 const char * NodeComment ,
53 const bool GeneratedName ,
56 int * Graph_prof_debug ,
57 ofstream * Graph_fdebug ) :
58 GraphBase::GOTONode::GOTONode( ORB , ptrNamingService , FuncName ,
60 NodeName , akind , NodeFirstCreation ,
61 NodeLastModification , NodeEditorRelease ,
62 NodeAuthor , NodeComment , GeneratedName ,
63 X , Y , Graph_prof_debug , Graph_fdebug ) {
65 cdebug_in << "GraphBase::EndOfSwitchNode::EndOfSwitchNode " << this
66 << "' _Name " << (void *) Name() << " '" << Name() << " _Comment "
67 << (void *) Comment() << " " << Comment() << " "
68 << " KindOfNode " << Kind() << " FuncName " << FuncName
69 << " ServiceName " << ServiceName() << " In("
70 << ServiceInParameter().length()
71 << ") Out(" << ServiceOutParameter().length() << ")" << endl ;
73 cdebug_out << "GraphBase::EndOfSwitchNode::EndOfSwitchNode" << endl;
76 GraphBase::EndOfSwitchNode::~EndOfSwitchNode() {
77 cdebug << "GraphBase::EndOfSwitchNode::~EndOfSwitchNode " << this
78 << " _Name " << (void *) Name() << " " << Name() << " _Comment "
79 << (void *) Comment() << " " << Comment() << " " << endl ;
80 // if ( _ComponentName != NULLSTRING )
81 // delete [] _ComponentName ;
83 // delete [] _EditorRelease ;
84 // if ( _Author != NULLSTRING )
85 // delete [] _Author ;
86 // if ( _Computer != FACTORYSERVER )
87 // delete [] _Computer;
88 // if ( _Comment != NULLSTRING )
89 // delete [] _Comment;
92 void GraphBase::EndOfSwitchNode::InitEndSwitchInPortLinked() { // without StreamInPorts
93 cdebug << "Base::EndOfSwitchNode::InitEndSwitchInPortLinked of " << Name() << endl ;
94 //JR 06.07.2005 : the InGatePort(Default) must also be counted (enhancement) ...
95 // _EndSwitchInPortLinkedNumber = GetNodeInPortsSize() - DataStreamInPortsNumber() - 1 ;
96 _EndSwitchInPortLinkedNumber = GetNodeInPortsSize() - DataStreamInPortsNumber() ;
97 _SwitchWithGOTO = false ;
99 //JR 06.07.2005 : the InGatePort must also be counted (enhancement) ...
100 // for ( i = 0 ; i < GetNodeInPortsSize()-1 ; i++ ) {
101 for ( i = 0 ; i < GetNodeInPortsSize() ; i++ ) {
102 GetChangeNodeInPort( i )->BranchOfSwitchLinked( false ) ;
106 bool GraphBase::EndOfSwitchNode::DecrEndSwitchInPortLinked( GraphBase::InPort * anInPort ,
107 string & anErrorMessage ) {
109 //JR 16.02.2005 : except for DefaultPort
110 //JR 06.07.2005 : the InGatePort must also be counted now (enhancement) ...
111 // if ( !anInPort->IsGate() ) {
112 if ( !anInPort->BranchOfSwitchLinked( true ) ) {
113 cdebug << Name() << "->DecrEndSwitchInPortLinked ERROR " << anInPort->NodeName() << "( "
114 << anInPort->PortName() << " ) was already linked in that branch." << endl ;
115 anErrorMessage = anErrorMessage + string( Name() ) + string( " The port " ) +
116 string( anInPort->NodeName() ) + string( "( " ) +
117 string( anInPort->PortName() ) +
118 string( " ) was already linked in that branch.\n" ) ;
121 _EndSwitchInPortLinkedNumber -= 1 ;
124 << "->EndOfSwitchNode::DecrEndSwitchInPortLinked EndSwitchInPortLinkedNumber "
125 << _EndSwitchInPortLinkedNumber << " InPort '" << anInPort->PortName() << "' of "
126 << anInPort->NodeName() << " RetVal " << RetVal << endl ;
130 bool GraphBase::EndOfSwitchNode::CheckEndSwitchInPortsLinked( string & anErrorMessage ) {
132 bool DefaultNotLinked = false ;
133 // Check that all inports of the EndSwitchNode are reachable in that branch(es)
135 //JR 06.07.2005 : the InGatePort must also be counted now (enhancement) ...
136 // for ( i = 0 ; i < GetNodeInPortsSize()-1 ; i++ ) {
137 for ( i = 0 ; i < GetNodeInPortsSize() ; i++ ) {
138 GraphBase::InPort * anInPort = GetChangeNodeInPort( i ) ;
139 if ( !anInPort->IsDataStream() && !anInPort->BranchOfSwitchLinked() ) {
140 cdebug << Name() << "->EndOfSwitchNode::CheckEndSwitchInPortsLinked "
141 << anInPort->PortName() << " have no link in that branch"
142 << " SwitchWithGOTO() " << SwitchWithGOTO() << endl ;
143 if ( !SwitchWithGOTO() ) {
144 anErrorMessage = anErrorMessage + string( Name() ) + string( "( " ) +
145 string( anInPort->PortName() ) +
146 string( " ) has no link from that branch.\n" ) ;
147 if ( anInPort->IsGate() ) {
148 DefaultNotLinked = true ;
151 RetVal = false ; // that InPort is not linked
156 // Check that all inports of the EndSwitchNode will have a value only once
157 if ( _EndSwitchInPortLinkedNumber != 0 ) {
159 << "->EndOfSwitchNode::CheckEndSwitchInPortsLinked EndSwitchInPortLinkedNumber "
160 << _EndSwitchInPortLinkedNumber << " SwitchWithGOTO() " << SwitchWithGOTO()
161 << " DefaultNotLinked " << DefaultNotLinked << endl ;
162 if ( !SwitchWithGOTO() ) {
163 if ( RetVal && _EndSwitchInPortLinkedNumber == 1 && DefaultNotLinked ) {
166 if ( _EndSwitchInPortLinkedNumber > 0 ) {
167 anErrorMessage = anErrorMessage + string( Name() ) +
168 string( " has some InPort(s) not linked.\n" ) ;
171 anErrorMessage = anErrorMessage + string( Name() ) +
172 string( " has some InPort(s) multiply linked.\n" ) ;
174 RetVal = false ; // Some InPort is not linked or multiply linked