1 // SUPERV GraphBase : contains fondamental classes for Services, Input Ports, Output Ports Links and Nodes.
3 // Copyright (C) 2003 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
24 // File : DataFlowBase_PortsOfNode.cxx
25 // Author : Jean Rahuel, CEA
30 #include "DataFlowBase_PortsOfNode.hxx"
32 GraphBase::PortsOfNode::PortsOfNode() :
33 GraphBase::Service::Service( SALOME_ModuleCatalog::Service() ) {
34 // MESSAGE( "GraphBase::PortsOfNode::PortsOfNode " << this ) ;
35 // cout << "GraphBase::PortsOfNode::PortsOfNode " << this << endl ;
36 // cdebug << "GraphBase::PortsOfNode::PortsOfNode " << this << endl ;
37 _NodeInPortsSize = 0 ;
38 _NodeOutPortsSize = 0 ;
39 _DataStreamInPortsNumber = 0 ;
40 _DataStreamOutPortsNumber = 0 ;
43 GraphBase::PortsOfNode::PortsOfNode( const char *DataFlowName ) :
44 GraphBase::Service::Service( SALOME_ModuleCatalog::Service() ) {
45 // MESSAGE( "GraphBase::PortsOfNode::PortsOfNode " << this ) ;
46 // cout << "GraphBase::PortsOfNode::PortsOfNode " << this << endl ;
47 // cdebug << "GraphBase::PortsOfNode::PortsOfNode " << this << endl ;
48 _NodeInPortsSize = 0 ;
49 _NodeOutPortsSize = 0 ;
50 _DataStreamInPortsNumber = 0 ;
51 _DataStreamOutPortsNumber = 0 ;
54 GraphBase::PortsOfNode::~PortsOfNode() {
55 cdebug << "GraphBase::PortsOfNode::~PortsOfNode " << this
58 // for ( i = 0 ; i < _NodeInPortsSize ; i++ ) {
59 // delete _NodeInPorts[ i ] ;
61 // for ( i = 0 ; i < _NodeOutPortsSize ; i++ ) {
62 // delete _NodeOutPorts[ i ] ;
66 void GraphBase::PortsOfNode::DefPortsOfNode(
68 const SALOME_ModuleCatalog::Service& aService ,
69 const char *const * NodeName ,
70 const SUPERV::KindOfNode aKind ,
71 int * Graph_prof_debug ,
72 ofstream * Graph_fdebug ) {
74 SetDebug( ORB , Graph_prof_debug , Graph_fdebug ) ;
75 // MESSAGE( "DefPortsOfNode " << NodeName << " Graph_prof_debug "
76 // << Graph_prof_debug << " _prof_debug " << _prof_debug ) ;
77 cdebug_in << "DefPortsOfNode : " << *NodeName << " ServiceName " << aService.ServiceName << endl ;
78 const bool DataFlowOrComputing = (aKind == SUPERV::DataFlowGraph) ||
79 (aKind == SUPERV::ComputingNode) ||
80 (aKind == SUPERV::FactoryNode) ;
81 // WithInLoop : InitLoop or DoLoop
82 const bool WithInLoop = (aKind == SUPERV::LoopNode) || (aKind == SUPERV::EndLoopNode) ;
83 // WithInGate : InGate or Default
84 const bool WithInGate = (aKind == SUPERV::DataFlowGraph) || (aKind == SUPERV::DataStreamGraph) ||
85 (aKind == SUPERV::ComputingNode) || (aKind == SUPERV::FactoryNode) ||
86 (aKind == SUPERV::InLineNode) || (aKind == SUPERV::GOTONode) ||
87 (aKind == SUPERV::LoopNode) || (aKind == SUPERV::EndLoopNode) ||
88 (aKind == SUPERV::SwitchNode) || (aKind == SUPERV::EndSwitchNode) ||
89 (aKind == SUPERV::MacroNode) ;
90 // WithOutGate : OutGate or Default
91 const bool WithOutGate = (aKind == SUPERV::DataFlowGraph) || (aKind == SUPERV::DataStreamGraph) ||
92 (aKind == SUPERV::ComputingNode) || (aKind == SUPERV::FactoryNode) ||
93 (aKind == SUPERV::InLineNode) || (aKind == SUPERV::GOTONode) ||
94 /* asv : 15.12.04 : adding out gate ports for Loop/EndLoop, too. p2.5, PAL7385*/
95 (aKind == SUPERV::LoopNode) || (aKind == SUPERV::EndLoopNode) ||
96 (aKind == SUPERV::SwitchNode) || (aKind == SUPERV::EndSwitchNode) ||
97 (aKind == SUPERV::MacroNode) ;
98 SUPERV::KindOfPort aPortKind = SUPERV::ServiceParameter ;
99 if ( aKind == SUPERV::InLineNode ) {
100 aPortKind = SUPERV::InLineParameter ;
102 else if ( aKind == SUPERV::LoopNode || aKind == SUPERV::EndLoopNode ) {
103 aPortKind = SUPERV::InLineParameter ;
105 else if ( aKind == SUPERV::SwitchNode || aKind == SUPERV::EndSwitchNode ) {
106 aPortKind = SUPERV::InLineParameter ;
108 else if ( aKind == SUPERV::GOTONode ) {
109 aPortKind = SUPERV::InLineParameter ;
111 else if ( aKind == SUPERV::MacroNode ) {
112 aPortKind = SUPERV::InLineParameter ;
114 for ( i = 0 ; i < _NodeInPortsSize ; i++ ) {
115 cdebug << "DefPortsOfNode delete In" << i << ". " << _NodeInPorts[i]->PortName()
117 _MapOfNodeInPorts.erase( _NodeInPorts[i]->PortName() ) ;
118 delete _NodeInPorts[i] ;
120 _NodeInPorts.resize( 0 );
121 for ( i = 0 ; i < _NodeOutPortsSize ; i++ ) {
122 cdebug << "DefPortsOfNode delete Out" << i << ". " << _NodeOutPorts[i]->PortName()
124 _MapOfNodeOutPorts.erase( _NodeOutPorts[i]->PortName() ) ;
125 delete _NodeOutPorts[i] ;
127 _NodeOutPorts.resize( 0 );
129 SetService( aService ) ;
132 _NodeInPortsSize = aService.ServiceinParameter.length() ;
134 SALOME_ModuleCatalog::ServicesParameter anInLoopParameter ;
135 _NodeInPortsSize = _NodeInPortsSize + 1 ;
137 // char *aParametername = "InitLoop" ;
138 // if ( aKind == SUPERV::EndLoopNode ) {
139 char * aParametername = "DoLoop" ;
141 anInLoopParameter.Parametertype = CORBA::string_dup( "long" ) ;
142 anInLoopParameter.Parametername = CORBA::string_dup( aParametername ) ;
143 if ( _NodeInPortsSize > (int ) _NodeInPorts.size() ) {
144 _NodeInPorts.resize( _NodeInPortsSize );
146 _MapOfNodeInPorts[ aParametername ] = iVec ;
147 _NodeInPorts[iVec-1] = new GraphBase::InPort( NodeName , anInLoopParameter ,
148 SUPERV::LoopParameter );
149 _NodeInPorts[iVec-1]->SetDebug( ORB , Graph_prof_debug , Graph_fdebug ) ;
150 cdebug << "DefPortsOfNode : " << "_MapOfNodeInPorts[ " << aParametername
151 << " ] = " << iVec << " " << _NodeInPorts[iVec-1]->Kind() << " "
152 << _NodeInPorts[iVec-1] << endl ;
154 if ( _NodeInPortsSize > (int ) _NodeInPorts.size() ) {
155 _NodeInPorts.resize(_NodeInPortsSize);
157 cdebug << "NodeInPortsSize " << _NodeInPortsSize << endl ;
158 for ( i = iVec ; i < _NodeInPortsSize ; i++ ) {
159 //JR 24.02.2005 Memory Leak string _aParametername = CORBA::string_dup(aService.ServiceinParameter[i-iVec].Parametername) ;
160 string _aParametername = string(aService.ServiceinParameter[i-iVec].Parametername) ;
161 const char *aParametername = _aParametername.c_str() ;
162 if ( _MapOfNodeInPorts[ aParametername ] ) {
163 if ( !DataFlowOrComputing &&
164 !strcmp( aParametername , "Gate" ) ) {
167 cdebug << "Error, Parametername duplicated : " << aParametername
172 _MapOfNodeInPorts[ aParametername ] = i+1 ;
173 // cdebug << "DefPortsOfNode : " << "_MapOfNodeInPorts[ " << aParametername
174 // << " ] = " << i+1 << endl ;
175 const SALOME_ModuleCatalog::ServicesParameter aServiceParameter = aService.ServiceinParameter[i-iVec] ;
176 _NodeInPorts[i] = new GraphBase::InPort( NodeName , aServiceParameter ,
178 _NodeInPorts[i]->SetDebug( ORB , Graph_prof_debug , Graph_fdebug ) ;
179 cdebug << i << ". " << *_NodeInPorts[i] << " " << _NodeInPorts[i]->Kind() << endl ;
182 iVec += aService.ServiceinParameter.length() ;
184 SALOME_ModuleCatalog::ServicesParameter anInGateParameter ;
185 _NodeInPortsSize = _NodeInPortsSize + 1 ;
187 char *aParametername = "Gate" ;
188 if ( aKind == SUPERV::EndSwitchNode ) {
189 aParametername = "Default" ;
191 anInGateParameter.Parametertype = CORBA::string_dup( "long" ) ;
192 anInGateParameter.Parametername = CORBA::string_dup( aParametername ) ;
193 _NodeInPorts.resize( _NodeInPortsSize );
194 _MapOfNodeInPorts[ aParametername ] = iVec ;
195 _NodeInPorts[iVec-1] = new GraphBase::InPort( NodeName , anInGateParameter ,
196 SUPERV::GateParameter );
197 _NodeInPorts[iVec-1]->SetDebug( ORB , Graph_prof_debug , Graph_fdebug ) ;
198 // cdebug << "DefPortsOfNode : " << "_MapOfNodeInPorts[ " << aParametername
199 // << " ] = " << iVec << " " << _NodeInPorts[iVec-1]->Kind() << " "
200 // << _NodeInPorts[iVec-1] << endl ;
204 _NodeOutPortsSize = aService.ServiceoutParameter.length() ;
206 SALOME_ModuleCatalog::ServicesParameter anOutLoopParameter ;
207 _NodeOutPortsSize = _NodeOutPortsSize + 1 ;
209 char *aParametername = "DoLoop" ;
210 anOutLoopParameter.Parametertype = CORBA::string_dup( "long" ) ;
211 anOutLoopParameter.Parametername = CORBA::string_dup( aParametername ) ;
212 if ( _NodeOutPortsSize > (int ) _NodeOutPorts.size() ) {
213 _NodeOutPorts.resize(_NodeOutPortsSize);
215 _MapOfNodeOutPorts[ aParametername ] = iVec ;
216 _NodeOutPorts[iVec-1] = new GraphBase::OutPort( NodeName , anOutLoopParameter ,
217 SUPERV::LoopParameter );
218 _NodeOutPorts[iVec-1]->SetDebug( ORB , Graph_prof_debug , Graph_fdebug ) ;
219 // cdebug << "DefPortsOfNode : " << "_MapOfNodeOutPorts[ " << aParametername
220 // << " ] = " << iVec << " " << _NodeOutPorts[iVec-1]->Kind() << " "
221 // << _NodeOutPorts[iVec-1] << endl ;
223 if ( _NodeOutPortsSize > (int ) _NodeOutPorts.size() ) {
224 _NodeOutPorts.resize(_NodeOutPortsSize);
226 cdebug << "NodeOutPortsSize " << _NodeOutPortsSize << endl ;
227 for ( i = iVec ; i < _NodeOutPortsSize ; i++ ) {
228 //JR 24.02.2005 Memory Leak string _aParametername = CORBA::string_dup(aService.ServiceoutParameter[i-iVec].Parametername) ;
229 string _aParametername = string(aService.ServiceoutParameter[i-iVec].Parametername) ;
230 const char *aParametername = _aParametername.c_str() ;
231 if ( _MapOfNodeOutPorts[ aParametername ] ) {
232 if ( !DataFlowOrComputing &&
233 !strcmp( aParametername , "Gate" ) ) {
236 cdebug << "Error, Parametername duplicated : " << aParametername
241 // cdebug << "DefPortsOfNode : " << "_MapOfNodeOutPorts[ " << aParametername
242 // << " ] = " << i+1 << endl ;
243 _MapOfNodeOutPorts[ aParametername ] = i+1 ;
244 const SALOME_ModuleCatalog::ServicesParameter aServiceParameter = aService.ServiceoutParameter[i-iVec] ;
245 _NodeOutPorts[i] = new GraphBase::OutPort( NodeName , aServiceParameter ,
247 _NodeOutPorts[i]->SetDebug( ORB , Graph_prof_debug , Graph_fdebug ) ;
248 cdebug << i << ". " << *_NodeOutPorts[i] << " " << _NodeOutPorts[i]->Kind() << endl ;
251 iVec += aService.ServiceoutParameter.length() ;
253 SALOME_ModuleCatalog::ServicesParameter anOutGateParameter ;
254 _NodeOutPortsSize = _NodeOutPortsSize + 1 ;
256 char *aParametername = "Gate" ;
257 if ( aKind == SUPERV::SwitchNode ) {
258 aParametername = "Default" ;
260 anOutGateParameter.Parametertype = CORBA::string_dup( "long" ) ;
261 anOutGateParameter.Parametername = CORBA::string_dup( aParametername ) ;
262 _NodeOutPorts.resize(_NodeOutPortsSize);
263 _MapOfNodeOutPorts[ aParametername ] = iVec ;
264 _NodeOutPorts[iVec-1] = new GraphBase::OutPort( NodeName , anOutGateParameter ,
265 SUPERV::GateParameter );
266 _NodeOutPorts[iVec-1]->SetDebug( ORB , Graph_prof_debug , Graph_fdebug ) ;
267 // cdebug << "DefPortsOfNode : " << "_MapOfNodeOutPorts[ " << aParametername
268 // << " ] = " << iVec << " " << _NodeOutPorts[iVec-1]->Kind() << " "
269 // << _NodeOutPorts[iVec-1] << endl ;
271 cdebug_out << "DefPortsOfNode : " << *NodeName << endl ;
274 GraphBase::InPort * GraphBase::PortsOfNode::AddInPort( CORBA::ORB_ptr ORB ,
275 const char *const * NodeName ,
276 const SUPERV::KindOfNode aKindOfNode ,
277 const char * InputParameterName ,
278 const char * InputParameterType ,
279 SUPERV::KindOfPort aKindOfPort ,
281 int * Graph_prof_debug ,
282 ofstream * Graph_fdebug ) {
283 // MESSAGE( "DefPortsOfNode " << *NodeName << " Graph_prof_debug "
284 // << Graph_prof_debug << " _prof_debug " << _prof_debug ) ;
285 cdebug_in << "PortsOfNode::AddInPort : " << *NodeName << " " << aKindOfNode << " InputParameterName "
286 << InputParameterName << " InputParameterType " << InputParameterType << " aKindOfPort "
287 << aKindOfPort << " DataStreamInPortsNumber " << DataStreamInPortsNumber() << " _NodeInPortsSize "
288 << _NodeInPortsSize << " index " << index << endl ;
289 GraphBase::InPort * anInPort = NULL ;
291 anInPort = GetChangeInPort( InputParameterName ) ;
292 if ( anInPort == NULL ) {
293 _NodeInPortsSize = _NodeInPortsSize + 1 ;
294 _NodeInPorts.resize(_NodeInPortsSize);
295 SALOME_ModuleCatalog::ServicesParameter aServiceParameter ;
296 aServiceParameter.Parametername = CORBA::string_dup( InputParameterName ) ;
297 aServiceParameter.Parametertype = CORBA::string_dup( InputParameterType ) ;
300 else if ( aKindOfPort == SUPERV::DataStreamParameter ) {
301 index = _NodeInPortsSize-2 ;
302 IncrDataStreamInPorts() ;
305 index = _NodeInPortsSize-2 - DataStreamInPortsNumber() ;
309 for ( i = _NodeInPortsSize - 2 ; i >= index ; i-- ) {
310 _NodeInPorts[ i + 1 ] = _NodeInPorts[ i ] ; // Gate - Default
311 _MapOfNodeInPorts.erase( _NodeInPorts[ i + 1 ]->PortName() ) ;
312 _MapOfNodeInPorts[ _NodeInPorts[ i + 1 ]->PortName() ] = i + 2 ;
314 _MapOfNodeInPorts[ InputParameterName ] = index + 1 ;
315 if ( aKindOfPort == SUPERV::DataStreamParameter ) {
316 _NodeInPorts[index] = new GraphBase::InDataStreamPort( NodeName ,
317 aServiceParameter ) ;
320 _NodeInPorts[index] = new GraphBase::InPort( NodeName ,
324 _NodeInPorts[index]->SetDebug( ORB , Graph_prof_debug , Graph_fdebug ) ;
325 anInPort = _NodeInPorts[index] ;
326 cdebug << "NodeInPorts[ " << index << " ]" << endl ;
329 cdebug << "GraphBase::PortsOfNode::AddInPort ERROR index " << index << " _NodeInPortsSize "
330 << _NodeInPortsSize << endl ;
334 cdebug << "GraphBase::PortsOfNode::AddInPort InPort already exists" << endl ;
335 anInPort->Kind( aKindOfPort ) ;
337 cdebug << "GraphBase::PortsOfNode::AddInPort index " << index << " _NodeInPortsSize " << _NodeInPortsSize << endl ;
340 for ( i = 0 ; i < _NodeInPortsSize ; i++ ) {
341 cdebug << *NodeName << " _NodeInPorts[ " << i << " ] = " << _NodeInPorts[ i ]->PortName()
342 << " _MapOfNodeInPorts[ " << _NodeInPorts[ i ]->PortName() << " ] = "
343 << _MapOfNodeInPorts[ _NodeInPorts[ i ]->PortName() ] << " - 1 "
344 << _NodeInPorts[ i ]->Kind() << " Dependency " << _NodeInPorts[ i ]->Dependency() ;
345 if ( _NodeInPorts[ i ]->IsDataStream() ) {
346 SUPERV::KindOfSchema aKindOfSchema ;
347 SUPERV::KindOfInterpolation aKindOfInterpolation ;
348 SUPERV::KindOfExtrapolation aKindOfExtrapolation ;
349 ((GraphBase::InDataStreamPort * ) _NodeInPorts[ i ])->Params( aKindOfSchema , aKindOfInterpolation , aKindOfExtrapolation ) ;
350 cdebug << " " << aKindOfSchema << " " << aKindOfInterpolation << " " << aKindOfExtrapolation ;
352 if ( _NodeInPorts[ i ]->GetOutPort() ) {
353 cdebug << " <--OutPort " << _NodeInPorts[ i ]->GetOutPort()
354 << " " << _NodeInPorts[ i ]->GetOutPort()->NodeName()
355 << "(" << _NodeInPorts[ i ]->GetOutPort()->PortName() << ")" ;
358 cdebug << " <--NOOutPort " << _NodeInPorts[ i ]->GetOutPort() ;
360 cdebug << " " << _NodeInPorts[ i ]->PortStatus() << endl ;
363 cdebug_out << "GraphBase::PortsOfNode::AddInPort _NodeInPortsSize " << _NodeInPortsSize
364 << " " << anInPort->Kind() << endl ;
368 GraphBase::OutPort * GraphBase::PortsOfNode::AddOutPort( CORBA::ORB_ptr ORB ,
369 const char * const * NodeName ,
370 const SUPERV::KindOfNode aKindOfNode ,
371 const char * OutputParameterName ,
372 const char * OutputParameterType ,
373 SUPERV::KindOfPort aKindOfPort ,
375 int * Graph_prof_debug ,
376 ofstream * Graph_fdebug ) {
377 cdebug_in << "GraphBase::PortsOfNode::AddOutPort : " << *NodeName << " " << aKindOfNode
378 << " OutputParameterName " << OutputParameterName << " OutputParameterType " << OutputParameterType
379 << " aKindOfPort " << aKindOfPort << " DataStreamOutPortsNumber " << DataStreamOutPortsNumber()
380 << " _NodeOutPortsSize " << _NodeOutPortsSize << " index " << index << endl ;
381 GraphBase::OutPort * anOutPort = NULL ;
383 anOutPort = GetChangeOutPort( OutputParameterName ) ;
384 if ( anOutPort == NULL ) {
385 _NodeOutPortsSize = _NodeOutPortsSize + 1 ;
386 _NodeOutPorts.resize(_NodeOutPortsSize);
387 SALOME_ModuleCatalog::ServicesParameter aServiceParameter ;
388 aServiceParameter.Parametername = CORBA::string_dup( OutputParameterName ) ;
389 aServiceParameter.Parametertype = CORBA::string_dup( OutputParameterType ) ;
392 else if ( aKindOfPort == SUPERV::DataStreamParameter ) {
393 index = _NodeOutPortsSize-2 ;
394 IncrDataStreamOutPorts() ;
397 index = _NodeOutPortsSize-2 - DataStreamOutPortsNumber() ;
399 if ( aKindOfNode == SUPERV::LoopNode || aKindOfNode == SUPERV::EndLoopNode ) {
404 for ( i = _NodeOutPortsSize - 2 ; i >= index ; i-- ) {
405 _NodeOutPorts[ i + 1 ] = _NodeOutPorts[ i ] ; // Gate - Default
406 _MapOfNodeOutPorts.erase( _NodeOutPorts[ i + 1 ]->PortName() ) ;
407 _MapOfNodeOutPorts[ _NodeOutPorts[ i + 1 ]->PortName() ] = i + 2 ;
409 _MapOfNodeOutPorts[ OutputParameterName ] = index + 1 ;
410 if ( aKindOfPort == SUPERV::DataStreamParameter ) {
411 _NodeOutPorts[index] = new GraphBase::OutDataStreamPort( NodeName ,
412 aServiceParameter ) ;
415 _NodeOutPorts[index] = new GraphBase::OutPort( NodeName ,
419 // MESSAGE( "GraphBase::PortsOfNode::AddOutPort " << OutputParameterName << " --> SetDebug" ) ;
420 _NodeOutPorts[index]->SetDebug( ORB , Graph_prof_debug , Graph_fdebug ) ;
421 anOutPort = _NodeOutPorts[index] ;
422 cdebug << "NodeOutPorts[ " << index << " ]" << endl ;
425 cdebug << "GraphBase::PortsOfNode::AddOutPort ERROR index " << index << " _NodeOutPortsSize "
426 << _NodeOutPortsSize << endl ;
430 cdebug << "GraphBase::PortsOfNode::AddOutPort OutPort already exists" << endl ;
431 anOutPort->Kind( aKindOfPort ) ;
433 cdebug << "GraphBase::PortsOfNode::AddOutPort index " << index << " _NodeOutPortsSize " << _NodeOutPortsSize << endl ;
436 for ( i = 0 ; i < _NodeOutPortsSize ; i++ ) {
437 cdebug << *NodeName << " _NodeOutPorts[ " << i << " ] = " << _NodeOutPorts[ i ]->PortName()
438 << " _MapOfNodeOutPorts[ " << _NodeOutPorts[ i ]->PortName() << " ] = "
439 << _MapOfNodeOutPorts[ _NodeOutPorts[ i ]->PortName() ] << " - 1 "
440 << _NodeOutPorts[ i ]->Kind() << " Dependency " << _NodeOutPorts[ i ]->Dependency() ;
441 if ( _NodeOutPorts[ i ]->IsDataStream() ) {
442 cdebug << " NumberOfValues " << ((GraphBase::OutDataStreamPort * ) _NodeOutPorts[ i ])->NumberOfValues() ;
444 cdebug << " " << _NodeOutPorts[ i ]->PortStatus() << endl ;
447 cdebug_out << "GraphBase::PortsOfNode::AddOutPort _NodeOutPortsSize "
448 << _NodeOutPortsSize << " " << anOutPort->Kind() << endl ;
452 void GraphBase::PortsOfNode::MoveInPort( const char * InputParameterName , int toindex ) {
453 int fromindex = _MapOfNodeInPorts[ InputParameterName ] - 1 ;
454 GraphBase::InPort * anInPort = _NodeInPorts[ toindex ] ;
455 _NodeInPorts[ toindex ] = _NodeInPorts[ fromindex ] ;
456 _NodeInPorts[ fromindex ] = anInPort ;
457 _MapOfNodeInPorts.erase( _NodeInPorts[ toindex ]->PortName() ) ;
458 _MapOfNodeInPorts[ _NodeInPorts[ toindex ]->PortName() ] = toindex + 1 ;
459 _MapOfNodeInPorts.erase( _NodeInPorts[ fromindex ]->PortName() ) ;
460 _MapOfNodeInPorts[ _NodeInPorts[ fromindex ]->PortName() ] = fromindex + 1 ;
463 void GraphBase::PortsOfNode::MoveOutPort( const char * OutputParameterName , int toindex ) {
464 int fromindex = _MapOfNodeOutPorts[ OutputParameterName ] - 1 ;
465 GraphBase::OutPort * anOutPort = _NodeOutPorts[ toindex ] ;
466 _NodeOutPorts[ toindex ] = _NodeOutPorts[ fromindex ] ;
467 _NodeOutPorts[ fromindex ] = anOutPort ;
468 _MapOfNodeOutPorts.erase( _NodeOutPorts[ toindex ]->PortName() ) ;
469 _MapOfNodeOutPorts[ _NodeOutPorts[ toindex ]->PortName() ] = toindex + 1 ;
470 _MapOfNodeOutPorts.erase( _NodeOutPorts[ fromindex ]->PortName() ) ;
471 _MapOfNodeOutPorts[ _NodeOutPorts[ fromindex ]->PortName() ] = fromindex + 1 ;
474 void GraphBase::PortsOfNode::DelInPort( const char * InputParameterName ) {
475 cdebug << "DefPortsOfNode::DelInPort : " << InputParameterName << endl ;
476 int index = _MapOfNodeInPorts[ InputParameterName ] -1 ;
478 cdebug << "DefPortsOfNode::DelInPort : _NodeInPorts[" << index << "] "
479 << _NodeInPorts[ index ]->PortName() << " "
480 << _NodeInPorts[ index ]->NodeName() << endl ;
481 if ( _NodeInPorts[ index ]->IsDataStream() ) {
482 DecrDataStreamInPorts() ;
484 _MapOfNodeInPorts.erase( InputParameterName ) ;
485 _NodeInPorts[ index ]->destroy() ;
487 for ( i = index ; i < _NodeInPortsSize - 1 ; i++ ) {
488 _MapOfNodeInPorts.erase( _NodeInPorts[ i+1 ]->PortName() ) ;
489 _MapOfNodeInPorts[ _NodeInPorts[ i+1 ]->PortName() ] = i+1 ;
490 _NodeInPorts[ i ] = _NodeInPorts[ i+1 ] ;
492 _NodeInPortsSize = _NodeInPortsSize - 1 ;
493 _NodeInPorts.resize( _NodeInPortsSize ) ;
494 for ( i = 0 ; i < _NodeInPortsSize ; i++ ) {
495 cdebug << "DefPortsOfNode::DelInPort ListOfInPorts : _NodeInPorts[" << i << "] "
496 << _NodeInPorts[ i ]->PortName() << " "
497 << _NodeInPorts[ i ]->NodeName() << endl ;
501 cdebug << "DefPortsOfNode::DelInPort : index out of range ERROR " << index
506 void GraphBase::PortsOfNode::DelOutPort( const char * OutputParameterName ) {
507 cdebug << "DefPortsOfNode::DelOutPort : " << OutputParameterName << endl ;
508 int index = _MapOfNodeOutPorts[ OutputParameterName ] - 1 ;
510 cdebug << "DefPortsOfNode::DelOutPort : _NodeOutPorts[" << index << "] "
511 << _NodeOutPorts[ index ]->PortName() << " "
512 << _NodeOutPorts[ index ]->NodeName() << endl ;
513 if ( _NodeOutPorts[ index ]->IsDataStream() ) {
514 DecrDataStreamOutPorts() ;
516 _MapOfNodeOutPorts.erase( OutputParameterName ) ;
517 _NodeOutPorts[ index ]->destroy() ;
519 for ( i = index ; i < _NodeOutPortsSize - 1 ; i++ ) {
520 _MapOfNodeOutPorts.erase( _NodeOutPorts[ i+1 ]->PortName() ) ;
521 _MapOfNodeOutPorts[ _NodeOutPorts[ i+1 ]->PortName() ] = i+1 ;
522 _NodeOutPorts[ i ] = _NodeOutPorts[ i+1 ] ;
524 _NodeOutPortsSize = _NodeOutPortsSize - 1 ;
525 _NodeOutPorts.resize( _NodeOutPortsSize ) ;
526 for ( i = 0 ; i < _NodeOutPortsSize ; i++ ) {
527 cdebug << "DefPortsOfNode::DelOutPort ListOfOutPorts : _NodeOutPorts[" << i
528 << "] " << _NodeOutPorts[ i ]->PortName() << " "
529 << _NodeOutPorts[ i ]->NodeName() << endl ;
533 cdebug << "DefPortsOfNode::DelOutPort : index out of range ERROR " << index
538 const GraphBase::InPort *GraphBase::PortsOfNode::GetInPort( const char *name) {
539 return GetChangeInPort( name ) ;
542 const GraphBase::OutPort *GraphBase::PortsOfNode::GetOutPort( const char *name) {
543 return GetChangeOutPort( name ) ;
546 GraphBase::InPort *GraphBase::PortsOfNode::GetChangeInPort( const char * name) {
547 // cdebug_in << "GraphBase::PortsOfNode::GetChangeInPort " << name << endl;
549 GraphBase::InPort * pP = NULL;
550 if ( !_MapOfNodeInPorts.empty() ) {
552 if ( !strcmp( name , "InGate" ) ) {
553 index = _MapOfNodeInPorts[ "Gate" ] ;
556 index = _MapOfNodeInPorts[ name ] ;
559 // cdebug << "GraphBase::PortsOfNode::GetChangeInPort _MapOfNodeInPorts[ "
560 // << name << " ] : " << i-1 << " " << _NodeInPorts[ i-1 ]->NodeName()
562 pP = _NodeInPorts[ index-1 ] ;
565 cdebug << "GraphBase::PortsOfNode::GetChangeInPort _MapOfNodeInPorts[ "
566 << name << " ] : " << index << " NOT FOUND. Known ports :" << endl ;
568 map< string , int >::iterator aMapOfNodeInPortsIterator ;
570 for ( aMapOfNodeInPortsIterator = _MapOfNodeInPorts.begin() ;
571 aMapOfNodeInPortsIterator != _MapOfNodeInPorts.end() ; aMapOfNodeInPortsIterator++ ) {
572 cdebug << "MapOfNodeInPorts" << i++ << " " << aMapOfNodeInPortsIterator->first << " --> "
573 << aMapOfNodeInPortsIterator->second << endl ;
578 // cdebug_out << "GraphBase::PortsOfNode::GetChangeInPort " << endl;
583 GraphBase::OutPort *GraphBase::PortsOfNode::GetChangeOutPort( const char * name ) {
584 // cdebug_in << "GraphBase::PortsOfNode::GetChangeOutPort " << name << endl;
586 GraphBase::OutPort * pP = NULL;
587 if ( !_MapOfNodeOutPorts.empty() ) {
589 if ( !strcmp( name , "OutGate" ) ) {
590 index = _MapOfNodeOutPorts[ "Gate" ] ;
593 index = _MapOfNodeOutPorts[ name ] ;
596 // cdebug << "GraphBase::PortsOfNode::GetChangeOutPort _MapOfNodeOutPorts[ "
597 // << name << " ] : " << i-1 << " " << _NodeOutPorts[ i-1 ]->NodeName() << endl ;
598 pP = _NodeOutPorts[ index-1 ] ;
601 cdebug << "GraphBase::PortsOfNode::GetChangeOutPort _MapOfNodeOutPorts[ "
602 << name << " ] : " << index << " NOT FOUND. Known ports :" << endl ;
604 map< string , int >::iterator aMapOfNodeOutPortsIterator ;
606 for ( aMapOfNodeOutPortsIterator = _MapOfNodeOutPorts.begin() ;
607 aMapOfNodeOutPortsIterator != _MapOfNodeOutPorts.end() ; aMapOfNodeOutPortsIterator++ ) {
608 cdebug << "MapOfNodeInPorts" << i++ << " " << aMapOfNodeOutPortsIterator->first << " --> "
609 << aMapOfNodeOutPortsIterator->second << endl ;
617 void GraphBase::PortsOfNode::ListPorts( ostream & f,
618 const bool klink ) const {
622 f << " Input Ports : " ;
624 f << GetNodeInPortsSize() << " port"
625 << (GetNodeInPortsSize() > 1 ? "s" : "") << endl;
627 for ( i = 0 ; i < GetNodeInPortsSize() ; i++ ) {
629 // << hex << GetNodeInPort(i) << dec << " "
630 << *(GetNodeInPort(i)) << " " ;
631 GetNodeInPort(i)->StringValue( f ) ;
635 f << " Output Ports : " ;
638 f << GetNodeOutPortsSize() << " port"
639 << (GetNodeOutPortsSize() > 1 ? "s" : "") << endl;
641 for ( i = 0 ; i < GetNodeOutPortsSize() ; i++ ) {
643 // << hex << GetNodeOutPort(i) << dec << " "
644 << *(GetNodeOutPort(i)) << " " ;
645 GetNodeOutPort(i)->StringValue( f ) ;
650 f << " Output Ports : " ;
651 f << GetNodeInPortsSize() << " port"
652 << (GetNodeInPortsSize() > 1 ? "s" : "") << endl;
654 for ( i = 0 ; i < GetNodeInPortsSize() ; i++ ) {
656 // << hex << GetNodeInPort(i) << dec << " "
657 << *(GetNodeInPort(i)) << " " ;
658 GetNodeInPort(i)->StringValue( f ) ;
665 ostream & operator<< (ostream & f ,const SUPERV::KindOfNode & s ) {
667 case SUPERV::ComputingNode :
668 f << "ComputingNode";
670 case SUPERV::FactoryNode :
673 case SUPERV::InLineNode :
676 case SUPERV::MacroNode :
679 case SUPERV::DataFlowGraph :
680 f << "DataFlowGraph";
682 case SUPERV::DataStreamGraph :
683 f << "DataStreamGraph";
685 case SUPERV::LoopNode :
688 case SUPERV::EndLoopNode :
691 case SUPERV::SwitchNode :
694 case SUPERV::EndSwitchNode :
695 f << "EndSwitchNode";
697 case SUPERV::GOTONode :
701 f << "UnknownKindOfNode";