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 // WithOutGate : OutGate or Default
90 const bool WithOutGate = (aKind == SUPERV::DataFlowGraph) || (aKind == SUPERV::DataStreamGraph) ||
91 (aKind == SUPERV::ComputingNode) || (aKind == SUPERV::FactoryNode) ||
92 (aKind == SUPERV::InLineNode) || (aKind == SUPERV::GOTONode) ||
93 (aKind == SUPERV::SwitchNode) || (aKind == SUPERV::EndSwitchNode) ;
94 SUPERV::KindOfPort aPortKind = SUPERV::ServiceParameter ;
95 if ( aKind == SUPERV::InLineNode ) {
96 aPortKind = SUPERV::InLineParameter ;
98 else if ( aKind == SUPERV::LoopNode || aKind == SUPERV::EndLoopNode ) {
99 aPortKind = SUPERV::InLineParameter ;
101 else if ( aKind == SUPERV::SwitchNode || aKind == SUPERV::EndSwitchNode ) {
102 aPortKind = SUPERV::InLineParameter ;
104 else if ( aKind == SUPERV::GOTONode ) {
105 aPortKind = SUPERV::InLineParameter ;
107 for ( i = 0 ; i < _NodeInPortsSize ; i++ ) {
108 cdebug << "DefPortsOfNode delete In" << i << ". " << _NodeInPorts[i]
110 _MapOfNodeInPorts.erase( _NodeInPorts[i]->PortName() ) ;
111 delete _NodeInPorts[i] ;
113 _NodeInPorts.resize( 0 );
114 for ( i = 0 ; i < _NodeOutPortsSize ; i++ ) {
115 cdebug << "DefPortsOfNode delete Out" << i << ". " << _NodeOutPorts[i]->PortName()
117 _MapOfNodeOutPorts.erase( _NodeOutPorts[i]->PortName() ) ;
118 delete _NodeOutPorts[i] ;
120 _NodeOutPorts.resize( 0 );
122 SetService( aService ) ;
125 _NodeInPortsSize = aService.ServiceinParameter.length() ;
127 SALOME_ModuleCatalog::ServicesParameter anInLoopParameter ;
128 _NodeInPortsSize = _NodeInPortsSize + 1 ;
130 char *aParametername = "InitLoop" ;
131 if ( aKind == SUPERV::EndLoopNode ) {
132 aParametername = "DoLoop" ;
134 anInLoopParameter.Parametertype = CORBA::string_dup( "long" ) ;
135 anInLoopParameter.Parametername = CORBA::string_dup( aParametername ) ;
136 if ( _NodeInPortsSize > (int ) _NodeInPorts.size() ) {
137 _NodeInPorts.resize( _NodeInPortsSize );
139 _MapOfNodeInPorts[ aParametername ] = iVec ;
140 _NodeInPorts[iVec-1] = new GraphBase::InPort( NodeName , anInLoopParameter ,
141 SUPERV::LoopParameter );
142 // MESSAGE( "GraphBase::PortsOfNode::DefPortsOfNode " << aParametername << " --> SetDebug" ) ;
143 _NodeInPorts[iVec-1]->SetDebug( ORB , Graph_prof_debug , Graph_fdebug ) ;
144 cdebug << "DefPortsOfNode : " << "_MapOfNodeInPorts[ " << aParametername
145 << " ] = " << iVec << " " << _NodeInPorts[iVec-1]->Kind() << " "
146 << _NodeInPorts[iVec-1] << endl ;
148 if ( _NodeInPortsSize > (int ) _NodeInPorts.size() ) {
149 _NodeInPorts.resize(_NodeInPortsSize);
151 cdebug << "NodeInPortsSize " << _NodeInPortsSize << endl ;
152 for ( i = iVec ; i < _NodeInPortsSize ; i++ ) {
153 string _aParametername = CORBA::string_dup(aService.ServiceinParameter[i-iVec].Parametername) ;
154 const char *aParametername = _aParametername.c_str() ;
155 if ( _MapOfNodeInPorts[ aParametername ] ) {
156 if ( !DataFlowOrComputing &&
157 !strcmp( aParametername , "Gate" ) ) {
160 cdebug << "Error, Parametername duplicated : " << aParametername
165 _MapOfNodeInPorts[ aParametername ] = i+1 ;
166 cdebug << "DefPortsOfNode : " << "_MapOfNodeInPorts[ " << aParametername
167 << " ] = " << i+1 << endl ;
168 const SALOME_ModuleCatalog::ServicesParameter aServiceParameter = aService.ServiceinParameter[i-iVec] ;
169 _NodeInPorts[i] = new GraphBase::InPort( NodeName , aServiceParameter ,
171 // MESSAGE( "GraphBase::PortsOfNode::DefPortsOfNode " << aParametername << " --> SetDebug" ) ;
172 _NodeInPorts[i]->SetDebug( ORB , Graph_prof_debug , Graph_fdebug ) ;
173 cdebug << i << ". " << *_NodeInPorts[i] << " " << _NodeInPorts[i]->Kind() << endl ;
176 iVec += aService.ServiceinParameter.length() ;
178 SALOME_ModuleCatalog::ServicesParameter anInGateParameter ;
179 _NodeInPortsSize = _NodeInPortsSize + 1 ;
181 char *aParametername = "Gate" ;
182 if ( aKind == SUPERV::EndSwitchNode ) {
183 aParametername = "Default" ;
185 anInGateParameter.Parametertype = CORBA::string_dup( "long" ) ;
186 anInGateParameter.Parametername = CORBA::string_dup( aParametername ) ;
187 _NodeInPorts.resize( _NodeInPortsSize );
188 _MapOfNodeInPorts[ aParametername ] = iVec ;
189 _NodeInPorts[iVec-1] = new GraphBase::InPort( NodeName , anInGateParameter ,
190 SUPERV::GateParameter );
191 // MESSAGE( "GraphBase::PortsOfNode::DefPortsOfNode " << aParametername << " --> SetDebug" ) ;
192 _NodeInPorts[iVec-1]->SetDebug( ORB , Graph_prof_debug , Graph_fdebug ) ;
193 cdebug << "DefPortsOfNode : " << "_MapOfNodeInPorts[ " << aParametername
194 << " ] = " << iVec << " " << _NodeInPorts[iVec-1]->Kind() << " "
195 << _NodeInPorts[iVec-1] << endl ;
199 _NodeOutPortsSize = aService.ServiceoutParameter.length() ;
201 SALOME_ModuleCatalog::ServicesParameter anOutLoopParameter ;
202 _NodeOutPortsSize = _NodeOutPortsSize + 1 ;
204 char *aParametername = "DoLoop" ;
205 anOutLoopParameter.Parametertype = CORBA::string_dup( "long" ) ;
206 anOutLoopParameter.Parametername = CORBA::string_dup( aParametername ) ;
207 if ( _NodeOutPortsSize > (int ) _NodeOutPorts.size() ) {
208 _NodeOutPorts.resize(_NodeOutPortsSize);
210 _MapOfNodeOutPorts[ aParametername ] = iVec ;
211 _NodeOutPorts[iVec-1] = new GraphBase::OutPort( NodeName , anOutLoopParameter ,
212 SUPERV::LoopParameter );
213 // MESSAGE( "GraphBase::PortsOfNode::DefPortsOfNode " << aParametername << " --> SetDebug" ) ;
214 _NodeOutPorts[iVec-1]->SetDebug( ORB , Graph_prof_debug , Graph_fdebug ) ;
215 cdebug << "DefPortsOfNode : " << "_MapOfNodeOutPorts[ " << aParametername
216 << " ] = " << iVec << " " << _NodeOutPorts[iVec-1]->Kind() << " "
217 << _NodeOutPorts[iVec-1] << endl ;
219 if ( _NodeOutPortsSize > (int ) _NodeOutPorts.size() ) {
220 _NodeOutPorts.resize(_NodeOutPortsSize);
222 cdebug << "NodeOutPortsSize " << _NodeOutPortsSize << endl ;
223 for ( i = iVec ; i < _NodeOutPortsSize ; i++ ) {
224 string _aParametername = CORBA::string_dup(aService.ServiceoutParameter[i-iVec].Parametername) ;
225 const char *aParametername = _aParametername.c_str() ;
226 if ( _MapOfNodeOutPorts[ aParametername ] ) {
227 if ( !DataFlowOrComputing &&
228 !strcmp( aParametername , "Gate" ) ) {
231 cdebug << "Error, Parametername duplicated : " << aParametername
236 cdebug << "DefPortsOfNode : " << "_MapOfNodeOutPorts[ " << aParametername
237 << " ] = " << i+1 << endl ;
238 _MapOfNodeOutPorts[ aParametername ] = i+1 ;
239 const SALOME_ModuleCatalog::ServicesParameter aServiceParameter = aService.ServiceoutParameter[i-iVec] ;
240 _NodeOutPorts[i] = new GraphBase::OutPort( NodeName , aServiceParameter ,
242 // MESSAGE( "GraphBase::PortsOfNode::DefPortsOfNode " << aParametername << " --> SetDebug" ) ;
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 // MESSAGE( "GraphBase::PortsOfNode::DefPortsOfNode " << aParametername << " --> SetDebug" ) ;
263 _NodeOutPorts[iVec-1]->SetDebug( ORB , Graph_prof_debug , Graph_fdebug ) ;
264 cdebug << "DefPortsOfNode : " << "_MapOfNodeOutPorts[ " << aParametername
265 << " ] = " << iVec << " " << _NodeOutPorts[iVec-1]->Kind() << " "
266 << _NodeOutPorts[iVec-1] << endl ;
268 cdebug_out << "DefPortsOfNode : " << *NodeName << endl ;
271 GraphBase::InPort * GraphBase::PortsOfNode::AddInPort( CORBA::ORB_ptr ORB ,
272 const char *const * NodeName ,
273 const SUPERV::KindOfNode aKindOfNode ,
274 const char * InputParameterName ,
275 const char * InputParameterType ,
276 SUPERV::KindOfPort aKindOfPort ,
277 // const int DataStreamInPortsNumber ,
278 int * Graph_prof_debug ,
279 ofstream * Graph_fdebug ) {
280 // MESSAGE( "DefPortsOfNode " << *NodeName << " Graph_prof_debug "
281 // << Graph_prof_debug << " _prof_debug " << _prof_debug ) ;
282 cdebug_in << "PortsOfNode::AddInPort : " << *NodeName << " " << aKindOfNode << " InputParameterName " << InputParameterName << " InputParameterType "
283 << InputParameterType << " aKindOfPort " << aKindOfPort << " DataStreamInPortsNumber " << DataStreamInPortsNumber() << " _NodeInPortsSize "
284 << _NodeInPortsSize << 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 ) ;
294 if ( aKindOfPort == SUPERV::DataStreamParameter ) {
295 index = _NodeInPortsSize-2 ;
296 IncrDataStreamInPorts() ;
299 index = _NodeInPortsSize-2 - DataStreamInPortsNumber() ;
301 // if ( aKindOfNode != SUPERV::EndLoopNode ) {
303 for ( i = _NodeInPortsSize - 2 ; i >= index ; i-- ) {
304 _NodeInPorts[ i + 1 ] = _NodeInPorts[ i ] ; // Gate - Default
305 _MapOfNodeInPorts.erase( _NodeInPorts[ i + 1 ]->PortName() ) ;
306 _MapOfNodeInPorts[ _NodeInPorts[ i + 1 ]->PortName() ] = i + 2 ;
308 _MapOfNodeInPorts[ InputParameterName ] = index + 1 ;
309 if ( aKindOfPort == SUPERV::DataStreamParameter ) {
310 _NodeInPorts[index] = new GraphBase::InDataStreamPort( NodeName ,
311 aServiceParameter ) ;
314 _NodeInPorts[index] = new GraphBase::InPort( NodeName ,
318 _NodeInPorts[index]->SetDebug( ORB , Graph_prof_debug , Graph_fdebug ) ;
319 anInPort = _NodeInPorts[index] ;
320 cdebug << "NodeInPorts[ " << index << " ]" << endl ;
322 // else { // EndLoopNode
323 // _MapOfNodeInPorts[ InputParameterName ] = _NodeInPortsSize-1 + 1 ;
324 // _NodeInPorts[_NodeInPortsSize-1] = new GraphBase::InPort( NodeName ,
325 // aServiceParameter ,//
327 // MESSAGE( "GraphBase::PortsOfNode::AddInPort " << InputParameterName << " --> SetDebug" ) ;
328 // _NodeInPorts[_NodeInPortsSize-1]->SetDebug( ORB , Graph_prof_debug , Graph_fdebug ) ;
329 // anInPort = _NodeInPorts[_NodeInPortsSize-1] ;
330 // cdebug << "NodeInPorts[ " << _NodeInPortsSize-1 << " ]" << endl ;
334 cdebug << "GraphBase::PortsOfNode::AddInPort InPort already exists" << endl ;
335 anInPort->Kind( aKindOfPort ) ;
337 cdebug << "GraphBase::PortsOfNode::AddInPort index " << index << " _NodeInPortsSize " << _NodeInPortsSize << endl ;
339 for ( i = 0 ; i < _NodeInPortsSize ; i++ ) {
340 cdebug << *NodeName << " _NodeInPorts[ " << i << " ] = " << _NodeInPorts[ i ]->PortName()
341 << " _MapOfNodeInPorts[ " << _NodeInPorts[ i ]->PortName() << " ] = "
342 << _MapOfNodeInPorts[ _NodeInPorts[ i ]->PortName() ] - 1 << " "
343 << _NodeInPorts[ i ]->Kind() << " Dependency " << _NodeInPorts[ i ]->Dependency() ;
344 if ( _NodeInPorts[ i ]->IsDataStream() ) {
345 SUPERV::KindOfSchema aKindOfSchema ;
346 SUPERV::KindOfInterpolation aKindOfInterpolation ;
347 SUPERV::KindOfExtrapolation aKindOfExtrapolation ;
348 ((GraphBase::InDataStreamPort * ) _NodeInPorts[ i ])->Params( aKindOfSchema , aKindOfInterpolation , aKindOfExtrapolation ) ;
349 cdebug << " " << aKindOfSchema << " " << aKindOfInterpolation << " " << aKindOfExtrapolation ;
353 cdebug_out << "GraphBase::PortsOfNode::AddInPort _NodeInPortsSize " << _NodeInPortsSize
354 << " " << anInPort->Kind() << endl ;
358 GraphBase::OutPort * GraphBase::PortsOfNode::AddOutPort( CORBA::ORB_ptr ORB ,
359 const char * const * NodeName ,
360 const SUPERV::KindOfNode aKindOfNode ,
361 const char * OutputParameterName ,
362 const char * OutputParameterType ,
363 SUPERV::KindOfPort aKindOfPort ,
364 // const int DataStreamOutPortsNumber ,
365 int * Graph_prof_debug ,
366 ofstream * Graph_fdebug ) {
367 cdebug_in << "GraphBase::PortsOfNode::AddOutPort : " << *NodeName << " " << aKindOfNode << " OutputParameterName " << OutputParameterName
368 << " OutputParameterType " << OutputParameterType << " aKindOfPort " << aKindOfPort << " DataStreamOutPortsNumber " << DataStreamOutPortsNumber()
369 << " _NodeOutPortsSize " << _NodeOutPortsSize << endl ;
370 GraphBase::OutPort * anOutPort = NULL ;
372 anOutPort = GetChangeOutPort( OutputParameterName ) ;
373 if ( anOutPort == NULL ) {
374 _NodeOutPortsSize = _NodeOutPortsSize + 1 ;
375 _NodeOutPorts.resize(_NodeOutPortsSize);
376 SALOME_ModuleCatalog::ServicesParameter aServiceParameter ;
377 aServiceParameter.Parametername = CORBA::string_dup( OutputParameterName ) ;
378 aServiceParameter.Parametertype = CORBA::string_dup( OutputParameterType ) ;
379 if ( aKindOfPort == SUPERV::DataStreamParameter ) {
380 index = _NodeOutPortsSize-2 ;
381 IncrDataStreamOutPorts() ;
384 index = _NodeOutPortsSize-2 - DataStreamOutPortsNumber() ;
386 if ( aKindOfNode == SUPERV::LoopNode || aKindOfNode == SUPERV::EndLoopNode ) {
389 // if ( aKindOfNode != SUPERV::LoopNode && aKindOfNode != SUPERV::EndLoopNode ) {
391 for ( i = _NodeOutPortsSize - 2 ; i >= index ; i-- ) {
392 _NodeOutPorts[ i + 1 ] = _NodeOutPorts[ i ] ; // Gate - Default
393 _MapOfNodeOutPorts.erase( _NodeOutPorts[ i + 1 ]->PortName() ) ;
394 _MapOfNodeOutPorts[ _NodeOutPorts[ i + 1 ]->PortName() ] = i + 2 ;
396 _MapOfNodeOutPorts[ OutputParameterName ] = index + 1 ;
397 if ( aKindOfPort == SUPERV::DataStreamParameter ) {
398 _NodeOutPorts[index] = new GraphBase::OutDataStreamPort( NodeName ,
399 aServiceParameter ) ;
402 _NodeOutPorts[index] = new GraphBase::OutPort( NodeName ,
406 // MESSAGE( "GraphBase::PortsOfNode::AddOutPort " << OutputParameterName << " --> SetDebug" ) ;
407 _NodeOutPorts[index]->SetDebug( ORB , Graph_prof_debug , Graph_fdebug ) ;
408 anOutPort = _NodeOutPorts[index] ;
409 cdebug << "NodeOutPorts[ " << index << " ]" << endl ;
411 // else { // LoopNode || EndLoopNode
412 // _MapOfNodeOutPorts[ OutputParameterName ] = index + 2 ;
413 // _NodeOutPorts[index + 1] = new GraphBase::OutPort( NodeName ,
414 // aServiceParameter ,
416 // MESSAGE( "GraphBase::PortsOfNode::AddOutPort " << OutputParameterName << " --> SetDebug" ) ;
417 // _NodeOutPorts[index + 1]->SetDebug( ORB , Graph_prof_debug , Graph_fdebug ) ;
418 // anOutPort = _NodeOutPorts[index + 1] ;
419 // cdebug << "NodeOutPorts[ " << index + 1 << " ]" << endl ;
423 cdebug << "GraphBase::PortsOfNode::AddOutPort OutPort already exists" << endl ;
424 anOutPort->Kind( aKindOfPort ) ;
426 cdebug << "GraphBase::PortsOfNode::AddOutPort index " << index << " _NodeOutPortsSize " << _NodeOutPortsSize << endl ;
428 for ( i = 0 ; i < _NodeOutPortsSize ; i++ ) {
429 cdebug << *NodeName << " _NodeOutPorts[ " << i << " ] = " << _NodeOutPorts[ i ]->PortName()
430 << " _MapOfNodeOutPorts[ " << _NodeOutPorts[ i ]->PortName() << " ] = "
431 << _MapOfNodeOutPorts[ _NodeOutPorts[ i ]->PortName() ] - 1 << " "
432 << _NodeOutPorts[ i ]->Kind() << " Dependency " << _NodeOutPorts[ i ]->Dependency() ;
433 if ( _NodeOutPorts[ i ]->IsDataStream() ) {
434 cdebug << " NumberOfValues " << ((GraphBase::OutDataStreamPort * ) _NodeOutPorts[ i ])->NumberOfValues() ;
438 cdebug_out << "GraphBase::PortsOfNode::AddOutPort _NodeOutPortsSize "
439 << _NodeOutPortsSize << " " << anOutPort->Kind() << endl ;
443 void GraphBase::PortsOfNode::DelInPort( const char * InputParameterName ) {
444 cdebug << "DefPortsOfNode::DelInPort : " << InputParameterName << endl ;
445 int index = _MapOfNodeInPorts[ InputParameterName ] -1 ;
447 cdebug << "DefPortsOfNode::DelInPort : _NodeInPorts[" << index << "] "
448 << _NodeInPorts[ index ]->PortName() << " "
449 << _NodeInPorts[ index ]->NodeName() << endl ;
450 if ( _NodeInPorts[ index ]->IsDataStream() ) {
451 DecrDataStreamInPorts() ;
453 _MapOfNodeInPorts.erase( InputParameterName ) ;
454 _NodeInPorts[ index ]->destroy() ;
456 for ( i = index ; i < _NodeInPortsSize - 1 ; i++ ) {
457 _MapOfNodeInPorts.erase( _NodeInPorts[ i+1 ]->PortName() ) ;
458 _MapOfNodeInPorts[ _NodeInPorts[ i+1 ]->PortName() ] = i+1 ;
459 _NodeInPorts[ i ] = _NodeInPorts[ i+1 ] ;
461 _NodeInPortsSize = _NodeInPortsSize - 1 ;
462 _NodeInPorts.resize( _NodeInPortsSize ) ;
463 for ( i = 0 ; i < _NodeInPortsSize ; i++ ) {
464 cdebug << "DefPortsOfNode::DelInPort ListOfInPorts : _NodeInPorts[" << i << "] "
465 << _NodeInPorts[ i ]->PortName() << " "
466 << _NodeInPorts[ i ]->NodeName() << endl ;
470 cdebug << "DefPortsOfNode::DelInPort : index out of range ERROR " << index
475 void GraphBase::PortsOfNode::DelOutPort( const char * OutputParameterName ) {
476 cdebug << "DefPortsOfNode::DelOutPort : " << OutputParameterName << endl ;
477 int index = _MapOfNodeOutPorts[ OutputParameterName ] - 1 ;
479 cdebug << "DefPortsOfNode::DelOutPort : _NodeOutPorts[" << index << "] "
480 << _NodeOutPorts[ index ]->PortName() << " "
481 << _NodeOutPorts[ index ]->NodeName() << endl ;
482 if ( _NodeOutPorts[ index ]->IsDataStream() ) {
483 DecrDataStreamOutPorts() ;
485 _MapOfNodeOutPorts.erase( OutputParameterName ) ;
486 _NodeOutPorts[ index ]->destroy() ;
488 for ( i = index ; i < _NodeOutPortsSize - 1 ; i++ ) {
489 _MapOfNodeOutPorts.erase( _NodeOutPorts[ i+1 ]->PortName() ) ;
490 _MapOfNodeOutPorts[ _NodeOutPorts[ i+1 ]->PortName() ] = i+1 ;
491 _NodeOutPorts[ i ] = _NodeOutPorts[ i+1 ] ;
493 _NodeOutPortsSize = _NodeOutPortsSize - 1 ;
494 _NodeOutPorts.resize( _NodeOutPortsSize ) ;
495 for ( i = 0 ; i < _NodeOutPortsSize ; i++ ) {
496 cdebug << "DefPortsOfNode::DelOutPort ListOfOutPorts : _NodeOutPorts[" << i
497 << "] " << _NodeOutPorts[ i ]->PortName() << " "
498 << _NodeOutPorts[ i ]->NodeName() << endl ;
502 cdebug << "DefPortsOfNode::DelOutPort : index out of range ERROR " << index
508 void GraphBase::PortsOfNode::InOutPort( GraphBase::InPort * InputPort ,
509 GraphBase::OutPort * OutputPort ) {
510 cdebug_in << "DefPortsOfNode::InOutPort : " << InputPort->PortName()
511 << " " << OutputPort->PortName() << endl ;
512 InputPort->PortIndex( _MapOfNodeOutPorts[ OutputPort->PortName() ] - 1 ) ;
513 OutputPort->PortIndex( _MapOfNodeInPorts[ InputPort->PortName() ] - 1 ) ;
514 cdebug_out << "DefPortsOfNode::InOutPort " << InputPort->PortIndex()
515 << " " << OutputPort->PortIndex() << endl ;
519 const GraphBase::InPort *GraphBase::PortsOfNode::GetInPort( const char *name) {
520 return GetChangeInPort( name ) ;
523 const GraphBase::OutPort *GraphBase::PortsOfNode::GetOutPort( const char *name) {
524 return GetChangeOutPort( name ) ;
527 GraphBase::InPort *GraphBase::PortsOfNode::GetChangeInPort( const char * name) {
528 // cdebug_in << "GraphBase::PortsOfNode::GetChangeInPort " << name << endl;
530 GraphBase::InPort * pP = NULL;
531 if ( !_MapOfNodeInPorts.empty() ) {
533 if ( !strcmp( name , "InGate" ) ) {
534 i = _MapOfNodeInPorts[ "Gate" ] ;
537 i = _MapOfNodeInPorts[ name ] ;
540 // cdebug << "GraphBase::PortsOfNode::GetChangeInPort _MapOfNodeInPorts[ "
541 // << name << " ] : " << i-1 << " " << _NodeInPorts[ i-1 ]->NodeName()
543 pP = _NodeInPorts[ i-1 ] ;
546 // if ( pP == NULL ) {
548 // for ( i = 0 ; i < _NodeInPortsSize ; i++ ) {
549 // cdebug << " _NodeInPorts[ " << i << " ] = " << _NodeInPorts[ i ]->PortName()
550 // << " _MapOfNodeInPorts[ " << _NodeInPorts[ i ]->PortName() << " ] = "
551 // << _MapOfNodeInPorts[ _NodeInPorts[ i ]->PortName() ] - 1 << " "
552 // << _NodeInPorts[ i ]->Kind() << " Dependency " << _NodeInPorts[ i ]->Dependency() ;
553 // if ( _NodeInPorts[ i ]->IsDataStream() ) {
554 // SUPERV::KindOfSchema aKindOfSchema ;
555 // SUPERV::KindOfInterpolation aKindOfInterpolation ;
556 // SUPERV::KindOfExtrapolation aKindOfExtrapolation ;
557 // ((GraphBase::InDataStreamPort * ) _NodeInPorts[ i ])->Params( aKindOfSchema , aKindOfInterpolation , aKindOfExtrapolation ) ;
558 // cdebug << " " << aKindOfSchema << " " << aKindOfInterpolation << " " << aKindOfExtrapolation ;
560 // if ( !strcmp( _NodeInPorts[ i ]->PortName() , name ) ) {
561 // cdebug << " ERROR" ;
566 // cdebug_out << "GraphBase::PortsOfNode::GetChangeInPort " << endl;
571 GraphBase::OutPort *GraphBase::PortsOfNode::GetChangeOutPort( const char * name ) {
572 // cdebug_in << "GraphBase::PortsOfNode::GetChangeOutPort " << name << endl;
574 GraphBase::OutPort * pP = NULL;
575 if ( !_MapOfNodeOutPorts.empty() ) {
577 if ( !strcmp( name , "OutGate" ) ) {
578 i = _MapOfNodeOutPorts[ "Gate" ] ;
581 i = _MapOfNodeOutPorts[ name ] ;
584 // cdebug << "GraphBase::PortsOfNode::GetChangeOutPort _MapOfNodeOutPorts[ "
585 // << name << " ] : " << i-1 << " " << _NodeOutPorts[ i-1 ]->NodeName() << endl ;
586 pP = _NodeOutPorts[ i-1 ] ;
589 // cdebug_out << "GraphBase::PortsOfNode::GetChangeOutPort " << endl;
591 // if ( pP == NULL ) {
593 // for ( i = 0 ; i < _NodeOutPortsSize ; i++ ) {
594 // cdebug << " _NodeOutPorts[ " << i << " ] = " << _NodeOutPorts[ i ]->PortName()
595 // << " _MapOfNodeOutPorts[ " << _NodeOutPorts[ i ]->PortName() << " ] = "
596 // << _MapOfNodeOutPorts[ _NodeOutPorts[ i ]->PortName() ] - 1 << " "
597 // << _NodeOutPorts[ i ]->Kind() << " Dependency " << _NodeOutPorts[ i ]->Dependency() ;
598 // if ( _NodeOutPorts[ i ]->IsDataStream() ) {
599 // cdebug << " NumberOfValues " << ((GraphBase::OutDataStreamPort * ) _NodeOutPorts[ i ])->NumberOfValues() ;
601 // if ( !strcmp( _NodeOutPorts[ i ]->PortName() , name ) ) {
602 // cdebug << " ERROR" ;
611 bool GraphBase::PortsOfNode::RemoveLinks() {
614 for ( i = 0 ; i < _NodeInPortsSize ; i++ ) {
615 cdebug << "GraphBase::PortsOfNode::RemoveLinks of InPorts : "
616 << *_NodeInPorts[ i ] ;
617 if ( _NodeInPorts[ i ]->IsConnected() ) {
618 RetVal = _NodeInPorts[ i ]->GetLink()->RemoveLink( _NodeInPorts[ i ] ) ;
620 << *_NodeInPorts[ i ]->GetLink() ;
623 cdebug << " not connected" ;
630 for ( i = 0 ; i < _NodeOutPortsSize ; i++ ) {
631 cdebug << "GraphBase::PortsOfNode::RemoveLinks of OutPort : "
632 << *_NodeOutPorts[ i ] ;
633 RetVal = _NodeOutPorts[ i ]->RemoveLinks() ;
642 void GraphBase::PortsOfNode::ListPorts( ostream & f,
643 const bool klink ) const {
647 f << " Input 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 ) ;
660 f << " Output Ports : " ;
663 f << GetNodeOutPortsSize() << " port"
664 << (GetNodeOutPortsSize() > 1 ? "s" : "") << endl;
666 for ( i = 0 ; i < GetNodeOutPortsSize() ; i++ ) {
668 // << hex << GetNodeOutPort(i) << dec << " "
669 << *(GetNodeOutPort(i)) << " " ;
670 GetNodeOutPort(i)->StringValue( f ) ;
675 f << " Output Ports : " ;
676 f << GetNodeInPortsSize() << " port"
677 << (GetNodeInPortsSize() > 1 ? "s" : "") << endl;
679 for ( i = 0 ; i < GetNodeInPortsSize() ; i++ ) {
681 // << hex << GetNodeInPort(i) << dec << " "
682 << *(GetNodeInPort(i)) << " " ;
683 GetNodeInPort(i)->StringValue( f ) ;
690 ostream & operator<< (ostream & f ,const SUPERV::KindOfNode & s ) {
692 case SUPERV::ComputingNode :
693 f << "ComputingNode";
695 case SUPERV::FactoryNode :
698 case SUPERV::InLineNode :
701 case SUPERV::DataFlowGraph :
702 f << "DataFlowGraph";
704 case SUPERV::DataStreamGraph :
705 f << "DataStreamGraph";
707 case SUPERV::LoopNode :
710 case SUPERV::EndLoopNode :
713 case SUPERV::SwitchNode :
716 case SUPERV::EndSwitchNode :
717 f << "EndSwitchNode";
719 case SUPERV::GOTONode :
723 f << "UnknownKindOfNode";