1 // SUPERV Supervision : contains the implementation of interfaces of SuperVision described in SUPERV.idl
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 : StreamGraph_Impl.cxx
25 // Author : Jean Rahuel
31 #include "StreamGraph_Impl.hxx"
33 StreamGraph_Impl::StreamGraph_Impl( CORBA::ORB_ptr orb ,
34 PortableServer::POA_ptr poa ,
35 PortableServer::ObjectId * contId ,
36 const char *instanceName ,
37 const char *interfaceName ,
38 const char *aDataFlowName ,
39 const SUPERV::KindOfNode aKindOfGraphNode ) :
40 // Graph_Impl(orb, poa, contId, instanceName, interfaceName, aDataFlowName , SUPERV::DataStreamGraph ) {
41 Graph_Impl(orb, poa, contId, instanceName, interfaceName, aDataFlowName , aKindOfGraphNode ) {
42 // MESSAGE("StreamGraph_Impl::StreamGraph_Impl activate object instanceName("
43 // << instanceName << ") interfaceName(" << interfaceName << ") --> "
44 // << hex << (void *) this << dec )
45 beginService( "StreamGraph_Impl::StreamGraph_Impl" );
47 _id = _poa->activate_object(_thisObj);
48 _Orb = CORBA::ORB::_duplicate(orb);
52 endService( "StreamGraph_Impl::StreamGraph_Impl" );
55 StreamGraph_Impl::StreamGraph_Impl( CORBA::ORB_ptr orb ,
56 PortableServer::POA_ptr poa ,
57 PortableServer::ObjectId * contId ,
58 const char *instanceName ,
59 const char *interfaceName ,
60 GraphEditor::DataFlow * aDataFlowEditor ,
61 GraphEditor::InNode * aDataFlowNode ) :
62 Graph_Impl( orb , poa , contId , instanceName , interfaceName , aDataFlowEditor , aDataFlowNode ) {
63 beginService( "StreamGraph_Impl::StreamGraph_Impl" );
64 if ( aDataFlowEditor->Graph()->IsDataStreamNode() ||
65 ( aDataFlowNode && aDataFlowNode->IsMacroNode() ) ) {
66 MESSAGE( "StreamGraph_Impl::StreamGraph_Impl _poa->activate_object" );
68 _id = _poa->activate_object(_thisObj);
71 MESSAGE( "StreamGraph_Impl::StreamGraph_Impl NO _poa->activate_object " );
73 _Orb = CORBA::ORB::_duplicate(orb);
76 endService( "StreamGraph_Impl::StreamGraph_Impl" );
79 StreamGraph_Impl::StreamGraph_Impl() {
82 StreamGraph_Impl::~StreamGraph_Impl() {
83 beginService( "StreamGraph_Impl::~StreamGraph_Impl" );
84 endService( "StreamGraph_Impl::~StreamGraph_Impl" );
87 void StreamGraph_Impl::destroy() {
88 beginService( "StreamGraph_Impl::destroy" );
89 _poa->deactivate_object(*_id) ;
90 CORBA::release(_poa) ;
92 _thisObj->_remove_ref();
93 endService( "StreamGraph_Impl::destroy" );
96 SUPERV::StreamGraph_ptr StreamGraph_Impl::StreamCopy() {
97 beginService( "StreamGraph_Impl::StreamCopy" );
98 SUPERV::StreamGraph_var iobject = SUPERV::StreamGraph::_nil() ;
100 StreamGraph_Impl * myStreamGraph ;
101 myStreamGraph = new StreamGraph_Impl( _Orb , _Poa, _ContId,
102 instanceName() , interfaceName() ,
103 DataFlowEditor()->Graph()->Name() ) ;
104 PortableServer::ObjectId * id = myStreamGraph->getId() ;
105 CORBA::Object_var obj = _poa->id_to_reference(*id);
106 iobject = SUPERV::StreamGraph::_narrow(obj) ;
107 GraphBase::ListOfSGraphs * aListOfSGraphs = GetGraphs() ;
108 myStreamGraph->LoadGraphs( aListOfSGraphs ) ;
110 endService( "StreamGraph_Impl::StreamCopy" );
111 return SUPERV::StreamGraph::_duplicate(iobject) ;
114 SUPERV::StreamGraph_ptr StreamGraph_Impl::StreamMNode( const char * aXmlFileName ) {
115 beginService( "StreamGraph_Impl::StreamMNode" );
116 SUPERV::StreamGraph_var streamiobject = SUPERV::StreamGraph::_nil() ;
117 SUPERV::StreamGraph_var macroiobject = SUPERV::StreamGraph::_nil() ;
120 GraphEditor::DataFlow * aDataFlowEditor ;
121 CreateEditor( _Orb , instanceName() , aXmlFileName , SUPERV::DataStreamGraph ,
122 dbgfile , &aDataFlowEditor ) ;
123 int lenname = strlen( aXmlFileName ) ;
124 bool created = false ;
125 if ( lenname > 4 && !strcmp( &aXmlFileName[ lenname - 4 ] , ".xml" ) ) {
126 created = aDataFlowEditor->LoadXml( aXmlFileName ) ;
129 StreamGraph_Impl * myStreamGraph ;
130 myStreamGraph = new StreamGraph_Impl( _Orb , _Poa, _ContId,
131 instanceName() , interfaceName() ,
132 aDataFlowEditor , NULL ) ;
133 PortableServer::ObjectId * id = myStreamGraph->getId() ;
134 CORBA::Object_var obj = _poa->id_to_reference(*id);
135 streamiobject = SUPERV::StreamGraph::_narrow( obj ) ;
136 myStreamGraph->SetObjRef( SUPERV::StreamGraph::_duplicate( streamiobject ) ) ;
138 StreamGraph_Impl * myStreamMacroNode ;
139 myStreamMacroNode = new StreamGraph_Impl( _Orb , _Poa, _ContId,
140 instanceName() , interfaceName() ,
141 aXmlFileName , SUPERV::StreamMacroNode ) ;
142 id = myStreamMacroNode->getId() ;
143 obj = _poa->id_to_reference(*id);
144 macroiobject = SUPERV::StreamGraph::_narrow( obj ) ;
145 myStreamMacroNode->DataFlowEditor( DataFlowEditor() ) ;
146 myStreamMacroNode->DataFlowEditor()->Graph()->SetObjImpl( this ) ;
147 myStreamMacroNode->SetObjRef( SUPERV::CNode::_duplicate( SUPERV::CNode::_narrow( obj ) ) ) ;
148 char * aMacroNodeName = myStreamGraph->Name() ;
149 GraphBase::ListOfFuncName aFuncName ;
150 aFuncName.resize( 1 ) ;
152 SUPERV::ListOfStrings aListOfStrings ;
153 aListOfStrings.length( 1 ) ;
154 aListOfStrings[0] = "" ;
155 GraphBase::ListOfPythonFunctions aPythonFunction ;
156 aPythonFunction.resize( 1 ) ;
157 aPythonFunction[0] = &aListOfStrings ;
158 SALOME_ModuleCatalog::Service * aMacroNodeService = myStreamGraph->Service() ;
159 GraphEditor::InNode * aDataFlowNode = DataFlowEditor()->AddNode( *aMacroNodeService , "" , "" ,
160 aMacroNodeName , SUPERV::StreamMacroNode ,
161 aFuncName , aPythonFunction ) ;
162 myStreamMacroNode->DataFlowNode( aDataFlowNode ) ;
163 myStreamGraph->MacroObject( SUPERV::StreamGraph::_duplicate( macroiobject ) ) ;
164 myStreamMacroNode->MacroObject( SUPERV::StreamGraph::_duplicate( streamiobject ) ) ;
165 MESSAGE( "DataFlowNode Graph " << this << " DataFlowEditor " << DataFlowEditor() << " aDataFlowNode "
166 << aDataFlowNode << " " << aDataFlowNode->Name()
170 delete aDataFlowEditor ;
173 endService( "StreamGraph_Impl::StreamMNode" );
174 return SUPERV::StreamGraph::_duplicate( macroiobject ) ;
177 SUPERV::StreamGraph_ptr StreamGraph_Impl::StreamGraphMNode( SUPERV::StreamGraph_ptr myMacroStreamGraph ) {
178 SUPERV::StreamGraph_var iobject = myMacroStreamGraph ;
179 // GraphBase::Graph * myMacroGraph = aGraph;
180 SUPERV::StreamGraph_var macroiobject = SUPERV::StreamGraph::_nil() ;
181 beginService( "StreamGraph_Impl::StreamGraphMNode" ) ;
182 endService( "StreamGraph_Impl::StreamGraphMNode" ) ;
183 return SUPERV::StreamGraph::_duplicate( macroiobject ) ;
186 SUPERV::StreamLink_ptr StreamGraph_Impl::StreamLink( SUPERV::StreamPort_ptr OutStreamPort ,
187 SUPERV::StreamPort_ptr InStreamPort ) {
188 beginService( "StreamGraph_Impl::StreamLink" );
189 SUPERV::StreamLink_var iobject = SUPERV::StreamLink::_nil() ;
190 if ( DataFlowEditor()->IsEditing() && !DataFlowEditor()->IsReadOnly() && !IsMacro() &&
191 OutStreamPort->IsDataStream() && InStreamPort->IsDataStream() ) {
192 GraphBase::InPort * anInPort = DataFlowEditor()->GetNode( InStreamPort->Node()->Name() )->ComputingNode()->GetChangeInPort( InStreamPort->Name() ) ;
193 GraphBase::OutPort * anOutPort = DataFlowEditor()->GetNode( OutStreamPort->Node()->Name() )->ComputingNode()->GetChangeOutPort( OutStreamPort->Name() ) ;
194 if ( CORBA::is_nil( anOutPort->InPortObjRef( anInPort ) ) ) {
195 const char * DataFlowOutNodeName = OutStreamPort->Node()->Name() ;
196 GraphEditor::InNode * DataFlowOutNode = DataFlowEditor()->GetNode( DataFlowOutNodeName ) ;
197 const char * DataFlowInNodeName = InStreamPort->Node()->Name() ;
198 GraphEditor::InNode * DataFlowInNode = DataFlowEditor()->GetNode( DataFlowInNodeName ) ;
199 if ( DataFlowOutNode && DataFlowInNode ) {
201 StreamLink_Impl * myStreamLink = new StreamLink_Impl( _Orb , _Poa , _ContId ,
202 instanceName() , interfaceName() ,
205 InStreamPort->Name() ,
207 OutStreamPort->Name() ,
210 PortableServer::ObjectId * id = myStreamLink->getId() ;
211 CORBA::Object_var obj = _poa->id_to_reference(*id);
212 iobject = SUPERV::StreamLink::_narrow(obj) ;
213 anOutPort->AddInPortObjRef( anInPort , SUPERV::StreamLink::_duplicate(iobject) ) ;
214 DataFlowEditor()->UnValid() ;
219 iobject = SUPERV::StreamLink::_narrow( anOutPort->InPortObjRef( anInPort ) ) ;
222 endService( "StreamGraph_Impl::StreamLink" );
223 return SUPERV::StreamLink::_duplicate(iobject) ;
226 SUPERV::ListOfStreamLinks * StreamGraph_Impl::GStreamLinks() {
227 return StreamLinks( NULL , NULL ) ;
230 SUPERV::ListOfStreamLinks * StreamGraph_Impl::StreamLinks( GraphBase::ComputingNode * theNode ,
231 const char * anInputParam ) {
233 SUPERV::ListOfStreamLinks_var RetVal = new SUPERV::ListOfStreamLinks ;
235 int i , j , countlink ;
237 for ( i = 0 ; i < DataFlowEditor()->Graph()->GraphNodesSize() ; i++ ) {
238 GraphEditor::InNode * aNode = NULL ;
239 aNode = (GraphEditor::InNode * ) DataFlowEditor()->Graph()->GraphNodes( i )->GetInNode() ;
240 bool ToProcess = false ;
241 if ( theNode == NULL ) {
245 if ( !strcmp( theNode->Name() , aNode->Name() ) ) {
246 if ( !theNode->IsEndSwitchNode() ) {
250 else if ( theNode->IsEndSwitchNode() ) {
255 for ( j = 0 ; j < aNode->GetNodeInPortsSize() ; j++ ) {
256 GraphBase::InPort * anInPort = NULL ;
257 anInPort = aNode->GetChangeNodeInPort( j ) ;
258 if ( anInputParam == NULL ||
259 !strcmp( anInPort->PortName() , anInputParam ) ) {
260 GraphBase::OutPort * anOutPort = NULL ;
261 anOutPort = anInPort->GetOutPort() ;
262 if ( anOutPort && anOutPort->IsDataStream() ) {
263 if ( strcmp( anOutPort->NodeName() , Name() ) ) {
264 MESSAGE("StreamGraph_Impl::StreamLinks " << anOutPort->NodeName() << "("
265 << anOutPort->PortName() << ") --> " << aNode->Name() << "("
266 << anInPort->PortName() << ")" ) ;
267 if ( theNode == NULL ||
268 ( theNode != NULL && !theNode->IsEndSwitchNode() &&
269 !strcmp( theNode->Name() , aNode->Name() ) ) ) {
270 if ( anInPort->IsLoop() || anOutPort->IsLoop() ||
271 ( aNode->IsEndLoopNode() && !strcmp( aNode->CoupledNode()->Name() ,
272 anOutPort->NodeName() ) ) ) {
273 MESSAGE( "StreamLink " << anOutPort->NodeName() << "("
274 << anOutPort->PortName() << ") --> " << aNode->Name() << "("
275 << anInPort->PortName() << ")" << " ignored" ) ;
277 else if ( CORBA::is_nil( anOutPort->InPortObjRef( anInPort ) ) ) {
279 beginService( "StreamGraph_Impl::StreamLinks" );
282 GraphEditor::InNode * anOutNode = NULL ;
283 anOutNode = (GraphEditor::InNode * ) DataFlowEditor()->Graph()->GetChangeGraphNode( anOutPort->NodeName() )->GetInNode() ;
286 StreamLink_Impl * myStreamLink = new StreamLink_Impl(
287 _Orb , _Poa , _ContId ,
288 instanceName() , interfaceName() ,
291 anInPort->PortName() ,
293 anOutPort->PortName() ,
296 PortableServer::ObjectId * id = myStreamLink->getId() ;
297 CORBA::Object_var obj = _poa->id_to_reference(*id);
298 SUPERV::StreamLink_var iobject ;
299 iobject = SUPERV::StreamLink::_narrow(obj) ;
300 RetVal->length( countlink + 1 ) ;
301 RetVal[ countlink++ ] = SUPERV::StreamLink::_duplicate( iobject ) ;
302 anOutPort->AddInPortObjRef( anInPort , SUPERV::StreamLink::_duplicate( iobject ) ) ;
303 MESSAGE( "Link" << countlink-1 << " "
304 << RetVal[countlink-1]->OutStreamPort()->Node()->Name() << "("
305 << RetVal[countlink-1]->OutStreamPort()->Name() << ") --> "
306 << RetVal[countlink-1]->InStreamPort()->Node()->Name() << "("
307 << RetVal[countlink-1]->InStreamPort()->Name() << ")" ) ;
312 RetVal->length( countlink + 1 ) ;
313 RetVal[ countlink++ ] = SUPERV::StreamLink::_duplicate( SUPERV::StreamLink::_narrow( anOutPort->InPortObjRef( anInPort ) ) ) ;
314 MESSAGE( "Link" << countlink-1 << " "
315 << RetVal[countlink-1]->OutStreamPort()->Node()->Name() << "("
316 << RetVal[countlink-1]->OutStreamPort()->Name() << ") --> "
317 << RetVal[countlink-1]->InStreamPort()->Node()->Name() << "("
318 << RetVal[countlink-1]->InStreamPort()->Name() << ")" ) ;
326 for ( j = 0 ; j < aNode->GetNodeOutPortsSize() ; j++ ) {
327 GraphBase::OutPort * anOutPort = aNode->GetChangeNodeOutPort( j ) ;
329 for ( k = 0 ; k < anOutPort->InPortsSize() ; k++ ) {
330 GraphBase::InPort * anInPort = anOutPort->ChangeInPorts( k ) ;
331 GraphEditor::InNode * toNode = (GraphEditor::InNode * ) DataFlowEditor()->Graph()->GetChangeGraphNode( anInPort->NodeName() )->GetInNode() ;
332 if ( theNode == NULL ||
333 !strcmp( theNode->Name() , aNode->Name() ) ) {
334 if ( anInPort->IsDataStream() ) {
335 if ( theNode || ( toNode->IsEndSwitchNode() && !aNode->IsSwitchNode() ) ) {
336 if ( anInputParam == NULL ||
337 !strcmp( anInPort->PortName() , anInputParam ) ) {
338 MESSAGE( "StreamLink " << anOutPort->NodeName() << "("
339 << anOutPort->PortName() << ") --> " << toNode->Name() << "("
340 << anInPort->PortName() << ")" ) ;
341 MESSAGE( " IOR " << DataFlowEditor()->ObjectToString( anOutPort->InPortObjRef( anInPort ) ) ) ;
342 if ( anInPort->IsLoop() || anOutPort->IsLoop() ||
343 ( toNode->IsEndLoopNode() && !strcmp( toNode->CoupledNode()->Name() ,
344 anOutPort->NodeName() ) ) ) {
345 MESSAGE( "StreamLink " << anOutPort->NodeName() << "("
346 << anOutPort->PortName() << ") --> " << toNode->Name() << "("
347 << anInPort->PortName() << ")" << " ignored" ) ;
349 else if ( CORBA::is_nil( anOutPort->InPortObjRef( anInPort ) ) ) {
351 beginService( "Graph_Impl::StreamLinks" );
355 StreamLink_Impl * myStreamLink = new StreamLink_Impl(
356 _Orb , _Poa , _ContId ,
357 instanceName() , interfaceName() ,
360 anInPort->PortName() ,
362 anOutPort->PortName() ,
365 PortableServer::ObjectId * id = myStreamLink->getId() ;
366 CORBA::Object_var obj = _poa->id_to_reference(*id);
367 SUPERV::StreamLink_var iobject ;
368 iobject = SUPERV::StreamLink::_narrow(obj) ;
369 RetVal->length( countlink + 1 ) ;
370 RetVal[ countlink++ ] = SUPERV::StreamLink::_duplicate( iobject ) ;
371 anOutPort->AddInPortObjRef( anInPort , SUPERV::StreamLink::_duplicate( iobject ) ) ;
372 MESSAGE( "Link" << countlink-1 << " "
373 << RetVal[countlink-1]->OutStreamPort()->Node()->Name() << "("
374 << RetVal[countlink-1]->OutStreamPort()->Name() << ") --> "
375 << RetVal[countlink-1]->InStreamPort()->Node()->Name() << "("
376 << RetVal[countlink-1]->InStreamPort()->Name() << ")" ) ;
380 RetVal->length( countlink + 1 ) ;
381 RetVal[ countlink++ ] = SUPERV::StreamLink::_duplicate( SUPERV::StreamLink::_narrow( anOutPort->InPortObjRef( anInPort ) ) ) ;
382 MESSAGE( "Link" << countlink-1 << " "
383 << RetVal[countlink-1]->OutStreamPort()->Node()->Name() << "("
384 << RetVal[countlink-1]->OutStreamPort()->Name() << ") --> "
385 << RetVal[countlink-1]->InStreamPort()->Node()->Name() << "("
386 << RetVal[countlink-1]->InStreamPort()->Name() << ")" ) ;
390 MESSAGE( "StreamLink " << anOutPort->NodeName() << "("
391 << anOutPort->PortName() << ") --> " << toNode->Name() << "("
392 << anInPort->PortName() << ")" << " skipped" ) ;
401 const char * NodeName = "" ;
402 const char * InputParamName = "" ;
404 NodeName = theNode->Name() ;
406 if ( anInputParam ) {
407 InputParamName = anInputParam ;
409 MESSAGE( RetVal->length() << " StreamLinks of Node " << NodeName << " and of InPort " << InputParamName ) ;
410 for ( i = 0 ; i < (int ) RetVal->length() ; i++ ) {
411 MESSAGE( "Link" << i << " " << RetVal[i]->OutStreamPort()->Node()->Name() << "("
412 << RetVal[i]->OutStreamPort()->Name() << ") --> "
413 << RetVal[i]->InStreamPort()->Node()->Name() << "("
414 << RetVal[i]->InStreamPort()->Name() << ")" ) ;
418 endService( "StreamGraph_Impl::StreamLinks" );
421 return ( RetVal._retn() ) ;
424 bool StreamGraph_Impl::SetStreamParams( const long Timeout ,
425 const SUPERV::KindOfDataStreamTrace DataStreamTrace ,
426 const double DeltaTime ) {
429 sts = DataFlowEditor()->StreamGraph()->SetStreamParams( Timeout , DataStreamTrace , DeltaTime ) ;
431 DataFlowEditor()->UnValid() ;
437 void StreamGraph_Impl::StreamParams( long & Timeout ,
438 SUPERV::KindOfDataStreamTrace & DataStreamTrace ,
439 double & DeltaTime ) {
441 DataFlowEditor()->StreamGraph()->StreamParams( Timeout , DataStreamTrace , DeltaTime ) ;
445 long StreamGraph_Impl::SubStreamGraphsNumber() {
446 // beginService( "StreamGraph_Impl::StreamGraphsNumber" );
448 if ( DataFlowEditor()->IsExecutable() && !IsMacro() ) {
449 RetVal = DataFlowEditor()->SubStreamGraphsNumber() ;
451 // endService( "StreamGraph_Impl::SubStreamGraphsNumber" );
455 SUPERV::ListOfNodes * StreamGraph_Impl::SubStreamGraphsNodes( const long aSubStreamGraphNumber ) {
456 beginService( "StreamGraph_Impl::SubStreamGraphsNodes" );
457 SUPERV::ListOfNodes_var RetVal = new SUPERV::ListOfNodes ;
458 if ( DataFlowEditor()->IsEditing() && !IsMacro() ) {
459 SUPERV::ListOfNodes * aGraphNodes = Nodes() ;
462 for ( i = 0 ; i < (int ) aGraphNodes->CNodes.length() ; i++ ) {
463 SUPERV::CNode_var aNode = (aGraphNodes->CNodes)[ i ] ;
464 if ( aNode->SubStreamGraph() == aSubStreamGraphNumber ) {
465 RetVal = SetNode( RetVal , DataFlowEditor()->Graph()->GetChangeGraphNode( aNode->Name() ) ) ;
469 for ( i = 0 ; i < (int ) aGraphNodes->FNodes.length() ; i++ ) {
470 SUPERV::FNode_var aNode = (aGraphNodes->FNodes)[ i ] ;
471 if ( aNode->SubStreamGraph() == aSubStreamGraphNumber ) {
472 RetVal = SetNode( RetVal , DataFlowEditor()->Graph()->GetChangeGraphNode( aNode->Name() ) ) ;
476 for ( i = 0 ; i < (int ) aGraphNodes->INodes.length() ; i++ ) {
477 SUPERV::INode_var aNode = (aGraphNodes->INodes)[ i ] ;
478 if ( aNode->SubStreamGraph() == aSubStreamGraphNumber ) {
479 RetVal = SetNode( RetVal , DataFlowEditor()->Graph()->GetChangeGraphNode( aNode->Name() ) ) ;
483 for ( i = 0 ; i < (int ) aGraphNodes->GNodes.length() ; i++ ) {
484 SUPERV::GNode_var aNode = (aGraphNodes->GNodes)[ i ] ;
485 if ( aNode->SubStreamGraph() == aSubStreamGraphNumber ) {
486 RetVal = SetNode( RetVal , DataFlowEditor()->Graph()->GetChangeGraphNode( aNode->Name() ) ) ;
490 for ( i = 0 ; i < (int ) aGraphNodes->LNodes.length() ; i++ ) {
491 SUPERV::LNode_var aNode = (aGraphNodes->LNodes)[ i ] ;
492 if ( aNode->SubStreamGraph() == aSubStreamGraphNumber ) {
493 RetVal = SetNode( RetVal , DataFlowEditor()->Graph()->GetChangeGraphNode( aNode->Name() ) ) ;
497 for ( i = 0 ; i < (int ) aGraphNodes->ELNodes.length() ; i++ ) {
498 SUPERV::ELNode_var aNode = (aGraphNodes->ELNodes)[ i ] ;
499 if ( aNode->SubStreamGraph() == aSubStreamGraphNumber ) {
500 RetVal = SetNode( RetVal , DataFlowEditor()->Graph()->GetChangeGraphNode( aNode->Name() ) ) ;
504 for ( i = 0 ; i < (int ) aGraphNodes->SNodes.length() ; i++ ) {
505 SUPERV::SNode_var aNode = (aGraphNodes->SNodes)[ i ] ;
506 if ( aNode->SubStreamGraph() == aSubStreamGraphNumber ) {
507 RetVal = SetNode( RetVal , DataFlowEditor()->Graph()->GetChangeGraphNode( aNode->Name() ) ) ;
511 for ( i = 0 ; i < (int ) aGraphNodes->ESNodes.length() ; i++ ) {
512 SUPERV::ESNode_var aNode = (aGraphNodes->ESNodes)[ i ] ;
513 if ( aNode->SubStreamGraph() == aSubStreamGraphNumber ) {
514 RetVal = SetNode( RetVal , DataFlowEditor()->Graph()->GetChangeGraphNode( aNode->Name() ) ) ;
518 endService( "StreamGraph_Impl::SubStreamGraphsNodes" );
519 return ( RetVal._retn() ) ;
522 SUPERV::Graph_ptr StreamGraph_Impl::ToFlowGraph() {
523 SUPERV::Graph_var iobject = SUPERV::Graph::_nil() ;
524 beginService( "StreamGraph_Impl::ToFlowGraph" );
526 // Graph_Impl * myFlowGraph = new Graph_Impl( _Orb , _Poa , _ContId ,
527 // instanceName() , interfaceName() ) ;
528 // PortableServer::ObjectId * id = myFlowGraph->getId() ;
529 // CORBA::Object_var obj = _poa->id_to_reference(*id);
530 if ( !CORBA::is_nil( DataFlowEditor()->StreamGraph()->ObjRef() ) ) {
531 iobject = SUPERV::Graph::_narrow( DataFlowEditor()->StreamGraph()->ObjRef() ) ;
534 endService( "StreamGraph_Impl::ToFlowGraph" );
535 return SUPERV::Graph::_duplicate( iobject ) ;
538 bool StreamGraph_Impl::StreamMerge(const SUPERV::StreamGraph_ptr aStreamGraph ) {
539 beginService( "StreamGraph_Impl::StreamMerge" );
540 bool RetVal = false ;
542 map< string , int > aMapOfNodes ;
543 RetVal = Merge( aStreamGraph , aMapOfNodes ) ;
545 SUPERV::ListOfStreamLinks * aGraphLinks = aStreamGraph->GStreamLinks() ;
546 SUPERV::ListOfStreamPorts * aGraphPorts = aStreamGraph->StreamPorts() ;
547 //cout << "Graph_Impl::StreamMerge " << aGraphLinks->length() << " links " << aGraphPorts->length()
548 // << " GraphPorts" << endl ;
550 for ( i = 0 ; i < (int ) aGraphLinks->length() ; i++ ) {
551 SUPERV::StreamLink_var aLink = (*aGraphLinks)[ i ] ;
552 SUPERV::StreamPort_var OutPort = aLink->OutStreamPort() ;
553 SUPERV::StreamPort_var InPort = aLink->InStreamPort() ;
554 string * aLinkFromNodeName = new string( OutPort->Node()->Name() ) ;
555 string * aLinkToNodeName = new string( InPort->Node()->Name() ) ;
556 //cout << "Graph_Impl::StreamMerge " << aLinkFromNodeName << "(" << OutPort->Name() << ") ---> "
557 // << aLinkToNodeName << "(" << InPort->Name() << ")" << endl ;
558 RetVal = DataFlowEditor()->AddLink( DataFlowEditor()->Graph()->GetGraphNode( aMapOfNodes[ aLinkFromNodeName->c_str() ] )->Name() ,
560 DataFlowEditor()->Graph()->GetGraphNode( aMapOfNodes[ aLinkToNodeName->c_str() ] )->Name() ,
562 //cout << "Graph_Impl::StreamMerge " << aLinkFromNodeName << "(" << OutPort->Name() << ") ---> "
563 // << aLinkToNodeName << "(" << InPort->Name() << ") RetVal" << RetVal << endl ;
566 for ( j = 1 ; j <= aLink->CoordsSize() ; j++ ) {
568 RetVal = aLink->Coords( j , X , Y ) ;
571 RetVal = DataFlowEditor()->AddLinkCoord( DataFlowEditor()->Graph()->GetGraphNode( aMapOfNodes[ aLinkFromNodeName->c_str() ] )->Name() ,
573 DataFlowEditor()->Graph()->GetGraphNode( aMapOfNodes[ aLinkToNodeName->c_str() ] )->Name() ,
581 delete aLinkFromNodeName ;
582 delete aLinkToNodeName ;
588 for ( i = 0 ; i < (int ) aGraphPorts->length() ; i++ ) {
589 SUPERV::StreamPort_var aPort = (*aGraphPorts)[ i ] ;
590 if ( !aPort->IsGate() ) {
591 MESSAGE( "Graph_Impl::StreamMerge " << i << ". " << aPort->Node()->Name() << " " << aPort->Name() ) ;
592 char * aPortName = aPort->Name() ;
593 char * aNodeName = new char[ strlen( aPortName ) + 1 ] ;
594 strcpy( aNodeName , aPortName ) ;
595 // char * thePortName = strchr( aNodeName , '\\' ) ;
596 char * thePortName = strchr( aNodeName , '_' ) ;
597 thePortName[ 0 ] = '\0' ;
598 bool hasinput = aStreamGraph->Node( aNodeName )->Port( thePortName + 1 )->HasInput() ;
599 // cout << "Graph_Impl::StreamMerge " << " aNodeName " << aNodeName << " aPort " << thePortName + 1
600 // << " HasInput " << hasinput << endl ;
602 RetVal = DataFlowEditor()->AddInputData( DataFlowEditor()->StreamGraph()->GetGraphNode( aMapOfNodes[ aNodeName ] )->Name() ,
604 *(aPort->ToAny()) ) ;
606 delete [] aNodeName ;
615 endService( "StreamGraph_Impl::StreamMerge" );