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 : Graph_Impl.cxx
25 // Author : Jean Rahuel
35 //#include "utilities.h"
37 #include "StreamGraph_Impl.hxx"
39 #include "DataFlowEditor_DataFlow.hxx"
41 extern GraphExecutor::FiniteStateMachine * theAutomaton ;
43 static void CreateEditor( CORBA::ORB_ptr orb ,
44 const char *instanceName ,
45 const char *aDataFlowName ,
46 const SUPERV::KindOfNode aKindOfNode ,
48 GraphEditor::DataFlow ** aDataFlowEditor ) {
49 // string dbgfile = "/tmp/" ;
50 bool aXmlFile = false ;
52 dbgfile += instanceName ;
54 int lenname = strlen( aDataFlowName ) ;
55 char * theDataFlowName = new char [ lenname+1 ] ;
56 strcpy( theDataFlowName , aDataFlowName ) ;
57 if ( aDataFlowName ) {
58 if ( lenname > 4 && !strcmp( &aDataFlowName[ lenname - 4 ] , ".xml" ) ) {
59 strncpy( theDataFlowName , &aDataFlowName[ 0 ] , lenname-4 ) ;
60 theDataFlowName[ lenname-4 ] = '\0' ;
63 for ( i = lenname - 5 ; i >= 0 ; i-- ) {
64 if ( aDataFlowName[ i ] == '/' ) {
65 strncpy( theDataFlowName , &aDataFlowName[ i + 1 ] , lenname-5-i ) ;
66 theDataFlowName[ lenname-5-i ] = '\0' ;
72 strcpy( theDataFlowName , &aDataFlowName[ 0 ] ) ;
75 string theDataFlowInstanceName = theDataFlowName ;
77 // theDataFlowInstanceName = theAutomaton->GraphInstanceName( theDataFlowName ) ;
79 dbgfile += theDataFlowInstanceName ;
80 dbgfile = dbgfile + "_" + theAutomaton->DbgFileNumber() + ".log" ;
81 SALOME_NamingService * NamingService = new SALOME_NamingService( orb ) ;
82 *aDataFlowEditor = new GraphEditor::DataFlow( orb , NamingService ,
83 theDataFlowInstanceName.c_str() , dbgfile.c_str() ,
85 MESSAGE( "CreateEditor " << theDataFlowName << " uniquely named " << theDataFlowInstanceName << " created with "
86 << dbgfile.c_str() ) ;
88 delete [] theDataFlowName ;
91 static void CreateExecutor( CORBA::ORB_ptr orb ,
92 const char *instanceName ,
93 const char *aDataFlowName ,
94 const SUPERV::KindOfNode aKindOfNode ,
96 GraphExecutor::DataFlow ** aDataFlowExecutor ) {
97 // string dbgfile = "/tmp/" ;
99 dbgfile += instanceName ;
101 int lenname = strlen( aDataFlowName ) ;
102 char * theDataFlowName = new char [ lenname+1 ] ;
103 strcpy( theDataFlowName , aDataFlowName ) ;
104 if ( aDataFlowName ) {
105 strcpy( theDataFlowName , &aDataFlowName[ 0 ] ) ;
107 string theDataFlowInstanceName = theDataFlowName ;
108 dbgfile += theDataFlowInstanceName ;
109 dbgfile = dbgfile + "_" + theAutomaton->DbgFileNumber() ;
112 astr << theAutomaton->ExecNumber() ;
113 dbgfile += astr.str() ;
114 dbgfile += string( "_Exec.log" ) ;
116 SALOME_NamingService * NamingService = new SALOME_NamingService( orb ) ;
117 *aDataFlowExecutor = new GraphExecutor::DataFlow( orb , NamingService ,
118 theDataFlowInstanceName.c_str() , dbgfile.c_str() ,
120 MESSAGE( "CreateExecutor " << theDataFlowName << " " << theDataFlowInstanceName << " created with "
121 << dbgfile.c_str() ) ;
123 delete [] theDataFlowName ;
126 Graph_Impl::Graph_Impl( CORBA::ORB_ptr orb ,
127 PortableServer::POA_ptr poa ,
128 PortableServer::ObjectId * contId ,
129 const char *instanceName ,
130 const char *interfaceName ,
131 const char *aDataFlowName ,
132 const SUPERV::KindOfNode aKindOfNode ) :
133 GNode_Impl( orb , poa , contId , instanceName , interfaceName , aDataFlowName , aKindOfNode ) {
134 // MESSAGE("Graph_Impl::Graph_Impl activate object instanceName("
135 // << instanceName << ") interfaceName(" << interfaceName << ") --> "
136 // << hex << (void *) this << dec )
137 // beginService( "Graph_Impl::Graph_Impl" );
138 _Orb = CORBA::ORB::_duplicate(orb);
141 _DebugFileName = NULL ;
142 if ( aKindOfNode == SUPERV::DataFlowGraph || aKindOfNode == SUPERV::MacroNode ) {
143 // MESSAGE( "Graph_Impl::Graph_Impl _poa->activate_object" );
145 _id = _poa->activate_object(_thisObj);
148 // MESSAGE( "Graph_Impl::Graph_Impl NO _poa->activate_object " );
151 if ( aKindOfNode == SUPERV::DataFlowGraph || aKindOfNode == SUPERV::DataStreamGraph ) {
153 GraphEditor::DataFlow * aDataFlowEditor ;
154 CreateEditor( orb , instanceName , aDataFlowName , aKindOfNode ,
155 dbgfile , &aDataFlowEditor ) ;
157 if ( _DebugFileName ) {
158 delete [] _DebugFileName ;
160 _DebugFileName = new char[ strlen( dbgfile.c_str() )+1 ] ;
161 strcpy( _DebugFileName , dbgfile.c_str() ) ;
163 _NamingService = new SALOME_NamingService( orb ) ;
164 DataFlowEditor( aDataFlowEditor ) ;
165 DataFlowEditor()->Graph()->GraphEditor( aDataFlowEditor ) ;
166 DataFlowEditor()->Graph()->SetObjImpl( this ) ;
168 pthread_mutex_init( &_MutexExecutorWait , NULL ) ;
169 // DataFlowExecutor( NULL ) ;
170 // endService( "Graph_Impl::Graph_Impl" );
173 Graph_Impl::Graph_Impl( CORBA::ORB_ptr orb ,
174 PortableServer::POA_ptr poa ,
175 PortableServer::ObjectId * contId ,
176 const char *instanceName ,
177 const char *interfaceName ,
178 GraphEditor::DataFlow * aDataFlowEditor ,
179 GraphEditor::InNode * aDataFlowNode ) :
180 GNode_Impl( orb , poa , contId , instanceName , interfaceName , aDataFlowEditor , aDataFlowNode ) {
181 // beginService( "Graph_Impl::Graph_Impl" );
182 // MESSAGE( aDataFlowEditor->Graph()->Name() << " " );
183 if ( aDataFlowEditor->Graph()->IsDataFlowNode() ||
184 ( aDataFlowNode && aDataFlowNode->IsMacroNode() ) ) {
185 // MESSAGE( "Graph_Impl::Graph_Impl _poa->activate_object" );
187 _id = _poa->activate_object(_thisObj);
190 // MESSAGE( "Graph_Impl::Graph_Impl NO _poa->activate_object " );
192 _Orb = CORBA::ORB::_duplicate(orb);
195 _DebugFileName = NULL ;
196 DataFlowEditor( aDataFlowEditor ) ;
197 DataFlowEditor()->Graph()->GraphEditor( aDataFlowEditor ) ;
198 DataFlowEditor()->Graph()->SetObjImpl( this ) ;
199 pthread_mutex_init( &_MutexExecutorWait , NULL ) ;
200 // DataFlowExecutor( NULL ) ;
201 // endService( "Graph_Impl::Graph_Impl" );
204 Graph_Impl::Graph_Impl() {
207 Graph_Impl::~Graph_Impl() {
208 beginService( "Graph_Impl::~Graph_Impl" );
209 endService( "Graph_Impl::~Graph_Impl" );
212 void Graph_Impl::destroy() {
213 beginService( "Graph_Impl::destroy" );
214 if ( DataFlowNode() && DataFlowNode()->ComputingNode()->IsMacroNode() ) {
215 SUPERV::Graph_var aGraph = DataFlowNode()->GOTONode()->MacroObject() ;
216 GNode_Impl::Delete() ;
217 if ( !CORBA::is_nil( aGraph ) ) {
222 SUPERV::Graph_var aGraph = DataFlowEditor()->Graph()->MacroObject() ;
223 GNode_Impl::Delete() ;
224 if ( !CORBA::is_nil( aGraph ) ) {
228 _poa->deactivate_object(*_id) ;
229 CORBA::release(_poa) ;
231 _thisObj->_remove_ref();
232 endService( "Graph_Impl::destroy" );
236 char* Graph_Impl::getIOR() {
238 return CORBA::string_dup( NULLSTRING ) ;
240 else if ( CORBA::is_nil( myServant ) ) {
241 PortableServer::ObjectId* id = getId();
242 CORBA::Object_var obj;
243 obj = _poa->id_to_reference(*id);
244 myServant = SUPERV::Graph::_narrow(obj);
246 return(CORBA::string_dup(_Orb->object_to_string(myServant)));
249 SUPERV::Graph_ptr Graph_Impl::Copy() {
250 beginService( "Graph_Impl::Copy" );
251 SUPERV::Graph_var iobject = SUPERV::Graph::_nil() ;
253 Graph_Impl * myGraph ;
254 myGraph = new Graph_Impl( _Orb , _Poa, _ContId,
255 instanceName() , interfaceName() ,
256 DataFlowEditor()->Graph()->Name() , SUPERV::DataFlowGraph ) ;
257 PortableServer::ObjectId * id = myGraph->getId() ;
258 CORBA::Object_var obj = _poa->id_to_reference(*id);
259 iobject = SUPERV::Graph::_narrow(obj) ;
260 GraphBase::ListOfSGraphs * aListOfSGraphs = GetGraphs() ;
261 myGraph->LoadGraphs( aListOfSGraphs ) ;
263 endService( "Graph_Impl::Copy" );
264 return SUPERV::Graph::_duplicate(iobject) ;
267 void Graph_Impl::ReadOnly() {
268 DataFlowEditor()->ReadOnly() ;
271 SUPERV::INode_ptr Graph_Impl::Node() {
272 // beginService( "Graph_Impl::Node" );
273 PortableServer::ObjectId * id = getId() ;
274 CORBA::Object_var obj = _poa->id_to_reference(*id);
275 SUPERV::Graph_var iobject ;
276 iobject = SUPERV::Graph::_narrow(obj) ;
277 // endService( "Graph_Impl::Node" );
278 return SUPERV::Graph::_duplicate(iobject) ;
281 GraphBase::ListOfSGraphs * Graph_Impl::GetGraphs() {
282 return DataFlowEditor()->GetDataFlows() ;
285 bool Graph_Impl::LoadGraphs( GraphBase::ListOfSGraphs * aListOfDataFlows ) {
286 beginService( "Graph_Impl::LoadGraphs" );
287 bool RetVal = false ;
288 if ( DataFlowEditor()->IsEditing() ) {
289 // RetVal = DataFlowEditor()->LoadDataFlows( aListOfDataFlows ) ;
290 if ( CORBA::is_nil( LoadDataFlows( DataFlowEditor() , aListOfDataFlows , 0 ) ) ) {
294 endService( "Graph_Impl::LoadGraphs" );
298 bool Graph_Impl::Import(const char * aXmlFile ) {
299 beginService( "Graph_Impl::Import" );
300 bool RetVal = false ;
301 if ( DataFlowEditor()->IsEditing() && !IsMacro() ) {
302 GraphBase::ListOfSGraphs aListOfDataFlows ;
303 RetVal = DataFlowEditor()->LoadXml( aXmlFile , aListOfDataFlows ) ;
304 if ( RetVal && aXmlFile != NULL ) {
305 // RetVal = DataFlowEditor()->LoadDataFlows( &aListOfDataFlows ) ;
306 if ( CORBA::is_nil( LoadDataFlows( DataFlowEditor() , &aListOfDataFlows , 0 ) ) ) {
311 endService( "Graph_Impl::Import" );
315 bool Graph_Impl::Export(const char * anXmlFile ) {
316 beginService( "Graph_Impl::Export" );
317 bool RetVal = false ;
319 char * aFile = new char [ strlen( anXmlFile ) + 5 ] ;
320 strcpy( aFile , anXmlFile ) ;
321 int len = strlen( aFile ) ;
322 if ( !strcmp( &aFile[ len - 4 ] , ".xml" ) ) {
324 else if ( !strcmp( &aFile[ len - 3 ] , ".py" ) ) {
325 strcpy( &aFile[ len - 3 ] , ".xml" ) ;
326 len = strlen( aFile ) ;
329 strcat( aFile , ".xml" ) ;
330 len = strlen( aFile ) ;
332 RetVal = DataFlowEditor()->SaveXml( aFile ) ;
334 strcpy( &aFile[ len - 4 ] , ".py" ) ;
335 RetVal = DataFlowEditor()->SavePy( aFile ) ;
339 endService( "Graph_Impl::Export" );
343 SUPERV::CNode_ptr Graph_Impl::CNode( const SALOME_ModuleCatalog::Service &NodeService ) {
344 beginService( "Graph_Impl::CNode" );
345 SUPERV::CNode_var iobject = SUPERV::CNode::_nil() ;
346 if ( DataFlowEditor()->IsEditing() && !DataFlowEditor()->IsReadOnly() && !IsMacro() ) {
347 CNode_Impl * myNode = new CNode_Impl( _Orb , _Poa , _ContId ,
348 instanceName() , interfaceName() ,
350 NodeService , NULLSTRING ,
351 SUPERV::ComputingNode , NULLSTRING ) ;
352 if ( myNode->DataFlowNode() ) {
353 PortableServer::ObjectId * id = myNode->getId() ;
354 CORBA::Object_var obj = _poa->id_to_reference(*id);
355 iobject = SUPERV::CNode::_narrow(obj) ;
356 myNode->SetObjRef( SUPERV::CNode::_duplicate( iobject ) ) ;
359 DataFlowEditor()->UnValid() ;
360 endService( "Graph_Impl::CNode" );
361 return SUPERV::CNode::_duplicate( iobject ) ;
364 SUPERV::FNode_ptr Graph_Impl::FNode( const char * NodeComponentName ,
365 const char * NodeInterfaceName ,
366 const SALOME_ModuleCatalog::Service &NodeService ) {
367 beginService( "Graph_Impl::FNode" );
368 SUPERV::FNode_var iobject = SUPERV::FNode::_nil() ;
369 if ( DataFlowEditor()->IsEditing() && !DataFlowEditor()->IsReadOnly() && !IsMacro() ) {
370 FNode_Impl * myNode = new FNode_Impl( _Orb , _Poa , _ContId ,
371 instanceName() , interfaceName() ,
375 NodeInterfaceName ) ;
376 if ( myNode->DataFlowNode() ) {
377 PortableServer::ObjectId * id = myNode->getId() ;
378 CORBA::Object_var obj = _poa->id_to_reference(*id);
379 iobject = SUPERV::FNode::_narrow(obj) ;
380 myNode->SetObjRef( SUPERV::FNode::_duplicate( iobject ) ) ;
383 DataFlowEditor()->UnValid() ;
384 endService( "Graph_Impl::FNode" );
385 return SUPERV::FNode::_duplicate( iobject ) ;
388 SUPERV::INode_ptr Graph_Impl::INode( const char * FuncName ,
389 const SUPERV::ListOfStrings & PythonFuntion ) {
390 beginService( "Graph_Impl::INode" );
391 SUPERV::INode_var iobject = SUPERV::INode::_nil() ;
392 if ( DataFlowEditor()->IsEditing() && !DataFlowEditor()->IsReadOnly() && !IsMacro() ) {
393 INode_Impl * myNode = new INode_Impl( _Orb , _Poa , _ContId ,
394 instanceName() , interfaceName() ,
396 FuncName , PythonFuntion ,
397 SUPERV::InLineNode ) ;
398 if ( myNode->DataFlowNode() ) {
399 PortableServer::ObjectId * id = myNode->getId() ;
400 CORBA::Object_var obj = _poa->id_to_reference(*id);
401 iobject = SUPERV::INode::_narrow(obj) ;
402 myNode->SetObjRef( SUPERV::INode::_duplicate( iobject ) ) ;
405 endService( "Graph_Impl::INode" );
406 return SUPERV::INode::_duplicate( iobject ) ;
410 SUPERV::GNode_ptr Graph_Impl::GNode( const char * FuncName ,
411 const SUPERV::ListOfStrings & PythonFuntion ,
412 const char * anInLineNode ) {
413 beginService( "Graph_Impl::GNode" );
414 SUPERV::GNode_var iobject = SUPERV::GNode::_nil() ;
415 if ( DataFlowEditor()->IsEditing() && !DataFlowEditor()->IsReadOnly() && !IsMacro() ) {
416 GNode_Impl * myNode = new GNode_Impl( _Orb , _Poa , _ContId ,
417 instanceName() , interfaceName() ,
419 FuncName , PythonFuntion ,
421 if ( myNode->DataFlowNode() ) {
422 PortableServer::ObjectId * id = myNode->getId() ;
423 CORBA::Object_var obj = _poa->id_to_reference(*id);
424 iobject = SUPERV::GNode::_narrow(obj) ;
425 myNode->SetObjRef( SUPERV::GNode::_duplicate( iobject ) ) ;
426 if ( strlen( anInLineNode ) ) {
427 GraphBase::InLineNode * CoupledINode = (GraphBase::InLineNode * ) DataFlowEditor()->Graph()->GetGraphNode( anInLineNode ) ;
428 if ( anInLineNode ) {
429 myNode->SetCoupled( anInLineNode ) ;
430 Link( myNode->Port( "OutGate" ) , CoupledINode->ObjRef()->Port( "InGate" ) ) ;
435 DataFlowEditor()->UnValid() ;
436 endService( "Graph_Impl::GNode" );
437 return SUPERV::GNode::_duplicate( iobject ) ;
440 SUPERV::LNode_ptr Graph_Impl::LNode( const char * InitName ,
441 const SUPERV::ListOfStrings & InitFunction ,
442 const char * MoreName ,
443 const SUPERV::ListOfStrings & MoreFunction ,
444 const char * NextName ,
445 const SUPERV::ListOfStrings & NextFunction ,
446 SUPERV::INode_out anEndOfLoop ) {
447 beginService( "Graph_Impl::LNode" );
448 SUPERV::LNode_var iobject = SUPERV::LNode::_nil() ;
449 SUPERV::ELNode_var iendobject = SUPERV::ELNode::_nil() ;
450 if ( DataFlowEditor()->IsEditing() && !DataFlowEditor()->IsReadOnly() && !IsMacro() ) {
451 GraphBase::ListOfFuncName FuncNameList ;
452 FuncNameList.resize(3) ;
453 FuncNameList[0] = InitName ;
454 FuncNameList[1] = MoreName ;
455 FuncNameList[2] = NextName ;
456 GraphBase::ListOfPythonFunctions PythonFunctionList ;
457 PythonFunctionList.resize(3) ;
458 PythonFunctionList[0] = &InitFunction ;
459 PythonFunctionList[1] = &MoreFunction ;
460 PythonFunctionList[2] = &NextFunction ;
461 LNode_Impl * myNode = new LNode_Impl( _Orb , _Poa , _ContId ,
462 instanceName() , interfaceName() ,
464 FuncNameList , PythonFunctionList ,
465 // InitName , InitFunction ,
466 // MoreName , MoreFunction ,
467 // NextName , NextFunction ,
469 if ( myNode->DataFlowNode() ) {
470 PortableServer::ObjectId * id = myNode->getId() ;
471 CORBA::Object_var obj = _poa->id_to_reference(*id);
472 iobject = SUPERV::LNode::_narrow(obj) ;
473 myNode->SetObjRef( SUPERV::LNode::_duplicate( iobject ) ) ;
475 SALOME_ModuleCatalog::Service aVoidService = SALOME_ModuleCatalog::Service() ;
477 if ( strlen( InitName ) ) {
478 anEndName = new char( 3 + strlen( InitName ) + 1 ) ;
479 strcpy( anEndName , "End" ) ;
480 strcat( anEndName , InitName ) ;
483 anEndName = new char( 3 + strlen( "Loop" ) + 1 ) ;
484 strcpy( anEndName , "EndLoop" ) ;
486 ELNode_Impl * myEndNode = new ELNode_Impl( _Orb , _Poa , _ContId ,
487 instanceName() , interfaceName() ,
490 SUPERV::EndLoopNode ) ;
491 PortableServer::ObjectId * endid = myEndNode->getId() ;
492 CORBA::Object_var endobj = _poa->id_to_reference(*endid);
493 iendobject = SUPERV::ELNode::_narrow(endobj) ;
494 myEndNode->SetObjRef( SUPERV::ELNode::_duplicate( iendobject ) ) ;
495 myNode->SetCoupled( myEndNode->BaseNode()->Name() ) ;
496 myEndNode->SetCoupled( myNode->BaseNode()->Name() ) ;
497 Link( myNode->Port( "DoLoop" ) , myEndNode->Port( "DoLoop" ) ) ;
498 Link( myEndNode->Port( "DoLoop" ) , myNode->Port( "InitLoop" ) ) ;
501 anEndOfLoop = SUPERV::ELNode::_duplicate( iendobject ) ;
502 DataFlowEditor()->UnValid() ;
503 endService( "Graph_Impl::LNode" );
504 return SUPERV::LNode::_duplicate( iobject ) ;
507 SUPERV::SNode_ptr Graph_Impl::SNode( const char * FuncName ,
508 const SUPERV::ListOfStrings & PythonFunction ,
509 SUPERV::INode_out anEndOfSwitch ) {
510 beginService( "Graph_Impl::SNode" );
511 SUPERV::SNode_var iobject = SUPERV::SNode::_nil() ;
512 SUPERV::ESNode_var iendobject = SUPERV::ESNode::_nil() ;
513 if ( DataFlowEditor()->IsEditing() && !DataFlowEditor()->IsReadOnly() && !IsMacro() ) {
514 SNode_Impl * myNode = new SNode_Impl( _Orb , _Poa , _ContId ,
515 instanceName() , interfaceName() ,
517 FuncName , PythonFunction ,
518 SUPERV::SwitchNode ) ;
519 if ( myNode->DataFlowNode() ) {
520 PortableServer::ObjectId * id = myNode->getId() ;
521 CORBA::Object_var obj = _poa->id_to_reference(*id);
522 iobject = SUPERV::SNode::_narrow(obj) ;
523 myNode->SetObjRef( SUPERV::SNode::_duplicate( iobject ) ) ;
525 string anEndName = "End" ;
526 if ( strlen( FuncName ) ) {
527 anEndName += FuncName ;
530 anEndName += "Switch" ;
532 // cout << "Graph_Impl::SNode anEndName " << (void *) FuncName << " " << FuncName
533 // << " " << strlen(FuncName) << " " << (void *) anEndName.c_str() << " "
534 // << anEndName.c_str() << endl ;
535 ESNode_Impl * myEndNode = new ESNode_Impl( _Orb , _Poa , _ContId ,
536 instanceName() , interfaceName() ,
539 SUPERV::EndSwitchNode ) ;
540 // cout << "Graph_Impl::SNode returned anEndName " << (void *) FuncName << " "
541 // << FuncName << " " << strlen(FuncName) << " " << (void *) anEndName.c_str()
542 // << " " << anEndName.c_str() << endl ;
543 PortableServer::ObjectId * endid = myEndNode->getId() ;
544 CORBA::Object_var endobj = _poa->id_to_reference(*endid);
545 iendobject = SUPERV::ESNode::_narrow(endobj) ;
546 myEndNode->SetObjRef( SUPERV::ESNode::_duplicate( iendobject ) ) ;
547 myNode->SetCoupled( myEndNode->BaseNode()->Name() ) ;
548 myEndNode->SetCoupled( myNode->BaseNode()->Name() ) ;
549 if ( !Link( myNode->Port( "Default" ) , myEndNode->Port( "Default" ) ) ) {
550 iobject = SUPERV::SNode::_nil() ;
551 iendobject = SUPERV::ESNode::_nil() ;
555 anEndOfSwitch = SUPERV::ESNode::_duplicate( iendobject ) ;
556 DataFlowEditor()->UnValid() ;
557 endService( "Graph_Impl::SNode" );
558 return SUPERV::SNode::_duplicate( iobject ) ;
561 // WARNING : THIS IS COMPLICATED :
562 SUPERV::Graph_var Graph_Impl::LoadDataFlows( GraphEditor::DataFlow * aDataFlowEditor ,
563 GraphBase::ListOfSGraphs * aListOfDataFlows ,
565 beginService( "Graph_Impl::EditorLoadDataFlows" ) ;
566 MESSAGE("Graph_Impl::LoadDataFlows index " << index << " " << (*aListOfDataFlows)[index].Info.theName.c_str() ) ;
568 SUPERV::Graph_var iobject = SUPERV::Graph::_nil() ;
569 // That method is recursive :
570 // At first we load the supergraph with index = 0 :
571 // (After we load the graph corresponding to each MacroNode :)
572 if ( !aDataFlowEditor->LoadDataFlow( &(*aListOfDataFlows)[ index ] ) ) {
573 MESSAGE("Graph_Impl::LoadDataFlows failed " << (*aListOfDataFlows)[index].Info.theName.c_str() ) ;
574 return SUPERV::Graph::_duplicate( iobject ) ;
576 // That graph is not a StreamGraph :
577 else if ( !aDataFlowEditor->Graph()->HasDataStream() ) {
578 aDataFlowEditor->Graph()->Kind( SUPERV::DataFlowGraph ) ;
579 // aDataFlowEditor->Graph()->SetGraphEditor( aDataFlowEditor ) ;
580 Graph_Impl * myGraph ;
581 // We create a Graph ObjRef for that graph
582 myGraph = new Graph_Impl( _Orb , _Poa, _ContId,
583 instanceName() , interfaceName() ,
584 aDataFlowEditor , NULL ) ;
585 PortableServer::ObjectId * id = myGraph->getId() ;
586 CORBA::Object_var obj = _poa->id_to_reference(*id) ;
587 iobject = SUPERV::Graph::_narrow( obj ) ;
588 myGraph->SetObjRef( SUPERV::Graph::_duplicate( iobject ) ) ;
589 myGraph->SetObjImpl( (CNode_Impl * ) myGraph ) ;
590 GraphBase::Graph * aGraph = myGraph->DataFlowEditor()->Graph() ;
593 // asv: set Editor for the graph itself and for all its macro nodes
594 aGraph->GraphEditor( aDataFlowEditor );
596 // For the supergraph or each graph of MacroNodes we search MacroNodes recursively :
597 for ( i = 0 ; i < aGraph->GraphNodesSize() ; i++ ) {
598 if ( aGraph->GraphNodes( i )->IsMacroNode() ) {
599 GraphBase::GOTONode * aMacroNode = (GraphBase::GOTONode * ) aGraph->GraphNodes( i ) ;
601 // asv : 05.11.04 : fix of bug - "insert file" into existing graph with MacroNodes worked incorrectly!
602 // aMacroNode is an "old" node, and here we must analize only "new" nodes, that
603 // came from aListOfDataFlows and were loaded by aDataFlowEditor->LoadDataFlow( &(*aListOfDataFlows)[ index ] )
604 // so here we check if the node is "new" or "old"
605 if ( aMacroNode->GraphEditor() && aMacroNode->CoupledNode() )
608 // asv: set Editor for the graph itself and for all its macro nodes
609 aMacroNode->GraphEditor( aDataFlowEditor );
611 // Creation of a GraphMacroNode ObjRef in the current editor
612 SUPERV::Graph_var macroiobject = SUPERV::Graph::_nil() ;
613 Graph_Impl * myMacroNode ;
614 myMacroNode = new Graph_Impl( _Orb , _Poa, _ContId,
615 instanceName() , interfaceName() ,
616 aMacroNode->Name() , SUPERV::MacroNode ) ;
617 id = myMacroNode->getId() ;
618 obj = _poa->id_to_reference(*id);
619 macroiobject = SUPERV::Graph::_narrow( obj ) ;
620 myMacroNode->DataFlowEditor( aDataFlowEditor ) ;
621 GraphEditor::InNode * aDataFlowNode = (GraphEditor::InNode * ) aMacroNode->GetInNode() ;
622 myMacroNode->DataFlowNode( aDataFlowNode ) ;
623 aDataFlowNode->SetObjRef( SUPERV::CNode::_duplicate( SUPERV::CNode::_narrow( obj ) ) ) ;
624 aDataFlowNode->SetObjImpl( myMacroNode ) ;
626 char * aCoupledNodeName = aMacroNode->CoupledNodeName() ;
627 MESSAGE( "LoadDataFlows MacroNode " << aMacroNode->Name() << " --> " << aCoupledNodeName
628 << " to be searched among " << (*aListOfDataFlows).size() << " Graphs" ) ;
631 for ( index = 0 ; index < (int ) (*aListOfDataFlows).size() ; index++ ) {
632 MESSAGE( "LoadDataFlows Graph" << index << " " << (*aListOfDataFlows)[index].Info.theName.c_str() ) ;
633 if ( !strcmp( aCoupledNodeName , (*aListOfDataFlows)[index].Info.theName.c_str() ) ) {
636 // At first create the editor and a StreamGraph
637 GraphEditor::DataFlow * aMacroGraphDataFlowEditor ;
638 CreateEditor( _Orb , instanceName() , aCoupledNodeName , SUPERV::DataStreamGraph ,
639 dbgfile , &aMacroGraphDataFlowEditor ) ;
641 if ( _DebugFileName ) {
642 delete [] _DebugFileName ;
644 _DebugFileName = new char[ strlen( dbgfile.c_str() )+1 ] ;
645 strcpy( _DebugFileName , dbgfile.c_str() ) ;
647 MESSAGE( "RECURSIVE IMPORT OF GRAPHS OF MACRONODES :" << aCoupledNodeName ) ;
648 if ( CORBA::is_nil( LoadDataFlows( aMacroGraphDataFlowEditor , aListOfDataFlows , index ) ) ) {
649 MESSAGE("Graph_Impl::LoadDataFlows failed" ) ;
650 return SUPERV::Graph::_duplicate( iobject ) ;
653 // That graph is not a StreamGraph :
654 else if ( !aMacroGraphDataFlowEditor->Graph()->HasDataStream() ) {
655 Graph_Impl * myMacroGraph ;
656 // The Graph ObjRef for that graph was already created
657 myMacroGraph = (Graph_Impl * ) aMacroGraphDataFlowEditor->Graph()->ObjImpl() ;
659 GraphBase::Graph * aMacroGraph = myMacroGraph->DataFlowEditor()->Graph() ;
661 aMacroGraph->GraphMacroLevel( aGraph->GraphMacroLevel() + 1 ) ;
662 aMacroGraph->CoupledNode( aMacroNode ) ;
663 aMacroGraph->MacroObject( SUPERV::Graph::_duplicate( macroiobject ) ) ;
665 // Set the GraphMacroNode ObjRef in the MacroNode
666 aMacroNode->GraphMacroLevel( aGraph->GraphMacroLevel() + 1 ) ;
667 aMacroNode->CoupledNode( aMacroGraph ) ;
668 aMacroNode->MacroObject( SUPERV::Graph::_narrow( aMacroGraphDataFlowEditor->Graph()->ObjRef() ) ) ;
669 MESSAGE( "LoadDataFlows aMacroGraph " << aMacroGraph << " " << aMacroGraph->Name()
670 << " coupled to " << aMacroGraph->CoupledNode() << " "
671 << aMacroGraph->CoupledNode()->Name() << " Editor " << aMacroGraph->GraphEditor() ) ;
672 MESSAGE( "LoadDataFlows aMacroNode " << aMacroNode << " " << aMacroNode->Name()
673 << " coupled to " << aMacroNode->CoupledNode() << " "
674 << aMacroNode->CoupledNode()->Name() << " Editor " << aMacroNode->GraphEditor() ) ;
675 MESSAGE( "LoadDataFlows current Graph " << aGraph << " " << aGraph->Name()
676 << " coupled to " << aGraph->CoupledNode()
677 << " Editor " << aGraph->GraphEditor() << " " << aGraph->Name() ) ;
683 return SUPERV::Graph::_duplicate( SUPERV::Graph::_nil() ) ;
688 else if ( (*aListOfDataFlows).size() == 1 ) {
689 StreamGraph_Impl * myStreamGraph ;
690 // We create a Graph ObjRef for that graph
691 myStreamGraph = new StreamGraph_Impl( _Orb , _Poa, _ContId,
692 instanceName() , interfaceName() ,
693 aDataFlowEditor , NULL ) ;
694 PortableServer::ObjectId * id = myStreamGraph->getId() ;
695 CORBA::Object_var obj = _poa->id_to_reference(*id) ;
696 SUPERV::StreamGraph_var Streamiobject = SUPERV::StreamGraph::_nil() ;
697 Streamiobject = SUPERV::StreamGraph::_narrow( obj ) ;
698 myStreamGraph->SetObjRef( SUPERV::StreamGraph::_duplicate( Streamiobject ) ) ;
699 myStreamGraph->SetObjImpl( (CNode_Impl * ) myStreamGraph ) ;
700 // iobject = SUPERV::Graph::_narrow( obj ) ;
701 iobject = SUPERV::Graph::_narrow( Streamiobject ) ;
704 MESSAGE( "Graph_Impl::LoadDataFlows StreamGraph with MacroNodes not yet implemented" ) ;
707 endService( "Graph_Impl::EditorLoadDataFlows" );
708 return SUPERV::Graph::_duplicate( iobject ) ;
711 SUPERV::Graph_var Graph_Impl::LoadDataFlows( GraphExecutor::DataFlow * aDataFlowExecutor ,
712 GraphBase::ListOfSGraphs * aListOfDataFlows ,
714 beginService( "Graph_Impl::ExecutorLoadDataFlows" ) ;
715 MESSAGE("Graph_Impl::LoadDataFlows(Executor) index " << index << " " << (*aListOfDataFlows)[index].Info.theName.c_str() << " aDataFlowExecutor " << aDataFlowExecutor ) ;
717 // That method is recursive :
718 // At first we load the supergraph with index = 0 :
719 // (After we load the graph corresponding to each MacroNode :)
720 if ( !aDataFlowExecutor->LoadDataFlow( &(*aListOfDataFlows)[ index ] ) ) {
721 MESSAGE("Graph_Impl::LoadDataFlows(Executor) failed, could not LoadDataFlow(supergraph)" ) ;
722 return SUPERV::Graph::_duplicate( SUPERV::Graph::_nil() ) ;
725 // That graph is not a StreamGraph :
727 aDataFlowExecutor->Graph()->Kind( SUPERV::DataFlowGraph ) ;
728 GraphEditor::DataFlow * aDataFlowEditor ;
729 aDataFlowEditor = DataFlowEditor() ;
730 GraphBase::Graph * anEditorGraph = aDataFlowEditor->Graph() ;
731 GraphBase::Graph * anExecutorGraph = aDataFlowExecutor->Graph() ;
732 if ( aDataFlowEditor->Executor() ) {
733 delete aDataFlowEditor->Executor() ;
734 aDataFlowEditor->Executor( NULL ) ;
735 aDataFlowEditor->Editing() ;
737 aDataFlowEditor->Executor( aDataFlowExecutor ) ;
738 anExecutorGraph->GraphEditor( aDataFlowEditor ) ;
740 if ( !aDataFlowExecutor->Graph()->HasDataStream() ) {
741 // For the supergraph or each graph of MacroNodes we search MacroNodes recursively :
743 for ( i = 0 ; i < anExecutorGraph->GraphNodesSize() ; i++ ) {
744 if ( anExecutorGraph->GraphNodes( i )->IsMacroNode() ) {
745 GraphBase::GOTONode * aMacroNode = (GraphBase::GOTONode * ) anExecutorGraph->GraphNodes( i ) ;
746 aMacroNode->GraphEditor( aDataFlowEditor ) ;
748 // get the macro node's editor object
749 char * aMacroGraphName = aMacroNode->CoupledNodeName() ;
750 GraphBase::Graph* aMacroGraph = (GraphBase::Graph*)((GraphBase::GOTONode *)anEditorGraph->GetGraphNode( aMacroNode->Name() ))->CoupledNode() ;
751 GraphEditor::DataFlow* aMacroGraphEditor = aMacroGraph->GraphEditor();
753 MESSAGE( "LoadDataFlows(Executor) MacroNode " << aMacroNode->Name() << " Coupled to " << aMacroGraphName
754 << " to be searched among " << (*aListOfDataFlows).size() << " Graphs" << endl ) ;
757 for ( index = 0 ; index < (int ) (*aListOfDataFlows).size() && !found; index++ ) {
758 if ( !strcmp( aMacroGraphName , (*aListOfDataFlows)[index].Info.theName.c_str() ) )
762 MESSAGE("Graph_Impl::LoadDataFlows(Executor) failed, Macro node's coupled graph \"" << aMacroGraphName << "\" was not found" ) ;
763 return SUPERV::Graph::_duplicate( SUPERV::Graph::_nil() ) ;
765 index--; // it was incremented in "for ..." before last check ( !found ).
767 // At first create the editor and a StreamGraph
769 GraphExecutor::DataFlow * aMacroGraphExecutor ;
770 CreateExecutor( _Orb , instanceName() , aMacroGraphName , SUPERV::DataStreamGraph ,
771 dbgfile , &aMacroGraphExecutor );
773 // set GraphMacroLevel for Executor's graph
774 GraphBase::Graph* aMacroGraphExe = aMacroGraphExecutor->Graph();
775 aMacroGraphExe->GraphMacroLevel( anExecutorGraph->GraphMacroLevel() + 1 );
777 // load data flows in MacroGraph's executor
778 Graph_Impl* aMacroGraphImpl = (Graph_Impl*) aMacroGraphEditor->Graph()->ObjImpl();
779 MESSAGE( "RECURSIVE IMPORT OF GRAPHS OF MACRONODES : " << aMacroGraphName ) ;
780 if ( CORBA::is_nil( aMacroGraphImpl->LoadDataFlows( aMacroGraphExecutor, aListOfDataFlows , index ) ) ) {
781 MESSAGE("Graph_Impl::LoadDataFlows(Executor) failed, could not LoadDataFlow( MacroNodeGraph \"" <<aMacroGraphName << "\" )" ) ;
782 return SUPERV::Graph::_duplicate( SUPERV::Graph::_nil() ) ;
785 // set coupled pair MacroNode <--> MacroGraph
786 aMacroGraphExe->CoupledNode( aMacroNode ) ;
787 aMacroNode->CoupledNode( aMacroGraphExe ) ;
789 // initialize MacroNode's InPorts with corresponding "external" values
791 for ( q = 0 ; q < aMacroNode->GetNodeInPortsSize() ; q++ ) {
792 const GraphBase::InPort * anInPort = aMacroNode->GetNodeInPort( q ) ;
793 if ( anInPort->IsDataConnected() ) {
794 const char* aMacroGraphInPortName = aMacroGraph->GetNodeInPort( q )->PortName();
795 if ( !aMacroGraphExecutor->InputOfAny( aMacroGraphInPortName, *anInPort->GetOutPort()->Value(),false ) ) {
796 return SUPERV::Graph::_duplicate( SUPERV::Graph::_nil() ) ;
799 MESSAGE( "LoadDataFlows(Executor) " << aMacroGraph->Name() << "->InputOfAny( "
800 << aMacroGraphInPortName << " , Value )" ) ;
803 } // end of init MacroNode's InPorts
805 aMacroGraphImpl->Run() ;
808 } // end of for( get nodes of the graph...)
810 } // end of setting initial graph's structure..
812 endService( "Graph_Impl::ExecutorLoadDataFlows" );
814 PortableServer::ObjectId * id = getId();
815 CORBA::Object_var obj = _poa->id_to_reference( *id );
816 SUPERV::Graph_var iobject = SUPERV::Graph::_narrow( obj ) ;
817 return SUPERV::Graph::_duplicate( iobject ) ;
820 SUPERV::Graph_ptr Graph_Impl::MNode( const char * aXmlFileName ) {
821 beginService( "Graph_Impl::MNode" );
822 SUPERV::Graph_var iobject = SUPERV::Graph::_nil() ;
823 MESSAGE( "Graph_Impl::MNode( " << aXmlFileName << " )" ) ;
825 GraphBase::ListOfSGraphs aListOfDataFlows ;
827 // At first create the editor and a StreamGraph with the xml file
828 GraphEditor::DataFlow * aDataFlowEditor ;
829 CreateEditor( _Orb , instanceName() , aXmlFileName , SUPERV::DataStreamGraph ,
830 dbgfile , &aDataFlowEditor ) ;
832 if ( _DebugFileName ) {
833 delete [] _DebugFileName ;
835 _DebugFileName = new char[ strlen( dbgfile.c_str() )+1 ] ;
836 strcpy( _DebugFileName , dbgfile.c_str() ) ;
838 int lenname = strlen( aXmlFileName ) ;
839 bool loaded = false ;
840 // Import of the xml file
841 if ( lenname > 4 && !strcmp( &aXmlFileName[ lenname - 4 ] , ".xml" ) ) {
842 loaded = aDataFlowEditor->LoadXml( aXmlFileName , aListOfDataFlows ) ;
844 iobject = MNode( aDataFlowEditor , &aListOfDataFlows ) ;
851 // WARNING : THIS IS COMPLICATED :
852 // I should have to remove duplicated code ...
853 SUPERV::Graph_ptr Graph_Impl::MNode( GraphEditor::DataFlow * aMacroGraphDataFlowEditor ,
854 GraphBase::ListOfSGraphs * aListOfDataFlows ) {
855 beginService( "Graph_Impl::MNode" ) ;
856 SUPERV::Graph_var iobject = SUPERV::Graph::_nil() ;
857 SUPERV::Graph_var macroiobject = SUPERV::Graph::_nil() ;
860 MESSAGE( "Graph_Impl::MNode DataFlowEditor->LoadDataFlow" ) ;
861 // if ( !aMacroGraphDataFlowEditor->LoadDataFlow( &aListOfDataFlows[ 0 ] ) ) {
862 iobject = LoadDataFlows( aMacroGraphDataFlowEditor , aListOfDataFlows , 0 ) ;
863 if ( CORBA::is_nil( iobject ) ) {
864 MESSAGE("Graph_Impl::MNode LoadDataFlow failed" ) ;
868 // That graph is not a StreamGraph :
869 else if ( !aMacroGraphDataFlowEditor->Graph()->HasDataStream() ) {
870 aMacroGraphDataFlowEditor->Graph()->Kind( SUPERV::DataFlowGraph ) ;
871 aMacroGraphDataFlowEditor->Graph()->GraphEditor( aMacroGraphDataFlowEditor ) ;
873 Graph_Impl * myMacroGraph = (Graph_Impl * ) aMacroGraphDataFlowEditor->Graph()->ObjImpl() ;
874 // Creation of a GraphMacroNode in the current editor
875 string aMacroNodeName = string( "Macro_" ) + string( myMacroGraph->Name() ) ;
876 Graph_Impl * myMacroNode ;
877 myMacroNode = new Graph_Impl( _Orb , _Poa, _ContId,
878 instanceName() , interfaceName() ,
879 aMacroNodeName.c_str() , SUPERV::MacroNode ) ;
880 PortableServer::ObjectId * id = myMacroNode->getId() ;
881 CORBA::Object_var obj = _poa->id_to_reference(*id);
882 macroiobject = SUPERV::Graph::_narrow( obj ) ;
883 myMacroNode->DataFlowEditor( DataFlowEditor() ) ;
885 // Creation of the MacroNode itself in the current Graph
886 GraphBase::ListOfFuncName aFuncName ;
887 aFuncName.resize( 1 ) ;
889 SUPERV::ListOfStrings aListOfStrings ;
890 aListOfStrings.length( 1 ) ;
891 aListOfStrings[0] = "" ;
892 GraphBase::ListOfPythonFunctions aPythonFunction ;
893 aPythonFunction.resize( 1 ) ;
894 aPythonFunction[0] = &aListOfStrings ;
895 SALOME_ModuleCatalog::Service * aMacroNodeService = myMacroGraph->Service() ;
896 GraphEditor::InNode * aDataFlowNode = DataFlowEditor()->AddNode( *aMacroNodeService , "" , "" ,
897 aMacroNodeName.c_str() , SUPERV::MacroNode ,
898 aFuncName , aPythonFunction ) ;
899 aDataFlowNode->SetPythonFunction( "" , aListOfStrings ) ;
900 myMacroNode->DataFlowNode( aDataFlowNode ) ;
901 aDataFlowNode->ComputingNode()->SetService( *aMacroNodeService ) ;
902 aDataFlowNode->SetObjRef( SUPERV::CNode::_duplicate( SUPERV::CNode::_narrow( obj ) ) ) ;
903 aDataFlowNode->SetObjImpl( this ) ;
905 GraphBase::Graph * aGraph = myMacroGraph->DataFlowEditor()->Graph() ;
906 GraphBase::Graph * aGraphOfMacroGraph = myMacroNode->DataFlowEditor()->Graph() ;
907 GraphBase::Graph * aMacroGraph = myMacroNode->DataFlowNode()->GraphMacroNode() ;
908 aMacroGraph->Kind( SUPERV::MacroNode ) ;
909 aMacroGraph->GraphEditor( DataFlowEditor() ) ;
910 // Creation of the Ports of the MacroNode from the ports of the GraphMacroNode
911 aMacroGraph->SetMacroPorts( aGraph ) ;
912 // Valid ==> creation of Service and the ports of the current Graph
913 DataFlowEditor()->IsValid() ;
914 // Set the Input Datas from the GraphMacroNode to the current Graph
915 aMacroGraph->SetMacroDatas( aGraph , aGraphOfMacroGraph ) ;
916 aMacroGraphDataFlowEditor->UnValid() ;
917 // Set the MacroNode ObjRef in the GraphMacroNode
918 aGraph->CoupledNode( aMacroGraph ) ;
919 aGraph->MacroObject( SUPERV::Graph::_duplicate( macroiobject ) ) ;
920 // Set the GraphMacroNode ObjRef in the MacroNode
921 aDataFlowNode->GraphMacroNode()->GraphMacroLevel( aGraphOfMacroGraph->GraphMacroLevel() + 1 ) ;
922 aMacroGraph->CoupledNode( aGraph ) ;
923 // aGraphOfMacroGraph->CoupledNode( aGraph ) ;
924 aMacroGraph->MacroObject( SUPERV::Graph::_duplicate( iobject ) ) ;
925 // aGraphOfMacroGraph->MacroObject( SUPERV::Graph::_duplicate( iobject ) ) ;
926 // aDataFlowNode->CoupledNode( aGraph ) ;
927 // aDataFlowNode->ComputingNode()->MacroObject( SUPERV::Graph::_duplicate( iobject ) ) ;
928 // Set the MacroLevel of that graph
929 aGraph->GraphMacroLevel( aGraphOfMacroGraph->GraphMacroLevel() + 1 ) ;
930 aMacroGraph->Coordinates( 0 , 0 ) ;
931 MESSAGE( "DataFlowNode Graph " << this << " DataFlowEditor " << DataFlowEditor() << " aDataFlowNode "
932 << aDataFlowNode << " " << aDataFlowNode->Name() << " created" ) ;
933 MESSAGE( "MNode aGraph " << aGraph << " " << aGraph->Name()
934 << " coupled to " << aGraph->CoupledNode() << " "
935 << aGraph->CoupledNode()->Name() ) ;
936 MESSAGE( "MNode aMacroGraph " << aMacroGraph << " " << aMacroGraph->Name()
937 << " coupled to " << aMacroGraph->CoupledNode() << " "
938 << aMacroGraph->CoupledNode()->Name() ) ;
939 MESSAGE( "MNode aMacroGraph " << myMacroNode->DataFlowEditor()->Graph() << " "
940 << myMacroNode->DataFlowEditor()->Graph()->Name()
941 << " coupled to " << myMacroNode->DataFlowEditor()->Graph()->CoupledNode() ) ;
944 delete aMacroGraphDataFlowEditor ;
947 endService( "Graph_Impl::MNode" );
948 return SUPERV::Graph::_duplicate( macroiobject ) ;
951 // For python supergraph
952 SUPERV::Graph_ptr Graph_Impl::GraphMNode( SUPERV::Graph_ptr myMacroGraph ) {
953 SUPERV::Graph_var iobject = myMacroGraph ;
954 beginService( "Graph_Impl::GraphMNode" ) ;
956 // GraphBase::Graph * myMacroGraph = aGraph;
957 SUPERV::Graph_var macroiobject = SUPERV::StreamGraph::_nil() ;
958 // Creation of a GraphMacroNode in the current editor
960 string aMacroNodeName = string( "Macro_" ) + string( myMacroGraph->Name() ) ;
961 //string aMacroNodeName = string( myMacroGraph->CoupledName() ) ;
962 MESSAGE( "GraphMNode( " << myMacroGraph->Name() << " )" ) ;
963 Graph_Impl * myMacroNode ;
964 myMacroNode = new Graph_Impl( _Orb , _Poa, _ContId,
965 instanceName() , interfaceName() ,
966 aMacroNodeName.c_str() , SUPERV::MacroNode ) ;
967 PortableServer::ObjectId * id = myMacroNode->getId() ;
968 CORBA::Object_var obj = _poa->id_to_reference(*id);
969 macroiobject = SUPERV::Graph::_narrow( obj ) ;
970 myMacroNode->DataFlowEditor( DataFlowEditor() ) ;
972 // Creation of the MacroNode itself in the current Graph
973 GraphBase::ListOfFuncName aFuncName ;
974 aFuncName.resize( 1 ) ;
976 SUPERV::ListOfStrings aListOfStrings ;
977 aListOfStrings.length( 1 ) ;
978 aListOfStrings[0] = "" ;
979 GraphBase::ListOfPythonFunctions aPythonFunction ;
980 aPythonFunction.resize( 1 ) ;
981 aPythonFunction[0] = &aListOfStrings ;
982 SALOME_ModuleCatalog::Service * aMacroNodeService = myMacroGraph->Service() ;
983 GraphEditor::InNode * aDataFlowNode ;
984 aDataFlowNode = DataFlowEditor()->AddNode( *aMacroNodeService , "" , "" ,
985 aMacroNodeName.c_str() , SUPERV::MacroNode ,
986 aFuncName , aPythonFunction ) ;
987 aDataFlowNode->SetPythonFunction( "" , aListOfStrings ) ;
988 myMacroNode->DataFlowNode( aDataFlowNode ) ;
989 aDataFlowNode->ComputingNode()->SetService( *aMacroNodeService ) ;
990 aDataFlowNode->SetObjRef( SUPERV::CNode::_duplicate( SUPERV::CNode::_narrow( obj ) ) ) ;
991 aDataFlowNode->SetObjImpl( this ) ;
993 // GraphBase::Graph * aGraph = DataFlowEditor()->Automaton()->MapGraph( myMacroGraph->Name() ) ;
994 GraphBase::Graph * aGraph ;
995 //DataFlowEditor()->Automaton()->GraphBase( &aGraph ) ;
996 myMacroGraph->Coupled() ;
997 GraphBase::Graph * aGraphOfMacroGraph = myMacroNode->DataFlowEditor()->Graph() ;
998 GraphBase::Graph * aMacroGraph = myMacroNode->DataFlowNode()->GraphMacroNode() ;
999 aMacroGraph->Kind( SUPERV::MacroNode ) ;
1000 aMacroGraph->GraphEditor( DataFlowEditor() ) ;
1001 // Creation of the Ports of the MacroNode from the ports of the GraphMacroNode
1002 aMacroGraph->SetMacroPorts( aGraph ) ;
1003 // Valid ==> creation of Service and the ports of the current Graph
1004 DataFlowEditor()->IsValid() ;
1005 // Set the Input Datas from the GraphMacroNode to the current Graph
1006 aMacroGraph->SetMacroDatas( aGraph , aGraphOfMacroGraph ) ;
1007 // aMacroGraphDataFlowEditor->UnValid() ;
1008 aGraph->GraphEditor()->UnValid() ;
1009 // Set the MacroNode ObjRef in the GraphMacroNode
1010 aGraph->CoupledNode( aMacroGraph ) ;
1011 aGraph->MacroObject( SUPERV::Graph::_duplicate( macroiobject ) ) ;
1012 // Set the GraphMacroNode ObjRef in the MacroNode
1013 aDataFlowNode->GraphMacroNode()->GraphMacroLevel( aGraphOfMacroGraph->GraphMacroLevel() + 1 ) ;
1014 aMacroGraph->CoupledNode( aGraph ) ;
1015 aMacroGraph->MacroObject( SUPERV::Graph::_duplicate( iobject ) ) ;
1016 // aDataFlowNode->CoupledNode( aGraph ) ;
1017 // aDataFlowNode->ComputingNode()->MacroObject( SUPERV::Graph::_duplicate( iobject ) ) ;
1018 // Set the MacroLevel of that graph
1019 aGraph->GraphMacroLevel( aGraphOfMacroGraph->GraphMacroLevel() + 1 ) ;
1020 aMacroGraph->Coordinates( 0 , 0 ) ;
1021 MESSAGE( aGraph->Name() << "->CoupledNode()->GraphEditor() : " << aGraph->CoupledNode()->GraphEditor() ) ;
1022 MESSAGE( aMacroGraph->Name() << "->CoupledNode()->GraphEditor() : "
1023 << aMacroGraph->CoupledNode()->GraphEditor() ) ;
1024 MESSAGE( "DataFlowNode Graph " << this << " DataFlowEditor " << DataFlowEditor() << " aDataFlowNode "
1025 << aDataFlowNode << " " << aDataFlowNode->Name() << " created" ) ;
1027 endService( "Graph_Impl::GraphMNode" ) ;
1028 return SUPERV::Graph::_duplicate( macroiobject ) ;
1031 SUPERV::Graph_ptr Graph_Impl::FlowObjRef() {
1032 beginService( "Graph_Impl::FlowObjRef" );
1033 SUPERV::Graph_var iobject = SUPERV::Graph::_nil() ;
1035 iobject = SUPERV::Graph::_narrow( DataFlowNode()->GraphMacroNode()->MacroObject() ) ;
1037 else if ( IsGraph() ) {
1038 iobject = SUPERV::Graph::_narrow( DataFlowEditor()->Graph()->MacroObject() ) ;
1040 if ( CORBA::is_nil( iobject ) ) {
1041 MESSAGE( "Graph_Impl::FlowObjRef() returns a NIL Object" ) ;
1043 endService( "Graph_Impl::FlowObjRef" );
1044 return SUPERV::Graph::_duplicate( iobject ) ;
1047 SUPERV::StreamGraph_ptr Graph_Impl::StreamObjRef() {
1048 beginService( "Graph_Impl::StreamObjRef" );
1049 SUPERV::StreamGraph_var iobject = SUPERV::StreamGraph::_nil() ;
1051 iobject = SUPERV::StreamGraph::_narrow( DataFlowNode()->GraphMacroNode()->MacroObject() ) ;
1053 else if ( IsGraph() || IsStreamGraph() ) {
1054 iobject = SUPERV::StreamGraph::_narrow( DataFlowEditor()->Graph()->MacroObject() ) ;
1056 if ( CORBA::is_nil( iobject ) ) {
1057 MESSAGE( "Graph_Impl::StreamObjRef() returns a NIL Object" ) ;
1059 endService( "Graph_Impl::StreamObjRef" );
1060 return SUPERV::StreamGraph::_duplicate( iobject ) ;
1063 SUPERV::CNode_ptr Graph_Impl::Node(char const * aNodeName ) {
1064 // beginService( "Graph_Impl::Node" );
1065 SUPERV::CNode_var iobject = SUPERV::CNode::_nil() ;
1067 if ( CORBA::is_nil( DataFlowEditor()->GetNode( aNodeName )->ObjRef() ) ) {
1068 CNode_Impl * myNode = new CNode_Impl( _Orb , _Poa , _ContId ,
1069 instanceName() , interfaceName() ,
1071 DataFlowEditor()->GetNode( aNodeName ) ) ;
1072 PortableServer::ObjectId * id = myNode->getId() ;
1073 CORBA::Object_var obj = _poa->id_to_reference(*id);
1074 iobject = SUPERV::CNode::_narrow(obj) ;
1075 myNode->SetObjRef( SUPERV::CNode::_duplicate( iobject ) ) ;
1078 iobject = DataFlowEditor()->GetNode( aNodeName )->ObjRef() ;
1081 GraphEditor::InNode * anInNode = DataFlowEditor()->GetNode( aNodeName ) ;
1083 if ( CORBA::is_nil( anInNode->ObjRef() ) ) {
1084 SetNodeObjRef( anInNode ) ;
1086 iobject = anInNode->ObjRef() ;
1089 // endService( "Graph_Impl::Node" );
1090 return SUPERV::CNode::_duplicate( iobject ) ;
1093 SUPERV::Link_ptr Graph_Impl::Link( SUPERV::Port_ptr OutPort ,
1094 SUPERV::Port_ptr InPort ) {
1095 // beginService( "Graph_Impl::Link" );
1096 SUPERV::Link_var iobject = SUPERV::Link::_nil() ;
1097 if ( DataFlowEditor()->IsEditing() && !DataFlowEditor()->IsReadOnly() &&
1098 !OutPort->IsDataStream() && !InPort->IsDataStream() && !IsMacro() ) {
1099 MESSAGE( "Graph_Impl::Link( " << OutPort->Node()->Name() << "( " << OutPort->Name() << " ) --> "
1100 << InPort->Node()->Name() << "( " << InPort->Name() << " )" ) ;
1101 GraphEditor::InNode * anInNode = DataFlowEditor()->GetNode( InPort->Node()->Name() ) ;
1102 GraphEditor::InNode * anOutNode = DataFlowEditor()->GetNode( OutPort->Node()->Name() ) ;
1103 if ( anInNode == NULL || anOutNode== NULL ) {
1104 MESSAGE( "Graph_Impl::Link( " << OutPort->Node()->Name() << " " << anOutNode << " , "
1105 << InPort->Node()->Name() << " " << anInNode << " ) Node(s) not found in " << Name() ) ;
1108 GraphBase::InPort * anInPort = anInNode->ComputingNode()->GetChangeInPort( InPort->Name() ) ;
1109 GraphBase::OutPort * anOutPort = anOutNode->ComputingNode()->GetChangeOutPort( OutPort->Name() ) ;
1110 if ( anInPort == NULL || anOutPort== NULL ) {
1111 MESSAGE( "Graph_Impl::Link( " << OutPort->Name() << " " << anOutPort << " , "
1112 << InPort->Name() << " " << anInPort << " ) Port(s) not found" ) ;
1114 else if ( CORBA::is_nil( anOutPort->InPortObjRef( anInPort ) ) ) {
1115 const char * DataFlowOutNodeName = OutPort->Node()->Name() ;
1116 GraphEditor::InNode * DataFlowOutNode = DataFlowEditor()->GetNode( DataFlowOutNodeName ) ;
1117 const char * DataFlowInNodeName = InPort->Node()->Name() ;
1118 GraphEditor::InNode * DataFlowInNode = DataFlowEditor()->GetNode( DataFlowInNodeName ) ;
1119 if ( DataFlowOutNode && DataFlowInNode ) {
1121 Link_Impl * myLink = new Link_Impl( _Orb , _Poa , _ContId ,
1122 instanceName() , interfaceName() ,
1128 true , false , Success ) ;
1130 PortableServer::ObjectId * id = myLink->getId() ;
1131 CORBA::Object_var obj = _poa->id_to_reference(*id);
1132 iobject = SUPERV::Link::_narrow(obj) ;
1133 anOutPort->AddInPortObjRef( anInPort , SUPERV::Link::_duplicate( iobject ) ) ;
1138 iobject = anOutPort->InPortObjRef( anInPort ) ;
1142 DataFlowEditor()->UnValid() ;
1143 // endService( "Graph_Impl::Link" );
1144 return SUPERV::Link::_duplicate( iobject ) ;
1147 // Only to see MacroNodes with actual GUI ... :
1148 #define GOTOMacroNode 0
1150 void Graph_Impl::SetNodeObjRef( GraphEditor::InNode * anInNode ) {
1151 MESSAGE("Graph_Impl::SetNodeObjRef " << anInNode->Name() << " " << anInNode->Kind() ) ;
1152 CORBA::Object_var obj ;
1153 if ( anInNode->IsComputingNode() ) {
1154 CNode_Impl * myNode = new CNode_Impl( _Orb , _Poa , _ContId ,
1155 instanceName() , interfaceName() ,
1158 PortableServer::ObjectId * id = myNode->getId() ;
1159 obj = _poa->id_to_reference(*id);
1160 SUPERV::CNode_var iobject = SUPERV::CNode::_narrow(obj) ;
1161 myNode->SetObjRef( SUPERV::CNode::_duplicate( iobject ) ) ;
1163 else if ( anInNode->IsFactoryNode() ) {
1164 FNode_Impl * myNode = new FNode_Impl( _Orb , _Poa , _ContId ,
1165 instanceName() , interfaceName() ,
1168 PortableServer::ObjectId * id = myNode->getId() ;
1169 obj = _poa->id_to_reference(*id);
1170 SUPERV::FNode_var iobject = SUPERV::FNode::_narrow(obj) ;
1171 myNode->SetObjRef( SUPERV::FNode::_duplicate( iobject ) ) ;
1173 else if ( anInNode->IsInLineNode() ) {
1174 INode_Impl * myNode = new INode_Impl( _Orb , _Poa , _ContId ,
1175 instanceName() , interfaceName() ,
1178 PortableServer::ObjectId * id = myNode->getId() ;
1179 obj = _poa->id_to_reference(*id);
1180 SUPERV::INode_var iobject = SUPERV::INode::_narrow(obj) ;
1181 myNode->SetObjRef( SUPERV::INode::_duplicate( iobject ) ) ;
1184 else if ( anInNode->IsGOTONode() || anInNode->IsMacroNode() ) {
1185 if ( anInNode->IsMacroNode() ) {
1186 anInNode->ComputingNode()->Kind( SUPERV::GOTONode ) ;
1189 else if ( anInNode->IsGOTONode() ) {
1191 GNode_Impl * myNode = new GNode_Impl( _Orb , _Poa , _ContId ,
1192 instanceName() , interfaceName() ,
1195 PortableServer::ObjectId * id = myNode->getId() ;
1196 obj = _poa->id_to_reference(*id);
1197 SUPERV::GNode_var iobject = SUPERV::GNode::_narrow(obj) ;
1198 myNode->SetObjRef( SUPERV::GNode::_duplicate( iobject ) ) ;
1200 else if ( anInNode->IsMacroNode() ) {
1201 Graph_Impl * myNode = new Graph_Impl( _Orb , _Poa , _ContId ,
1202 instanceName() , interfaceName() ,
1205 PortableServer::ObjectId * id = myNode->getId() ;
1206 obj = _poa->id_to_reference(*id);
1207 SUPERV::Graph_var iobject = SUPERV::Graph::_narrow(obj) ;
1208 myNode->SetObjRef( SUPERV::Graph::_duplicate( iobject ) ) ;
1210 else if ( anInNode->IsLoopNode() ) {
1211 LNode_Impl * myNode = new LNode_Impl( _Orb , _Poa , _ContId ,
1212 instanceName() , interfaceName() ,
1215 PortableServer::ObjectId * id = myNode->getId() ;
1216 obj = _poa->id_to_reference(*id);
1217 SUPERV::LNode_var iobject = SUPERV::LNode::_narrow(obj) ;
1218 myNode->SetObjRef( SUPERV::LNode::_duplicate( iobject ) ) ;
1220 else if ( anInNode->IsEndLoopNode() ) {
1221 ELNode_Impl * myNode = new ELNode_Impl( _Orb , _Poa , _ContId ,
1222 instanceName() , interfaceName() ,
1225 PortableServer::ObjectId * id = myNode->getId() ;
1226 obj = _poa->id_to_reference(*id);
1227 SUPERV::ELNode_var iobject = SUPERV::ELNode::_narrow(obj) ;
1228 myNode->SetObjRef( SUPERV::ELNode::_duplicate( iobject ) ) ;
1230 else if ( anInNode->IsSwitchNode() ) {
1231 SNode_Impl * myNode = new SNode_Impl( _Orb , _Poa , _ContId ,
1232 instanceName() , interfaceName() ,
1235 PortableServer::ObjectId * id = myNode->getId() ;
1236 obj = _poa->id_to_reference(*id);
1237 SUPERV::SNode_var iobject = SUPERV::SNode::_narrow(obj) ;
1238 myNode->SetObjRef( SUPERV::SNode::_duplicate( iobject ) ) ;
1240 else if ( anInNode->IsEndSwitchNode() ) {
1241 ESNode_Impl * myNode = new ESNode_Impl( _Orb , _Poa , _ContId ,
1242 instanceName() , interfaceName() ,
1245 PortableServer::ObjectId * id = myNode->getId() ;
1246 obj = _poa->id_to_reference(*id);
1247 SUPERV::ESNode_var iobject = SUPERV::ESNode::_narrow(obj) ;
1248 myNode->SetObjRef( SUPERV::ESNode::_duplicate( iobject ) ) ;
1252 SUPERV::ListOfNodes_var Graph_Impl::SetNode( SUPERV::ListOfNodes_var RetVal ,
1253 GraphBase::ComputingNode * aNode ) {
1255 // if ( _DataFlowExecutor ) {
1256 if ( DataFlowExecutor() ) {
1257 MESSAGE("Graph_Impl::SetNode " << aNode->Name() << " " << aNode->Kind() << " "
1258 << DataFlowExecutor()->StateName( DataFlowExecutor()->AutomatonState( aNode->Name() ) ) ) ;
1261 MESSAGE("Graph_Impl::SetNode " << aNode->Name() << " " << aNode->Kind() ) ;
1263 if ( aNode->IsComputingNode() ) {
1264 index = RetVal->CNodes.length() ;
1265 RetVal->CNodes.length( index+1 );
1267 else if ( aNode->IsFactoryNode() ) {
1268 index = RetVal->FNodes.length() ;
1269 RetVal->FNodes.length( index+1 );
1271 else if ( aNode->IsInLineNode() ) {
1272 index = RetVal->INodes.length() ;
1273 RetVal->INodes.length( index+1 );
1276 else if ( aNode->IsGOTONode() || aNode->IsMacroNode() ) {
1278 else if ( aNode->IsGOTONode() ) {
1280 index = RetVal->GNodes.length() ;
1281 RetVal->GNodes.length( index+1 );
1283 else if ( aNode->IsMacroNode() ) {
1284 index = RetVal->Graphs.length() ;
1285 RetVal->Graphs.length( index+1 );
1287 else if ( aNode->IsLoopNode() ) {
1288 index = RetVal->LNodes.length() ;
1289 RetVal->LNodes.length( index+1 );
1291 else if ( aNode->IsEndLoopNode() ) {
1292 index = RetVal->ELNodes.length() ;
1293 RetVal->ELNodes.length( index+1 );
1295 else if ( aNode->IsSwitchNode() ) {
1296 index = RetVal->SNodes.length() ;
1297 RetVal->SNodes.length( index+1 );
1299 else if ( aNode->IsEndSwitchNode() ) {
1300 index = RetVal->ESNodes.length() ;
1301 RetVal->ESNodes.length( index+1 );
1303 if ( CORBA::is_nil( aNode->ObjRef() ) ) {
1304 SetNodeObjRef( (GraphEditor::InNode * ) aNode->GetInNode() ) ;
1306 SUPERV::CNode_var aNodeObjRef = aNode->ObjRef() ;
1307 if ( aNode->IsComputingNode() ) {
1308 RetVal->CNodes[index] = SUPERV::CNode::_duplicate( aNodeObjRef ) ;
1310 else if ( aNode->IsFactoryNode() ) {
1311 RetVal->FNodes[index] = SUPERV::FNode::_duplicate( SUPERV::FNode::_narrow( aNodeObjRef ) ) ;
1313 else if ( aNode->IsInLineNode() ) {
1314 RetVal->INodes[index] = SUPERV::INode::_duplicate( SUPERV::INode::_narrow( aNodeObjRef ) ) ;
1317 else if ( aNode->IsGOTONode() || aNode->IsMacroNode() ) {
1319 else if ( aNode->IsGOTONode() ) {
1321 RetVal->GNodes[index] = SUPERV::GNode::_duplicate( SUPERV::GNode::_narrow( aNodeObjRef ) ) ;
1323 else if ( aNode->IsMacroNode() ) {
1324 RetVal->Graphs[index] = SUPERV::Graph::_duplicate( SUPERV::Graph::_narrow( aNodeObjRef ) ) ;
1326 else if ( aNode->IsLoopNode() ) {
1327 RetVal->LNodes[index] = SUPERV::LNode::_duplicate( SUPERV::LNode::_narrow( aNodeObjRef ) ) ;
1329 else if ( aNode->IsEndLoopNode() ) {
1330 RetVal->ELNodes[index] = SUPERV::ELNode::_duplicate( SUPERV::ELNode::_narrow( aNodeObjRef ) ) ;
1332 else if ( aNode->IsSwitchNode() ) {
1333 RetVal->SNodes[index] = SUPERV::SNode::_duplicate( SUPERV::SNode::_narrow( aNodeObjRef ) ) ;
1335 else if ( aNode->IsEndSwitchNode() ) {
1336 RetVal->ESNodes[index] = SUPERV::ESNode::_duplicate( SUPERV::ESNode::_narrow( aNodeObjRef ) ) ;
1338 return ( RetVal._retn() ) ;
1341 SUPERV::ListOfNodes * Graph_Impl::Nodes() {
1342 SUPERV::ListOfNodes_var RetVal = new SUPERV::ListOfNodes;
1343 beginService( "Graph_Impl::Nodes" );
1344 RetVal->CNodes.length(0) ;
1345 RetVal->FNodes.length(0) ;
1346 RetVal->INodes.length(0) ;
1347 RetVal->LNodes.length(0) ;
1348 RetVal->SNodes.length(0) ;
1349 RetVal->GNodes.length(0) ;
1350 RetVal->Graphs.length(0) ;
1353 for ( i = 0 ; i < DataFlowEditor()->Graph()->GraphNodesSize() ; i++ ) {
1354 GraphBase::ComputingNode * aNode = DataFlowEditor()->Graph()->GraphNodes( i ) ;
1355 RetVal = SetNode( RetVal , aNode ) ;
1358 char * aStateG = "" ;
1359 if ( DataFlowExecutor() ) {
1360 aStateG = (char *) DataFlowExecutor()->StateName( DataFlowExecutor()->AutomatonState() ) ;
1362 MESSAGE("Graph_Impl::Nodes GraphState " << aStateG << " CNodes " << RetVal->CNodes.length() ) ;
1363 for ( i = 0 ; i < RetVal->CNodes.length() ; i++ ) {
1364 MESSAGE(" " << RetVal->CNodes[ i ] ->Name() ) ;
1366 MESSAGE("FNodes " << RetVal->FNodes.length() ) ;
1367 for ( i = 0 ; i < RetVal->FNodes.length() ; i++ ) {
1368 MESSAGE(" " << RetVal->FNodes[ i ] ->Name() ) ;
1370 MESSAGE("INodes " << RetVal->INodes.length() ) ;
1371 for ( i = 0 ; i < RetVal->INodes.length() ; i++ ) {
1372 MESSAGE(" " << RetVal->INodes[ i ] ->Name() ) ;
1374 MESSAGE("GNodes " << RetVal->GNodes.length() ) ;
1375 for ( i = 0 ; i < RetVal->GNodes.length() ; i++ ) {
1376 MESSAGE(" " << RetVal->GNodes[ i ] ->Name() ) ;
1378 MESSAGE("LNodes " << RetVal->LNodes.length() ) ;
1379 for ( i = 0 ; i < RetVal->LNodes.length() ; i++ ) {
1380 MESSAGE(" " << RetVal->LNodes[ i ] ->Name() ) ;
1382 MESSAGE("ELNodes " << RetVal->ELNodes.length() ) ;
1383 for ( i = 0 ; i < RetVal->ELNodes.length() ; i++ ) {
1384 MESSAGE(" " << RetVal->ELNodes[ i ] ->Name() ) ;
1386 MESSAGE("SNodes " << RetVal->SNodes.length() ) ;
1387 for ( i = 0 ; i < RetVal->SNodes.length() ; i++ ) {
1388 MESSAGE(" " << RetVal->SNodes[ i ] ->Name() ) ;
1390 MESSAGE("ESNodes " << RetVal->ESNodes.length() ) ;
1391 for ( i = 0 ; i < RetVal->ESNodes.length() ; i++ ) {
1392 MESSAGE(" " << RetVal->ESNodes[ i ] ->Name() ) ;
1394 MESSAGE("Graphs " << RetVal->Graphs.length() ) ;
1395 for ( i = 0 ; i < RetVal->Graphs.length() ; i++ ) {
1396 MESSAGE(" " << RetVal->Graphs[ i ] ->Name() ) ;
1398 if ( DataFlowExecutor() ) {
1399 DataFlowExecutor()->EventList() ;
1403 endService( "Graph_Impl::Nodes" );
1404 return ( RetVal._retn() ) ;
1407 SUPERV::ListOfLinks * Graph_Impl::GLinks() {
1408 return Links( NULL , NULL ) ;
1411 SUPERV::ListOfLinks * Graph_Impl::Links( GraphBase::ComputingNode * theNode ,
1412 const char * anInputParam ) {
1414 SUPERV::ListOfLinks_var RetVal = new SUPERV::ListOfLinks ;
1415 RetVal->length( 0 ) ;
1417 int i , j , countlink ;
1419 for ( i = 0 ; i < DataFlowEditor()->Graph()->GraphNodesSize() ; i++ ) {
1420 GraphEditor::InNode * aNode = NULL ;
1421 aNode = (GraphEditor::InNode * ) DataFlowEditor()->Graph()->GraphNodes( i )->GetInNode() ;
1422 bool ToProcess = false ;
1423 if ( theNode == NULL ) {
1427 if ( !strcmp( theNode->Name() , aNode->Name() ) ) {
1428 if ( !theNode->IsEndSwitchNode() ) {
1432 else if ( theNode->IsEndSwitchNode() ) {
1437 for ( j = 0 ; j < aNode->GetNodeInPortsSize() ; j++ ) {
1438 GraphBase::InPort * anInPort = NULL ;
1439 anInPort = aNode->GetChangeNodeInPort( j ) ;
1440 if ( anInputParam == NULL ||
1441 !strcmp( anInPort->PortName() , anInputParam ) ) {
1442 GraphBase::OutPort * anOutPort = NULL ;
1443 anOutPort = anInPort->GetOutPort() ;
1444 if ( anOutPort && !anOutPort->IsDataStream() ) {
1445 if ( strcmp( anOutPort->NodeName() , Name() ) ) {
1446 // MESSAGE("Graph_Impl::Links " << anOutPort->NodeName() << "("
1447 // << anOutPort->PortName() << ") --> " << aNode->Name() << "("
1448 // << anInPort->PortName() << ")" ) ;
1449 if ( theNode == NULL ||
1450 ( theNode != NULL && !theNode->IsEndSwitchNode() &&
1451 !strcmp( theNode->Name() , aNode->Name() ) ) ) {
1452 if ( anInPort->IsLoop() || anOutPort->IsLoop() ||
1453 ( aNode->IsEndLoopNode() && !strcmp( aNode->CoupledNode()->Name() ,
1454 anOutPort->NodeName() ) ) ) {
1455 // MESSAGE( "Link " << anOutPort->NodeName() << "("
1456 // << anOutPort->PortName() << ") --> " << aNode->Name() << "("
1457 // << anInPort->PortName() << ")" << " ignored" ) ;
1459 else if ( CORBA::is_nil( anOutPort->InPortObjRef( anInPort ) ) ) {
1461 beginService( "Graph_Impl::Links" );
1464 GraphEditor::InNode * anOutNode = NULL ;
1465 anOutNode = (GraphEditor::InNode * ) DataFlowEditor()->Graph()->GetChangeGraphNode( anOutPort->NodeName() )->GetInNode() ;
1468 Link_Impl * myLink = new Link_Impl( _Orb , _Poa , _ContId ,
1469 instanceName() , interfaceName() ,
1472 anInPort->PortName() ,
1474 anOutPort->PortName() ,
1475 false , true , Success ) ;
1477 PortableServer::ObjectId * id = myLink->getId() ;
1478 CORBA::Object_var obj = _poa->id_to_reference(*id);
1479 SUPERV::Link_var iobject ;
1480 iobject = SUPERV::Link::_narrow(obj) ;
1481 RetVal->length( countlink + 1 ) ;
1482 RetVal[ countlink++ ] = SUPERV::Link::_duplicate( iobject ) ;
1483 anOutPort->AddInPortObjRef( anInPort , SUPERV::Link::_duplicate( iobject ) ) ;
1488 RetVal->length( countlink + 1 ) ;
1489 RetVal[ countlink++ ] = SUPERV::Link::_duplicate( anOutPort->InPortObjRef( anInPort ) ) ;
1491 // MESSAGE( "Link " << anOutPort->NodeName() << "("
1492 // << anOutPort->PortName() << ") --> " << aNode->Name() << "("
1493 // << anInPort->PortName() << ")" << " selected" ) ;
1496 // MESSAGE( "Link " << anOutPort->NodeName() << "("
1497 // << anOutPort->PortName() << ") --> " << aNode->Name() << "("
1498 // << anInPort->PortName() << ")" << " skipped" ) ;
1505 for ( j = 0 ; j < aNode->GetNodeOutPortsSize() ; j++ ) {
1506 GraphBase::OutPort * anOutPort = aNode->GetChangeNodeOutPort( j ) ;
1507 // MESSAGE( "Graph_Impl::Links " << aNode->Name() << " Out" << j << " " << anOutPort->PortName() << " "
1508 // << anOutPort->PortStatus() << " PortConnected to " << anOutPort->InPortsSize() << " InPorts" ) ;
1510 for ( k = 0 ; k < anOutPort->InPortsSize() ; k++ ) {
1511 GraphBase::InPort * anInPort = anOutPort->ChangeInPorts( k ) ;
1512 // MESSAGE( " --> In" << k << " " << anInPort->NodeName() << " " << anInPort->PortName()
1513 // << " " << anInPort->PortStatus() ) ;
1514 if ( anInPort->IsPortConnected() ) {
1515 GraphBase::ComputingNode * aComputingNode = DataFlowEditor()->Graph()->GetChangeGraphNode( anInPort->NodeName() ) ;
1516 GraphEditor::InNode * toNode = (GraphEditor::InNode * ) aComputingNode->GetInNode() ;
1517 if ( theNode == NULL ||
1518 !strcmp( theNode->Name() , aNode->Name() ) ) {
1519 if ( !anInPort->IsDataStream() ) {
1520 if ( theNode || ( toNode->IsEndSwitchNode() && !aNode->IsSwitchNode() ) ) {
1521 if ( anInputParam == NULL ||
1522 !strcmp( anInPort->PortName() , anInputParam ) ) {
1523 if ( anInPort->IsLoop() || anOutPort->IsLoop() ||
1524 ( toNode->IsEndLoopNode() && !strcmp( toNode->CoupledNode()->Name() ,
1525 anOutPort->NodeName() ) ) ) {
1526 // MESSAGE( "Link " << anOutPort->NodeName() << "("
1527 // << anOutPort->PortName() << ") --> " << toNode->Name() << "("
1528 // << anInPort->PortName() << ")" << " ignored" ) ;
1530 else if ( CORBA::is_nil( anOutPort->InPortObjRef( anInPort ) ) ) {
1532 beginService( "Graph_Impl::Links" );
1536 Link_Impl * myLink = new Link_Impl( _Orb , _Poa , _ContId ,
1537 instanceName() , interfaceName() ,
1540 anInPort->PortName() ,
1542 anOutPort->PortName() ,
1543 false , true , Success ) ;
1545 PortableServer::ObjectId * id = myLink->getId() ;
1546 CORBA::Object_var obj = _poa->id_to_reference(*id);
1547 SUPERV::Link_var iobject ;
1548 iobject = SUPERV::Link::_narrow(obj) ;
1549 RetVal->length( countlink + 1 ) ;
1550 RetVal[ countlink++ ] = SUPERV::Link::_duplicate( iobject ) ;
1551 anOutPort->AddInPortObjRef( anInPort , SUPERV::Link::_duplicate( iobject ) ) ;
1555 RetVal->length( countlink + 1 ) ;
1556 RetVal[ countlink++ ] = SUPERV::Link::_duplicate( SUPERV::Link::_narrow( anOutPort->InPortObjRef( anInPort ) ) ) ;
1558 // MESSAGE( "Link " << anOutPort->NodeName() << "("
1559 // << anOutPort->PortName() << ") --> " << toNode->Name() << "("
1560 // << anInPort->PortName() << ")" << " selected" ) ;
1563 // MESSAGE( "Link " << anOutPort->NodeName() << "("
1564 // << anOutPort->PortName() << ") --> " << toNode->Name() << "("
1565 // << anInPort->PortName() << ")" << " skipped" ) ;
1576 const char * NodeName = "" ;
1577 const char * InputParamName = "" ;
1579 NodeName = theNode->Name() ;
1581 if ( anInputParam ) {
1582 InputParamName = anInputParam ;
1584 MESSAGE( RetVal->length() << " Links of Node " << NodeName << " and of InPort " << InputParamName ) ;
1585 for ( i = 0 ; i < (int ) RetVal->length() ; i++ ) {
1586 MESSAGE( "Link " << RetVal[i]->OutPort()->Node()->Name() << "("
1587 << RetVal[i]->OutPort()->Name() << ") --> "
1588 << RetVal[i]->InPort()->Node()->Name() << "("
1589 << RetVal[i]->InPort()->Name() << ")" ) ;
1593 endService( "Graph_Impl::Links" );
1596 return ( RetVal._retn() ) ;
1599 Engines::Component_ptr Graph_Impl::ComponentRef( const char * aComputerContainer ,
1600 const char * aComponentName ) {
1601 Engines::Component_var objComponent = Engines::Component::_nil() ;
1603 Engines::Container_var myContainer ;
1604 DataFlowEditor()->Graph()->StartComponent( 0 , aComputerContainer , aComponentName ,
1605 myContainer , objComponent ) ;
1607 return Engines::Component::_duplicate( objComponent ) ;
1610 bool Graph_Impl::IsValid() {
1611 // beginService( "Graph_Impl::IsValid" );
1612 bool RetVal = false ;
1614 RetVal = DataFlowEditor()->IsValid() ;
1616 // endService( "Graph_Impl::IsValid" );
1619 bool Graph_Impl::IsExecutable() {
1620 // beginService( "Graph_Impl::IsExecutable" );
1621 bool RetVal = false ;
1623 RetVal = DataFlowEditor()->IsExecutable() ;
1625 // endService( "Graph_Impl::IsExecutable" );
1629 bool Graph_Impl::IsEditing() {
1631 bool RetVal = false ;
1633 RetVal = DataFlowEditor()->IsEditing() ;
1639 return !IsExecuting();
1642 bool Graph_Impl::IsExecuting() {
1644 bool RetVal = false ;
1646 RetVal = !DataFlowEditor()->IsEditing() ;
1650 return CNode_Impl::IsExecuting();
1653 bool Graph_Impl::IsReadOnly() {
1654 // beginService( "Graph_Impl::IsExecuting" );
1655 bool RetVal = false ;
1657 RetVal = DataFlowEditor()->IsReadOnly() ;
1659 // endService( "Graph_Impl::IsExecuting" );
1663 long Graph_Impl::LevelMax() {
1664 // beginService( "Graph_Impl::LevelMax" );
1667 RetVal = DataFlowEditor()->LevelMax() ;
1669 // endService( "Graph_Impl::LevelMax" );
1672 SUPERV::ListOfNodes * Graph_Impl::LevelNodes(long aLevel ) {
1673 // beginService( "Graph_Impl::LevelNodes" );
1674 SUPERV::ListOfNodes_var RetVal = new SUPERV::ListOfNodes;
1677 SUPERV::ListOfStrings_var Nodes = DataFlowEditor()->LevelNodes( aLevel ) ;
1678 // RetVal->length( Nodes->length() );
1679 for ( i = 0 ; i < (int ) Nodes->length() ; i++ ) {
1680 // char * aNode = Nodes[ i ] ;
1681 GraphBase::ComputingNode * aNode = DataFlowEditor()->Graph()->GetChangeGraphNode( Nodes[ i ] ) ;
1682 RetVal = SetNode( RetVal , aNode ) ;
1683 // cout << "Graph_Impl::LevelNodes( " << aLevel << " ) " << aNode->Name() << endl ;
1684 // CNode_Impl * myNode = new CNode_Impl( _Orb , _Poa , _ContId ,
1685 // instanceName() , interfaceName() ,
1686 // DataFlowEditor() ,
1687 // (GraphEditor::InNode * ) DataFlowEditor()->GetChangeGraphNode( aNode )->GetInNode() ) ;
1688 // PortableServer::ObjectId * id = myNode->getId() ;
1689 // CORBA::Object_var obj = _poa->id_to_reference(*id);
1690 // SUPERV::CNode_var iobject ;
1691 // iobject = SUPERV::CNode::_narrow(obj) ;
1692 // RetVal[i] = SUPERV::CNode::_duplicate( iobject ) ;
1695 // endService( "Graph_Impl::LevelNodes" );
1696 return ( RetVal._retn() ) ;
1698 long Graph_Impl::ThreadsMax() {
1699 // beginService( "Graph_Impl::ThreadsMax" );
1702 RetVal = DataFlowEditor()->ThreadsMax() ;
1704 // endService( "Graph_Impl::ThreadsMax" );
1707 long Graph_Impl::Threads() {
1708 // beginService( "Node_Impl::Threads" );
1709 long RetVal = false ;
1711 RetVal = DataFlowExecutor()->Threads() ;
1713 // endService( "Node_Impl::Threads" );
1716 long Graph_Impl::SuspendedThreads() {
1717 // beginService( "Node_Impl::SuspendedThreads" );
1718 long RetVal = false ;
1720 RetVal = DataFlowExecutor()->SuspendedThreads() ;
1722 // endService( "Node_Impl::SuspendedThreads" );
1726 bool Graph_Impl::Begin() {
1727 bool RetVal = false ;
1728 if ( DataFlowEditor()->IsEditing() ) {
1729 if ( pthread_mutex_lock( &_MutexExecutorWait ) ) {
1730 perror("pthread_mutex_lock _MutexExecutorWait") ;
1733 if ( DataFlowExecutor() ) {
1734 MESSAGE( "Graph_Impl::Begin " << DataFlowExecutor()->Threads() << " threads" )
1735 // if ( DataFlowExecutor()->Threads() ) {
1736 // DataFlowExecutor()->JoinedWait() ;
1738 delete DataFlowExecutor() ;
1739 DataFlowEditor()->Executor( NULL ) ;
1741 if ( DataFlowEditor()->IsExecutable() ) {
1742 DataFlowEditor()->EditedAfterExecution( false ) ;
1743 GraphBase::ListOfSGraphs * myListOfGraphs = DataFlowEditor()->GetDataFlows() ;
1745 GraphExecutor::DataFlow * aDataFlowExecutor ;
1747 CreateExecutor( _Orb , instanceName() , (*myListOfGraphs)[ 0 ].Info.theName.c_str() , Kind() ,
1748 dbgfile , &aDataFlowExecutor ) ;
1750 MESSAGE( "Graph_Impl::Begin : DataFlowExecutor created" );
1751 if ( !CORBA::is_nil( LoadDataFlows( aDataFlowExecutor, myListOfGraphs , 0 ) ) )
1755 DataFlowExecutor()->Graph()->SetObjImpl( DataFlowEditor()->Graph()->ObjImpl() ) ;
1758 if ( pthread_mutex_unlock( &_MutexExecutorWait ) ) {
1759 perror("pthread_mutex_unlock _MutexExecutorWait") ;
1765 bool Graph_Impl::Run() {
1766 beginService( "Graph_Impl::Run" );
1767 bool RetVal = false ;
1768 if ( ( DataFlowEditor()->IsEditing() || IsDone() ) && !IsMacro() ) {
1769 MESSAGE( "Graph_Impl::Run " << DataFlowEditor()->Graph()->Name() << " " << DataFlowEditor() << " IsEditing" );
1770 if ( DataFlowEditor()->Graph()->GraphMacroLevel() ) {
1771 MESSAGE( "Graph_Impl::Run " << DataFlowEditor()->Graph()->Name() << " GraphMacroLevel "
1772 << DataFlowEditor()->Graph()->GraphMacroLevel() ) ;
1776 MESSAGE( "Graph_Impl::Run " << DataFlowEditor()->Graph()->Name() << " GraphMacroLevel "
1777 << DataFlowEditor()->Graph()->GraphMacroLevel() << " --> Begin()" ) ;
1781 MESSAGE( "Graph_Impl::Run " );
1782 DataFlowEditor()->Executing() ;
1783 RetVal = CNode_Impl::Run() ;
1786 // It is necessary to reload the dataflow because of ports with input initial values changed
1787 // during execution to values of outport of EndLoopNode or GOTONode
1788 // else if ( !IsMacro() && IsDone() ) {
1789 // MESSAGE( "Graph_Impl::Run " << DataFlowEditor()->Graph()->Name() << " " << DataFlowEditor()
1790 // << " IsNOTEditing --> CNode_Impl::ReRun" );
1791 // DataFlowEditor()->Executing() ;
1792 // RetVal = CNode_Impl::ReRun() ;
1794 MESSAGE( "Graph_Impl::Run " << DataFlowEditor()->Graph()->Name() << " RetVal " << RetVal ) ;
1795 endService( "Graph_Impl::Run" );
1798 bool Graph_Impl::Start() {
1799 beginService( "Graph_Impl::Start" );
1800 bool RetVal = false ;
1801 if ( ( DataFlowEditor()->IsEditing() || IsDone() ) && !IsMacro() ) {
1802 MESSAGE( "Graph_Impl::Start " << DataFlowEditor()->Graph()->Name() << " " << DataFlowEditor() << " IsEditing" );
1803 if ( DataFlowEditor()->Graph()->GraphMacroLevel() ) {
1804 MESSAGE( "Graph_Impl::Start " << DataFlowEditor()->Graph()->Name() << " GraphMacroLevel "
1805 << DataFlowEditor()->Graph()->GraphMacroLevel() ) ;
1809 MESSAGE( "Graph_Impl::Start " << DataFlowEditor()->Graph()->Name() << " GraphMacroLevel "
1810 << DataFlowEditor()->Graph()->GraphMacroLevel() << " --> Begin()" ) ;
1814 // Added by NKV to fix PAL6222 --> to be confirm by JR ; JR confirmed
1815 DataFlowEditor()->Executing() ;
1816 // End of NKV's correction
1817 MESSAGE( "Graph_Impl::(Re)Start " );
1818 RetVal = ReStart() ;
1821 // It is necessary to reload the dataflow because of ports with input initial values changed
1822 // during execution to values of outport of EndLoopNode or GOTONode
1823 // else if ( !IsMacro() && IsDone() ) {
1824 // MESSAGE( "Graph_Impl::Start " << DataFlowEditor()->Graph()->Name() << " " << DataFlowEditor()
1825 // << " IsNOTEditing --> CNode_Impl::ReStart" );
1826 // DataFlowEditor()->Executing() ;
1827 // RetVal = CNode_Impl::ReStart() ;
1829 MESSAGE( "Graph_Impl::Start " << DataFlowEditor()->Graph()->Name() << " RetVal " << RetVal ) ;
1830 endService( "Graph_Impl::Start" );
1834 bool Graph_Impl::EventNoW( SUPERV::CNode_out aNode ,
1835 SUPERV::GraphEvent & anEvent ,
1836 SUPERV::GraphState & aState ) {
1837 bool RetVal = false ;
1838 char * aNodeName = NULL ;
1839 SUPERV::GraphEvent theEvent = SUPERV::UndefinedEvent ;
1840 SUPERV::GraphState theState = SUPERV::UndefinedState ;
1841 if ( pthread_mutex_lock( &_MutexExecutorWait ) ) {
1842 perror("pthread_mutex_lock _MutexExecutorWait") ;
1845 if ( DataFlowExecutor() && !IsMacro() &&
1846 ( DataFlowExecutor()->GetListSize() || !DataFlowEditor()->IsEditing() ) ) {
1847 RetVal = DataFlowExecutor()->Event( & aNodeName , theEvent , theState , false ) ;
1848 // endService( "Graph_Impl::Event" );
1849 if ( strlen( aNodeName ) ) {
1850 if ( strcmp( aNodeName , Name() ) ) {
1851 aNode = Node( aNodeName ) ;
1858 aNode = SUPERV::Graph::_duplicate( SUPERV::Graph::_nil() ) ;
1860 // cout << "Graph_Impl::EventNoW " << aNode->Name() << " QSize " << DataFlowExecutor()->GetListSize() << endl ;
1863 // cout << "Graph_Impl::EventNoW NO DataFlowExecutor() or QSize=0 " << endl ;
1865 if ( pthread_mutex_unlock( &_MutexExecutorWait ) ) {
1866 perror("pthread_mutex_unlock _MutexExecutorWait") ;
1869 anEvent = theEvent ;
1874 bool Graph_Impl::Event( SUPERV::CNode_out aNode ,
1875 SUPERV::GraphEvent & anEvent ,
1876 SUPERV::GraphState & aState ) {
1877 // beginService( "Graph_Impl::Event" );
1878 bool RetVal = false ;
1879 char * aNodeName = NULL ;
1880 SUPERV::GraphEvent theEvent = SUPERV::UndefinedEvent ;
1881 SUPERV::GraphState theState = SUPERV::UndefinedState ;
1882 if ( pthread_mutex_lock( &_MutexExecutorWait ) ) {
1883 perror("pthread_mutex_lock _MutexExecutorWait") ;
1886 if ( DataFlowExecutor() && !IsMacro() &&
1887 ( DataFlowExecutor()->GetListSize() || !DataFlowEditor()->IsEditing() ) ){
1888 RetVal = DataFlowExecutor()->Event( & aNodeName , theEvent , theState ) ;
1889 // endService( "Graph_Impl::Event" );
1890 if ( strlen( aNodeName ) ) {
1891 if ( strcmp( aNodeName , Name() ) ) {
1892 aNode = Node( aNodeName ) ;
1899 aNode = SUPERV::Graph::_duplicate( SUPERV::Graph::_nil() ) ;
1901 // cout << "Graph_Impl::Event " << aNode->Name() << " QSize " << DataFlowExecutor()->GetListSize() << endl ;
1904 // cout << "Graph_Impl::Event NO DataFlowExecutor() or QSize=0 " << endl ;
1906 if ( pthread_mutex_unlock( &_MutexExecutorWait ) ) {
1907 perror("pthread_mutex_unlock _MutexExecutorWait") ;
1910 anEvent = theEvent ;
1915 bool Graph_Impl::EventW( SUPERV::CNode_out aNode ,
1916 SUPERV::GraphEvent & anEvent ,
1917 SUPERV::GraphState & aState ) {
1918 // beginService( "Graph_Impl::EventW" );
1919 bool RetVal = false ;
1920 char * aNodeName = NULL ;
1921 SUPERV::GraphEvent theEvent = SUPERV::UndefinedEvent ;
1922 SUPERV::GraphState theState = SUPERV::UndefinedState ;
1923 if ( pthread_mutex_lock( &_MutexExecutorWait ) ) {
1924 perror("pthread_mutex_lock _MutexExecutorWait") ;
1927 if ( DataFlowExecutor() && !IsMacro() &&
1928 ( DataFlowExecutor()->GetListSize() || !DataFlowEditor()->IsEditing() ) ) {
1929 RetVal = DataFlowExecutor()->EventW( & aNodeName , theEvent , theState ) ;
1930 if ( RetVal && strcmp( aNodeName , Name() ) ) {
1931 aNode = Node( aNodeName ) ;
1937 if ( pthread_mutex_unlock( &_MutexExecutorWait ) ) {
1938 perror("pthread_mutex_unlock _MutexExecutorWait") ;
1941 anEvent = theEvent ;
1943 // endService( "Graph_Impl::EventW" );
1947 long Graph_Impl::EventQSize() {
1948 // beginService( "Graph_Impl::EventQSize" );
1950 if ( pthread_mutex_lock( &_MutexExecutorWait ) ) {
1951 perror("pthread_mutex_lock _MutexExecutorWait") ;
1954 if ( DataFlowExecutor() && !IsMacro() ) {
1955 QSize = DataFlowExecutor()->EventQSize() ;
1957 if ( pthread_mutex_unlock( &_MutexExecutorWait ) ) {
1958 perror("pthread_mutex_unlock _MutexExecutorWait") ;
1961 // endService( "Graph_Impl::EventQSize" );
1965 long Graph_Impl::LastLevelDone() {
1966 // beginService( "Graph_Impl::LastLevelDone" );
1967 if ( pthread_mutex_lock( &_MutexExecutorWait ) ) {
1968 perror("pthread_mutex_lock _MutexExecutorWait") ;
1972 if ( DataFlowExecutor() && !IsMacro() ) {
1973 RetVal = DataFlowExecutor()->LastLevelDone() ;
1975 if ( pthread_mutex_unlock( &_MutexExecutorWait ) ) {
1976 perror("pthread_mutex_unlock _MutexExecutorWait") ;
1979 // endService( "Graph_Impl::LastLevelDone" );
1983 long Graph_Impl::SubGraphsNumber() {
1984 // beginService( "Graph_Impl::SubGraphsNumber" );
1986 if ( DataFlowEditor()->IsExecutable() && !IsMacro() ) {
1987 RetVal = DataFlowEditor()->SubGraphsNumber() ;
1989 // endService( "Graph_Impl::SubGraphsNumber" );
1993 SUPERV::ListOfNodes * Graph_Impl::SubGraphsNodes( const long aSubGraphNumber ) {
1994 beginService( "Graph_Impl::SubGraphsNodes" );
1995 SUPERV::ListOfNodes_var RetVal = new SUPERV::ListOfNodes ;
1996 if ( DataFlowEditor()->IsEditing() && !IsMacro() ) {
1997 SUPERV::ListOfNodes * aGraphNodes = Nodes() ;
2000 for ( i = 0 ; i < (int ) aGraphNodes->CNodes.length() ; i++ ) {
2001 SUPERV::CNode_var aNode = (aGraphNodes->CNodes)[ i ] ;
2002 if ( aNode->SubGraph() == aSubGraphNumber ) {
2003 RetVal = SetNode( RetVal , DataFlowEditor()->Graph()->GetChangeGraphNode( aNode->Name() ) ) ;
2007 for ( i = 0 ; i < (int ) aGraphNodes->FNodes.length() ; i++ ) {
2008 SUPERV::FNode_var aNode = (aGraphNodes->FNodes)[ i ] ;
2009 if ( aNode->SubGraph() == aSubGraphNumber ) {
2010 RetVal = SetNode( RetVal , DataFlowEditor()->Graph()->GetChangeGraphNode( aNode->Name() ) ) ;
2014 for ( i = 0 ; i < (int ) aGraphNodes->INodes.length() ; i++ ) {
2015 SUPERV::INode_var aNode = (aGraphNodes->INodes)[ i ] ;
2016 if ( aNode->SubGraph() == aSubGraphNumber ) {
2017 RetVal = SetNode( RetVal , DataFlowEditor()->Graph()->GetChangeGraphNode( aNode->Name() ) ) ;
2021 for ( i = 0 ; i < (int ) aGraphNodes->GNodes.length() ; i++ ) {
2022 SUPERV::GNode_var aNode = (aGraphNodes->GNodes)[ i ] ;
2023 if ( aNode->SubGraph() == aSubGraphNumber ) {
2024 RetVal = SetNode( RetVal , DataFlowEditor()->Graph()->GetChangeGraphNode( aNode->Name() ) ) ;
2028 for ( i = 0 ; i < (int ) aGraphNodes->LNodes.length() ; i++ ) {
2029 SUPERV::LNode_var aNode = (aGraphNodes->LNodes)[ i ] ;
2030 if ( aNode->SubGraph() == aSubGraphNumber ) {
2031 RetVal = SetNode( RetVal , DataFlowEditor()->Graph()->GetChangeGraphNode( aNode->Name() ) ) ;
2035 for ( i = 0 ; i < (int ) aGraphNodes->ELNodes.length() ; i++ ) {
2036 SUPERV::ELNode_var aNode = (aGraphNodes->ELNodes)[ i ] ;
2037 if ( aNode->SubGraph() == aSubGraphNumber ) {
2038 RetVal = SetNode( RetVal , DataFlowEditor()->Graph()->GetChangeGraphNode( aNode->Name() ) ) ;
2042 for ( i = 0 ; i < (int ) aGraphNodes->SNodes.length() ; i++ ) {
2043 SUPERV::SNode_var aNode = (aGraphNodes->SNodes)[ i ] ;
2044 if ( aNode->SubGraph() == aSubGraphNumber ) {
2045 RetVal = SetNode( RetVal , DataFlowEditor()->Graph()->GetChangeGraphNode( aNode->Name() ) ) ;
2049 for ( i = 0 ; i < (int ) aGraphNodes->ESNodes.length() ; i++ ) {
2050 SUPERV::ESNode_var aNode = (aGraphNodes->ESNodes)[ i ] ;
2051 if ( aNode->SubGraph() == aSubGraphNumber ) {
2052 RetVal = SetNode( RetVal , DataFlowEditor()->Graph()->GetChangeGraphNode( aNode->Name() ) ) ;
2056 endService( "Graph_Impl::SubGraphsNodes" );
2057 return ( RetVal._retn() ) ;
2060 bool Graph_Impl::Merge(const SUPERV::Graph_ptr aGraph ) {
2061 // beginService( "Graph_Impl::Merge" );
2062 bool RetVal = true ;
2064 map< string , int > aMapOfNodes ;
2065 RetVal = Merge( aGraph , aMapOfNodes ) ;
2067 // endService( "Graph_Impl::Merge" );
2071 bool Graph_Impl::Merge(const SUPERV::Graph_ptr aGraph , map< string , int > & aMapOfNodes ) {
2072 beginService( "Graph_Impl::Merge" );
2073 bool RetVal = true ;
2074 if ( DataFlowEditor()->IsEditing() && !IsMacro() ) {
2075 SUPERV::ListOfNodes * aGraphNodes = aGraph->Nodes() ;
2077 SUPERV::Port_ptr aPort ;
2078 // SUPERV::StreamPort_ptr aStreamPort ;
2080 for ( i = 0 ; i < (int ) aGraphNodes->CNodes.length() ; i++ ) {
2081 SUPERV::CNode_var aNode = (aGraphNodes->CNodes)[ i ] ;
2082 SUPERV::CNode_ptr myNode = CNode( *(aNode->Service()) ) ;
2083 if ( !CORBA::is_nil( myNode ) ) {
2084 myNode->SetName( aNode->Name() ) ;
2085 myNode->SetAuthor( aNode->Author() ) ;
2086 myNode->SetComment( aNode->Comment() ) ;
2087 myNode->Coords( aNode->X() , aNode->Y() ) ;
2088 string * aNodetheName = new string( aNode->Name() ) ;
2089 aMapOfNodes[ *aNodetheName ] = DataFlowEditor()->Graph()->GetGraphNodeIndex( myNode->Name() ) ;
2090 delete aNodetheName ;
2097 // The following informations are now in the service from SALOME_ModuleCatalog
2098 // SUPERV::ListOfStreamPorts myStreamPorts = *(aNode->StreamPorts()) ;
2100 // for ( j = 0 ; j < (int ) myStreamPorts.length() ; j++ ) {
2101 // if ( myStreamPorts[ j ]->IsInput() && myStreamPorts[ j ]->IsDataStream() ) {
2102 // aStreamPort = myNode->InStreamPort( myStreamPorts[ j ]->Name() , myStreamPorts[ j ]->Type() ) ;
2104 // else if ( myStreamPorts[ j ]->IsDataStream() ) {
2105 // aStreamPort = myNode->OutStreamPort( myStreamPorts[ j ]->Name() , myStreamPorts[ j ]->Type() ) ;
2111 for ( i = 0 ; i < (int ) aGraphNodes->FNodes.length() ; i++ ) {
2112 SUPERV::FNode_var aNode = (aGraphNodes->FNodes)[ i ] ;
2113 SUPERV::FNode_ptr myNode = FNode( aNode->GetComponentName() ,
2114 aNode->GetInterfaceName() ,
2115 *(aNode->Service()) ) ;
2116 if ( !CORBA::is_nil( myNode ) ) {
2117 myNode->SetName( aNode->Name() ) ;
2118 myNode->SetAuthor( aNode->Author() ) ;
2119 myNode->SetComment( aNode->Comment() ) ;
2120 myNode->Coords( aNode->X() , aNode->Y() ) ;
2121 string * aNodetheName = new string( aNode->Name() ) ;
2122 aMapOfNodes[ *aNodetheName ] = DataFlowEditor()->Graph()->GetGraphNodeIndex( myNode->Name() ) ;
2123 delete aNodetheName ;
2130 // The following informations are now in the service from SALOME_ModuleCatalog
2131 // SUPERV::ListOfStreamPorts myStreamPorts = *(aNode->StreamPorts()) ;
2133 // for ( j = 0 ; j < (int ) myStreamPorts.length() ; j++ ) {
2134 // if ( myStreamPorts[ j ]->IsInput() && myStreamPorts[ j ]->IsDataStream() ) {
2135 // aStreamPort = myNode->InStreamPort( myStreamPorts[ j ]->Name() , myStreamPorts[ j ]->Type() ) ;
2137 // else if ( myStreamPorts[ j ]->IsDataStream() ) {
2138 // aStreamPort = myNode->OutStreamPort( myStreamPorts[ j ]->Name() , myStreamPorts[ j ]->Type() ) ;
2145 for ( i = 0 ; i < (int ) aGraphNodes->INodes.length() ; i++ ) {
2146 SUPERV::INode_var aNode = (aGraphNodes->INodes)[ i ] ;
2147 SUPERV::INode_ptr myNode = INode( aNode->PyFuncName() , *(aNode->PyFunction()) ) ;
2148 if ( !CORBA::is_nil( myNode ) ) {
2149 myNode->SetName( aNode->Name() ) ;
2150 myNode->SetAuthor( aNode->Author() ) ;
2151 myNode->SetComment( aNode->Comment() ) ;
2152 myNode->Coords( aNode->X() , aNode->Y() ) ;
2153 string * aNodetheName = new string( aNode->Name() ) ;
2154 aMapOfNodes[ *aNodetheName ] = DataFlowEditor()->Graph()->GetGraphNodeIndex( myNode->Name() ) ;
2155 delete aNodetheName ;
2156 SUPERV::ListOfPorts myPorts = *(aNode->Ports()) ;
2158 for ( j = 0 ; j < (int ) myPorts.length() ; j++ ) {
2159 if ( myPorts[ j ]->IsInput() ) {
2160 aPort = myNode->InPort( myPorts[ j ]->Name() , myPorts[ j ]->Type() ) ;
2163 aPort = myNode->OutPort( myPorts[ j ]->Name() , myPorts[ j ]->Type() ) ;
2166 if ( DataFlowEditor()->Graph()->IsDataStreamNode() ) {
2167 SUPERV::ListOfStreamPorts myStreamPorts = *(aNode->StreamPorts()) ;
2168 for ( j = 0 ; j < (int ) myStreamPorts.length() ; j++ ) {
2169 if ( myStreamPorts[ j ]->IsInput() ) {
2170 aPort = myNode->InStreamPort( myStreamPorts[ j ]->Name() , StringToDataStreamType( myStreamPorts[ j ]->Type() ) , myStreamPorts[ j ]->Dependency() ) ;
2173 aPort = myNode->OutStreamPort( myStreamPorts[ j ]->Name() , StringToDataStreamType( myStreamPorts[ j ]->Type() ) , myStreamPorts[ j ]->Dependency() ) ;
2187 for ( i = 0 ; i < (int ) aGraphNodes->GNodes.length() ; i++ ) {
2188 SUPERV::GNode_var aNode = (aGraphNodes->GNodes)[ i ] ;
2189 SUPERV::GNode_ptr myNode = GNode( aNode->PyFuncName() , *(aNode->PyFunction()) , aNode->Coupled()->Name() ) ;
2190 if ( !CORBA::is_nil( myNode ) ) {
2191 myNode->SetName( aNode->Name() ) ;
2192 myNode->SetAuthor( aNode->Author() ) ;
2193 myNode->SetComment( aNode->Comment() ) ;
2194 myNode->Coords( aNode->X() , aNode->Y() ) ;
2195 string * aNodetheName = new string( aNode->Name() ) ;
2196 aMapOfNodes[ *aNodetheName ] = DataFlowEditor()->Graph()->GetGraphNodeIndex( myNode->Name() ) ;
2197 delete aNodetheName ;
2198 SUPERV::ListOfPorts myPorts = *(aNode->Ports()) ;
2200 for ( j = 0 ; j < (int ) myPorts.length() ; j++ ) {
2201 if ( myPorts[ j ]->IsInput() ) {
2202 aPort = myNode->InPort( myPorts[ j ]->Name() , myPorts[ j ]->Type() ) ;
2205 aPort = myNode->OutPort( myPorts[ j ]->Name() , myPorts[ j ]->Type() ) ;
2208 if ( DataFlowEditor()->Graph()->IsDataStreamNode() ) {
2209 SUPERV::ListOfStreamPorts myStreamPorts = *(aNode->StreamPorts()) ;
2210 for ( j = 0 ; j < (int ) myStreamPorts.length() ; j++ ) {
2211 if ( myStreamPorts[ j ]->IsInput() ) {
2212 aPort = myNode->InStreamPort( myStreamPorts[ j ]->Name() , StringToDataStreamType( myStreamPorts[ j ]->Type() ) , myStreamPorts[ j ]->Dependency() ) ;
2215 aPort = myNode->OutStreamPort( myStreamPorts[ j ]->Name() , StringToDataStreamType( myStreamPorts[ j ]->Type() ) , myStreamPorts[ j ]->Dependency() ) ;
2229 for ( i = 0 ; i < (int ) aGraphNodes->LNodes.length() ; i++ ) {
2230 SUPERV::LNode_var aNode = (aGraphNodes->LNodes)[ i ] ;
2231 SUPERV::INode_ptr anEndOfLoop ;
2232 SUPERV::LNode_ptr myNode = LNode( aNode->PyInitName() ,
2233 *(aNode->PyInit()) ,
2234 aNode->PyMoreName() ,
2235 *(aNode->PyMore()) ,
2236 aNode->PyNextName() ,
2237 *(aNode->PyNext()) ,
2239 if ( !CORBA::is_nil( myNode ) ) {
2240 myNode->SetName( aNode->Name() ) ;
2241 myNode->SetAuthor( aNode->Author() ) ;
2242 myNode->SetComment( aNode->Comment() ) ;
2243 myNode->Coords( aNode->X() , aNode->Y() ) ;
2244 string * aNodetheName = new string( aNode->Name() ) ;
2245 aMapOfNodes[ *aNodetheName ] = DataFlowEditor()->Graph()->GetGraphNodeIndex( myNode->Name() ) ;
2246 delete aNodetheName ;
2247 SUPERV::ListOfPorts myPorts = *(aNode->Ports()) ;
2249 for ( j = 0 ; j < (int ) myPorts.length() ; j++ ) {
2250 if ( myPorts[ j ]->IsInput() ) {
2251 aPort = myNode->InPort( myPorts[ j ]->Name() , myPorts[ j ]->Type() ) ;
2254 aPort = myNode->OutPort( myPorts[ j ]->Name() , myPorts[ j ]->Type() ) ;
2257 if ( DataFlowEditor()->Graph()->IsDataStreamNode() ) {
2258 SUPERV::ListOfStreamPorts myStreamPorts = *(aNode->StreamPorts()) ;
2259 for ( j = 0 ; j < (int ) myStreamPorts.length() ; j++ ) {
2260 if ( myStreamPorts[ j ]->IsInput() ) {
2261 aPort = myNode->InStreamPort( myStreamPorts[ j ]->Name() , StringToDataStreamType( myStreamPorts[ j ]->Type() ) , myStreamPorts[ j ]->Dependency() ) ;
2264 aPort = myNode->OutStreamPort( myStreamPorts[ j ]->Name() , StringToDataStreamType( myStreamPorts[ j ]->Type() ) , myStreamPorts[ j ]->Dependency() ) ;
2268 SUPERV::INode_ptr myEndOfLoop = aNode->Coupled() ;
2269 anEndOfLoop->SetName( myEndOfLoop->Name() ) ;
2270 anEndOfLoop->SetAuthor( myEndOfLoop->Author() ) ;
2271 anEndOfLoop->SetComment( myEndOfLoop->Comment() ) ;
2272 anEndOfLoop->Coords( myEndOfLoop->X() , myEndOfLoop->Y() ) ;
2273 anEndOfLoop->SetPyFunction( myEndOfLoop->PyFuncName() , *(myEndOfLoop->PyFunction()) ) ;
2274 aNodetheName = new string( myEndOfLoop->Name() ) ;
2275 aMapOfNodes[ *aNodetheName ] = DataFlowEditor()->Graph()->GetGraphNodeIndex( anEndOfLoop->Name() ) ;
2276 if ( DataFlowEditor()->Graph()->IsDataStreamNode() ) {
2277 SUPERV::ListOfStreamPorts myStreamLoopPorts = *(myEndOfLoop->StreamPorts()) ;
2278 for ( j = 0 ; j < (int ) myStreamLoopPorts.length() ; j++ ) {
2279 if ( myStreamLoopPorts[ j ]->IsInput() ) {
2280 aPort = myNode->InStreamPort( myStreamLoopPorts[ j ]->Name() , StringToDataStreamType( myStreamLoopPorts[ j ]->Type() ) , myStreamLoopPorts[ j ]->Dependency() ) ;
2283 aPort = myNode->OutStreamPort( myStreamLoopPorts[ j ]->Name() , StringToDataStreamType( myStreamLoopPorts[ j ]->Type() ) , myStreamLoopPorts[ j ]->Dependency() ) ;
2287 delete aNodetheName ;
2298 for ( i = 0 ; i < (int ) aGraphNodes->SNodes.length() ; i++ ) {
2299 SUPERV::SNode_var aNode = (aGraphNodes->SNodes)[ i ] ;
2300 SUPERV::INode_ptr anEndOfSwitch ;
2301 SUPERV::SNode_ptr myNode = SNode( aNode->PyFuncName() , *(aNode->PyFunction()) , anEndOfSwitch ) ;
2302 if ( !CORBA::is_nil( myNode ) ) {
2303 myNode->SetName( aNode->Name() ) ;
2304 myNode->SetAuthor( aNode->Author() ) ;
2305 myNode->SetComment( aNode->Comment() ) ;
2306 myNode->Coords( aNode->X() , aNode->Y() ) ;
2307 string * aNodetheName = new string( aNode->Name() ) ;
2308 aMapOfNodes[ *aNodetheName ] = DataFlowEditor()->Graph()->GetGraphNodeIndex( myNode->Name() ) ;
2309 delete aNodetheName ;
2310 SUPERV::ListOfPorts myPorts = *(aNode->Ports()) ;
2312 for ( j = 0 ; j < (int ) myPorts.length() ; j++ ) {
2313 if ( myPorts[ j ]->IsInput() ) {
2314 aPort = myNode->InPort( myPorts[ j ]->Name() , myPorts[ j ]->Type() ) ;
2317 aPort = myNode->OutPort( myPorts[ j ]->Name() , myPorts[ j ]->Type() ) ;
2320 if ( DataFlowEditor()->Graph()->IsDataStreamNode() ) {
2321 SUPERV::ListOfStreamPorts myStreamPorts = *(aNode->StreamPorts()) ;
2322 for ( j = 0 ; j < (int ) myStreamPorts.length() ; j++ ) {
2323 if ( myStreamPorts[ j ]->IsInput() ) {
2324 aPort = myNode->InStreamPort( myStreamPorts[ j ]->Name() , StringToDataStreamType( myStreamPorts[ j ]->Type() ) , myStreamPorts[ j ]->Dependency() ) ;
2327 aPort = myNode->OutStreamPort( myStreamPorts[ j ]->Name() , StringToDataStreamType( myStreamPorts[ j ]->Type() ) , myStreamPorts[ j ]->Dependency() ) ;
2331 SUPERV::INode_ptr myEndOfSwitch = aNode->Coupled() ;
2332 anEndOfSwitch->SetName( myEndOfSwitch->Name() ) ;
2333 anEndOfSwitch->SetAuthor( myEndOfSwitch->Author() ) ;
2334 anEndOfSwitch->SetComment( myEndOfSwitch->Comment() ) ;
2335 anEndOfSwitch->Coords( myEndOfSwitch->X() , myEndOfSwitch->Y() ) ;
2336 anEndOfSwitch->SetPyFunction( myEndOfSwitch->PyFuncName() , *(myEndOfSwitch->PyFunction()) ) ;
2337 aNodetheName = new string( myEndOfSwitch->Name() ) ;
2338 aMapOfNodes[ *aNodetheName ] = DataFlowEditor()->Graph()->GetGraphNodeIndex( anEndOfSwitch->Name() ) ;
2339 delete aNodetheName ;
2340 myPorts = *(myEndOfSwitch->Ports()) ;
2341 for ( j = 0 ; j < (int ) myPorts.length() ; j++ ) {
2342 if ( myPorts[ j ]->IsInput() ) {
2343 aPort = myNode->InPort( myPorts[ j ]->Name() , myPorts[ j ]->Type() ) ;
2346 aPort = myNode->OutPort( myPorts[ j ]->Name() , myPorts[ j ]->Type() ) ;
2349 if ( DataFlowEditor()->Graph()->IsDataStreamNode() ) {
2350 SUPERV::ListOfStreamPorts myStreamSwitchPorts = *(myEndOfSwitch->StreamPorts()) ;
2351 for ( j = 0 ; j < (int ) myStreamSwitchPorts.length() ; j++ ) {
2352 if ( myStreamSwitchPorts[ j ]->IsInput() ) {
2353 aPort = myNode->InStreamPort( myStreamSwitchPorts[ j ]->Name() , StringToDataStreamType( myStreamSwitchPorts[ j ]->Type() ) , myStreamSwitchPorts[ j ]->Dependency() ) ;
2356 aPort = myNode->OutStreamPort( myStreamSwitchPorts[ j ]->Name() , StringToDataStreamType( myStreamSwitchPorts[ j ]->Type() ) , myStreamSwitchPorts[ j ]->Dependency() ) ;
2369 SUPERV::ListOfLinks * aGraphLinks = aGraph->GLinks() ;
2370 SUPERV::ListOfPorts * aGraphPorts = aGraph->Ports() ;
2371 // cout << "Graph_Impl::Merge " << aGraphLinks->length() << " links " << aGraphPorts->length() << " GraphPorts"
2373 for ( i = 0 ; i < (int ) aGraphLinks->length() ; i++ ) {
2374 SUPERV::Link_var aLink = (*aGraphLinks)[ i ] ;
2375 SUPERV::Port_var OutPort = aLink->OutPort() ;
2376 SUPERV::Port_var InPort = aLink->InPort() ;
2377 string * aLinkFromNodeName = new string( OutPort->Node()->Name() ) ;
2378 string * aLinkToNodeName = new string( InPort->Node()->Name() ) ;
2379 RetVal = DataFlowEditor()->AddLink( DataFlowEditor()->Graph()->GetGraphNode( aMapOfNodes[ aLinkFromNodeName->c_str() ] )->Name() ,
2381 DataFlowEditor()->Graph()->GetGraphNode( aMapOfNodes[ aLinkToNodeName->c_str() ] )->Name() ,
2385 for ( j = 1 ; j <= aLink->CoordsSize() ; j++ ) {
2387 RetVal = aLink->Coords( j , X , Y ) ;
2390 RetVal = DataFlowEditor()->AddLinkCoord( DataFlowEditor()->Graph()->GetGraphNode( aMapOfNodes[ aLinkFromNodeName->c_str() ] )->Name() ,
2392 DataFlowEditor()->Graph()->GetGraphNode( aMapOfNodes[ aLinkToNodeName->c_str() ] )->Name() ,
2400 delete aLinkFromNodeName ;
2401 delete aLinkToNodeName ;
2407 for ( i = 0 ; i < (int ) aGraphPorts->length() ; i++ ) {
2408 SUPERV::Port_var aPort = (*aGraphPorts)[ i ] ;
2409 if ( !aPort->IsGate() ) {
2410 MESSAGE( "Graph_Impl::Merge " << i << ". " << aPort->Node()->Name() << " " << aPort->Name() ) ;
2411 char * aPortName = aPort->Name() ;
2412 char * aNodeName = new char[ strlen( aPortName ) + 1 ] ;
2413 strcpy( aNodeName , aPortName ) ;
2414 // char * thePortName = strchr( aNodeName , '\\' ) ;
2415 char * thePortName = aNodeName ;
2416 while ( ( thePortName = strchr( thePortName , '_' ) ) ) {
2417 if ( thePortName[1] == '_' ) {
2418 thePortName[ 0 ] = '\0' ;
2422 thePortName = &thePortName[2] ;
2425 bool hasinput = aGraph->Node( aNodeName )->Port( thePortName + 2 )->HasInput() ;
2426 // cout << "Graph_Impl::Merge " << " aNodeName " << aNodeName << " aPort " << thePortName + 1
2427 // << " HasInput " << hasinput << endl ;
2429 RetVal = DataFlowEditor()->AddInputData( DataFlowEditor()->Graph()->GetGraphNode( aMapOfNodes[ aNodeName ] )->Name() ,
2431 *(aPort->ToAny()) ) ;
2433 delete [] aNodeName ;
2442 MESSAGE( "Graph_Impl::Merge returns " << RetVal ) ;
2443 endService( "Graph_Impl::Merge" );
2447 SUPERV::StreamGraph_ptr Graph_Impl::ToStreamGraph() {
2448 SUPERV::StreamGraph_var iobject = SUPERV::StreamGraph::_nil() ;
2449 beginService( "Graph_Impl::ToStreamGraph" );
2450 if ( IsStreamGraph() && !IsMacro() ) {
2451 // StreamGraph_Impl * myStreamGraph = new StreamGraph_Impl( _Orb , _Poa , _ContId ,
2452 // instanceName() , interfaceName() ) ;
2453 // PortableServer::ObjectId * id = myStreamGraph->getId() ;
2454 // CORBA::Object_var obj = _poa->id_to_reference(*id);
2455 iobject = SUPERV::StreamGraph::_narrow( ObjRef() ) ;
2456 if ( CORBA::is_nil( iobject ) ) {
2457 MESSAGE( "ToStreamGraph of " << Name() << " (IsStreamGraph) --> nil reference" ) ;
2461 MESSAGE( "ToStreamGraph of " << Name() << " (IsNOTStreamGraph) --> nil reference" ) ;
2463 endService( "Graph_Impl::ToStreamGraph" );
2464 return SUPERV::StreamGraph::_duplicate( iobject ) ;