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 ||
269 //JR 14.02.2005 : Debug : we must see also that links !
270 // ( theNode != NULL && !theNode->IsEndSwitchNode() &&
271 !strcmp( theNode->Name() , aNode->Name() ) ) {
272 if ( anInPort->IsLoop() || anOutPort->IsLoop() ||
273 ( aNode->IsEndLoopNode() && !strcmp( aNode->CoupledNode()->Name() ,
274 anOutPort->NodeName() ) ) ) {
275 MESSAGE( "StreamLink " << anOutPort->NodeName() << "("
276 << anOutPort->PortName() << ") --> " << aNode->Name() << "("
277 << anInPort->PortName() << ")" << " ignored" ) ;
279 else if ( CORBA::is_nil( anOutPort->InPortObjRef( anInPort ) ) ) {
281 beginService( "StreamGraph_Impl::StreamLinks" );
284 GraphEditor::InNode * anOutNode = NULL ;
285 anOutNode = (GraphEditor::InNode * ) DataFlowEditor()->Graph()->GetChangeGraphNode( anOutPort->NodeName() )->GetInNode() ;
288 StreamLink_Impl * myStreamLink = new StreamLink_Impl(
289 _Orb , _Poa , _ContId ,
290 instanceName() , interfaceName() ,
293 anInPort->PortName() ,
295 anOutPort->PortName() ,
298 PortableServer::ObjectId * id = myStreamLink->getId() ;
299 CORBA::Object_var obj = _poa->id_to_reference(*id);
300 SUPERV::StreamLink_var iobject ;
301 iobject = SUPERV::StreamLink::_narrow(obj) ;
302 RetVal->length( countlink + 1 ) ;
303 RetVal[ countlink++ ] = SUPERV::StreamLink::_duplicate( iobject ) ;
304 anOutPort->AddInPortObjRef( anInPort , SUPERV::StreamLink::_duplicate( iobject ) ) ;
305 MESSAGE( "Link" << countlink-1 << " "
306 << RetVal[countlink-1]->OutStreamPort()->Node()->Name() << "("
307 << RetVal[countlink-1]->OutStreamPort()->Name() << ") --> "
308 << RetVal[countlink-1]->InStreamPort()->Node()->Name() << "("
309 << RetVal[countlink-1]->InStreamPort()->Name() << ")" ) ;
314 RetVal->length( countlink + 1 ) ;
315 RetVal[ countlink++ ] = SUPERV::StreamLink::_duplicate( SUPERV::StreamLink::_narrow( anOutPort->InPortObjRef( anInPort ) ) ) ;
316 MESSAGE( "Link" << countlink-1 << " "
317 << RetVal[countlink-1]->OutStreamPort()->Node()->Name() << "("
318 << RetVal[countlink-1]->OutStreamPort()->Name() << ") --> "
319 << RetVal[countlink-1]->InStreamPort()->Node()->Name() << "("
320 << RetVal[countlink-1]->InStreamPort()->Name() << ")" ) ;
328 for ( j = 0 ; j < aNode->GetNodeOutPortsSize() ; j++ ) {
329 GraphBase::OutPort * anOutPort = aNode->GetChangeNodeOutPort( j ) ;
331 for ( k = 0 ; k < anOutPort->InPortsSize() ; k++ ) {
332 GraphBase::InPort * anInPort = anOutPort->ChangeInPorts( k ) ;
333 GraphEditor::InNode * toNode = (GraphEditor::InNode * ) DataFlowEditor()->Graph()->GetChangeGraphNode( anInPort->NodeName() )->GetInNode() ;
334 if ( theNode == NULL ||
335 !strcmp( theNode->Name() , aNode->Name() ) ) {
336 if ( anInPort->IsDataStream() ) {
338 //JR 14.02.2005 : Debug : we must see also that links !
339 // if ( theNode || ( toNode->IsEndSwitchNode() && !aNode->IsSwitchNode() ) ) {
340 if ( anInputParam == NULL ||
341 !strcmp( anInPort->PortName() , anInputParam ) ) {
342 MESSAGE( "StreamLink " << anOutPort->NodeName() << "("
343 << anOutPort->PortName() << ") --> " << toNode->Name() << "("
344 << anInPort->PortName() << ")" ) ;
345 MESSAGE( " IOR " << DataFlowEditor()->ObjectToString( anOutPort->InPortObjRef( anInPort ) ) ) ;
346 if ( anInPort->IsLoop() || anOutPort->IsLoop() ||
347 ( toNode->IsEndLoopNode() && !strcmp( toNode->CoupledNode()->Name() ,
348 anOutPort->NodeName() ) ) ) {
349 MESSAGE( "StreamLink " << anOutPort->NodeName() << "("
350 << anOutPort->PortName() << ") --> " << toNode->Name() << "("
351 << anInPort->PortName() << ")" << " ignored" ) ;
353 else if ( CORBA::is_nil( anOutPort->InPortObjRef( anInPort ) ) ) {
355 beginService( "Graph_Impl::StreamLinks" );
359 StreamLink_Impl * myStreamLink = new StreamLink_Impl(
360 _Orb , _Poa , _ContId ,
361 instanceName() , interfaceName() ,
364 anInPort->PortName() ,
366 anOutPort->PortName() ,
369 PortableServer::ObjectId * id = myStreamLink->getId() ;
370 CORBA::Object_var obj = _poa->id_to_reference(*id);
371 SUPERV::StreamLink_var iobject ;
372 iobject = SUPERV::StreamLink::_narrow(obj) ;
373 RetVal->length( countlink + 1 ) ;
374 RetVal[ countlink++ ] = SUPERV::StreamLink::_duplicate( iobject ) ;
375 anOutPort->AddInPortObjRef( anInPort , SUPERV::StreamLink::_duplicate( iobject ) ) ;
376 MESSAGE( "Link" << countlink-1 << " "
377 << RetVal[countlink-1]->OutStreamPort()->Node()->Name() << "("
378 << RetVal[countlink-1]->OutStreamPort()->Name() << ") --> "
379 << RetVal[countlink-1]->InStreamPort()->Node()->Name() << "("
380 << RetVal[countlink-1]->InStreamPort()->Name() << ")" ) ;
384 RetVal->length( countlink + 1 ) ;
385 RetVal[ countlink++ ] = SUPERV::StreamLink::_duplicate( SUPERV::StreamLink::_narrow( anOutPort->InPortObjRef( anInPort ) ) ) ;
386 MESSAGE( "Link" << countlink-1 << " "
387 << RetVal[countlink-1]->OutStreamPort()->Node()->Name() << "("
388 << RetVal[countlink-1]->OutStreamPort()->Name() << ") --> "
389 << RetVal[countlink-1]->InStreamPort()->Node()->Name() << "("
390 << RetVal[countlink-1]->InStreamPort()->Name() << ")" ) ;
394 MESSAGE( "StreamLink " << anOutPort->NodeName() << "("
395 << anOutPort->PortName() << ") --> " << toNode->Name() << "("
396 << anInPort->PortName() << ")" << " skipped" ) ;
405 const char * NodeName = "" ;
406 const char * InputParamName = "" ;
408 NodeName = theNode->Name() ;
410 if ( anInputParam ) {
411 InputParamName = anInputParam ;
413 MESSAGE( RetVal->length() << " StreamLinks of Node " << NodeName << " and of InPort " << InputParamName ) ;
414 for ( i = 0 ; i < (int ) RetVal->length() ; i++ ) {
415 MESSAGE( "Link" << i << " " << RetVal[i]->OutStreamPort()->Node()->Name() << "("
416 << RetVal[i]->OutStreamPort()->Name() << ") --> "
417 << RetVal[i]->InStreamPort()->Node()->Name() << "("
418 << RetVal[i]->InStreamPort()->Name() << ")" ) ;
422 endService( "StreamGraph_Impl::StreamLinks" );
425 return ( RetVal._retn() ) ;
428 bool StreamGraph_Impl::SetStreamParams( CORBA::Long Timeout ,
429 const SUPERV::KindOfDataStreamTrace DataStreamTrace ,
430 CORBA::Double DeltaTime ) {
433 sts = DataFlowEditor()->StreamGraph()->SetStreamParams( Timeout , DataStreamTrace , DeltaTime ) ;
435 DataFlowEditor()->UnValid() ;
441 void StreamGraph_Impl::StreamParams( CORBA::Long & Timeout ,
442 SUPERV::KindOfDataStreamTrace & DataStreamTrace ,
443 CORBA::Double & DeltaTime ) {
445 DataFlowEditor()->StreamGraph()->StreamParams( Timeout , DataStreamTrace , DeltaTime ) ;
449 CORBA::Long StreamGraph_Impl::SubStreamGraphsNumber() {
450 // beginService( "StreamGraph_Impl::StreamGraphsNumber" );
451 CORBA::Long RetVal = 0 ;
452 if ( DataFlowEditor()->IsExecutable() && !IsMacro() ) {
453 RetVal = DataFlowEditor()->SubStreamGraphsNumber() ;
455 // endService( "StreamGraph_Impl::SubStreamGraphsNumber" );
459 SUPERV::ListOfNodes * StreamGraph_Impl::SubStreamGraphsNodes( CORBA::Long aSubStreamGraphNumber ) {
460 beginService( "StreamGraph_Impl::SubStreamGraphsNodes" );
461 SUPERV::ListOfNodes_var RetVal = new SUPERV::ListOfNodes ;
462 if ( DataFlowEditor()->IsEditing() && !IsMacro() ) {
463 SUPERV::ListOfNodes * aGraphNodes = Nodes() ;
466 for ( i = 0 ; i < (int ) aGraphNodes->CNodes.length() ; i++ ) {
467 SUPERV::CNode_var aNode = (aGraphNodes->CNodes)[ i ] ;
468 if ( aNode->SubStreamGraph() == aSubStreamGraphNumber ) {
469 RetVal = SetNode( RetVal , DataFlowEditor()->Graph()->GetChangeGraphNode( aNode->Name() ) ) ;
473 for ( i = 0 ; i < (int ) aGraphNodes->FNodes.length() ; i++ ) {
474 SUPERV::FNode_var aNode = (aGraphNodes->FNodes)[ i ] ;
475 if ( aNode->SubStreamGraph() == aSubStreamGraphNumber ) {
476 RetVal = SetNode( RetVal , DataFlowEditor()->Graph()->GetChangeGraphNode( aNode->Name() ) ) ;
480 for ( i = 0 ; i < (int ) aGraphNodes->INodes.length() ; i++ ) {
481 SUPERV::INode_var aNode = (aGraphNodes->INodes)[ i ] ;
482 if ( aNode->SubStreamGraph() == aSubStreamGraphNumber ) {
483 RetVal = SetNode( RetVal , DataFlowEditor()->Graph()->GetChangeGraphNode( aNode->Name() ) ) ;
487 for ( i = 0 ; i < (int ) aGraphNodes->GNodes.length() ; i++ ) {
488 SUPERV::GNode_var aNode = (aGraphNodes->GNodes)[ i ] ;
489 if ( aNode->SubStreamGraph() == aSubStreamGraphNumber ) {
490 RetVal = SetNode( RetVal , DataFlowEditor()->Graph()->GetChangeGraphNode( aNode->Name() ) ) ;
494 for ( i = 0 ; i < (int ) aGraphNodes->LNodes.length() ; i++ ) {
495 SUPERV::LNode_var aNode = (aGraphNodes->LNodes)[ i ] ;
496 if ( aNode->SubStreamGraph() == aSubStreamGraphNumber ) {
497 RetVal = SetNode( RetVal , DataFlowEditor()->Graph()->GetChangeGraphNode( aNode->Name() ) ) ;
501 for ( i = 0 ; i < (int ) aGraphNodes->ELNodes.length() ; i++ ) {
502 SUPERV::ELNode_var aNode = (aGraphNodes->ELNodes)[ i ] ;
503 if ( aNode->SubStreamGraph() == aSubStreamGraphNumber ) {
504 RetVal = SetNode( RetVal , DataFlowEditor()->Graph()->GetChangeGraphNode( aNode->Name() ) ) ;
508 for ( i = 0 ; i < (int ) aGraphNodes->SNodes.length() ; i++ ) {
509 SUPERV::SNode_var aNode = (aGraphNodes->SNodes)[ i ] ;
510 if ( aNode->SubStreamGraph() == aSubStreamGraphNumber ) {
511 RetVal = SetNode( RetVal , DataFlowEditor()->Graph()->GetChangeGraphNode( aNode->Name() ) ) ;
515 for ( i = 0 ; i < (int ) aGraphNodes->ESNodes.length() ; i++ ) {
516 SUPERV::ESNode_var aNode = (aGraphNodes->ESNodes)[ i ] ;
517 if ( aNode->SubStreamGraph() == aSubStreamGraphNumber ) {
518 RetVal = SetNode( RetVal , DataFlowEditor()->Graph()->GetChangeGraphNode( aNode->Name() ) ) ;
522 endService( "StreamGraph_Impl::SubStreamGraphsNodes" );
523 return ( RetVal._retn() ) ;
526 SUPERV::Graph_ptr StreamGraph_Impl::ToFlowGraph() {
527 SUPERV::Graph_var iobject = SUPERV::Graph::_nil() ;
528 beginService( "StreamGraph_Impl::ToFlowGraph" );
530 // Graph_Impl * myFlowGraph = new Graph_Impl( _Orb , _Poa , _ContId ,
531 // instanceName() , interfaceName() ) ;
532 // PortableServer::ObjectId * id = myFlowGraph->getId() ;
533 // CORBA::Object_var obj = _poa->id_to_reference(*id);
534 if ( !CORBA::is_nil( DataFlowEditor()->StreamGraph()->ObjRef() ) ) {
535 iobject = SUPERV::Graph::_narrow( DataFlowEditor()->StreamGraph()->ObjRef() ) ;
538 endService( "StreamGraph_Impl::ToFlowGraph" );
539 return SUPERV::Graph::_duplicate( iobject ) ;
542 bool StreamGraph_Impl::StreamMerge(const SUPERV::StreamGraph_ptr aStreamGraph ) {
543 beginService( "StreamGraph_Impl::StreamMerge" );
544 bool RetVal = false ;
546 map< string , int > aMapOfNodes ;
547 RetVal = Merge( aStreamGraph , aMapOfNodes ) ;
549 SUPERV::ListOfStreamLinks * aGraphLinks = aStreamGraph->GStreamLinks() ;
550 SUPERV::ListOfStreamPorts * aGraphPorts = aStreamGraph->StreamPorts() ;
551 //cout << "Graph_Impl::StreamMerge " << aGraphLinks->length() << " links " << aGraphPorts->length()
552 // << " GraphPorts" << endl ;
554 for ( i = 0 ; i < (int ) aGraphLinks->length() ; i++ ) {
555 SUPERV::StreamLink_var aLink = (*aGraphLinks)[ i ] ;
556 SUPERV::StreamPort_var OutPort = aLink->OutStreamPort() ;
557 SUPERV::StreamPort_var InPort = aLink->InStreamPort() ;
558 string * aLinkFromNodeName = new string( OutPort->Node()->Name() ) ;
559 string * aLinkToNodeName = new string( InPort->Node()->Name() ) ;
560 //cout << "Graph_Impl::StreamMerge " << aLinkFromNodeName << "(" << OutPort->Name() << ") ---> "
561 // << aLinkToNodeName << "(" << InPort->Name() << ")" << endl ;
562 RetVal = DataFlowEditor()->AddLink( DataFlowEditor()->Graph()->GetGraphNode( aMapOfNodes[ aLinkFromNodeName->c_str() ] )->Name() ,
564 DataFlowEditor()->Graph()->GetGraphNode( aMapOfNodes[ aLinkToNodeName->c_str() ] )->Name() ,
566 //cout << "Graph_Impl::StreamMerge " << aLinkFromNodeName << "(" << OutPort->Name() << ") ---> "
567 // << aLinkToNodeName << "(" << InPort->Name() << ") RetVal" << RetVal << endl ;
570 for ( j = 1 ; j <= aLink->CoordsSize() ; j++ ) {
572 RetVal = aLink->Coords( j , X , Y ) ;
575 RetVal = DataFlowEditor()->AddLinkCoord( DataFlowEditor()->Graph()->GetGraphNode( aMapOfNodes[ aLinkFromNodeName->c_str() ] )->Name() ,
577 DataFlowEditor()->Graph()->GetGraphNode( aMapOfNodes[ aLinkToNodeName->c_str() ] )->Name() ,
585 delete aLinkFromNodeName ;
586 delete aLinkToNodeName ;
592 for ( i = 0 ; i < (int ) aGraphPorts->length() ; i++ ) {
593 SUPERV::StreamPort_var aPort = (*aGraphPorts)[ i ] ;
594 if ( !aPort->IsGate() ) {
595 MESSAGE( "Graph_Impl::StreamMerge " << i << ". " << aPort->Node()->Name() << " " << aPort->Name() ) ;
596 char * aPortName = aPort->Name() ;
597 char * aNodeName = new char[ strlen( aPortName ) + 1 ] ;
598 strcpy( aNodeName , aPortName ) ;
599 // char * thePortName = strchr( aNodeName , '\\' ) ;
600 char * thePortName = strchr( aNodeName , '_' ) ;
601 thePortName[ 0 ] = '\0' ;
602 bool hasinput = aStreamGraph->Node( aNodeName )->Port( thePortName + 1 )->HasInput() ;
603 // cout << "Graph_Impl::StreamMerge " << " aNodeName " << aNodeName << " aPort " << thePortName + 1
604 // << " HasInput " << hasinput << endl ;
606 RetVal = DataFlowEditor()->AddInputData( DataFlowEditor()->StreamGraph()->GetGraphNode( aMapOfNodes[ aNodeName ] )->Name() ,
608 *(aPort->ToAny()) ) ;
610 delete [] aNodeName ;
619 endService( "StreamGraph_Impl::StreamMerge" );