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 (aKind == SUPERV::SwitchNode) || (aKind == SUPERV::EndSwitchNode) ||
95 (aKind == SUPERV::MacroNode) ;
96 SUPERV::KindOfPort aPortKind = SUPERV::ServiceParameter ;
97 if ( aKind == SUPERV::InLineNode ) {
98 aPortKind = SUPERV::InLineParameter ;
100 else if ( aKind == SUPERV::LoopNode || aKind == SUPERV::EndLoopNode ) {
101 aPortKind = SUPERV::InLineParameter ;
103 else if ( aKind == SUPERV::SwitchNode || aKind == SUPERV::EndSwitchNode ) {
104 aPortKind = SUPERV::InLineParameter ;
106 else if ( aKind == SUPERV::GOTONode ) {
107 aPortKind = SUPERV::InLineParameter ;
109 else if ( aKind == SUPERV::MacroNode ) {
110 aPortKind = SUPERV::InLineParameter ;
112 for ( i = 0 ; i < _NodeInPortsSize ; i++ ) {
113 cdebug << "DefPortsOfNode delete In" << i << ". " << _NodeInPorts[i]
115 _MapOfNodeInPorts.erase( _NodeInPorts[i]->PortName() ) ;
116 delete _NodeInPorts[i] ;
118 _NodeInPorts.resize( 0 );
119 for ( i = 0 ; i < _NodeOutPortsSize ; i++ ) {
120 cdebug << "DefPortsOfNode delete Out" << i << ". " << _NodeOutPorts[i]->PortName()
122 _MapOfNodeOutPorts.erase( _NodeOutPorts[i]->PortName() ) ;
123 delete _NodeOutPorts[i] ;
125 _NodeOutPorts.resize( 0 );
127 SetService( aService ) ;
130 _NodeInPortsSize = aService.ServiceinParameter.length() ;
132 SALOME_ModuleCatalog::ServicesParameter anInLoopParameter ;
133 _NodeInPortsSize = _NodeInPortsSize + 1 ;
135 char *aParametername = "InitLoop" ;
136 if ( aKind == SUPERV::EndLoopNode ) {
137 aParametername = "DoLoop" ;
139 anInLoopParameter.Parametertype = CORBA::string_dup( "long" ) ;
140 anInLoopParameter.Parametername = CORBA::string_dup( aParametername ) ;
141 if ( _NodeInPortsSize > (int ) _NodeInPorts.size() ) {
142 _NodeInPorts.resize( _NodeInPortsSize );
144 _MapOfNodeInPorts[ aParametername ] = iVec ;
145 _NodeInPorts[iVec-1] = new GraphBase::InPort( NodeName , anInLoopParameter ,
146 SUPERV::LoopParameter );
147 _NodeInPorts[iVec-1]->SetDebug( ORB , Graph_prof_debug , Graph_fdebug ) ;
148 cdebug << "DefPortsOfNode : " << "_MapOfNodeInPorts[ " << aParametername
149 << " ] = " << iVec << " " << _NodeInPorts[iVec-1]->Kind() << " "
150 << _NodeInPorts[iVec-1] << endl ;
152 if ( _NodeInPortsSize > (int ) _NodeInPorts.size() ) {
153 _NodeInPorts.resize(_NodeInPortsSize);
155 cdebug << "NodeInPortsSize " << _NodeInPortsSize << endl ;
156 for ( i = iVec ; i < _NodeInPortsSize ; i++ ) {
157 string _aParametername = CORBA::string_dup(aService.ServiceinParameter[i-iVec].Parametername) ;
158 const char *aParametername = _aParametername.c_str() ;
159 if ( _MapOfNodeInPorts[ aParametername ] ) {
160 if ( !DataFlowOrComputing &&
161 !strcmp( aParametername , "Gate" ) ) {
164 cdebug << "Error, Parametername duplicated : " << aParametername
169 _MapOfNodeInPorts[ aParametername ] = i+1 ;
170 // cdebug << "DefPortsOfNode : " << "_MapOfNodeInPorts[ " << aParametername
171 // << " ] = " << i+1 << endl ;
172 const SALOME_ModuleCatalog::ServicesParameter aServiceParameter = aService.ServiceinParameter[i-iVec] ;
173 _NodeInPorts[i] = new GraphBase::InPort( NodeName , aServiceParameter ,
175 _NodeInPorts[i]->SetDebug( ORB , Graph_prof_debug , Graph_fdebug ) ;
176 // cdebug << i << ". " << *_NodeInPorts[i] << " " << _NodeInPorts[i]->Kind() << endl ;
179 iVec += aService.ServiceinParameter.length() ;
181 SALOME_ModuleCatalog::ServicesParameter anInGateParameter ;
182 _NodeInPortsSize = _NodeInPortsSize + 1 ;
184 char *aParametername = "Gate" ;
185 if ( aKind == SUPERV::EndSwitchNode ) {
186 aParametername = "Default" ;
188 anInGateParameter.Parametertype = CORBA::string_dup( "long" ) ;
189 anInGateParameter.Parametername = CORBA::string_dup( aParametername ) ;
190 _NodeInPorts.resize( _NodeInPortsSize );
191 _MapOfNodeInPorts[ aParametername ] = iVec ;
192 _NodeInPorts[iVec-1] = new GraphBase::InPort( NodeName , anInGateParameter ,
193 SUPERV::GateParameter );
194 _NodeInPorts[iVec-1]->SetDebug( ORB , Graph_prof_debug , Graph_fdebug ) ;
195 // cdebug << "DefPortsOfNode : " << "_MapOfNodeInPorts[ " << aParametername
196 // << " ] = " << iVec << " " << _NodeInPorts[iVec-1]->Kind() << " "
197 // << _NodeInPorts[iVec-1] << endl ;
201 _NodeOutPortsSize = aService.ServiceoutParameter.length() ;
203 SALOME_ModuleCatalog::ServicesParameter anOutLoopParameter ;
204 _NodeOutPortsSize = _NodeOutPortsSize + 1 ;
206 char *aParametername = "DoLoop" ;
207 anOutLoopParameter.Parametertype = CORBA::string_dup( "long" ) ;
208 anOutLoopParameter.Parametername = CORBA::string_dup( aParametername ) ;
209 if ( _NodeOutPortsSize > (int ) _NodeOutPorts.size() ) {
210 _NodeOutPorts.resize(_NodeOutPortsSize);
212 _MapOfNodeOutPorts[ aParametername ] = iVec ;
213 _NodeOutPorts[iVec-1] = new GraphBase::OutPort( NodeName , anOutLoopParameter ,
214 SUPERV::LoopParameter );
215 _NodeOutPorts[iVec-1]->SetDebug( ORB , Graph_prof_debug , Graph_fdebug ) ;
216 // cdebug << "DefPortsOfNode : " << "_MapOfNodeOutPorts[ " << aParametername
217 // << " ] = " << iVec << " " << _NodeOutPorts[iVec-1]->Kind() << " "
218 // << _NodeOutPorts[iVec-1] << endl ;
220 if ( _NodeOutPortsSize > (int ) _NodeOutPorts.size() ) {
221 _NodeOutPorts.resize(_NodeOutPortsSize);
223 cdebug << "NodeOutPortsSize " << _NodeOutPortsSize << endl ;
224 for ( i = iVec ; i < _NodeOutPortsSize ; i++ ) {
225 string _aParametername = CORBA::string_dup(aService.ServiceoutParameter[i-iVec].Parametername) ;
226 const char *aParametername = _aParametername.c_str() ;
227 if ( _MapOfNodeOutPorts[ aParametername ] ) {
228 if ( !DataFlowOrComputing &&
229 !strcmp( aParametername , "Gate" ) ) {
232 cdebug << "Error, Parametername duplicated : " << aParametername
237 // cdebug << "DefPortsOfNode : " << "_MapOfNodeOutPorts[ " << aParametername
238 // << " ] = " << i+1 << endl ;
239 _MapOfNodeOutPorts[ aParametername ] = i+1 ;
240 const SALOME_ModuleCatalog::ServicesParameter aServiceParameter = aService.ServiceoutParameter[i-iVec] ;
241 _NodeOutPorts[i] = new GraphBase::OutPort( NodeName , aServiceParameter ,
243 _NodeOutPorts[i]->SetDebug( ORB , Graph_prof_debug , Graph_fdebug ) ;
244 // cdebug << i << ". " << *_NodeOutPorts[i] << " " << _NodeOutPorts[i]->Kind() << endl ;
247 iVec += aService.ServiceoutParameter.length() ;
249 SALOME_ModuleCatalog::ServicesParameter anOutGateParameter ;
250 _NodeOutPortsSize = _NodeOutPortsSize + 1 ;
252 char *aParametername = "Gate" ;
253 if ( aKind == SUPERV::SwitchNode ) {
254 aParametername = "Default" ;
256 anOutGateParameter.Parametertype = CORBA::string_dup( "long" ) ;
257 anOutGateParameter.Parametername = CORBA::string_dup( aParametername ) ;
258 _NodeOutPorts.resize(_NodeOutPortsSize);
259 _MapOfNodeOutPorts[ aParametername ] = iVec ;
260 _NodeOutPorts[iVec-1] = new GraphBase::OutPort( NodeName , anOutGateParameter ,
261 SUPERV::GateParameter );
262 _NodeOutPorts[iVec-1]->SetDebug( ORB , Graph_prof_debug , Graph_fdebug ) ;
263 // cdebug << "DefPortsOfNode : " << "_MapOfNodeOutPorts[ " << aParametername
264 // << " ] = " << iVec << " " << _NodeOutPorts[iVec-1]->Kind() << " "
265 // << _NodeOutPorts[iVec-1] << endl ;
267 cdebug_out << "DefPortsOfNode : " << *NodeName << endl ;
270 GraphBase::InPort * GraphBase::PortsOfNode::AddInPort( CORBA::ORB_ptr ORB ,
271 const char *const * NodeName ,
272 const SUPERV::KindOfNode aKindOfNode ,
273 const char * InputParameterName ,
274 const char * InputParameterType ,
275 SUPERV::KindOfPort aKindOfPort ,
277 int * Graph_prof_debug ,
278 ofstream * Graph_fdebug ) {
279 // MESSAGE( "DefPortsOfNode " << *NodeName << " Graph_prof_debug "
280 // << Graph_prof_debug << " _prof_debug " << _prof_debug ) ;
281 cdebug_in << "PortsOfNode::AddInPort : " << *NodeName << " " << aKindOfNode << " InputParameterName "
282 << InputParameterName << " InputParameterType " << InputParameterType << " aKindOfPort "
283 << aKindOfPort << " DataStreamInPortsNumber " << DataStreamInPortsNumber() << " _NodeInPortsSize "
284 << _NodeInPortsSize << " index " << index << endl ;
285 GraphBase::InPort * anInPort = NULL ;
287 anInPort = GetChangeInPort( InputParameterName ) ;
288 if ( anInPort == NULL ) {
289 _NodeInPortsSize = _NodeInPortsSize + 1 ;
290 _NodeInPorts.resize(_NodeInPortsSize);
291 SALOME_ModuleCatalog::ServicesParameter aServiceParameter ;
292 aServiceParameter.Parametername = CORBA::string_dup( InputParameterName ) ;
293 aServiceParameter.Parametertype = CORBA::string_dup( InputParameterType ) ;
296 else if ( aKindOfPort == SUPERV::DataStreamParameter ) {
297 index = _NodeInPortsSize-2 ;
298 IncrDataStreamInPorts() ;
301 index = _NodeInPortsSize-2 - DataStreamInPortsNumber() ;
305 for ( i = _NodeInPortsSize - 2 ; i >= index ; i-- ) {
306 _NodeInPorts[ i + 1 ] = _NodeInPorts[ i ] ; // Gate - Default
307 _MapOfNodeInPorts.erase( _NodeInPorts[ i + 1 ]->PortName() ) ;
308 _MapOfNodeInPorts[ _NodeInPorts[ i + 1 ]->PortName() ] = i + 2 ;
310 _MapOfNodeInPorts[ InputParameterName ] = index + 1 ;
311 if ( aKindOfPort == SUPERV::DataStreamParameter ) {
312 _NodeInPorts[index] = new GraphBase::InDataStreamPort( NodeName ,
313 aServiceParameter ) ;
316 _NodeInPorts[index] = new GraphBase::InPort( NodeName ,
320 _NodeInPorts[index]->SetDebug( ORB , Graph_prof_debug , Graph_fdebug ) ;
321 anInPort = _NodeInPorts[index] ;
322 cdebug << "NodeInPorts[ " << index << " ]" << endl ;
325 cdebug << "GraphBase::PortsOfNode::AddInPort ERROR index " << index << " _NodeInPortsSize "
326 << _NodeInPortsSize << endl ;
330 cdebug << "GraphBase::PortsOfNode::AddInPort InPort already exists" << endl ;
331 anInPort->Kind( aKindOfPort ) ;
333 cdebug << "GraphBase::PortsOfNode::AddInPort index " << index << " _NodeInPortsSize " << _NodeInPortsSize << endl ;
336 for ( i = 0 ; i < _NodeInPortsSize ; i++ ) {
337 cdebug << *NodeName << " _NodeInPorts[ " << i << " ] = " << _NodeInPorts[ i ]->PortName()
338 << " _MapOfNodeInPorts[ " << _NodeInPorts[ i ]->PortName() << " ] = "
339 << _MapOfNodeInPorts[ _NodeInPorts[ i ]->PortName() ] << " - 1 "
340 << _NodeInPorts[ i ]->Kind() << " Dependency " << _NodeInPorts[ i ]->Dependency() ;
341 if ( _NodeInPorts[ i ]->IsDataStream() ) {
342 SUPERV::KindOfSchema aKindOfSchema ;
343 SUPERV::KindOfInterpolation aKindOfInterpolation ;
344 SUPERV::KindOfExtrapolation aKindOfExtrapolation ;
345 ((GraphBase::InDataStreamPort * ) _NodeInPorts[ i ])->Params( aKindOfSchema , aKindOfInterpolation , aKindOfExtrapolation ) ;
346 cdebug << " " << aKindOfSchema << " " << aKindOfInterpolation << " " << aKindOfExtrapolation ;
348 if ( _NodeInPorts[ i ]->GetOutPort() ) {
349 cdebug << " <--OutPort " << _NodeInPorts[ i ]->GetOutPort()
350 << " " << _NodeInPorts[ i ]->GetOutPort()->NodeName()
351 << "(" << _NodeInPorts[ i ]->GetOutPort()->PortName() << ")" ;
354 cdebug << " <--NOOutPort " << _NodeInPorts[ i ]->GetOutPort() ;
356 cdebug << " " << _NodeInPorts[ i ]->PortStatus() << endl ;
359 cdebug_out << "GraphBase::PortsOfNode::AddInPort _NodeInPortsSize " << _NodeInPortsSize
360 << " " << anInPort->Kind() << endl ;
364 GraphBase::OutPort * GraphBase::PortsOfNode::AddOutPort( CORBA::ORB_ptr ORB ,
365 const char * const * NodeName ,
366 const SUPERV::KindOfNode aKindOfNode ,
367 const char * OutputParameterName ,
368 const char * OutputParameterType ,
369 SUPERV::KindOfPort aKindOfPort ,
371 int * Graph_prof_debug ,
372 ofstream * Graph_fdebug ) {
373 cdebug_in << "GraphBase::PortsOfNode::AddOutPort : " << *NodeName << " " << aKindOfNode
374 << " OutputParameterName " << OutputParameterName << " OutputParameterType " << OutputParameterType
375 << " aKindOfPort " << aKindOfPort << " DataStreamOutPortsNumber " << DataStreamOutPortsNumber()
376 << " _NodeOutPortsSize " << _NodeOutPortsSize << " index " << index << endl ;
377 GraphBase::OutPort * anOutPort = NULL ;
379 anOutPort = GetChangeOutPort( OutputParameterName ) ;
380 if ( anOutPort == NULL ) {
381 _NodeOutPortsSize = _NodeOutPortsSize + 1 ;
382 _NodeOutPorts.resize(_NodeOutPortsSize);
383 SALOME_ModuleCatalog::ServicesParameter aServiceParameter ;
384 aServiceParameter.Parametername = CORBA::string_dup( OutputParameterName ) ;
385 aServiceParameter.Parametertype = CORBA::string_dup( OutputParameterType ) ;
388 else if ( aKindOfPort == SUPERV::DataStreamParameter ) {
389 index = _NodeOutPortsSize-2 ;
390 IncrDataStreamOutPorts() ;
393 index = _NodeOutPortsSize-2 - DataStreamOutPortsNumber() ;
395 if ( aKindOfNode == SUPERV::LoopNode || aKindOfNode == SUPERV::EndLoopNode ) {
400 for ( i = _NodeOutPortsSize - 2 ; i >= index ; i-- ) {
401 _NodeOutPorts[ i + 1 ] = _NodeOutPorts[ i ] ; // Gate - Default
402 _MapOfNodeOutPorts.erase( _NodeOutPorts[ i + 1 ]->PortName() ) ;
403 _MapOfNodeOutPorts[ _NodeOutPorts[ i + 1 ]->PortName() ] = i + 2 ;
405 _MapOfNodeOutPorts[ OutputParameterName ] = index + 1 ;
406 if ( aKindOfPort == SUPERV::DataStreamParameter ) {
407 _NodeOutPorts[index] = new GraphBase::OutDataStreamPort( NodeName ,
408 aServiceParameter ) ;
411 _NodeOutPorts[index] = new GraphBase::OutPort( NodeName ,
415 // MESSAGE( "GraphBase::PortsOfNode::AddOutPort " << OutputParameterName << " --> SetDebug" ) ;
416 _NodeOutPorts[index]->SetDebug( ORB , Graph_prof_debug , Graph_fdebug ) ;
417 anOutPort = _NodeOutPorts[index] ;
418 cdebug << "NodeOutPorts[ " << index << " ]" << endl ;
421 cdebug << "GraphBase::PortsOfNode::AddOutPort ERROR index " << index << " _NodeOutPortsSize "
422 << _NodeOutPortsSize << endl ;
426 cdebug << "GraphBase::PortsOfNode::AddOutPort OutPort already exists" << endl ;
427 anOutPort->Kind( aKindOfPort ) ;
429 cdebug << "GraphBase::PortsOfNode::AddOutPort index " << index << " _NodeOutPortsSize " << _NodeOutPortsSize << endl ;
432 for ( i = 0 ; i < _NodeOutPortsSize ; i++ ) {
433 cdebug << *NodeName << " _NodeOutPorts[ " << i << " ] = " << _NodeOutPorts[ i ]->PortName()
434 << " _MapOfNodeOutPorts[ " << _NodeOutPorts[ i ]->PortName() << " ] = "
435 << _MapOfNodeOutPorts[ _NodeOutPorts[ i ]->PortName() ] << " - 1 "
436 << _NodeOutPorts[ i ]->Kind() << " Dependency " << _NodeOutPorts[ i ]->Dependency() ;
437 if ( _NodeOutPorts[ i ]->IsDataStream() ) {
438 cdebug << " NumberOfValues " << ((GraphBase::OutDataStreamPort * ) _NodeOutPorts[ i ])->NumberOfValues() ;
440 cdebug << " " << _NodeOutPorts[ i ]->PortStatus() << endl ;
443 cdebug_out << "GraphBase::PortsOfNode::AddOutPort _NodeOutPortsSize "
444 << _NodeOutPortsSize << " " << anOutPort->Kind() << endl ;
448 void GraphBase::PortsOfNode::MoveInPort( const char * InputParameterName , int toindex ) {
449 int fromindex = _MapOfNodeInPorts[ InputParameterName ] - 1 ;
450 GraphBase::InPort * anInPort = _NodeInPorts[ toindex ] ;
451 _NodeInPorts[ toindex ] = _NodeInPorts[ fromindex ] ;
452 _NodeInPorts[ fromindex ] = anInPort ;
453 _MapOfNodeInPorts.erase( _NodeInPorts[ toindex ]->PortName() ) ;
454 _MapOfNodeInPorts[ _NodeInPorts[ toindex ]->PortName() ] = toindex + 1 ;
455 _MapOfNodeInPorts.erase( _NodeInPorts[ fromindex ]->PortName() ) ;
456 _MapOfNodeInPorts[ _NodeInPorts[ fromindex ]->PortName() ] = fromindex + 1 ;
459 void GraphBase::PortsOfNode::MoveOutPort( const char * OutputParameterName , int toindex ) {
460 int fromindex = _MapOfNodeOutPorts[ OutputParameterName ] - 1 ;
461 GraphBase::OutPort * anOutPort = _NodeOutPorts[ toindex ] ;
462 _NodeOutPorts[ toindex ] = _NodeOutPorts[ fromindex ] ;
463 _NodeOutPorts[ fromindex ] = anOutPort ;
464 _MapOfNodeOutPorts.erase( _NodeOutPorts[ toindex ]->PortName() ) ;
465 _MapOfNodeOutPorts[ _NodeOutPorts[ toindex ]->PortName() ] = toindex + 1 ;
466 _MapOfNodeOutPorts.erase( _NodeOutPorts[ fromindex ]->PortName() ) ;
467 _MapOfNodeOutPorts[ _NodeOutPorts[ fromindex ]->PortName() ] = fromindex + 1 ;
470 void GraphBase::PortsOfNode::DelInPort( const char * InputParameterName ) {
471 cdebug << "DefPortsOfNode::DelInPort : " << InputParameterName << endl ;
472 int index = _MapOfNodeInPorts[ InputParameterName ] -1 ;
474 cdebug << "DefPortsOfNode::DelInPort : _NodeInPorts[" << index << "] "
475 << _NodeInPorts[ index ]->PortName() << " "
476 << _NodeInPorts[ index ]->NodeName() << endl ;
477 if ( _NodeInPorts[ index ]->IsDataStream() ) {
478 DecrDataStreamInPorts() ;
480 _MapOfNodeInPorts.erase( InputParameterName ) ;
481 _NodeInPorts[ index ]->destroy() ;
483 for ( i = index ; i < _NodeInPortsSize - 1 ; i++ ) {
484 _MapOfNodeInPorts.erase( _NodeInPorts[ i+1 ]->PortName() ) ;
485 _MapOfNodeInPorts[ _NodeInPorts[ i+1 ]->PortName() ] = i+1 ;
486 _NodeInPorts[ i ] = _NodeInPorts[ i+1 ] ;
488 _NodeInPortsSize = _NodeInPortsSize - 1 ;
489 _NodeInPorts.resize( _NodeInPortsSize ) ;
490 for ( i = 0 ; i < _NodeInPortsSize ; i++ ) {
491 cdebug << "DefPortsOfNode::DelInPort ListOfInPorts : _NodeInPorts[" << i << "] "
492 << _NodeInPorts[ i ]->PortName() << " "
493 << _NodeInPorts[ i ]->NodeName() << endl ;
497 cdebug << "DefPortsOfNode::DelInPort : index out of range ERROR " << index
502 void GraphBase::PortsOfNode::DelOutPort( const char * OutputParameterName ) {
503 cdebug << "DefPortsOfNode::DelOutPort : " << OutputParameterName << endl ;
504 int index = _MapOfNodeOutPorts[ OutputParameterName ] - 1 ;
506 cdebug << "DefPortsOfNode::DelOutPort : _NodeOutPorts[" << index << "] "
507 << _NodeOutPorts[ index ]->PortName() << " "
508 << _NodeOutPorts[ index ]->NodeName() << endl ;
509 if ( _NodeOutPorts[ index ]->IsDataStream() ) {
510 DecrDataStreamOutPorts() ;
512 _MapOfNodeOutPorts.erase( OutputParameterName ) ;
513 _NodeOutPorts[ index ]->destroy() ;
515 for ( i = index ; i < _NodeOutPortsSize - 1 ; i++ ) {
516 _MapOfNodeOutPorts.erase( _NodeOutPorts[ i+1 ]->PortName() ) ;
517 _MapOfNodeOutPorts[ _NodeOutPorts[ i+1 ]->PortName() ] = i+1 ;
518 _NodeOutPorts[ i ] = _NodeOutPorts[ i+1 ] ;
520 _NodeOutPortsSize = _NodeOutPortsSize - 1 ;
521 _NodeOutPorts.resize( _NodeOutPortsSize ) ;
522 for ( i = 0 ; i < _NodeOutPortsSize ; i++ ) {
523 cdebug << "DefPortsOfNode::DelOutPort ListOfOutPorts : _NodeOutPorts[" << i
524 << "] " << _NodeOutPorts[ i ]->PortName() << " "
525 << _NodeOutPorts[ i ]->NodeName() << endl ;
529 cdebug << "DefPortsOfNode::DelOutPort : index out of range ERROR " << index
534 const GraphBase::InPort *GraphBase::PortsOfNode::GetInPort( const char *name) {
535 return GetChangeInPort( name ) ;
538 const GraphBase::OutPort *GraphBase::PortsOfNode::GetOutPort( const char *name) {
539 return GetChangeOutPort( name ) ;
542 GraphBase::InPort *GraphBase::PortsOfNode::GetChangeInPort( const char * name) {
543 // cdebug_in << "GraphBase::PortsOfNode::GetChangeInPort " << name << endl;
545 GraphBase::InPort * pP = NULL;
546 if ( !_MapOfNodeInPorts.empty() ) {
548 if ( !strcmp( name , "InGate" ) ) {
549 index = _MapOfNodeInPorts[ "Gate" ] ;
552 index = _MapOfNodeInPorts[ name ] ;
555 // cdebug << "GraphBase::PortsOfNode::GetChangeInPort _MapOfNodeInPorts[ "
556 // << name << " ] : " << i-1 << " " << _NodeInPorts[ i-1 ]->NodeName()
558 pP = _NodeInPorts[ index-1 ] ;
561 cdebug << "GraphBase::PortsOfNode::GetChangeInPort _MapOfNodeInPorts[ "
562 << name << " ] : " << index << " NOT FOUND. Known ports :" << endl ;
564 map< string , int >::iterator aMapOfNodeInPortsIterator ;
566 for ( aMapOfNodeInPortsIterator = _MapOfNodeInPorts.begin() ;
567 aMapOfNodeInPortsIterator != _MapOfNodeInPorts.end() ; aMapOfNodeInPortsIterator++ ) {
568 cdebug << "MapOfNodeInPorts" << i++ << " " << aMapOfNodeInPortsIterator->first << " --> "
569 << aMapOfNodeInPortsIterator->second << endl ;
574 // cdebug_out << "GraphBase::PortsOfNode::GetChangeInPort " << endl;
579 GraphBase::OutPort *GraphBase::PortsOfNode::GetChangeOutPort( const char * name ) {
580 // cdebug_in << "GraphBase::PortsOfNode::GetChangeOutPort " << name << endl;
582 GraphBase::OutPort * pP = NULL;
583 if ( !_MapOfNodeOutPorts.empty() ) {
585 if ( !strcmp( name , "OutGate" ) ) {
586 index = _MapOfNodeOutPorts[ "Gate" ] ;
589 index = _MapOfNodeOutPorts[ name ] ;
592 // cdebug << "GraphBase::PortsOfNode::GetChangeOutPort _MapOfNodeOutPorts[ "
593 // << name << " ] : " << i-1 << " " << _NodeOutPorts[ i-1 ]->NodeName() << endl ;
594 pP = _NodeOutPorts[ index-1 ] ;
597 cdebug << "GraphBase::PortsOfNode::GetChangeOutPort _MapOfNodeOutPorts[ "
598 << name << " ] : " << index << " NOT FOUND. Known ports :" << endl ;
600 map< string , int >::iterator aMapOfNodeOutPortsIterator ;
602 for ( aMapOfNodeOutPortsIterator = _MapOfNodeOutPorts.begin() ;
603 aMapOfNodeOutPortsIterator != _MapOfNodeOutPorts.end() ; aMapOfNodeOutPortsIterator++ ) {
604 cdebug << "MapOfNodeInPorts" << i++ << " " << aMapOfNodeOutPortsIterator->first << " --> "
605 << aMapOfNodeOutPortsIterator->second << endl ;
613 void GraphBase::PortsOfNode::ListPorts( ostream & f,
614 const bool klink ) const {
618 f << " Input Ports : " ;
620 f << GetNodeInPortsSize() << " port"
621 << (GetNodeInPortsSize() > 1 ? "s" : "") << endl;
623 for ( i = 0 ; i < GetNodeInPortsSize() ; i++ ) {
625 // << hex << GetNodeInPort(i) << dec << " "
626 << *(GetNodeInPort(i)) << " " ;
627 GetNodeInPort(i)->StringValue( f ) ;
631 f << " Output Ports : " ;
634 f << GetNodeOutPortsSize() << " port"
635 << (GetNodeOutPortsSize() > 1 ? "s" : "") << endl;
637 for ( i = 0 ; i < GetNodeOutPortsSize() ; i++ ) {
639 // << hex << GetNodeOutPort(i) << dec << " "
640 << *(GetNodeOutPort(i)) << " " ;
641 GetNodeOutPort(i)->StringValue( f ) ;
646 f << " Output Ports : " ;
647 f << GetNodeInPortsSize() << " port"
648 << (GetNodeInPortsSize() > 1 ? "s" : "") << endl;
650 for ( i = 0 ; i < GetNodeInPortsSize() ; i++ ) {
652 // << hex << GetNodeInPort(i) << dec << " "
653 << *(GetNodeInPort(i)) << " " ;
654 GetNodeInPort(i)->StringValue( f ) ;
661 ostream & operator<< (ostream & f ,const SUPERV::KindOfNode & s ) {
663 case SUPERV::ComputingNode :
664 f << "ComputingNode";
666 case SUPERV::FactoryNode :
669 case SUPERV::InLineNode :
672 case SUPERV::MacroNode :
675 case SUPERV::DataFlowGraph :
676 f << "DataFlowGraph";
678 case SUPERV::DataStreamGraph :
679 f << "DataStreamGraph";
681 case SUPERV::LoopNode :
684 case SUPERV::EndLoopNode :
687 case SUPERV::SwitchNode :
690 case SUPERV::EndSwitchNode :
691 f << "EndSwitchNode";
693 case SUPERV::GOTONode :
697 f << "UnknownKindOfNode";