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 #define PortsOfNodeTrace 1
34 GraphBase::PortsOfNode::PortsOfNode() :
35 GraphBase::Service::Service( SALOME_ModuleCatalog::Service() ) {
36 // MESSAGE( "GraphBase::PortsOfNode::PortsOfNode " << this ) ;
37 // cout << "GraphBase::PortsOfNode::PortsOfNode " << this << endl ;
38 // cdebug << "GraphBase::PortsOfNode::PortsOfNode " << this << endl ;
39 _NodeInPortsSize = 0 ;
40 _NodeOutPortsSize = 0 ;
41 _DataStreamInPortsNumber = 0 ;
42 _DataStreamOutPortsNumber = 0 ;
45 GraphBase::PortsOfNode::PortsOfNode( const char *DataFlowName ) :
46 GraphBase::Service::Service( SALOME_ModuleCatalog::Service() ) {
47 // MESSAGE( "GraphBase::PortsOfNode::PortsOfNode " << this ) ;
48 // cout << "GraphBase::PortsOfNode::PortsOfNode " << this << endl ;
49 // cdebug << "GraphBase::PortsOfNode::PortsOfNode " << this << endl ;
50 _NodeInPortsSize = 0 ;
51 _NodeOutPortsSize = 0 ;
52 _DataStreamInPortsNumber = 0 ;
53 _DataStreamOutPortsNumber = 0 ;
56 GraphBase::PortsOfNode::~PortsOfNode() {
57 cdebug << "GraphBase::PortsOfNode::~PortsOfNode " << this
60 // for ( i = 0 ; i < _NodeInPortsSize ; i++ ) {
61 // delete _NodeInPorts[ i ] ;
63 // for ( i = 0 ; i < _NodeOutPortsSize ; i++ ) {
64 // delete _NodeOutPorts[ i ] ;
68 void GraphBase::PortsOfNode::DefPortsOfNode(
70 const SALOME_ModuleCatalog::Service& aService ,
71 const char *const * NodeName ,
72 const SUPERV::KindOfNode aKind ,
73 int * Graph_prof_debug ,
74 ofstream * Graph_fdebug ) {
76 SetDebug( ORB , Graph_prof_debug , Graph_fdebug ) ;
77 // MESSAGE( "DefPortsOfNode " << NodeName << " Graph_prof_debug "
78 // << Graph_prof_debug << " _prof_debug " << _prof_debug ) ;
79 cdebug_in << "DefPortsOfNode : " << *NodeName << " ServiceName " << aService.ServiceName << endl ;
80 const bool DataFlowOrComputing = (aKind == SUPERV::DataFlowGraph) ||
81 (aKind == SUPERV::ComputingNode) ||
82 (aKind == SUPERV::FactoryNode) ;
83 // WithInLoop : InitLoop or DoLoop
84 const bool WithInLoop = (aKind == SUPERV::LoopNode) || (aKind == SUPERV::EndLoopNode) ;
85 // WithInGate : InGate or Default
86 const bool WithInGate = (aKind == SUPERV::DataFlowGraph) || (aKind == SUPERV::DataStreamGraph) ||
87 (aKind == SUPERV::ComputingNode) || (aKind == SUPERV::FactoryNode) ||
88 (aKind == SUPERV::InLineNode) || (aKind == SUPERV::GOTONode) ||
89 (aKind == SUPERV::LoopNode) || (aKind == SUPERV::EndLoopNode) ||
90 (aKind == SUPERV::SwitchNode) || (aKind == SUPERV::EndSwitchNode) ||
91 (aKind == SUPERV::MacroNode) ;
92 // WithOutGate : OutGate or Default
93 const bool WithOutGate = (aKind == SUPERV::DataFlowGraph) || (aKind == SUPERV::DataStreamGraph) ||
94 (aKind == SUPERV::ComputingNode) || (aKind == SUPERV::FactoryNode) ||
95 (aKind == SUPERV::InLineNode) || (aKind == SUPERV::GOTONode) ||
96 /* asv : 15.12.04 : adding out gate ports for Loop/EndLoop, too. p2.5, PAL7385*/
97 (aKind == SUPERV::LoopNode) || (aKind == SUPERV::EndLoopNode) ||
98 (aKind == SUPERV::SwitchNode) || (aKind == SUPERV::EndSwitchNode) ||
99 (aKind == SUPERV::MacroNode) ;
100 SUPERV::KindOfPort aPortKind = SUPERV::ServiceParameter ;
101 if ( aKind == SUPERV::InLineNode ) {
102 aPortKind = SUPERV::InLineParameter ;
104 else if ( aKind == SUPERV::LoopNode || aKind == SUPERV::EndLoopNode ) {
105 aPortKind = SUPERV::InLineParameter ;
107 else if ( aKind == SUPERV::SwitchNode || aKind == SUPERV::EndSwitchNode ) {
108 aPortKind = SUPERV::InLineParameter ;
110 else if ( aKind == SUPERV::GOTONode ) {
111 aPortKind = SUPERV::InLineParameter ;
113 else if ( aKind == SUPERV::MacroNode ) {
114 aPortKind = SUPERV::InLineParameter ;
116 for ( i = 0 ; i < _NodeInPortsSize ; i++ ) {
117 cdebug << "DefPortsOfNode delete In" << i << ". " << _NodeInPorts[i]->PortName()
119 _MapOfNodeInPorts.erase( _NodeInPorts[i]->PortName() ) ;
120 delete _NodeInPorts[i] ;
122 _NodeInPorts.resize( 0 );
123 for ( i = 0 ; i < _NodeOutPortsSize ; i++ ) {
124 cdebug << "DefPortsOfNode delete Out" << i << ". " << _NodeOutPorts[i]->PortName()
126 _MapOfNodeOutPorts.erase( _NodeOutPorts[i]->PortName() ) ;
127 delete _NodeOutPorts[i] ;
129 _NodeOutPorts.resize( 0 );
131 SetService( aService ) ;
134 _NodeInPortsSize = aService.ServiceinParameter.length() ;
136 SALOME_ModuleCatalog::ServicesParameter anInLoopParameter ;
137 _NodeInPortsSize = _NodeInPortsSize + 1 ;
139 // char *aParametername = "InitLoop" ;
140 // if ( aKind == SUPERV::EndLoopNode ) {
141 char * aParametername = "DoLoop" ;
143 anInLoopParameter.Parametertype = CORBA::string_dup( "long" ) ;
144 anInLoopParameter.Parametername = CORBA::string_dup( aParametername ) ;
145 if ( _NodeInPortsSize > (int ) _NodeInPorts.size() ) {
146 _NodeInPorts.resize( _NodeInPortsSize );
148 _MapOfNodeInPorts[ aParametername ] = iVec ;
149 _NodeInPorts[iVec-1] = new GraphBase::InPort( NodeName , anInLoopParameter ,
150 SUPERV::LoopParameter );
151 _NodeInPorts[iVec-1]->SetDebug( ORB , Graph_prof_debug , Graph_fdebug ) ;
152 cdebug << "DefPortsOfNode : " << "_MapOfNodeInPorts[ " << aParametername
153 << " ] = " << iVec << " " << _NodeInPorts[iVec-1]->Kind() << " "
154 << _NodeInPorts[iVec-1] << endl ;
156 if ( _NodeInPortsSize > (int ) _NodeInPorts.size() ) {
157 _NodeInPorts.resize(_NodeInPortsSize);
159 cdebug << "NodeInPortsSize " << _NodeInPortsSize << endl ;
160 for ( i = iVec ; i < _NodeInPortsSize ; i++ ) {
161 //JR 24.02.2005 Memory Leak string _aParametername = CORBA::string_dup(aService.ServiceinParameter[i-iVec].Parametername) ;
162 string _aParametername = string(aService.ServiceinParameter[i-iVec].Parametername) ;
163 const char *aParametername = _aParametername.c_str() ;
164 if ( _MapOfNodeInPorts[ aParametername ] ) {
165 if ( !DataFlowOrComputing &&
166 !strcmp( aParametername , "Gate" ) ) {
169 cdebug << "Error, Parametername duplicated : " << aParametername
174 _MapOfNodeInPorts[ aParametername ] = i+1 ;
175 // cdebug << "DefPortsOfNode : " << "_MapOfNodeInPorts[ " << aParametername
176 // << " ] = " << i+1 << endl ;
177 const SALOME_ModuleCatalog::ServicesParameter aServiceParameter = aService.ServiceinParameter[i-iVec] ;
178 _NodeInPorts[i] = new GraphBase::InPort( NodeName , aServiceParameter ,
180 _NodeInPorts[i]->SetDebug( ORB , Graph_prof_debug , Graph_fdebug ) ;
181 cdebug << i << ". " << *_NodeInPorts[i] << " " << _NodeInPorts[i]->Kind() << endl ;
184 iVec += aService.ServiceinParameter.length() ;
186 SALOME_ModuleCatalog::ServicesParameter anInGateParameter ;
187 _NodeInPortsSize = _NodeInPortsSize + 1 ;
189 char *aParametername = "Gate" ;
190 if ( aKind == SUPERV::EndSwitchNode ) {
191 aParametername = "Default" ;
193 anInGateParameter.Parametertype = CORBA::string_dup( "long" ) ;
194 anInGateParameter.Parametername = CORBA::string_dup( aParametername ) ;
195 _NodeInPorts.resize( _NodeInPortsSize );
196 _MapOfNodeInPorts[ aParametername ] = iVec ;
197 _NodeInPorts[iVec-1] = new GraphBase::InPort( NodeName , anInGateParameter ,
198 SUPERV::GateParameter );
199 _NodeInPorts[iVec-1]->SetDebug( ORB , Graph_prof_debug , Graph_fdebug ) ;
200 // cdebug << "DefPortsOfNode : " << "_MapOfNodeInPorts[ " << aParametername
201 // << " ] = " << iVec << " " << _NodeInPorts[iVec-1]->Kind() << " "
202 // << _NodeInPorts[iVec-1] << endl ;
206 _NodeOutPortsSize = aService.ServiceoutParameter.length() ;
208 SALOME_ModuleCatalog::ServicesParameter anOutLoopParameter ;
209 _NodeOutPortsSize = _NodeOutPortsSize + 1 ;
211 char *aParametername = "DoLoop" ;
212 anOutLoopParameter.Parametertype = CORBA::string_dup( "long" ) ;
213 anOutLoopParameter.Parametername = CORBA::string_dup( aParametername ) ;
214 if ( _NodeOutPortsSize > (int ) _NodeOutPorts.size() ) {
215 _NodeOutPorts.resize(_NodeOutPortsSize);
217 _MapOfNodeOutPorts[ aParametername ] = iVec ;
218 _NodeOutPorts[iVec-1] = new GraphBase::OutPort( NodeName , anOutLoopParameter ,
219 SUPERV::LoopParameter );
220 _NodeOutPorts[iVec-1]->SetDebug( ORB , Graph_prof_debug , Graph_fdebug ) ;
221 // cdebug << "DefPortsOfNode : " << "_MapOfNodeOutPorts[ " << aParametername
222 // << " ] = " << iVec << " " << _NodeOutPorts[iVec-1]->Kind() << " "
223 // << _NodeOutPorts[iVec-1] << endl ;
225 if ( _NodeOutPortsSize > (int ) _NodeOutPorts.size() ) {
226 _NodeOutPorts.resize(_NodeOutPortsSize);
228 cdebug << "NodeOutPortsSize " << _NodeOutPortsSize << endl ;
229 for ( i = iVec ; i < _NodeOutPortsSize ; i++ ) {
230 //JR 24.02.2005 Memory Leak string _aParametername = CORBA::string_dup(aService.ServiceoutParameter[i-iVec].Parametername) ;
231 string _aParametername = string(aService.ServiceoutParameter[i-iVec].Parametername) ;
232 const char *aParametername = _aParametername.c_str() ;
233 if ( _MapOfNodeOutPorts[ aParametername ] ) {
234 if ( !DataFlowOrComputing &&
235 !strcmp( aParametername , "Gate" ) ) {
238 cdebug << "Error, Parametername duplicated : " << aParametername
243 // cdebug << "DefPortsOfNode : " << "_MapOfNodeOutPorts[ " << aParametername
244 // << " ] = " << i+1 << endl ;
245 _MapOfNodeOutPorts[ aParametername ] = i+1 ;
246 const SALOME_ModuleCatalog::ServicesParameter aServiceParameter = aService.ServiceoutParameter[i-iVec] ;
247 _NodeOutPorts[i] = new GraphBase::OutPort( NodeName , aServiceParameter ,
249 _NodeOutPorts[i]->SetDebug( ORB , Graph_prof_debug , Graph_fdebug ) ;
250 cdebug << i << ". " << *_NodeOutPorts[i] << " " << _NodeOutPorts[i]->Kind() << endl ;
253 iVec += aService.ServiceoutParameter.length() ;
255 SALOME_ModuleCatalog::ServicesParameter anOutGateParameter ;
256 _NodeOutPortsSize = _NodeOutPortsSize + 1 ;
258 char *aParametername = "Gate" ;
259 if ( aKind == SUPERV::SwitchNode ) {
260 aParametername = "Default" ;
262 anOutGateParameter.Parametertype = CORBA::string_dup( "long" ) ;
263 anOutGateParameter.Parametername = CORBA::string_dup( aParametername ) ;
264 _NodeOutPorts.resize(_NodeOutPortsSize);
265 _MapOfNodeOutPorts[ aParametername ] = iVec ;
266 _NodeOutPorts[iVec-1] = new GraphBase::OutPort( NodeName , anOutGateParameter ,
267 SUPERV::GateParameter );
268 _NodeOutPorts[iVec-1]->SetDebug( ORB , Graph_prof_debug , Graph_fdebug ) ;
269 // cdebug << "DefPortsOfNode : " << "_MapOfNodeOutPorts[ " << aParametername
270 // << " ] = " << iVec << " " << _NodeOutPorts[iVec-1]->Kind() << " "
271 // << _NodeOutPorts[iVec-1] << endl ;
273 cdebug_out << "DefPortsOfNode : " << *NodeName << endl ;
276 GraphBase::InPort * GraphBase::PortsOfNode::AddInPort( CORBA::ORB_ptr ORB ,
277 const char *const * NodeName ,
278 const SUPERV::KindOfNode aKindOfNode ,
279 const char * InputParameterName ,
280 const char * InputParameterType ,
281 SUPERV::KindOfPort aKindOfPort ,
283 int * Graph_prof_debug ,
284 ofstream * Graph_fdebug ) {
285 // MESSAGE( "DefPortsOfNode " << *NodeName << " Graph_prof_debug "
286 // << Graph_prof_debug << " _prof_debug " << _prof_debug ) ;
287 cdebug_in << "PortsOfNode::AddInPort : " << *NodeName << " " << aKindOfNode << " InputParameterName "
288 << InputParameterName << " InputParameterType " << InputParameterType << " aKindOfPort "
289 << aKindOfPort << " DataStreamInPortsNumber " << DataStreamInPortsNumber() << " _NodeInPortsSize "
290 << _NodeInPortsSize << " index " << index << endl ;
291 GraphBase::InPort * anInPort = NULL ;
293 anInPort = GetChangeInPort( InputParameterName ) ;
294 if ( anInPort == NULL ) {
295 _NodeInPortsSize = _NodeInPortsSize + 1 ;
296 _NodeInPorts.resize(_NodeInPortsSize);
297 SALOME_ModuleCatalog::ServicesParameter aServiceParameter ;
298 aServiceParameter.Parametername = CORBA::string_dup( InputParameterName ) ;
299 aServiceParameter.Parametertype = CORBA::string_dup( InputParameterType ) ;
302 else if ( aKindOfPort == SUPERV::DataStreamParameter ) {
303 index = _NodeInPortsSize-2 ;
304 IncrDataStreamInPorts() ;
307 index = _NodeInPortsSize-2 - DataStreamInPortsNumber() ;
311 for ( i = _NodeInPortsSize - 2 ; i >= index ; i-- ) {
312 _NodeInPorts[ i + 1 ] = _NodeInPorts[ i ] ; // Gate - Default
313 _MapOfNodeInPorts.erase( _NodeInPorts[ i + 1 ]->PortName() ) ;
314 _MapOfNodeInPorts[ _NodeInPorts[ i + 1 ]->PortName() ] = i + 2 ;
316 _MapOfNodeInPorts[ InputParameterName ] = index + 1 ;
317 if ( aKindOfPort == SUPERV::DataStreamParameter ) {
318 _NodeInPorts[index] = new GraphBase::InDataStreamPort( NodeName ,
319 aServiceParameter ) ;
322 _NodeInPorts[index] = new GraphBase::InPort( NodeName ,
326 _NodeInPorts[index]->SetDebug( ORB , Graph_prof_debug , Graph_fdebug ) ;
327 anInPort = _NodeInPorts[index] ;
328 cdebug << "NodeInPorts[ " << index << " ]" << endl ;
331 cdebug << "GraphBase::PortsOfNode::AddInPort ERROR index " << index << " _NodeInPortsSize "
332 << _NodeInPortsSize << endl ;
336 cdebug << "GraphBase::PortsOfNode::AddInPort InPort already exists" << endl ;
337 anInPort->Kind( aKindOfPort ) ;
339 cdebug << "GraphBase::PortsOfNode::AddInPort index " << index << " _NodeInPortsSize " << _NodeInPortsSize << endl ;
342 for ( i = 0 ; i < _NodeInPortsSize ; i++ ) {
343 cdebug << *NodeName << " _NodeInPorts[ " << i << " ] = " << _NodeInPorts[ i ]->PortName()
344 << " _MapOfNodeInPorts[ " << _NodeInPorts[ i ]->PortName() << " ] = "
345 << _MapOfNodeInPorts[ _NodeInPorts[ i ]->PortName() ] << " - 1 "
346 << _NodeInPorts[ i ]->Kind() << " Dependency " << _NodeInPorts[ i ]->Dependency() ;
347 if ( _NodeInPorts[ i ]->IsDataStream() ) {
348 SUPERV::KindOfSchema aKindOfSchema ;
349 SUPERV::KindOfInterpolation aKindOfInterpolation ;
350 SUPERV::KindOfExtrapolation aKindOfExtrapolation ;
351 ((GraphBase::InDataStreamPort * ) _NodeInPorts[ i ])->Params( aKindOfSchema , aKindOfInterpolation , aKindOfExtrapolation ) ;
352 cdebug << " " << aKindOfSchema << " " << aKindOfInterpolation << " " << aKindOfExtrapolation ;
354 if ( _NodeInPorts[ i ]->GetOutPort() ) {
355 cdebug << " <--OutPort " << _NodeInPorts[ i ]->GetOutPort()
356 << " " << _NodeInPorts[ i ]->GetOutPort()->NodeName()
357 << "(" << _NodeInPorts[ i ]->GetOutPort()->PortName() << ")" ;
360 cdebug << " <--NOOutPort " << _NodeInPorts[ i ]->GetOutPort() ;
362 cdebug << " " << _NodeInPorts[ i ]->PortStatus() << endl ;
365 cdebug_out << "GraphBase::PortsOfNode::AddInPort _NodeInPortsSize " << _NodeInPortsSize
366 << " " << anInPort->Kind() << endl ;
370 GraphBase::OutPort * GraphBase::PortsOfNode::AddOutPort( CORBA::ORB_ptr ORB ,
371 const char * const * NodeName ,
372 const SUPERV::KindOfNode aKindOfNode ,
373 const char * OutputParameterName ,
374 const char * OutputParameterType ,
375 SUPERV::KindOfPort aKindOfPort ,
377 int * Graph_prof_debug ,
378 ofstream * Graph_fdebug ) {
379 cdebug_in << "GraphBase::PortsOfNode::AddOutPort : " << *NodeName << " " << aKindOfNode
380 << " OutputParameterName " << OutputParameterName << " OutputParameterType " << OutputParameterType
381 << " aKindOfPort " << aKindOfPort << " DataStreamOutPortsNumber " << DataStreamOutPortsNumber()
382 << " _NodeOutPortsSize " << _NodeOutPortsSize << " index " << index << endl ;
383 GraphBase::OutPort * anOutPort = NULL ;
385 anOutPort = GetChangeOutPort( OutputParameterName ) ;
386 if ( anOutPort == NULL ) {
387 _NodeOutPortsSize = _NodeOutPortsSize + 1 ;
388 _NodeOutPorts.resize(_NodeOutPortsSize);
389 SALOME_ModuleCatalog::ServicesParameter aServiceParameter ;
390 aServiceParameter.Parametername = CORBA::string_dup( OutputParameterName ) ;
391 aServiceParameter.Parametertype = CORBA::string_dup( OutputParameterType ) ;
394 else if ( aKindOfPort == SUPERV::DataStreamParameter ) {
395 index = _NodeOutPortsSize-2 ;
396 IncrDataStreamOutPorts() ;
399 index = _NodeOutPortsSize-2 - DataStreamOutPortsNumber() ;
401 //JR Debug 01.09.2005 : GraphEditGraphSwitchs for AddOutPort and not in AddInPort ???
402 // if ( aKindOfNode == SUPERV::LoopNode || aKindOfNode == SUPERV::EndLoopNode ) {
407 for ( i = _NodeOutPortsSize - 2 ; i >= index ; i-- ) {
408 _NodeOutPorts[ i + 1 ] = _NodeOutPorts[ i ] ; // Gate - Default
409 _MapOfNodeOutPorts.erase( _NodeOutPorts[ i + 1 ]->PortName() ) ;
410 _MapOfNodeOutPorts[ _NodeOutPorts[ i + 1 ]->PortName() ] = i + 2 ;
412 _MapOfNodeOutPorts[ OutputParameterName ] = index + 1 ;
413 if ( aKindOfPort == SUPERV::DataStreamParameter ) {
414 _NodeOutPorts[index] = new GraphBase::OutDataStreamPort( NodeName ,
415 aServiceParameter ) ;
418 _NodeOutPorts[index] = new GraphBase::OutPort( NodeName ,
422 // MESSAGE( "GraphBase::PortsOfNode::AddOutPort " << OutputParameterName << " --> SetDebug" ) ;
423 _NodeOutPorts[index]->SetDebug( ORB , Graph_prof_debug , Graph_fdebug ) ;
424 anOutPort = _NodeOutPorts[index] ;
425 cdebug << "NodeOutPorts[ " << index << " ]" << endl ;
428 cdebug << "GraphBase::PortsOfNode::AddOutPort ERROR index " << index << " _NodeOutPortsSize "
429 << _NodeOutPortsSize << endl ;
433 cdebug << "GraphBase::PortsOfNode::AddOutPort OutPort already exists" << endl ;
434 anOutPort->Kind( aKindOfPort ) ;
436 cdebug << "GraphBase::PortsOfNode::AddOutPort index " << index << " _NodeOutPortsSize " << _NodeOutPortsSize << endl ;
439 for ( i = 0 ; i < _NodeOutPortsSize ; i++ ) {
440 cdebug << *NodeName << " _NodeOutPorts[ " << i << " ] = " << _NodeOutPorts[ i ]->PortName()
441 << " _MapOfNodeOutPorts[ " << _NodeOutPorts[ i ]->PortName() << " ] = "
442 << _MapOfNodeOutPorts[ _NodeOutPorts[ i ]->PortName() ] << " - 1 "
443 << _NodeOutPorts[ i ]->Kind() << " Dependency " << _NodeOutPorts[ i ]->Dependency() ;
444 if ( _NodeOutPorts[ i ]->IsDataStream() ) {
445 cdebug << " NumberOfValues " << ((GraphBase::OutDataStreamPort * ) _NodeOutPorts[ i ])->NumberOfValues() ;
447 cdebug << " " << _NodeOutPorts[ i ]->PortStatus() << endl ;
450 cdebug_out << "GraphBase::PortsOfNode::AddOutPort _NodeOutPortsSize "
451 << _NodeOutPortsSize << " " << anOutPort->Kind() << endl ;
455 void GraphBase::PortsOfNode::MoveInPort( const char * InputParameterName , int toindex ) {
456 int fromindex = _MapOfNodeInPorts[ InputParameterName ] - 1 ;
457 GraphBase::InPort * anInPort = _NodeInPorts[ toindex ] ;
458 _NodeInPorts[ toindex ] = _NodeInPorts[ fromindex ] ;
459 _NodeInPorts[ fromindex ] = anInPort ;
460 _MapOfNodeInPorts.erase( _NodeInPorts[ toindex ]->PortName() ) ;
461 _MapOfNodeInPorts[ _NodeInPorts[ toindex ]->PortName() ] = toindex + 1 ;
462 _MapOfNodeInPorts.erase( _NodeInPorts[ fromindex ]->PortName() ) ;
463 _MapOfNodeInPorts[ _NodeInPorts[ fromindex ]->PortName() ] = fromindex + 1 ;
466 void GraphBase::PortsOfNode::MoveOutPort( const char * OutputParameterName , int toindex ) {
467 int fromindex = _MapOfNodeOutPorts[ OutputParameterName ] - 1 ;
468 GraphBase::OutPort * anOutPort = _NodeOutPorts[ toindex ] ;
469 _NodeOutPorts[ toindex ] = _NodeOutPorts[ fromindex ] ;
470 _NodeOutPorts[ fromindex ] = anOutPort ;
471 _MapOfNodeOutPorts.erase( _NodeOutPorts[ toindex ]->PortName() ) ;
472 _MapOfNodeOutPorts[ _NodeOutPorts[ toindex ]->PortName() ] = toindex + 1 ;
473 _MapOfNodeOutPorts.erase( _NodeOutPorts[ fromindex ]->PortName() ) ;
474 _MapOfNodeOutPorts[ _NodeOutPorts[ fromindex ]->PortName() ] = fromindex + 1 ;
477 void GraphBase::PortsOfNode::DelInPort( const char * InputParameterName ) {
478 cdebug << "DefPortsOfNode::DelInPort : " << InputParameterName << endl ;
479 int index = _MapOfNodeInPorts[ InputParameterName ] -1 ;
481 cdebug << "DefPortsOfNode::DelInPort : _NodeInPorts[" << index << "] "
482 << _NodeInPorts[ index ]->PortName() << " "
483 << _NodeInPorts[ index ]->NodeName() << endl ;
485 //JR Debug 08.06.2005 : RemoveOutPort was missing
486 _NodeInPorts[ index ]->RemoveOutPort() ;
487 if ( _NodeInPorts[ index ]->IsDataStream() ) {
488 DecrDataStreamInPorts() ;
490 _MapOfNodeInPorts.erase( InputParameterName ) ;
491 _NodeInPorts[ index ]->destroy() ;
493 for ( i = index ; i < _NodeInPortsSize - 1 ; i++ ) {
494 _MapOfNodeInPorts.erase( _NodeInPorts[ i+1 ]->PortName() ) ;
495 _MapOfNodeInPorts[ _NodeInPorts[ i+1 ]->PortName() ] = i+1 ;
496 _NodeInPorts[ i ] = _NodeInPorts[ i+1 ] ;
498 _NodeInPortsSize = _NodeInPortsSize - 1 ;
499 _NodeInPorts.resize( _NodeInPortsSize ) ;
500 for ( i = 0 ; i < _NodeInPortsSize ; i++ ) {
501 cdebug << "DefPortsOfNode::DelInPort ListOfInPorts : _NodeInPorts[" << i << "] "
502 << _NodeInPorts[ i ]->PortName() << " "
503 << _NodeInPorts[ i ]->NodeName() << endl ;
507 cdebug << "DefPortsOfNode::DelInPort : index out of range ERROR " << index
512 void GraphBase::PortsOfNode::DelOutPort( const char * OutputParameterName ) {
513 cdebug << "DefPortsOfNode::DelOutPort : " << OutputParameterName << endl ;
514 int index = _MapOfNodeOutPorts[ OutputParameterName ] - 1 ;
516 cdebug << "DefPortsOfNode::DelOutPort : _NodeOutPorts[" << index << "] "
517 << _NodeOutPorts[ index ]->PortName() << " "
518 << _NodeOutPorts[ index ]->NodeName() << endl ;
519 if ( _NodeOutPorts[ index ]->IsDataStream() ) {
520 DecrDataStreamOutPorts() ;
522 _MapOfNodeOutPorts.erase( OutputParameterName ) ;
523 _NodeOutPorts[ index ]->destroy() ;
525 for ( i = index ; i < _NodeOutPortsSize - 1 ; i++ ) {
526 _MapOfNodeOutPorts.erase( _NodeOutPorts[ i+1 ]->PortName() ) ;
527 _MapOfNodeOutPorts[ _NodeOutPorts[ i+1 ]->PortName() ] = i+1 ;
528 _NodeOutPorts[ i ] = _NodeOutPorts[ i+1 ] ;
530 _NodeOutPortsSize = _NodeOutPortsSize - 1 ;
531 _NodeOutPorts.resize( _NodeOutPortsSize ) ;
532 for ( i = 0 ; i < _NodeOutPortsSize ; i++ ) {
533 cdebug << "DefPortsOfNode::DelOutPort ListOfOutPorts : _NodeOutPorts[" << i
534 << "] " << _NodeOutPorts[ i ]->PortName() << " "
535 << _NodeOutPorts[ i ]->NodeName() << endl ;
539 cdebug << "DefPortsOfNode::DelOutPort : index out of range ERROR " << index
544 const GraphBase::InPort *GraphBase::PortsOfNode::GetInPort( const char *name) {
545 return GetChangeInPort( name ) ;
548 const GraphBase::OutPort *GraphBase::PortsOfNode::GetOutPort( const char *name) {
549 return GetChangeOutPort( name ) ;
552 GraphBase::InPort *GraphBase::PortsOfNode::GetChangeInPort( const char * name) {
554 cdebug_in << "GraphBase::PortsOfNode::GetChangeInPort Service " << ServiceName()
555 << " of OutPort " << name << endl;
558 GraphBase::InPort * pP = NULL;
559 if ( !_MapOfNodeInPorts.empty() ) {
561 if ( !strcmp( name , "InGate" ) ) {
562 index = _MapOfNodeInPorts[ "Gate" ] ;
565 index = _MapOfNodeInPorts[ name ] ;
569 cdebug << "GraphBase::PortsOfNode::GetChangeInPort _MapOfNodeInPorts[ "
570 << name << " ] : " << index-1 << " " << _NodeInPorts[ index-1 ]->NodeName()
573 pP = _NodeInPorts[ index-1 ] ;
577 cdebug << "GraphBase::PortsOfNode::GetChangeInPort Service " << ServiceName()
578 << " _MapOfNodeInPorts[ " << name << " ] : " << index << " NOT FOUND. Known ports :"
580 map< string , int >::iterator aMapOfNodeInPortsIterator ;
582 for ( aMapOfNodeInPortsIterator = _MapOfNodeInPorts.begin() ;
583 aMapOfNodeInPortsIterator != _MapOfNodeInPorts.end() ; aMapOfNodeInPortsIterator++ ) {
584 cdebug << "MapOfNodeInPorts" << i++ << " " << aMapOfNodeInPortsIterator->first << " --> "
585 << aMapOfNodeInPortsIterator->second << endl ;
591 cdebug_out << "GraphBase::PortsOfNode::GetChangeInPort " << endl;
597 GraphBase::OutPort *GraphBase::PortsOfNode::GetChangeOutPort( const char * name ) {
599 cdebug_in << "GraphBase::PortsOfNode::GetChangeOutPort " << name << endl;
602 GraphBase::OutPort * pP = NULL;
603 if ( !_MapOfNodeOutPorts.empty() ) {
605 if ( !strcmp( name , "OutGate" ) ) {
606 index = _MapOfNodeOutPorts[ "Gate" ] ;
609 index = _MapOfNodeOutPorts[ name ] ;
613 cdebug << "GraphBase::PortsOfNode::GetChangeOutPort _MapOfNodeOutPorts[ "
614 << name << " ] : " << index-1 << " " << _NodeOutPorts[ index-1 ]->NodeName() << endl ;
616 pP = _NodeOutPorts[ index-1 ] ;
620 cdebug << "GraphBase::PortsOfNode::GetChangeOutPort _MapOfNodeOutPorts[ "
621 << name << " ] : " << index << " NOT FOUND. Known ports :" << endl ;
622 map< string , int >::iterator aMapOfNodeOutPortsIterator ;
624 for ( aMapOfNodeOutPortsIterator = _MapOfNodeOutPorts.begin() ;
625 aMapOfNodeOutPortsIterator != _MapOfNodeOutPorts.end() ; aMapOfNodeOutPortsIterator++ ) {
626 cdebug << "MapOfNodeInPorts" << i++ << " " << aMapOfNodeOutPortsIterator->first << " --> "
627 << aMapOfNodeOutPortsIterator->second << endl ;
633 cdebug_out << "GraphBase::PortsOfNode::GetChangeOutPort " << endl;
638 void GraphBase::PortsOfNode::ListPorts( ostream & f,
639 const bool klink ) const {
643 f << " Input Ports : " ;
645 f << GetNodeInPortsSize() << " port"
646 << (GetNodeInPortsSize() > 1 ? "s" : "") << endl;
648 for ( i = 0 ; i < GetNodeInPortsSize() ; i++ ) {
650 // << hex << GetNodeInPort(i) << dec << " "
651 << *(GetNodeInPort(i)) << " " ;
652 GetNodeInPort(i)->StringValue( f ) ;
656 f << " Output Ports : " ;
659 f << GetNodeOutPortsSize() << " port"
660 << (GetNodeOutPortsSize() > 1 ? "s" : "") << endl;
662 for ( i = 0 ; i < GetNodeOutPortsSize() ; i++ ) {
664 // << hex << GetNodeOutPort(i) << dec << " "
665 << *(GetNodeOutPort(i)) << " " ;
666 GetNodeOutPort(i)->StringValue( f ) ;
671 f << " Output Ports : " ;
672 f << GetNodeInPortsSize() << " port"
673 << (GetNodeInPortsSize() > 1 ? "s" : "") << endl;
675 for ( i = 0 ; i < GetNodeInPortsSize() ; i++ ) {
677 // << hex << GetNodeInPort(i) << dec << " "
678 << *(GetNodeInPort(i)) << " " ;
679 GetNodeInPort(i)->StringValue( f ) ;
686 ostream & operator<< (ostream & f ,const SUPERV::KindOfNode & s ) {
688 case SUPERV::ComputingNode :
689 f << "ComputingNode";
691 case SUPERV::FactoryNode :
694 case SUPERV::InLineNode :
697 case SUPERV::MacroNode :
700 case SUPERV::DataFlowGraph :
701 f << "DataFlowGraph";
703 case SUPERV::DataStreamGraph :
704 f << "DataStreamGraph";
706 case SUPERV::LoopNode :
709 case SUPERV::EndLoopNode :
712 case SUPERV::SwitchNode :
715 case SUPERV::EndSwitchNode :
716 f << "EndSwitchNode";
718 case SUPERV::GOTONode :
722 f << "UnknownKindOfNode";