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]
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 string _aParametername = CORBA::string_dup(aService.ServiceinParameter[i-iVec].Parametername) ;
160 const char *aParametername = _aParametername.c_str() ;
161 if ( _MapOfNodeInPorts[ aParametername ] ) {
162 if ( !DataFlowOrComputing &&
163 !strcmp( aParametername , "Gate" ) ) {
166 cdebug << "Error, Parametername duplicated : " << aParametername
171 _MapOfNodeInPorts[ aParametername ] = i+1 ;
172 // cdebug << "DefPortsOfNode : " << "_MapOfNodeInPorts[ " << aParametername
173 // << " ] = " << i+1 << endl ;
174 const SALOME_ModuleCatalog::ServicesParameter aServiceParameter = aService.ServiceinParameter[i-iVec] ;
175 _NodeInPorts[i] = new GraphBase::InPort( NodeName , aServiceParameter ,
177 _NodeInPorts[i]->SetDebug( ORB , Graph_prof_debug , Graph_fdebug ) ;
178 // cdebug << i << ". " << *_NodeInPorts[i] << " " << _NodeInPorts[i]->Kind() << endl ;
181 iVec += aService.ServiceinParameter.length() ;
183 SALOME_ModuleCatalog::ServicesParameter anInGateParameter ;
184 _NodeInPortsSize = _NodeInPortsSize + 1 ;
186 char *aParametername = "Gate" ;
187 if ( aKind == SUPERV::EndSwitchNode ) {
188 aParametername = "Default" ;
190 anInGateParameter.Parametertype = CORBA::string_dup( "long" ) ;
191 anInGateParameter.Parametername = CORBA::string_dup( aParametername ) ;
192 _NodeInPorts.resize( _NodeInPortsSize );
193 _MapOfNodeInPorts[ aParametername ] = iVec ;
194 _NodeInPorts[iVec-1] = new GraphBase::InPort( NodeName , anInGateParameter ,
195 SUPERV::GateParameter );
196 _NodeInPorts[iVec-1]->SetDebug( ORB , Graph_prof_debug , Graph_fdebug ) ;
197 // cdebug << "DefPortsOfNode : " << "_MapOfNodeInPorts[ " << aParametername
198 // << " ] = " << iVec << " " << _NodeInPorts[iVec-1]->Kind() << " "
199 // << _NodeInPorts[iVec-1] << endl ;
203 _NodeOutPortsSize = aService.ServiceoutParameter.length() ;
205 SALOME_ModuleCatalog::ServicesParameter anOutLoopParameter ;
206 _NodeOutPortsSize = _NodeOutPortsSize + 1 ;
208 char *aParametername = "DoLoop" ;
209 anOutLoopParameter.Parametertype = CORBA::string_dup( "long" ) ;
210 anOutLoopParameter.Parametername = CORBA::string_dup( aParametername ) ;
211 if ( _NodeOutPortsSize > (int ) _NodeOutPorts.size() ) {
212 _NodeOutPorts.resize(_NodeOutPortsSize);
214 _MapOfNodeOutPorts[ aParametername ] = iVec ;
215 _NodeOutPorts[iVec-1] = new GraphBase::OutPort( NodeName , anOutLoopParameter ,
216 SUPERV::LoopParameter );
217 _NodeOutPorts[iVec-1]->SetDebug( ORB , Graph_prof_debug , Graph_fdebug ) ;
218 // cdebug << "DefPortsOfNode : " << "_MapOfNodeOutPorts[ " << aParametername
219 // << " ] = " << iVec << " " << _NodeOutPorts[iVec-1]->Kind() << " "
220 // << _NodeOutPorts[iVec-1] << endl ;
222 if ( _NodeOutPortsSize > (int ) _NodeOutPorts.size() ) {
223 _NodeOutPorts.resize(_NodeOutPortsSize);
225 cdebug << "NodeOutPortsSize " << _NodeOutPortsSize << endl ;
226 for ( i = iVec ; i < _NodeOutPortsSize ; i++ ) {
227 string _aParametername = CORBA::string_dup(aService.ServiceoutParameter[i-iVec].Parametername) ;
228 const char *aParametername = _aParametername.c_str() ;
229 if ( _MapOfNodeOutPorts[ aParametername ] ) {
230 if ( !DataFlowOrComputing &&
231 !strcmp( aParametername , "Gate" ) ) {
234 cdebug << "Error, Parametername duplicated : " << aParametername
239 // cdebug << "DefPortsOfNode : " << "_MapOfNodeOutPorts[ " << aParametername
240 // << " ] = " << i+1 << endl ;
241 _MapOfNodeOutPorts[ aParametername ] = i+1 ;
242 const SALOME_ModuleCatalog::ServicesParameter aServiceParameter = aService.ServiceoutParameter[i-iVec] ;
243 _NodeOutPorts[i] = new GraphBase::OutPort( NodeName , aServiceParameter ,
245 _NodeOutPorts[i]->SetDebug( ORB , Graph_prof_debug , Graph_fdebug ) ;
246 // cdebug << i << ". " << *_NodeOutPorts[i] << " " << _NodeOutPorts[i]->Kind() << endl ;
249 iVec += aService.ServiceoutParameter.length() ;
251 SALOME_ModuleCatalog::ServicesParameter anOutGateParameter ;
252 _NodeOutPortsSize = _NodeOutPortsSize + 1 ;
254 char *aParametername = "Gate" ;
255 if ( aKind == SUPERV::SwitchNode ) {
256 aParametername = "Default" ;
258 anOutGateParameter.Parametertype = CORBA::string_dup( "long" ) ;
259 anOutGateParameter.Parametername = CORBA::string_dup( aParametername ) ;
260 _NodeOutPorts.resize(_NodeOutPortsSize);
261 _MapOfNodeOutPorts[ aParametername ] = iVec ;
262 _NodeOutPorts[iVec-1] = new GraphBase::OutPort( NodeName , anOutGateParameter ,
263 SUPERV::GateParameter );
264 _NodeOutPorts[iVec-1]->SetDebug( ORB , Graph_prof_debug , Graph_fdebug ) ;
265 // cdebug << "DefPortsOfNode : " << "_MapOfNodeOutPorts[ " << aParametername
266 // << " ] = " << iVec << " " << _NodeOutPorts[iVec-1]->Kind() << " "
267 // << _NodeOutPorts[iVec-1] << endl ;
269 cdebug_out << "DefPortsOfNode : " << *NodeName << endl ;
272 GraphBase::InPort * GraphBase::PortsOfNode::AddInPort( CORBA::ORB_ptr ORB ,
273 const char *const * NodeName ,
274 const SUPERV::KindOfNode aKindOfNode ,
275 const char * InputParameterName ,
276 const char * InputParameterType ,
277 SUPERV::KindOfPort aKindOfPort ,
279 int * Graph_prof_debug ,
280 ofstream * Graph_fdebug ) {
281 // MESSAGE( "DefPortsOfNode " << *NodeName << " Graph_prof_debug "
282 // << Graph_prof_debug << " _prof_debug " << _prof_debug ) ;
283 cdebug_in << "PortsOfNode::AddInPort : " << *NodeName << " " << aKindOfNode << " InputParameterName "
284 << InputParameterName << " InputParameterType " << InputParameterType << " aKindOfPort "
285 << aKindOfPort << " DataStreamInPortsNumber " << DataStreamInPortsNumber() << " _NodeInPortsSize "
286 << _NodeInPortsSize << " index " << index << endl ;
287 GraphBase::InPort * anInPort = NULL ;
289 anInPort = GetChangeInPort( InputParameterName ) ;
290 if ( anInPort == NULL ) {
291 _NodeInPortsSize = _NodeInPortsSize + 1 ;
292 _NodeInPorts.resize(_NodeInPortsSize);
293 SALOME_ModuleCatalog::ServicesParameter aServiceParameter ;
294 aServiceParameter.Parametername = CORBA::string_dup( InputParameterName ) ;
295 aServiceParameter.Parametertype = CORBA::string_dup( InputParameterType ) ;
298 else if ( aKindOfPort == SUPERV::DataStreamParameter ) {
299 index = _NodeInPortsSize-2 ;
300 IncrDataStreamInPorts() ;
303 index = _NodeInPortsSize-2 - DataStreamInPortsNumber() ;
307 for ( i = _NodeInPortsSize - 2 ; i >= index ; i-- ) {
308 _NodeInPorts[ i + 1 ] = _NodeInPorts[ i ] ; // Gate - Default
309 _MapOfNodeInPorts.erase( _NodeInPorts[ i + 1 ]->PortName() ) ;
310 _MapOfNodeInPorts[ _NodeInPorts[ i + 1 ]->PortName() ] = i + 2 ;
312 _MapOfNodeInPorts[ InputParameterName ] = index + 1 ;
313 if ( aKindOfPort == SUPERV::DataStreamParameter ) {
314 _NodeInPorts[index] = new GraphBase::InDataStreamPort( NodeName ,
315 aServiceParameter ) ;
318 _NodeInPorts[index] = new GraphBase::InPort( NodeName ,
322 _NodeInPorts[index]->SetDebug( ORB , Graph_prof_debug , Graph_fdebug ) ;
323 anInPort = _NodeInPorts[index] ;
324 cdebug << "NodeInPorts[ " << index << " ]" << endl ;
327 cdebug << "GraphBase::PortsOfNode::AddInPort ERROR index " << index << " _NodeInPortsSize "
328 << _NodeInPortsSize << endl ;
332 cdebug << "GraphBase::PortsOfNode::AddInPort InPort already exists" << endl ;
333 anInPort->Kind( aKindOfPort ) ;
335 cdebug << "GraphBase::PortsOfNode::AddInPort index " << index << " _NodeInPortsSize " << _NodeInPortsSize << endl ;
338 for ( i = 0 ; i < _NodeInPortsSize ; i++ ) {
339 cdebug << *NodeName << " _NodeInPorts[ " << i << " ] = " << _NodeInPorts[ i ]->PortName()
340 << " _MapOfNodeInPorts[ " << _NodeInPorts[ i ]->PortName() << " ] = "
341 << _MapOfNodeInPorts[ _NodeInPorts[ i ]->PortName() ] << " - 1 "
342 << _NodeInPorts[ i ]->Kind() << " Dependency " << _NodeInPorts[ i ]->Dependency() ;
343 if ( _NodeInPorts[ i ]->IsDataStream() ) {
344 SUPERV::KindOfSchema aKindOfSchema ;
345 SUPERV::KindOfInterpolation aKindOfInterpolation ;
346 SUPERV::KindOfExtrapolation aKindOfExtrapolation ;
347 ((GraphBase::InDataStreamPort * ) _NodeInPorts[ i ])->Params( aKindOfSchema , aKindOfInterpolation , aKindOfExtrapolation ) ;
348 cdebug << " " << aKindOfSchema << " " << aKindOfInterpolation << " " << aKindOfExtrapolation ;
350 if ( _NodeInPorts[ i ]->GetOutPort() ) {
351 cdebug << " <--OutPort " << _NodeInPorts[ i ]->GetOutPort()
352 << " " << _NodeInPorts[ i ]->GetOutPort()->NodeName()
353 << "(" << _NodeInPorts[ i ]->GetOutPort()->PortName() << ")" ;
356 cdebug << " <--NOOutPort " << _NodeInPorts[ i ]->GetOutPort() ;
358 cdebug << " " << _NodeInPorts[ i ]->PortStatus() << endl ;
361 cdebug_out << "GraphBase::PortsOfNode::AddInPort _NodeInPortsSize " << _NodeInPortsSize
362 << " " << anInPort->Kind() << endl ;
366 GraphBase::OutPort * GraphBase::PortsOfNode::AddOutPort( CORBA::ORB_ptr ORB ,
367 const char * const * NodeName ,
368 const SUPERV::KindOfNode aKindOfNode ,
369 const char * OutputParameterName ,
370 const char * OutputParameterType ,
371 SUPERV::KindOfPort aKindOfPort ,
373 int * Graph_prof_debug ,
374 ofstream * Graph_fdebug ) {
375 cdebug_in << "GraphBase::PortsOfNode::AddOutPort : " << *NodeName << " " << aKindOfNode
376 << " OutputParameterName " << OutputParameterName << " OutputParameterType " << OutputParameterType
377 << " aKindOfPort " << aKindOfPort << " DataStreamOutPortsNumber " << DataStreamOutPortsNumber()
378 << " _NodeOutPortsSize " << _NodeOutPortsSize << " index " << index << endl ;
379 GraphBase::OutPort * anOutPort = NULL ;
381 anOutPort = GetChangeOutPort( OutputParameterName ) ;
382 if ( anOutPort == NULL ) {
383 _NodeOutPortsSize = _NodeOutPortsSize + 1 ;
384 _NodeOutPorts.resize(_NodeOutPortsSize);
385 SALOME_ModuleCatalog::ServicesParameter aServiceParameter ;
386 aServiceParameter.Parametername = CORBA::string_dup( OutputParameterName ) ;
387 aServiceParameter.Parametertype = CORBA::string_dup( OutputParameterType ) ;
390 else if ( aKindOfPort == SUPERV::DataStreamParameter ) {
391 index = _NodeOutPortsSize-2 ;
392 IncrDataStreamOutPorts() ;
395 index = _NodeOutPortsSize-2 - DataStreamOutPortsNumber() ;
397 if ( aKindOfNode == SUPERV::LoopNode || aKindOfNode == SUPERV::EndLoopNode ) {
402 for ( i = _NodeOutPortsSize - 2 ; i >= index ; i-- ) {
403 _NodeOutPorts[ i + 1 ] = _NodeOutPorts[ i ] ; // Gate - Default
404 _MapOfNodeOutPorts.erase( _NodeOutPorts[ i + 1 ]->PortName() ) ;
405 _MapOfNodeOutPorts[ _NodeOutPorts[ i + 1 ]->PortName() ] = i + 2 ;
407 _MapOfNodeOutPorts[ OutputParameterName ] = index + 1 ;
408 if ( aKindOfPort == SUPERV::DataStreamParameter ) {
409 _NodeOutPorts[index] = new GraphBase::OutDataStreamPort( NodeName ,
410 aServiceParameter ) ;
413 _NodeOutPorts[index] = new GraphBase::OutPort( NodeName ,
417 // MESSAGE( "GraphBase::PortsOfNode::AddOutPort " << OutputParameterName << " --> SetDebug" ) ;
418 _NodeOutPorts[index]->SetDebug( ORB , Graph_prof_debug , Graph_fdebug ) ;
419 anOutPort = _NodeOutPorts[index] ;
420 cdebug << "NodeOutPorts[ " << index << " ]" << endl ;
423 cdebug << "GraphBase::PortsOfNode::AddOutPort ERROR index " << index << " _NodeOutPortsSize "
424 << _NodeOutPortsSize << endl ;
428 cdebug << "GraphBase::PortsOfNode::AddOutPort OutPort already exists" << endl ;
429 anOutPort->Kind( aKindOfPort ) ;
431 cdebug << "GraphBase::PortsOfNode::AddOutPort index " << index << " _NodeOutPortsSize " << _NodeOutPortsSize << endl ;
434 for ( i = 0 ; i < _NodeOutPortsSize ; i++ ) {
435 cdebug << *NodeName << " _NodeOutPorts[ " << i << " ] = " << _NodeOutPorts[ i ]->PortName()
436 << " _MapOfNodeOutPorts[ " << _NodeOutPorts[ i ]->PortName() << " ] = "
437 << _MapOfNodeOutPorts[ _NodeOutPorts[ i ]->PortName() ] << " - 1 "
438 << _NodeOutPorts[ i ]->Kind() << " Dependency " << _NodeOutPorts[ i ]->Dependency() ;
439 if ( _NodeOutPorts[ i ]->IsDataStream() ) {
440 cdebug << " NumberOfValues " << ((GraphBase::OutDataStreamPort * ) _NodeOutPorts[ i ])->NumberOfValues() ;
442 cdebug << " " << _NodeOutPorts[ i ]->PortStatus() << endl ;
445 cdebug_out << "GraphBase::PortsOfNode::AddOutPort _NodeOutPortsSize "
446 << _NodeOutPortsSize << " " << anOutPort->Kind() << endl ;
450 void GraphBase::PortsOfNode::MoveInPort( const char * InputParameterName , int toindex ) {
451 int fromindex = _MapOfNodeInPorts[ InputParameterName ] - 1 ;
452 GraphBase::InPort * anInPort = _NodeInPorts[ toindex ] ;
453 _NodeInPorts[ toindex ] = _NodeInPorts[ fromindex ] ;
454 _NodeInPorts[ fromindex ] = anInPort ;
455 _MapOfNodeInPorts.erase( _NodeInPorts[ toindex ]->PortName() ) ;
456 _MapOfNodeInPorts[ _NodeInPorts[ toindex ]->PortName() ] = toindex + 1 ;
457 _MapOfNodeInPorts.erase( _NodeInPorts[ fromindex ]->PortName() ) ;
458 _MapOfNodeInPorts[ _NodeInPorts[ fromindex ]->PortName() ] = fromindex + 1 ;
461 void GraphBase::PortsOfNode::MoveOutPort( const char * OutputParameterName , int toindex ) {
462 int fromindex = _MapOfNodeOutPorts[ OutputParameterName ] - 1 ;
463 GraphBase::OutPort * anOutPort = _NodeOutPorts[ toindex ] ;
464 _NodeOutPorts[ toindex ] = _NodeOutPorts[ fromindex ] ;
465 _NodeOutPorts[ fromindex ] = anOutPort ;
466 _MapOfNodeOutPorts.erase( _NodeOutPorts[ toindex ]->PortName() ) ;
467 _MapOfNodeOutPorts[ _NodeOutPorts[ toindex ]->PortName() ] = toindex + 1 ;
468 _MapOfNodeOutPorts.erase( _NodeOutPorts[ fromindex ]->PortName() ) ;
469 _MapOfNodeOutPorts[ _NodeOutPorts[ fromindex ]->PortName() ] = fromindex + 1 ;
472 void GraphBase::PortsOfNode::DelInPort( const char * InputParameterName ) {
473 cdebug << "DefPortsOfNode::DelInPort : " << InputParameterName << endl ;
474 int index = _MapOfNodeInPorts[ InputParameterName ] -1 ;
476 cdebug << "DefPortsOfNode::DelInPort : _NodeInPorts[" << index << "] "
477 << _NodeInPorts[ index ]->PortName() << " "
478 << _NodeInPorts[ index ]->NodeName() << endl ;
479 if ( _NodeInPorts[ index ]->IsDataStream() ) {
480 DecrDataStreamInPorts() ;
482 _MapOfNodeInPorts.erase( InputParameterName ) ;
483 _NodeInPorts[ index ]->destroy() ;
485 for ( i = index ; i < _NodeInPortsSize - 1 ; i++ ) {
486 _MapOfNodeInPorts.erase( _NodeInPorts[ i+1 ]->PortName() ) ;
487 _MapOfNodeInPorts[ _NodeInPorts[ i+1 ]->PortName() ] = i+1 ;
488 _NodeInPorts[ i ] = _NodeInPorts[ i+1 ] ;
490 _NodeInPortsSize = _NodeInPortsSize - 1 ;
491 _NodeInPorts.resize( _NodeInPortsSize ) ;
492 for ( i = 0 ; i < _NodeInPortsSize ; i++ ) {
493 cdebug << "DefPortsOfNode::DelInPort ListOfInPorts : _NodeInPorts[" << i << "] "
494 << _NodeInPorts[ i ]->PortName() << " "
495 << _NodeInPorts[ i ]->NodeName() << endl ;
499 cdebug << "DefPortsOfNode::DelInPort : index out of range ERROR " << index
504 void GraphBase::PortsOfNode::DelOutPort( const char * OutputParameterName ) {
505 cdebug << "DefPortsOfNode::DelOutPort : " << OutputParameterName << endl ;
506 int index = _MapOfNodeOutPorts[ OutputParameterName ] - 1 ;
508 cdebug << "DefPortsOfNode::DelOutPort : _NodeOutPorts[" << index << "] "
509 << _NodeOutPorts[ index ]->PortName() << " "
510 << _NodeOutPorts[ index ]->NodeName() << endl ;
511 if ( _NodeOutPorts[ index ]->IsDataStream() ) {
512 DecrDataStreamOutPorts() ;
514 _MapOfNodeOutPorts.erase( OutputParameterName ) ;
515 _NodeOutPorts[ index ]->destroy() ;
517 for ( i = index ; i < _NodeOutPortsSize - 1 ; i++ ) {
518 _MapOfNodeOutPorts.erase( _NodeOutPorts[ i+1 ]->PortName() ) ;
519 _MapOfNodeOutPorts[ _NodeOutPorts[ i+1 ]->PortName() ] = i+1 ;
520 _NodeOutPorts[ i ] = _NodeOutPorts[ i+1 ] ;
522 _NodeOutPortsSize = _NodeOutPortsSize - 1 ;
523 _NodeOutPorts.resize( _NodeOutPortsSize ) ;
524 for ( i = 0 ; i < _NodeOutPortsSize ; i++ ) {
525 cdebug << "DefPortsOfNode::DelOutPort ListOfOutPorts : _NodeOutPorts[" << i
526 << "] " << _NodeOutPorts[ i ]->PortName() << " "
527 << _NodeOutPorts[ i ]->NodeName() << endl ;
531 cdebug << "DefPortsOfNode::DelOutPort : index out of range ERROR " << index
536 const GraphBase::InPort *GraphBase::PortsOfNode::GetInPort( const char *name) {
537 return GetChangeInPort( name ) ;
540 const GraphBase::OutPort *GraphBase::PortsOfNode::GetOutPort( const char *name) {
541 return GetChangeOutPort( name ) ;
544 GraphBase::InPort *GraphBase::PortsOfNode::GetChangeInPort( const char * name) {
545 // cdebug_in << "GraphBase::PortsOfNode::GetChangeInPort " << name << endl;
547 GraphBase::InPort * pP = NULL;
548 if ( !_MapOfNodeInPorts.empty() ) {
550 if ( !strcmp( name , "InGate" ) ) {
551 index = _MapOfNodeInPorts[ "Gate" ] ;
554 index = _MapOfNodeInPorts[ name ] ;
557 // cdebug << "GraphBase::PortsOfNode::GetChangeInPort _MapOfNodeInPorts[ "
558 // << name << " ] : " << i-1 << " " << _NodeInPorts[ i-1 ]->NodeName()
560 pP = _NodeInPorts[ index-1 ] ;
563 cdebug << "GraphBase::PortsOfNode::GetChangeInPort _MapOfNodeInPorts[ "
564 << name << " ] : " << index << " NOT FOUND. Known ports :" << endl ;
566 map< string , int >::iterator aMapOfNodeInPortsIterator ;
568 for ( aMapOfNodeInPortsIterator = _MapOfNodeInPorts.begin() ;
569 aMapOfNodeInPortsIterator != _MapOfNodeInPorts.end() ; aMapOfNodeInPortsIterator++ ) {
570 cdebug << "MapOfNodeInPorts" << i++ << " " << aMapOfNodeInPortsIterator->first << " --> "
571 << aMapOfNodeInPortsIterator->second << endl ;
576 // cdebug_out << "GraphBase::PortsOfNode::GetChangeInPort " << endl;
581 GraphBase::OutPort *GraphBase::PortsOfNode::GetChangeOutPort( const char * name ) {
582 // cdebug_in << "GraphBase::PortsOfNode::GetChangeOutPort " << name << endl;
584 GraphBase::OutPort * pP = NULL;
585 if ( !_MapOfNodeOutPorts.empty() ) {
587 if ( !strcmp( name , "OutGate" ) ) {
588 index = _MapOfNodeOutPorts[ "Gate" ] ;
591 index = _MapOfNodeOutPorts[ name ] ;
594 // cdebug << "GraphBase::PortsOfNode::GetChangeOutPort _MapOfNodeOutPorts[ "
595 // << name << " ] : " << i-1 << " " << _NodeOutPorts[ i-1 ]->NodeName() << endl ;
596 pP = _NodeOutPorts[ index-1 ] ;
599 cdebug << "GraphBase::PortsOfNode::GetChangeOutPort _MapOfNodeOutPorts[ "
600 << name << " ] : " << index << " NOT FOUND. Known ports :" << endl ;
602 map< string , int >::iterator aMapOfNodeOutPortsIterator ;
604 for ( aMapOfNodeOutPortsIterator = _MapOfNodeOutPorts.begin() ;
605 aMapOfNodeOutPortsIterator != _MapOfNodeOutPorts.end() ; aMapOfNodeOutPortsIterator++ ) {
606 cdebug << "MapOfNodeInPorts" << i++ << " " << aMapOfNodeOutPortsIterator->first << " --> "
607 << aMapOfNodeOutPortsIterator->second << endl ;
615 void GraphBase::PortsOfNode::ListPorts( ostream & f,
616 const bool klink ) const {
620 f << " Input Ports : " ;
622 f << GetNodeInPortsSize() << " port"
623 << (GetNodeInPortsSize() > 1 ? "s" : "") << endl;
625 for ( i = 0 ; i < GetNodeInPortsSize() ; i++ ) {
627 // << hex << GetNodeInPort(i) << dec << " "
628 << *(GetNodeInPort(i)) << " " ;
629 GetNodeInPort(i)->StringValue( f ) ;
633 f << " Output Ports : " ;
636 f << GetNodeOutPortsSize() << " port"
637 << (GetNodeOutPortsSize() > 1 ? "s" : "") << endl;
639 for ( i = 0 ; i < GetNodeOutPortsSize() ; i++ ) {
641 // << hex << GetNodeOutPort(i) << dec << " "
642 << *(GetNodeOutPort(i)) << " " ;
643 GetNodeOutPort(i)->StringValue( f ) ;
648 f << " Output Ports : " ;
649 f << GetNodeInPortsSize() << " port"
650 << (GetNodeInPortsSize() > 1 ? "s" : "") << endl;
652 for ( i = 0 ; i < GetNodeInPortsSize() ; i++ ) {
654 // << hex << GetNodeInPort(i) << dec << " "
655 << *(GetNodeInPort(i)) << " " ;
656 GetNodeInPort(i)->StringValue( f ) ;
663 ostream & operator<< (ostream & f ,const SUPERV::KindOfNode & s ) {
665 case SUPERV::ComputingNode :
666 f << "ComputingNode";
668 case SUPERV::FactoryNode :
671 case SUPERV::InLineNode :
674 case SUPERV::MacroNode :
677 case SUPERV::DataFlowGraph :
678 f << "DataFlowGraph";
680 case SUPERV::DataStreamGraph :
681 f << "DataStreamGraph";
683 case SUPERV::LoopNode :
686 case SUPERV::EndLoopNode :
689 case SUPERV::SwitchNode :
692 case SUPERV::EndSwitchNode :
693 f << "EndSwitchNode";
695 case SUPERV::GOTONode :
699 f << "UnknownKindOfNode";