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 "SALOME_Container_i.hxx"
39 #include "StreamGraph_Impl.hxx"
41 #include "DataFlowEditor_DataFlow.hxx"
43 extern GraphExecutor::FiniteStateMachine * theAutomaton ;
45 static void CreateEditor( CORBA::ORB_ptr orb ,
46 const char *instanceName ,
47 const char *aDataFlowName ,
48 const SUPERV::KindOfNode aKindOfNode ,
50 GraphEditor::DataFlow ** aDataFlowEditor ) {
51 bool aXmlFile = false ;
52 int lenname = strlen( aDataFlowName ) ;
53 char * theDataFlowName = new char [ lenname+1 ] ;
54 strcpy( theDataFlowName , aDataFlowName ) ;
55 if ( aDataFlowName ) {
56 if ( lenname > 4 && !strcmp( &aDataFlowName[ lenname - 4 ] , ".xml" ) ) {
57 strncpy( theDataFlowName , &aDataFlowName[ 0 ] , lenname-4 ) ;
58 theDataFlowName[ lenname-4 ] = '\0' ;
61 for ( i = lenname - 5 ; i >= 0 ; i-- ) {
62 if ( aDataFlowName[ i ] == '/' ) {
63 strncpy( theDataFlowName , &aDataFlowName[ i + 1 ] , lenname-5-i ) ;
64 theDataFlowName[ lenname-5-i ] = '\0' ;
70 strcpy( theDataFlowName , &aDataFlowName[ 0 ] ) ;
74 string theDataFlowInstanceName = theDataFlowName ;
76 // asv : 16.11.04 : creation of log file in /tmp/logs/$USER dir.
77 // "/tmp/logs/$USER" was created by runSalome.py -> orbmodule.py.
78 dbgfile = "/tmp/logs/" ;
79 dbgfile += getenv( "USER" ) ;
81 dbgfile += instanceName ;
83 dbgfile += theDataFlowInstanceName ;
84 dbgfile = dbgfile + "_" + theAutomaton->DbgFileNumber() + ".log" ;
85 FILE* f = fopen ( dbgfile.c_str(), "a" );
86 if ( f ) { // check if file can be opened for writing
89 else { // if file can't be opened - use a guaranteed temp file name
90 char* aTempNam = tempnam( NULL, NULL );
95 SALOME_NamingService * NamingService = new SALOME_NamingService( orb ) ;
96 *aDataFlowEditor = new GraphEditor::DataFlow( orb , NamingService ,
97 theDataFlowInstanceName.c_str() , dbgfile.c_str() ,
99 MESSAGE( "CreateEditor " << theDataFlowName << " uniquely named " << theDataFlowInstanceName << " created with "
100 << dbgfile.c_str() ) ;
102 delete [] theDataFlowName ;
105 static void CreateExecutor( CORBA::ORB_ptr orb ,
106 const char *instanceName ,
107 const char *aDataFlowName ,
108 const SUPERV::KindOfNode aKindOfNode ,
110 GraphExecutor::DataFlow ** aDataFlowExecutor ) {
111 int lenname = strlen( aDataFlowName ) ;
112 char * theDataFlowName = new char [ lenname+1 ] ;
113 strcpy( theDataFlowName , aDataFlowName ) ;
114 if ( aDataFlowName ) {
115 strcpy( theDataFlowName , &aDataFlowName[ 0 ] ) ;
118 string theDataFlowInstanceName = theDataFlowName ;
120 // asv : 16.11.04 : creation of log file in /tmp/logs/$USER dir.
121 // "/tmp/logs/$USER" was created by runSalome.py -> orbmodule.py.
122 dbgfile = "/tmp/logs/" ;
123 dbgfile += getenv( "USER" ) ;
125 dbgfile += instanceName ;
127 dbgfile += theDataFlowInstanceName ;
128 dbgfile = dbgfile + "_" + theAutomaton->DbgFileNumber() ;
130 astr << theAutomaton->ExecNumber() ;
131 dbgfile += astr.str() ;
132 dbgfile += string( "_Exec.log" ) ;
133 FILE* f = fopen ( dbgfile.c_str(), "a" );
134 if ( f ) { // check if file can be opened for writing
137 else { // if file can't be opened - use a guaranteed temp file name
138 char* aTempNam = tempnam( NULL, NULL );
143 SALOME_NamingService * NamingService = new SALOME_NamingService( orb ) ;
144 *aDataFlowExecutor = new GraphExecutor::DataFlow( orb , NamingService ,
145 theDataFlowInstanceName.c_str() , dbgfile.c_str() ,
148 MESSAGE( "CreateExecutor " << theDataFlowName << " " << theDataFlowInstanceName << " created with "
149 << dbgfile.c_str() ) ;
151 delete [] theDataFlowName ;
154 Graph_Impl::Graph_Impl( CORBA::ORB_ptr orb ,
155 PortableServer::POA_ptr poa ,
156 PortableServer::ObjectId * contId ,
157 const char *instanceName ,
158 const char *interfaceName ,
159 const char *aDataFlowName ,
160 const SUPERV::KindOfNode aKindOfNode ) :
161 GNode_Impl( orb , poa , contId , instanceName , interfaceName , aDataFlowName , aKindOfNode ) {
162 // MESSAGE("Graph_Impl::Graph_Impl activate object instanceName("
163 // << instanceName << ") interfaceName(" << interfaceName << ") --> "
164 // << hex << (void *) this << dec )
165 // beginService( "Graph_Impl::Graph_Impl" );
166 _Orb = CORBA::ORB::_duplicate(orb);
169 _DebugFileName = NULL ;
170 if ( aKindOfNode == SUPERV::DataFlowGraph || aKindOfNode == SUPERV::MacroNode ) {
171 // MESSAGE( "Graph_Impl::Graph_Impl _poa->activate_object" );
173 _id = _poa->activate_object(_thisObj);
176 // MESSAGE( "Graph_Impl::Graph_Impl NO _poa->activate_object " );
179 if ( aKindOfNode == SUPERV::DataFlowGraph || aKindOfNode == SUPERV::DataStreamGraph ) {
181 GraphEditor::DataFlow * aDataFlowEditor ;
182 CreateEditor( orb , instanceName , aDataFlowName , aKindOfNode ,
183 dbgfile , &aDataFlowEditor ) ;
185 if ( _DebugFileName ) {
186 delete [] _DebugFileName ;
188 _DebugFileName = new char[ strlen( dbgfile.c_str() )+1 ] ;
189 strcpy( _DebugFileName , dbgfile.c_str() ) ;
191 _NamingService = new SALOME_NamingService( orb ) ;
192 DataFlowEditor( aDataFlowEditor ) ;
193 DataFlowEditor()->Graph()->GraphEditor( aDataFlowEditor ) ;
194 DataFlowEditor()->Graph()->SetObjImpl( this ) ;
196 pthread_mutex_init( &_MutexExecutorWait , NULL ) ;
197 // DataFlowExecutor( NULL ) ;
198 // endService( "Graph_Impl::Graph_Impl" );
201 Graph_Impl::Graph_Impl( CORBA::ORB_ptr orb ,
202 PortableServer::POA_ptr poa ,
203 PortableServer::ObjectId * contId ,
204 const char *instanceName ,
205 const char *interfaceName ,
206 GraphEditor::DataFlow * aDataFlowEditor ,
207 GraphEditor::InNode * aDataFlowNode ) :
208 GNode_Impl( orb , poa , contId , instanceName , interfaceName , aDataFlowEditor , aDataFlowNode ) {
209 // beginService( "Graph_Impl::Graph_Impl" );
210 // MESSAGE( aDataFlowEditor->Graph()->Name() << " " );
211 if ( aDataFlowEditor->Graph()->IsDataFlowNode() ||
212 ( aDataFlowNode && aDataFlowNode->IsMacroNode() ) ) {
213 // MESSAGE( "Graph_Impl::Graph_Impl _poa->activate_object" );
215 _id = _poa->activate_object(_thisObj);
218 // MESSAGE( "Graph_Impl::Graph_Impl NO _poa->activate_object " );
220 _Orb = CORBA::ORB::_duplicate(orb);
223 _DebugFileName = NULL ;
224 DataFlowEditor( aDataFlowEditor ) ;
225 DataFlowEditor()->Graph()->GraphEditor( aDataFlowEditor ) ;
226 DataFlowEditor()->Graph()->SetObjImpl( this ) ;
227 pthread_mutex_init( &_MutexExecutorWait , NULL ) ;
228 // DataFlowExecutor( NULL ) ;
229 // endService( "Graph_Impl::Graph_Impl" );
232 Graph_Impl::Graph_Impl() {
235 Graph_Impl::~Graph_Impl() {
236 beginService( "Graph_Impl::~Graph_Impl" );
237 endService( "Graph_Impl::~Graph_Impl" );
240 void Graph_Impl::destroy() {
241 beginService( "Graph_Impl::destroy" );
242 if ( DataFlowNode() && DataFlowNode()->ComputingNode()->IsMacroNode() ) {
243 SUPERV::Graph_var aGraph = DataFlowNode()->GOTONode()->MacroObject() ;
244 GNode_Impl::Delete() ;
245 if ( !CORBA::is_nil( aGraph ) ) {
250 SUPERV::Graph_var aGraph = DataFlowEditor()->Graph()->MacroObject() ;
251 GNode_Impl::Delete() ;
252 if ( !CORBA::is_nil( aGraph ) ) {
256 _poa->deactivate_object(*_id) ;
257 CORBA::release(_poa) ;
259 _thisObj->_remove_ref();
260 endService( "Graph_Impl::destroy" );
264 char* Graph_Impl::getIOR() {
266 return CORBA::string_dup( NULLSTRING ) ;
268 else if ( CORBA::is_nil( myServant ) ) {
269 PortableServer::ObjectId* id = getId();
270 CORBA::Object_var obj;
271 obj = _poa->id_to_reference(*id);
272 myServant = SUPERV::Graph::_narrow(obj);
274 return(CORBA::string_dup(_Orb->object_to_string(myServant)));
277 SUPERV::Graph_ptr Graph_Impl::Copy() {
278 beginService( "Graph_Impl::Copy" );
279 SUPERV::Graph_var iobject = SUPERV::Graph::_nil() ;
281 Graph_Impl * myGraph ;
282 myGraph = new Graph_Impl( _Orb , _Poa, _ContId,
283 instanceName() , interfaceName() ,
284 DataFlowEditor()->Graph()->Name() , SUPERV::DataFlowGraph ) ;
285 PortableServer::ObjectId * id = myGraph->getId() ;
286 CORBA::Object_var obj = _poa->id_to_reference(*id);
287 iobject = SUPERV::Graph::_narrow(obj) ;
288 GraphBase::ListOfSGraphs * aListOfSGraphs = GetGraphs() ;
289 myGraph->LoadGraphs( aListOfSGraphs ) ;
291 endService( "Graph_Impl::Copy" );
292 return SUPERV::Graph::_duplicate(iobject) ;
295 void Graph_Impl::ReadOnly() {
296 DataFlowEditor()->ReadOnly() ;
299 SUPERV::INode_ptr Graph_Impl::Node() {
300 // beginService( "Graph_Impl::Node" );
301 PortableServer::ObjectId * id = getId() ;
302 CORBA::Object_var obj = _poa->id_to_reference(*id);
303 SUPERV::Graph_var iobject ;
304 iobject = SUPERV::Graph::_narrow(obj) ;
305 // endService( "Graph_Impl::Node" );
306 return SUPERV::Graph::_duplicate(iobject) ;
309 GraphBase::ListOfSGraphs * Graph_Impl::GetGraphs() {
310 return DataFlowEditor()->GetDataFlows() ;
313 bool Graph_Impl::LoadGraphs( GraphBase::ListOfSGraphs * aListOfDataFlows ) {
314 beginService( "Graph_Impl::LoadGraphs" );
315 bool RetVal = false ;
316 if ( DataFlowEditor()->IsEditing() ) {
317 // RetVal = DataFlowEditor()->LoadDataFlows( aListOfDataFlows ) ;
318 if ( CORBA::is_nil( LoadDataFlows( DataFlowEditor() , aListOfDataFlows , 0 ) ) ) {
322 endService( "Graph_Impl::LoadGraphs" );
326 bool Graph_Impl::Import(const char * aXmlFile ) {
327 beginService( "Graph_Impl::Import" );
328 bool RetVal = false ;
329 if ( DataFlowEditor()->IsEditing() && !IsMacro() ) {
330 GraphBase::ListOfSGraphs aListOfDataFlows ;
331 RetVal = DataFlowEditor()->LoadXml( aXmlFile , aListOfDataFlows ) ;
332 if ( RetVal && aXmlFile != NULL ) {
333 // RetVal = DataFlowEditor()->LoadDataFlows( &aListOfDataFlows ) ;
334 if ( CORBA::is_nil( LoadDataFlows( DataFlowEditor() , &aListOfDataFlows , 0 ) ) ) {
339 endService( "Graph_Impl::Import" );
343 bool Graph_Impl::Export(const char * anXmlFile ) {
344 beginService( "Graph_Impl::Export" );
345 bool RetVal = false ;
347 char * aFile = new char [ strlen( anXmlFile ) + 5 ] ;
348 strcpy( aFile , anXmlFile ) ;
349 int len = strlen( aFile ) ;
350 if ( !strcmp( &aFile[ len - 4 ] , ".xml" ) ) {
352 else if ( !strcmp( &aFile[ len - 3 ] , ".py" ) ) {
353 strcpy( &aFile[ len - 3 ] , ".xml" ) ;
354 len = strlen( aFile ) ;
357 strcat( aFile , ".xml" ) ;
358 len = strlen( aFile ) ;
360 RetVal = DataFlowEditor()->SaveXml( aFile ) ;
362 strcpy( &aFile[ len - 4 ] , ".py" ) ;
363 RetVal = DataFlowEditor()->SavePy( aFile ) ;
367 endService( "Graph_Impl::Export" );
371 SUPERV::CNode_ptr Graph_Impl::CNode( const SALOME_ModuleCatalog::Service &NodeService ) {
372 beginService( "Graph_Impl::CNode" );
373 SUPERV::CNode_var iobject = SUPERV::CNode::_nil() ;
374 if ( DataFlowEditor()->IsEditing() && !DataFlowEditor()->IsReadOnly() && !IsMacro() ) {
375 CNode_Impl * myNode = new CNode_Impl( _Orb , _Poa , _ContId ,
376 instanceName() , interfaceName() ,
378 NodeService , NULLSTRING ,
379 SUPERV::ComputingNode , NULLSTRING ) ;
380 if ( myNode->DataFlowNode() ) {
381 PortableServer::ObjectId * id = myNode->getId() ;
382 CORBA::Object_var obj = _poa->id_to_reference(*id);
383 iobject = SUPERV::CNode::_narrow(obj) ;
384 myNode->SetObjRef( SUPERV::CNode::_duplicate( iobject ) ) ;
387 DataFlowEditor()->UnValid() ;
388 endService( "Graph_Impl::CNode" );
389 return SUPERV::CNode::_duplicate( iobject ) ;
392 SUPERV::FNode_ptr Graph_Impl::FNode( const char * NodeComponentName ,
393 const char * NodeInterfaceName ,
394 const SALOME_ModuleCatalog::Service &NodeService ) {
395 beginService( "Graph_Impl::FNode" );
396 SUPERV::FNode_var iobject = SUPERV::FNode::_nil() ;
397 if ( DataFlowEditor()->IsEditing() && !DataFlowEditor()->IsReadOnly() && !IsMacro() ) {
398 FNode_Impl * myNode = new FNode_Impl( _Orb , _Poa , _ContId ,
399 instanceName() , interfaceName() ,
403 NodeInterfaceName ) ;
404 if ( myNode->DataFlowNode() ) {
405 PortableServer::ObjectId * id = myNode->getId() ;
406 CORBA::Object_var obj = _poa->id_to_reference(*id);
407 iobject = SUPERV::FNode::_narrow(obj) ;
408 myNode->SetObjRef( SUPERV::FNode::_duplicate( iobject ) ) ;
411 DataFlowEditor()->UnValid() ;
412 endService( "Graph_Impl::FNode" );
413 return SUPERV::FNode::_duplicate( iobject ) ;
416 SUPERV::INode_ptr Graph_Impl::INode( const char * FuncName ,
417 const SUPERV::ListOfStrings & PythonFuntion ) {
418 beginService( "Graph_Impl::INode" );
419 SUPERV::INode_var iobject = SUPERV::INode::_nil() ;
420 if ( DataFlowEditor()->IsEditing() && !DataFlowEditor()->IsReadOnly() && !IsMacro() ) {
421 INode_Impl * myNode = new INode_Impl( _Orb , _Poa , _ContId ,
422 instanceName() , interfaceName() ,
424 FuncName , PythonFuntion ,
425 SUPERV::InLineNode ) ;
426 if ( myNode->DataFlowNode() ) {
427 PortableServer::ObjectId * id = myNode->getId() ;
428 CORBA::Object_var obj = _poa->id_to_reference(*id);
429 iobject = SUPERV::INode::_narrow(obj) ;
430 myNode->SetObjRef( SUPERV::INode::_duplicate( iobject ) ) ;
433 endService( "Graph_Impl::INode" );
434 return SUPERV::INode::_duplicate( iobject ) ;
438 SUPERV::GNode_ptr Graph_Impl::GNode( const char * FuncName ,
439 const SUPERV::ListOfStrings & PythonFuntion ,
440 const char * anInLineNode ) {
441 beginService( "Graph_Impl::GNode" );
442 SUPERV::GNode_var iobject = SUPERV::GNode::_nil() ;
443 if ( DataFlowEditor()->IsEditing() && !DataFlowEditor()->IsReadOnly() && !IsMacro() ) {
444 GNode_Impl * myNode = new GNode_Impl( _Orb , _Poa , _ContId ,
445 instanceName() , interfaceName() ,
447 FuncName , PythonFuntion ,
449 if ( myNode->DataFlowNode() ) {
450 PortableServer::ObjectId * id = myNode->getId() ;
451 CORBA::Object_var obj = _poa->id_to_reference(*id);
452 iobject = SUPERV::GNode::_narrow(obj) ;
453 myNode->SetObjRef( SUPERV::GNode::_duplicate( iobject ) ) ;
454 if ( strlen( anInLineNode ) ) {
455 GraphBase::InLineNode * CoupledINode = (GraphBase::InLineNode * ) DataFlowEditor()->Graph()->GetGraphNode( anInLineNode ) ;
456 if ( anInLineNode ) {
457 myNode->SetCoupled( anInLineNode ) ;
458 Link( myNode->Port( "OutGate" ) , CoupledINode->ObjRef()->Port( "InGate" ) ) ;
463 DataFlowEditor()->UnValid() ;
464 endService( "Graph_Impl::GNode" );
465 return SUPERV::GNode::_duplicate( iobject ) ;
468 SUPERV::LNode_ptr Graph_Impl::LNode( const char * InitName ,
469 const SUPERV::ListOfStrings & InitFunction ,
470 const char * MoreName ,
471 const SUPERV::ListOfStrings & MoreFunction ,
472 const char * NextName ,
473 const SUPERV::ListOfStrings & NextFunction ,
474 SUPERV::INode_out anEndOfLoop ) {
475 beginService( "Graph_Impl::LNode" );
476 SUPERV::LNode_var iobject = SUPERV::LNode::_nil() ;
477 SUPERV::ELNode_var iendobject = SUPERV::ELNode::_nil() ;
478 if ( DataFlowEditor()->IsEditing() && !DataFlowEditor()->IsReadOnly() && !IsMacro() ) {
479 GraphBase::ListOfFuncName FuncNameList ;
480 FuncNameList.resize(3) ;
481 FuncNameList[0] = InitName ;
482 FuncNameList[1] = MoreName ;
483 FuncNameList[2] = NextName ;
484 GraphBase::ListOfPythonFunctions PythonFunctionList ;
485 PythonFunctionList.resize(3) ;
486 PythonFunctionList[0] = &InitFunction ;
487 PythonFunctionList[1] = &MoreFunction ;
488 PythonFunctionList[2] = &NextFunction ;
489 LNode_Impl * myNode = new LNode_Impl( _Orb , _Poa , _ContId ,
490 instanceName() , interfaceName() ,
492 FuncNameList , PythonFunctionList ,
493 // InitName , InitFunction ,
494 // MoreName , MoreFunction ,
495 // NextName , NextFunction ,
497 if ( myNode->DataFlowNode() ) {
498 PortableServer::ObjectId * id = myNode->getId() ;
499 CORBA::Object_var obj = _poa->id_to_reference(*id);
500 iobject = SUPERV::LNode::_narrow(obj) ;
501 myNode->SetObjRef( SUPERV::LNode::_duplicate( iobject ) ) ;
503 SALOME_ModuleCatalog::Service aVoidService = SALOME_ModuleCatalog::Service() ;
505 if ( strlen( InitName ) ) {
506 anEndName = new char( 3 + strlen( InitName ) + 1 ) ;
507 strcpy( anEndName , "End" ) ;
508 strcat( anEndName , InitName ) ;
511 anEndName = new char( 3 + strlen( "Loop" ) + 1 ) ;
512 strcpy( anEndName , "EndLoop" ) ;
514 ELNode_Impl * myEndNode = new ELNode_Impl( _Orb , _Poa , _ContId ,
515 instanceName() , interfaceName() ,
518 SUPERV::EndLoopNode ) ;
519 PortableServer::ObjectId * endid = myEndNode->getId() ;
520 CORBA::Object_var endobj = _poa->id_to_reference(*endid);
521 iendobject = SUPERV::ELNode::_narrow(endobj) ;
522 myEndNode->SetObjRef( SUPERV::ELNode::_duplicate( iendobject ) ) ;
523 myNode->SetCoupled( myEndNode->BaseNode()->Name() ) ;
524 myEndNode->SetCoupled( myNode->BaseNode()->Name() ) ;
525 //JR 25.01.2005 That links are already done in SetCoupled above ...
526 // Link( myNode->Port( "DoLoop" ) , myEndNode->Port( "DoLoop" ) ) ;
527 // Link( myEndNode->Port( "DoLoop" ) , myNode->Port( "InitLoop" ) ) ;
528 // Link( myEndNode->Port( "DoLoop" ) , myNode->Port( "DoLoop" ) ) ;
531 anEndOfLoop = SUPERV::ELNode::_duplicate( iendobject ) ;
532 DataFlowEditor()->UnValid() ;
533 endService( "Graph_Impl::LNode" );
534 return SUPERV::LNode::_duplicate( iobject ) ;
537 SUPERV::SNode_ptr Graph_Impl::SNode( const char * FuncName ,
538 const SUPERV::ListOfStrings & PythonFunction ,
539 SUPERV::INode_out anEndOfSwitch ) {
540 beginService( "Graph_Impl::SNode" );
541 SUPERV::SNode_var iobject = SUPERV::SNode::_nil() ;
542 SUPERV::ESNode_var iendobject = SUPERV::ESNode::_nil() ;
543 if ( DataFlowEditor()->IsEditing() && !DataFlowEditor()->IsReadOnly() && !IsMacro() ) {
544 SNode_Impl * myNode = new SNode_Impl( _Orb , _Poa , _ContId ,
545 instanceName() , interfaceName() ,
547 FuncName , PythonFunction ,
548 SUPERV::SwitchNode ) ;
549 if ( myNode->DataFlowNode() ) {
550 PortableServer::ObjectId * id = myNode->getId() ;
551 CORBA::Object_var obj = _poa->id_to_reference(*id);
552 iobject = SUPERV::SNode::_narrow(obj) ;
553 myNode->SetObjRef( SUPERV::SNode::_duplicate( iobject ) ) ;
555 string anEndName = "End" ;
556 if ( strlen( FuncName ) ) {
557 anEndName += FuncName ;
560 anEndName += "Switch" ;
562 // cout << "Graph_Impl::SNode anEndName " << (void *) FuncName << " " << FuncName
563 // << " " << strlen(FuncName) << " " << (void *) anEndName.c_str() << " "
564 // << anEndName.c_str() << endl ;
565 ESNode_Impl * myEndNode = new ESNode_Impl( _Orb , _Poa , _ContId ,
566 instanceName() , interfaceName() ,
569 SUPERV::EndSwitchNode ) ;
570 // cout << "Graph_Impl::SNode returned anEndName " << (void *) FuncName << " "
571 // << FuncName << " " << strlen(FuncName) << " " << (void *) anEndName.c_str()
572 // << " " << anEndName.c_str() << endl ;
573 PortableServer::ObjectId * endid = myEndNode->getId() ;
574 CORBA::Object_var endobj = _poa->id_to_reference(*endid);
575 iendobject = SUPERV::ESNode::_narrow(endobj) ;
576 myEndNode->SetObjRef( SUPERV::ESNode::_duplicate( iendobject ) ) ;
577 myNode->SetCoupled( myEndNode->BaseNode()->Name() ) ;
578 myEndNode->SetCoupled( myNode->BaseNode()->Name() ) ;
579 if ( !Link( myNode->Port( "Default" ) , myEndNode->Port( "Default" ) ) ) {
580 iobject = SUPERV::SNode::_nil() ;
581 iendobject = SUPERV::ESNode::_nil() ;
585 anEndOfSwitch = SUPERV::ESNode::_duplicate( iendobject ) ;
586 DataFlowEditor()->UnValid() ;
587 endService( "Graph_Impl::SNode" );
588 return SUPERV::SNode::_duplicate( iobject ) ;
591 // WARNING : THIS IS COMPLICATED :
592 SUPERV::Graph_var Graph_Impl::LoadDataFlows( GraphEditor::DataFlow * aDataFlowEditor ,
593 GraphBase::ListOfSGraphs * aListOfDataFlows ,
595 beginService( "Graph_Impl::EditorLoadDataFlows" ) ;
596 MESSAGE("Graph_Impl::LoadDataFlows index " << index << " " << (*aListOfDataFlows)[index].Info.theName.c_str() ) ;
598 SUPERV::Graph_var iobject = SUPERV::Graph::_nil() ;
599 // That method is recursive :
600 // At first we load the supergraph with index = 0 :
601 // (After we load the graph corresponding to each MacroNode :)
602 if ( !aDataFlowEditor->LoadDataFlow( &(*aListOfDataFlows)[ index ] ) ) {
603 MESSAGE("Graph_Impl::LoadDataFlows failed " << (*aListOfDataFlows)[index].Info.theName.c_str() ) ;
604 return SUPERV::Graph::_duplicate( iobject ) ;
606 // That graph is not a StreamGraph :
607 else if ( !aDataFlowEditor->Graph()->HasDataStream() ) {
608 aDataFlowEditor->Graph()->Kind( SUPERV::DataFlowGraph ) ;
609 // aDataFlowEditor->Graph()->SetGraphEditor( aDataFlowEditor ) ;
610 Graph_Impl * myGraph ;
611 // We create a Graph ObjRef for that graph
612 myGraph = new Graph_Impl( _Orb , _Poa, _ContId,
613 instanceName() , interfaceName() ,
614 aDataFlowEditor , NULL ) ;
615 PortableServer::ObjectId * id = myGraph->getId() ;
616 CORBA::Object_var obj = _poa->id_to_reference(*id) ;
617 iobject = SUPERV::Graph::_narrow( obj ) ;
618 myGraph->SetObjRef( SUPERV::Graph::_duplicate( iobject ) ) ;
619 myGraph->SetObjImpl( (CNode_Impl * ) myGraph ) ;
620 GraphBase::Graph * aGraph = myGraph->DataFlowEditor()->Graph() ;
623 // asv: set Editor for the graph itself and for all its macro nodes
624 aGraph->GraphEditor( aDataFlowEditor );
626 // For the supergraph or each graph of MacroNodes we search MacroNodes recursively :
627 for ( i = 0 ; i < aGraph->GraphNodesSize() ; i++ ) {
628 if ( aGraph->GraphNodes( i )->IsMacroNode() ) {
629 GraphBase::GOTONode * aMacroNode = (GraphBase::GOTONode * ) aGraph->GraphNodes( i ) ;
631 // asv : 05.11.04 : fix of bug - "insert file" into existing graph with MacroNodes worked incorrectly!
632 // aMacroNode is an "old" node, and here we must analize only "new" nodes, that
633 // came from aListOfDataFlows and were loaded by aDataFlowEditor->LoadDataFlow( &(*aListOfDataFlows)[ index ] )
634 // so here we check if the node is "new" or "old"
635 if ( aMacroNode->GraphEditor() && aMacroNode->CoupledNode() )
638 // asv: set Editor for the graph itself and for all its macro nodes
639 aMacroNode->GraphEditor( aDataFlowEditor );
641 // Creation of a GraphMacroNode ObjRef in the current editor
642 SUPERV::Graph_var macroiobject = SUPERV::Graph::_nil() ;
643 Graph_Impl * myMacroNode ;
644 myMacroNode = new Graph_Impl( _Orb , _Poa, _ContId,
645 instanceName() , interfaceName() ,
646 aMacroNode->Name() , SUPERV::MacroNode ) ;
647 id = myMacroNode->getId() ;
648 obj = _poa->id_to_reference(*id);
649 macroiobject = SUPERV::Graph::_narrow( obj ) ;
650 myMacroNode->DataFlowEditor( aDataFlowEditor ) ;
651 GraphEditor::InNode * aDataFlowNode = (GraphEditor::InNode * ) aMacroNode->GetInNode() ;
652 myMacroNode->DataFlowNode( aDataFlowNode ) ;
653 aDataFlowNode->SetObjRef( SUPERV::CNode::_duplicate( SUPERV::CNode::_narrow( obj ) ) ) ;
654 aDataFlowNode->SetObjImpl( myMacroNode ) ;
656 char * aCoupledNodeName = aMacroNode->CoupledNodeName() ;
657 MESSAGE( "LoadDataFlows MacroNode " << aMacroNode->Name() << " --> " << aCoupledNodeName
658 << " to be searched among " << (*aListOfDataFlows).size() << " Graphs" ) ;
661 for ( index = 0 ; index < (int ) (*aListOfDataFlows).size() ; index++ ) {
662 MESSAGE( "LoadDataFlows Graph" << index << " " << (*aListOfDataFlows)[index].Info.theName.c_str() ) ;
663 if ( !strcmp( aCoupledNodeName , (*aListOfDataFlows)[index].Info.theName.c_str() ) ) {
666 // At first create the editor and a StreamGraph
667 GraphEditor::DataFlow * aMacroGraphDataFlowEditor ;
668 CreateEditor( _Orb , instanceName() , aCoupledNodeName , SUPERV::DataStreamGraph ,
669 dbgfile , &aMacroGraphDataFlowEditor ) ;
671 if ( _DebugFileName ) {
672 delete [] _DebugFileName ;
674 _DebugFileName = new char[ strlen( dbgfile.c_str() )+1 ] ;
675 strcpy( _DebugFileName , dbgfile.c_str() ) ;
677 MESSAGE( "RECURSIVE IMPORT OF GRAPHS OF MACRONODES :" << aCoupledNodeName ) ;
678 if ( CORBA::is_nil( LoadDataFlows( aMacroGraphDataFlowEditor , aListOfDataFlows , index ) ) ) {
679 MESSAGE("Graph_Impl::LoadDataFlows failed" ) ;
680 return SUPERV::Graph::_duplicate( iobject ) ;
683 // That graph is not a StreamGraph :
684 else if ( !aMacroGraphDataFlowEditor->Graph()->HasDataStream() ) {
685 Graph_Impl * myMacroGraph ;
686 // The Graph ObjRef for that graph was already created
687 myMacroGraph = (Graph_Impl * ) aMacroGraphDataFlowEditor->Graph()->ObjImpl() ;
689 GraphBase::Graph * aMacroGraph = myMacroGraph->DataFlowEditor()->Graph() ;
691 aMacroGraph->GraphMacroLevel( aGraph->GraphMacroLevel() + 1 ) ;
692 aMacroGraph->CoupledNode( aMacroNode ) ;
693 aMacroGraph->MacroObject( SUPERV::Graph::_duplicate( macroiobject ) ) ;
695 // Set the GraphMacroNode ObjRef in the MacroNode
696 aMacroNode->GraphMacroLevel( aGraph->GraphMacroLevel() + 1 ) ;
697 aMacroNode->CoupledNode( aMacroGraph ) ;
698 aMacroNode->MacroObject( SUPERV::Graph::_narrow( aMacroGraphDataFlowEditor->Graph()->ObjRef() ) ) ;
699 MESSAGE( "LoadDataFlows aMacroGraph " << aMacroGraph << " " << aMacroGraph->Name()
700 << " coupled to " << aMacroGraph->CoupledNode() << " "
701 << aMacroGraph->CoupledNode()->Name() << " Editor " << aMacroGraph->GraphEditor() ) ;
702 MESSAGE( "LoadDataFlows aMacroNode " << aMacroNode << " " << aMacroNode->Name()
703 << " coupled to " << aMacroNode->CoupledNode() << " "
704 << aMacroNode->CoupledNode()->Name() << " Editor " << aMacroNode->GraphEditor() ) ;
705 MESSAGE( "LoadDataFlows current Graph " << aGraph << " " << aGraph->Name()
706 << " coupled to " << aGraph->CoupledNode()
707 << " Editor " << aGraph->GraphEditor() << " " << aGraph->Name() ) ;
713 return SUPERV::Graph::_duplicate( SUPERV::Graph::_nil() ) ;
718 else if ( (*aListOfDataFlows).size() == 1 ) {
719 StreamGraph_Impl * myStreamGraph ;
720 // We create a Graph ObjRef for that graph
721 myStreamGraph = new StreamGraph_Impl( _Orb , _Poa, _ContId,
722 instanceName() , interfaceName() ,
723 aDataFlowEditor , NULL ) ;
724 PortableServer::ObjectId * id = myStreamGraph->getId() ;
725 CORBA::Object_var obj = _poa->id_to_reference(*id) ;
726 SUPERV::StreamGraph_var Streamiobject = SUPERV::StreamGraph::_nil() ;
727 Streamiobject = SUPERV::StreamGraph::_narrow( obj ) ;
728 myStreamGraph->SetObjRef( SUPERV::StreamGraph::_duplicate( Streamiobject ) ) ;
729 myStreamGraph->SetObjImpl( (CNode_Impl * ) myStreamGraph ) ;
730 // iobject = SUPERV::Graph::_narrow( obj ) ;
731 iobject = SUPERV::Graph::_narrow( Streamiobject ) ;
734 MESSAGE( "Graph_Impl::LoadDataFlows StreamGraph with MacroNodes not yet implemented" ) ;
737 endService( "Graph_Impl::EditorLoadDataFlows" );
738 return SUPERV::Graph::_duplicate( iobject ) ;
741 SUPERV::Graph_var Graph_Impl::LoadDataFlows( GraphExecutor::DataFlow * aDataFlowExecutor ,
742 GraphBase::ListOfSGraphs * aListOfDataFlows ,
744 beginService( "Graph_Impl::ExecutorLoadDataFlows" ) ;
745 MESSAGE("Graph_Impl::LoadDataFlows(Executor) index " << index << " " << (*aListOfDataFlows)[index].Info.theName.c_str() << " aDataFlowExecutor " << aDataFlowExecutor ) ;
747 // That method is recursive :
748 // At first we load the supergraph with index = 0 :
749 // (After we load the graph corresponding to each MacroNode :)
750 if ( !aDataFlowExecutor->LoadDataFlow( &(*aListOfDataFlows)[ index ] ) ) {
751 MESSAGE("Graph_Impl::LoadDataFlows(Executor) failed, could not LoadDataFlow(supergraph)" ) ;
752 return SUPERV::Graph::_duplicate( SUPERV::Graph::_nil() ) ;
755 // That graph is not a StreamGraph :
757 aDataFlowExecutor->Graph()->Kind( SUPERV::DataFlowGraph ) ;
758 GraphEditor::DataFlow * aDataFlowEditor ;
759 aDataFlowEditor = DataFlowEditor() ;
760 GraphBase::Graph * anEditorGraph = aDataFlowEditor->Graph() ;
761 GraphBase::Graph * anExecutorGraph = aDataFlowExecutor->Graph() ;
762 if ( aDataFlowEditor->Executor() ) {
763 delete aDataFlowEditor->Executor() ;
764 aDataFlowEditor->Executor( NULL ) ;
765 aDataFlowEditor->Editing() ;
767 aDataFlowEditor->Executor( aDataFlowExecutor ) ;
768 anExecutorGraph->GraphEditor( aDataFlowEditor ) ;
770 if ( !aDataFlowExecutor->Graph()->HasDataStream() ) {
771 // For the supergraph or each graph of MacroNodes we search MacroNodes recursively :
773 for ( i = 0 ; i < anExecutorGraph->GraphNodesSize() ; i++ ) {
774 if ( anExecutorGraph->GraphNodes( i )->IsMacroNode() ) {
775 GraphBase::GOTONode * aMacroNode = (GraphBase::GOTONode * ) anExecutorGraph->GraphNodes( i ) ;
776 aMacroNode->GraphEditor( aDataFlowEditor ) ;
778 // get the macro node's editor object
779 char * aMacroGraphName = aMacroNode->CoupledNodeName() ;
780 GraphBase::Graph* aMacroGraph = (GraphBase::Graph*)((GraphBase::GOTONode *)anEditorGraph->GetGraphNode( aMacroNode->Name() ))->CoupledNode() ;
781 GraphEditor::DataFlow* aMacroGraphEditor = aMacroGraph->GraphEditor();
783 MESSAGE( "LoadDataFlows(Executor) MacroNode " << aMacroNode->Name() << " Coupled to " << aMacroGraphName
784 << " to be searched among " << (*aListOfDataFlows).size() << " Graphs" << endl ) ;
787 for ( index = 0 ; index < (int ) (*aListOfDataFlows).size() && !found; index++ ) {
788 if ( !strcmp( aMacroGraphName , (*aListOfDataFlows)[index].Info.theName.c_str() ) )
792 MESSAGE("Graph_Impl::LoadDataFlows(Executor) failed, Macro node's coupled graph \"" << aMacroGraphName << "\" was not found" ) ;
793 return SUPERV::Graph::_duplicate( SUPERV::Graph::_nil() ) ;
795 index--; // it was incremented in "for ..." before last check ( !found ).
797 // At first create the editor and a StreamGraph
799 GraphExecutor::DataFlow * aMacroGraphExecutor ;
800 CreateExecutor( _Orb , instanceName() , aMacroGraphName , SUPERV::DataStreamGraph ,
801 dbgfile , &aMacroGraphExecutor );
803 // set GraphMacroLevel for Executor's graph
804 GraphBase::Graph* aMacroGraphExe = aMacroGraphExecutor->Graph();
805 aMacroGraphExe->GraphMacroLevel( anExecutorGraph->GraphMacroLevel() + 1 );
807 // load data flows in MacroGraph's executor
808 Graph_Impl* aMacroGraphImpl = (Graph_Impl*) aMacroGraphEditor->Graph()->ObjImpl();
809 MESSAGE( "RECURSIVE IMPORT OF GRAPHS OF MACRONODES : " << aMacroGraphName ) ;
810 if ( CORBA::is_nil( aMacroGraphImpl->LoadDataFlows( aMacroGraphExecutor, aListOfDataFlows , index ) ) ) {
811 MESSAGE("Graph_Impl::LoadDataFlows(Executor) failed, could not LoadDataFlow( MacroNodeGraph \"" <<aMacroGraphName << "\" )" ) ;
812 return SUPERV::Graph::_duplicate( SUPERV::Graph::_nil() ) ;
815 // set coupled pair MacroNode <--> MacroGraph
816 aMacroGraphExe->CoupledNode( aMacroNode ) ;
817 aMacroNode->CoupledNode( aMacroGraphExe ) ;
819 // initialize MacroNode's InPorts with corresponding "external" values
821 for ( q = 0 ; q < aMacroNode->GetNodeInPortsSize() ; q++ ) {
822 const GraphBase::InPort * anInPort = aMacroNode->GetNodeInPort( q ) ;
823 if ( anInPort->IsDataConnected() ) {
824 const char* aMacroGraphInPortName = aMacroGraph->GetNodeInPort( q )->PortName();
825 if ( !aMacroGraphExecutor->InputOfAny( aMacroGraphInPortName, *anInPort->GetOutPort()->Value(),false ) ) {
826 return SUPERV::Graph::_duplicate( SUPERV::Graph::_nil() ) ;
829 MESSAGE( "LoadDataFlows(Executor) " << aMacroGraph->Name() << "->InputOfAny( "
830 << aMacroGraphInPortName << " , Value )" ) ;
833 } // end of init MacroNode's InPorts
835 aMacroGraphImpl->Run() ;
838 } // end of for( get nodes of the graph...)
840 } // end of setting initial graph's structure..
842 endService( "Graph_Impl::ExecutorLoadDataFlows" );
844 PortableServer::ObjectId * id = getId();
845 CORBA::Object_var obj = _poa->id_to_reference( *id );
846 SUPERV::Graph_var iobject = SUPERV::Graph::_narrow( obj ) ;
847 return SUPERV::Graph::_duplicate( iobject ) ;
850 SUPERV::Graph_ptr Graph_Impl::MNode( const char * aXmlFileName ) {
851 beginService( "Graph_Impl::MNode" );
852 SUPERV::Graph_var iobject = SUPERV::Graph::_nil() ;
853 MESSAGE( "Graph_Impl::MNode( " << aXmlFileName << " )" ) ;
855 GraphBase::ListOfSGraphs aListOfDataFlows ;
857 // At first create the editor and a StreamGraph with the xml file
858 GraphEditor::DataFlow * aDataFlowEditor ;
859 CreateEditor( _Orb , instanceName() , aXmlFileName , SUPERV::DataStreamGraph ,
860 dbgfile , &aDataFlowEditor ) ;
862 if ( _DebugFileName ) {
863 delete [] _DebugFileName ;
865 _DebugFileName = new char[ strlen( dbgfile.c_str() )+1 ] ;
866 strcpy( _DebugFileName , dbgfile.c_str() ) ;
868 int lenname = strlen( aXmlFileName ) ;
869 bool loaded = false ;
870 // Import of the xml file
871 if ( lenname > 4 && !strcmp( &aXmlFileName[ lenname - 4 ] , ".xml" ) ) {
872 loaded = aDataFlowEditor->LoadXml( aXmlFileName , aListOfDataFlows ) ;
874 iobject = MNode( aDataFlowEditor , &aListOfDataFlows ) ;
881 // WARNING : THIS IS COMPLICATED :
882 // I should have to remove duplicated code ...
883 SUPERV::Graph_ptr Graph_Impl::MNode( GraphEditor::DataFlow * aMacroGraphDataFlowEditor ,
884 GraphBase::ListOfSGraphs * aListOfDataFlows ) {
885 beginService( "Graph_Impl::MNode" ) ;
886 SUPERV::Graph_var iobject = SUPERV::Graph::_nil() ;
887 SUPERV::Graph_var macroiobject = SUPERV::Graph::_nil() ;
890 MESSAGE( "Graph_Impl::MNode DataFlowEditor->LoadDataFlow" ) ;
891 // if ( !aMacroGraphDataFlowEditor->LoadDataFlow( &aListOfDataFlows[ 0 ] ) ) {
892 iobject = LoadDataFlows( aMacroGraphDataFlowEditor , aListOfDataFlows , 0 ) ;
893 if ( CORBA::is_nil( iobject ) ) {
894 MESSAGE("Graph_Impl::MNode LoadDataFlow failed" ) ;
898 // That graph is not a StreamGraph :
899 else if ( !aMacroGraphDataFlowEditor->Graph()->HasDataStream() ) {
900 aMacroGraphDataFlowEditor->Graph()->Kind( SUPERV::DataFlowGraph ) ;
901 aMacroGraphDataFlowEditor->Graph()->GraphEditor( aMacroGraphDataFlowEditor ) ;
903 Graph_Impl * myMacroGraph = (Graph_Impl * ) aMacroGraphDataFlowEditor->Graph()->ObjImpl() ;
904 // Creation of a GraphMacroNode in the current editor
905 string aMacroNodeName = string( "Macro_" ) + string( myMacroGraph->Name() ) ;
906 Graph_Impl * myMacroNode ;
907 myMacroNode = new Graph_Impl( _Orb , _Poa, _ContId,
908 instanceName() , interfaceName() ,
909 aMacroNodeName.c_str() , SUPERV::MacroNode ) ;
910 PortableServer::ObjectId * id = myMacroNode->getId() ;
911 CORBA::Object_var obj = _poa->id_to_reference(*id);
912 macroiobject = SUPERV::Graph::_narrow( obj ) ;
913 myMacroNode->DataFlowEditor( DataFlowEditor() ) ;
915 // Creation of the MacroNode itself in the current Graph
916 GraphBase::ListOfFuncName aFuncName ;
917 aFuncName.resize( 1 ) ;
919 SUPERV::ListOfStrings aListOfStrings ;
920 aListOfStrings.length( 1 ) ;
921 aListOfStrings[0] = "" ;
922 GraphBase::ListOfPythonFunctions aPythonFunction ;
923 aPythonFunction.resize( 1 ) ;
924 aPythonFunction[0] = &aListOfStrings ;
925 SALOME_ModuleCatalog::Service * aMacroNodeService = myMacroGraph->Service() ;
926 GraphEditor::InNode * aDataFlowNode = DataFlowEditor()->AddNode( *aMacroNodeService , "" , "" ,
927 aMacroNodeName.c_str() , SUPERV::MacroNode ,
928 aFuncName , aPythonFunction ) ;
929 aDataFlowNode->SetPythonFunction( "" , aListOfStrings ) ;
930 myMacroNode->DataFlowNode( aDataFlowNode ) ;
931 aDataFlowNode->ComputingNode()->SetService( *aMacroNodeService ) ;
932 aDataFlowNode->SetObjRef( SUPERV::CNode::_duplicate( SUPERV::CNode::_narrow( obj ) ) ) ;
933 aDataFlowNode->SetObjImpl( this ) ;
935 GraphBase::Graph * aGraph = myMacroGraph->DataFlowEditor()->Graph() ;
936 GraphBase::Graph * aGraphOfMacroGraph = myMacroNode->DataFlowEditor()->Graph() ;
937 GraphBase::Graph * aMacroGraph = myMacroNode->DataFlowNode()->GraphMacroNode() ;
938 aMacroGraph->Kind( SUPERV::MacroNode ) ;
939 aMacroGraph->GraphEditor( DataFlowEditor() ) ;
940 // Creation of the Ports of the MacroNode from the ports of the GraphMacroNode
941 aMacroGraph->SetMacroPorts( aGraph ) ;
942 // Valid ==> creation of Service and the ports of the current Graph
943 DataFlowEditor()->IsValid() ;
944 // Set the Input Datas from the GraphMacroNode to the current Graph
945 aMacroGraph->SetMacroDatas( aGraph , aGraphOfMacroGraph ) ;
946 aMacroGraphDataFlowEditor->UnValid() ;
947 // Set the MacroNode ObjRef in the GraphMacroNode
948 aGraph->CoupledNode( aMacroGraph ) ;
949 aGraph->MacroObject( SUPERV::Graph::_duplicate( macroiobject ) ) ;
950 // Set the GraphMacroNode ObjRef in the MacroNode
951 aDataFlowNode->GraphMacroNode()->GraphMacroLevel( aGraphOfMacroGraph->GraphMacroLevel() + 1 ) ;
952 aMacroGraph->CoupledNode( aGraph ) ;
953 // aGraphOfMacroGraph->CoupledNode( aGraph ) ;
954 aMacroGraph->MacroObject( SUPERV::Graph::_duplicate( iobject ) ) ;
955 // aGraphOfMacroGraph->MacroObject( SUPERV::Graph::_duplicate( iobject ) ) ;
956 // aDataFlowNode->CoupledNode( aGraph ) ;
957 // aDataFlowNode->ComputingNode()->MacroObject( SUPERV::Graph::_duplicate( iobject ) ) ;
958 // Set the MacroLevel of that graph
959 aGraph->GraphMacroLevel( aGraphOfMacroGraph->GraphMacroLevel() + 1 ) ;
960 aMacroGraph->Coordinates( 0 , 0 ) ;
961 MESSAGE( "DataFlowNode Graph " << this << " DataFlowEditor " << DataFlowEditor() << " aDataFlowNode "
962 << aDataFlowNode << " " << aDataFlowNode->Name() << " created" ) ;
963 MESSAGE( "MNode aGraph " << aGraph << " " << aGraph->Name()
964 << " coupled to " << aGraph->CoupledNode() << " "
965 << aGraph->CoupledNode()->Name() ) ;
966 MESSAGE( "MNode aMacroGraph " << aMacroGraph << " " << aMacroGraph->Name()
967 << " coupled to " << aMacroGraph->CoupledNode() << " "
968 << aMacroGraph->CoupledNode()->Name() ) ;
969 MESSAGE( "MNode aMacroGraph " << myMacroNode->DataFlowEditor()->Graph() << " "
970 << myMacroNode->DataFlowEditor()->Graph()->Name()
971 << " coupled to " << myMacroNode->DataFlowEditor()->Graph()->CoupledNode() ) ;
974 delete aMacroGraphDataFlowEditor ;
977 endService( "Graph_Impl::MNode" );
978 return SUPERV::Graph::_duplicate( macroiobject ) ;
981 // For python supergraph
982 SUPERV::Graph_ptr Graph_Impl::GraphMNode( SUPERV::Graph_ptr myMacroGraph ) {
983 SUPERV::Graph_var iobject = myMacroGraph ;
984 beginService( "Graph_Impl::GraphMNode" ) ;
986 // GraphBase::Graph * myMacroGraph = aGraph;
987 SUPERV::Graph_var macroiobject = SUPERV::StreamGraph::_nil() ;
988 // Creation of a GraphMacroNode in the current editor
990 string aMacroNodeName = string( "Macro_" ) + string( myMacroGraph->Name() ) ;
991 //string aMacroNodeName = string( myMacroGraph->CoupledName() ) ;
992 MESSAGE( "GraphMNode( " << myMacroGraph->Name() << " )" ) ;
993 Graph_Impl * myMacroNode ;
994 myMacroNode = new Graph_Impl( _Orb , _Poa, _ContId,
995 instanceName() , interfaceName() ,
996 aMacroNodeName.c_str() , SUPERV::MacroNode ) ;
997 PortableServer::ObjectId * id = myMacroNode->getId() ;
998 CORBA::Object_var obj = _poa->id_to_reference(*id);
999 macroiobject = SUPERV::Graph::_narrow( obj ) ;
1000 myMacroNode->DataFlowEditor( DataFlowEditor() ) ;
1002 // Creation of the MacroNode itself in the current Graph
1003 GraphBase::ListOfFuncName aFuncName ;
1004 aFuncName.resize( 1 ) ;
1006 SUPERV::ListOfStrings aListOfStrings ;
1007 aListOfStrings.length( 1 ) ;
1008 aListOfStrings[0] = "" ;
1009 GraphBase::ListOfPythonFunctions aPythonFunction ;
1010 aPythonFunction.resize( 1 ) ;
1011 aPythonFunction[0] = &aListOfStrings ;
1012 SALOME_ModuleCatalog::Service * aMacroNodeService = myMacroGraph->Service() ;
1013 GraphEditor::InNode * aDataFlowNode ;
1014 aDataFlowNode = DataFlowEditor()->AddNode( *aMacroNodeService , "" , "" ,
1015 aMacroNodeName.c_str() , SUPERV::MacroNode ,
1016 aFuncName , aPythonFunction ) ;
1017 aDataFlowNode->SetPythonFunction( "" , aListOfStrings ) ;
1018 myMacroNode->DataFlowNode( aDataFlowNode ) ;
1019 aDataFlowNode->ComputingNode()->SetService( *aMacroNodeService ) ;
1020 aDataFlowNode->SetObjRef( SUPERV::CNode::_duplicate( SUPERV::CNode::_narrow( obj ) ) ) ;
1021 aDataFlowNode->SetObjImpl( this ) ;
1023 // GraphBase::Graph * aGraph = DataFlowEditor()->Automaton()->MapGraph( myMacroGraph->Name() ) ;
1024 GraphBase::Graph * aGraph ;
1025 //DataFlowEditor()->Automaton()->GraphBase( &aGraph ) ;
1026 myMacroGraph->Coupled() ;
1027 GraphBase::Graph * aGraphOfMacroGraph = myMacroNode->DataFlowEditor()->Graph() ;
1028 GraphBase::Graph * aMacroGraph = myMacroNode->DataFlowNode()->GraphMacroNode() ;
1029 aMacroGraph->Kind( SUPERV::MacroNode ) ;
1030 aMacroGraph->GraphEditor( DataFlowEditor() ) ;
1031 // Creation of the Ports of the MacroNode from the ports of the GraphMacroNode
1032 aMacroGraph->SetMacroPorts( aGraph ) ;
1033 // Valid ==> creation of Service and the ports of the current Graph
1034 DataFlowEditor()->IsValid() ;
1035 // Set the Input Datas from the GraphMacroNode to the current Graph
1036 aMacroGraph->SetMacroDatas( aGraph , aGraphOfMacroGraph ) ;
1037 // aMacroGraphDataFlowEditor->UnValid() ;
1038 aGraph->GraphEditor()->UnValid() ;
1039 // Set the MacroNode ObjRef in the GraphMacroNode
1040 aGraph->CoupledNode( aMacroGraph ) ;
1041 aGraph->MacroObject( SUPERV::Graph::_duplicate( macroiobject ) ) ;
1042 // Set the GraphMacroNode ObjRef in the MacroNode
1043 aDataFlowNode->GraphMacroNode()->GraphMacroLevel( aGraphOfMacroGraph->GraphMacroLevel() + 1 ) ;
1044 aMacroGraph->CoupledNode( aGraph ) ;
1045 aMacroGraph->MacroObject( SUPERV::Graph::_duplicate( iobject ) ) ;
1046 // aDataFlowNode->CoupledNode( aGraph ) ;
1047 // aDataFlowNode->ComputingNode()->MacroObject( SUPERV::Graph::_duplicate( iobject ) ) ;
1048 // Set the MacroLevel of that graph
1049 aGraph->GraphMacroLevel( aGraphOfMacroGraph->GraphMacroLevel() + 1 ) ;
1050 aMacroGraph->Coordinates( 0 , 0 ) ;
1051 MESSAGE( aGraph->Name() << "->CoupledNode()->GraphEditor() : " << aGraph->CoupledNode()->GraphEditor() ) ;
1052 MESSAGE( aMacroGraph->Name() << "->CoupledNode()->GraphEditor() : "
1053 << aMacroGraph->CoupledNode()->GraphEditor() ) ;
1054 MESSAGE( "DataFlowNode Graph " << this << " DataFlowEditor " << DataFlowEditor() << " aDataFlowNode "
1055 << aDataFlowNode << " " << aDataFlowNode->Name() << " created" ) ;
1057 endService( "Graph_Impl::GraphMNode" ) ;
1058 return SUPERV::Graph::_duplicate( macroiobject ) ;
1061 SUPERV::Graph_ptr Graph_Impl::FlowObjRef() {
1062 beginService( "Graph_Impl::FlowObjRef" );
1063 SUPERV::Graph_var iobject = SUPERV::Graph::_nil() ;
1065 iobject = SUPERV::Graph::_narrow( DataFlowNode()->GraphMacroNode()->MacroObject() ) ;
1067 else if ( IsGraph() ) {
1068 iobject = SUPERV::Graph::_narrow( DataFlowEditor()->Graph()->MacroObject() ) ;
1070 if ( CORBA::is_nil( iobject ) ) {
1071 MESSAGE( "Graph_Impl::FlowObjRef() returns a NIL Object" ) ;
1073 endService( "Graph_Impl::FlowObjRef" );
1074 return SUPERV::Graph::_duplicate( iobject ) ;
1077 SUPERV::StreamGraph_ptr Graph_Impl::StreamObjRef() {
1078 beginService( "Graph_Impl::StreamObjRef" );
1079 SUPERV::StreamGraph_var iobject = SUPERV::StreamGraph::_nil() ;
1081 iobject = SUPERV::StreamGraph::_narrow( DataFlowNode()->GraphMacroNode()->MacroObject() ) ;
1083 else if ( IsGraph() || IsStreamGraph() ) {
1084 iobject = SUPERV::StreamGraph::_narrow( DataFlowEditor()->Graph()->MacroObject() ) ;
1086 if ( CORBA::is_nil( iobject ) ) {
1087 MESSAGE( "Graph_Impl::StreamObjRef() returns a NIL Object" ) ;
1089 endService( "Graph_Impl::StreamObjRef" );
1090 return SUPERV::StreamGraph::_duplicate( iobject ) ;
1093 SUPERV::CNode_ptr Graph_Impl::Node(char const * aNodeName ) {
1094 // beginService( "Graph_Impl::Node" );
1095 SUPERV::CNode_var iobject = SUPERV::CNode::_nil() ;
1097 if ( CORBA::is_nil( DataFlowEditor()->GetNode( aNodeName )->ObjRef() ) ) {
1098 CNode_Impl * myNode = new CNode_Impl( _Orb , _Poa , _ContId ,
1099 instanceName() , interfaceName() ,
1101 DataFlowEditor()->GetNode( aNodeName ) ) ;
1102 PortableServer::ObjectId * id = myNode->getId() ;
1103 CORBA::Object_var obj = _poa->id_to_reference(*id);
1104 iobject = SUPERV::CNode::_narrow(obj) ;
1105 myNode->SetObjRef( SUPERV::CNode::_duplicate( iobject ) ) ;
1108 iobject = DataFlowEditor()->GetNode( aNodeName )->ObjRef() ;
1111 GraphEditor::InNode * anInNode = DataFlowEditor()->GetNode( aNodeName ) ;
1113 if ( CORBA::is_nil( anInNode->ObjRef() ) ) {
1114 SetNodeObjRef( anInNode ) ;
1116 iobject = anInNode->ObjRef() ;
1119 // endService( "Graph_Impl::Node" );
1120 return SUPERV::CNode::_duplicate( iobject ) ;
1123 SUPERV::Link_ptr Graph_Impl::Link( SUPERV::Port_ptr OutPort ,
1124 SUPERV::Port_ptr InPort ) {
1125 // beginService( "Graph_Impl::Link" );
1126 SUPERV::Link_var iobject = SUPERV::Link::_nil() ;
1127 if ( DataFlowEditor()->IsEditing() && !DataFlowEditor()->IsReadOnly() &&
1128 !OutPort->IsDataStream() && !InPort->IsDataStream() && !IsMacro() ) {
1129 MESSAGE( "Graph_Impl::Link( " << OutPort->Node()->Name() << "( " << OutPort->Name() << " ) --> "
1130 << InPort->Node()->Name() << "( " << InPort->Name() << " )" ) ;
1131 GraphEditor::InNode * anInNode = DataFlowEditor()->GetNode( InPort->Node()->Name() ) ;
1132 GraphEditor::InNode * anOutNode = DataFlowEditor()->GetNode( OutPort->Node()->Name() ) ;
1133 if ( anInNode == NULL || anOutNode== NULL ) {
1134 MESSAGE( "Graph_Impl::Link( " << OutPort->Node()->Name() << " " << anOutNode << " , "
1135 << InPort->Node()->Name() << " " << anInNode << " ) Node(s) not found in " << Name() ) ;
1138 GraphBase::InPort * anInPort = anInNode->ComputingNode()->GetChangeInPort( InPort->Name() ) ;
1139 GraphBase::OutPort * anOutPort = anOutNode->ComputingNode()->GetChangeOutPort( OutPort->Name() ) ;
1140 if ( anInPort == NULL || anOutPort== NULL ) {
1141 MESSAGE( "Graph_Impl::Link( " << OutPort->Name() << " " << anOutPort << " , "
1142 << InPort->Name() << " " << anInPort << " ) Port(s) not found" ) ;
1144 else if ( CORBA::is_nil( anOutPort->InPortObjRef( anInPort ) ) ) {
1145 const char * DataFlowOutNodeName = OutPort->Node()->Name() ;
1146 GraphEditor::InNode * DataFlowOutNode = DataFlowEditor()->GetNode( DataFlowOutNodeName ) ;
1147 const char * DataFlowInNodeName = InPort->Node()->Name() ;
1148 GraphEditor::InNode * DataFlowInNode = DataFlowEditor()->GetNode( DataFlowInNodeName ) ;
1149 if ( DataFlowOutNode && DataFlowInNode ) {
1151 Link_Impl * myLink = new Link_Impl( _Orb , _Poa , _ContId ,
1152 instanceName() , interfaceName() ,
1158 true , false , Success ) ;
1160 PortableServer::ObjectId * id = myLink->getId() ;
1161 CORBA::Object_var obj = _poa->id_to_reference(*id);
1162 iobject = SUPERV::Link::_narrow(obj) ;
1163 anOutPort->AddInPortObjRef( anInPort , SUPERV::Link::_duplicate( iobject ) ) ;
1168 iobject = anOutPort->InPortObjRef( anInPort ) ;
1172 DataFlowEditor()->UnValid() ;
1173 // endService( "Graph_Impl::Link" );
1174 return SUPERV::Link::_duplicate( iobject ) ;
1177 // Only to see MacroNodes with actual GUI ... :
1178 #define GOTOMacroNode 0
1180 void Graph_Impl::SetNodeObjRef( GraphEditor::InNode * anInNode ) {
1181 MESSAGE("Graph_Impl::SetNodeObjRef " << anInNode->Name() << " " << anInNode->Kind() ) ;
1182 CORBA::Object_var obj ;
1183 if ( anInNode->IsComputingNode() ) {
1184 CNode_Impl * myNode = new CNode_Impl( _Orb , _Poa , _ContId ,
1185 instanceName() , interfaceName() ,
1188 PortableServer::ObjectId * id = myNode->getId() ;
1189 obj = _poa->id_to_reference(*id);
1190 SUPERV::CNode_var iobject = SUPERV::CNode::_narrow(obj) ;
1191 myNode->SetObjRef( SUPERV::CNode::_duplicate( iobject ) ) ;
1193 else if ( anInNode->IsFactoryNode() ) {
1194 FNode_Impl * myNode = new FNode_Impl( _Orb , _Poa , _ContId ,
1195 instanceName() , interfaceName() ,
1198 PortableServer::ObjectId * id = myNode->getId() ;
1199 obj = _poa->id_to_reference(*id);
1200 SUPERV::FNode_var iobject = SUPERV::FNode::_narrow(obj) ;
1201 myNode->SetObjRef( SUPERV::FNode::_duplicate( iobject ) ) ;
1203 else if ( anInNode->IsInLineNode() ) {
1204 INode_Impl * myNode = new INode_Impl( _Orb , _Poa , _ContId ,
1205 instanceName() , interfaceName() ,
1208 PortableServer::ObjectId * id = myNode->getId() ;
1209 obj = _poa->id_to_reference(*id);
1210 SUPERV::INode_var iobject = SUPERV::INode::_narrow(obj) ;
1211 myNode->SetObjRef( SUPERV::INode::_duplicate( iobject ) ) ;
1214 else if ( anInNode->IsGOTONode() || anInNode->IsMacroNode() ) {
1215 if ( anInNode->IsMacroNode() ) {
1216 anInNode->ComputingNode()->Kind( SUPERV::GOTONode ) ;
1219 else if ( anInNode->IsGOTONode() ) {
1221 GNode_Impl * myNode = new GNode_Impl( _Orb , _Poa , _ContId ,
1222 instanceName() , interfaceName() ,
1225 PortableServer::ObjectId * id = myNode->getId() ;
1226 obj = _poa->id_to_reference(*id);
1227 SUPERV::GNode_var iobject = SUPERV::GNode::_narrow(obj) ;
1228 myNode->SetObjRef( SUPERV::GNode::_duplicate( iobject ) ) ;
1230 else if ( anInNode->IsMacroNode() ) {
1231 Graph_Impl * myNode = new Graph_Impl( _Orb , _Poa , _ContId ,
1232 instanceName() , interfaceName() ,
1235 PortableServer::ObjectId * id = myNode->getId() ;
1236 obj = _poa->id_to_reference(*id);
1237 SUPERV::Graph_var iobject = SUPERV::Graph::_narrow(obj) ;
1238 myNode->SetObjRef( SUPERV::Graph::_duplicate( iobject ) ) ;
1240 else if ( anInNode->IsLoopNode() ) {
1241 LNode_Impl * myNode = new LNode_Impl( _Orb , _Poa , _ContId ,
1242 instanceName() , interfaceName() ,
1245 PortableServer::ObjectId * id = myNode->getId() ;
1246 obj = _poa->id_to_reference(*id);
1247 SUPERV::LNode_var iobject = SUPERV::LNode::_narrow(obj) ;
1248 myNode->SetObjRef( SUPERV::LNode::_duplicate( iobject ) ) ;
1250 else if ( anInNode->IsEndLoopNode() ) {
1251 ELNode_Impl * myNode = new ELNode_Impl( _Orb , _Poa , _ContId ,
1252 instanceName() , interfaceName() ,
1255 PortableServer::ObjectId * id = myNode->getId() ;
1256 obj = _poa->id_to_reference(*id);
1257 SUPERV::ELNode_var iobject = SUPERV::ELNode::_narrow(obj) ;
1258 myNode->SetObjRef( SUPERV::ELNode::_duplicate( iobject ) ) ;
1260 else if ( anInNode->IsSwitchNode() ) {
1261 SNode_Impl * myNode = new SNode_Impl( _Orb , _Poa , _ContId ,
1262 instanceName() , interfaceName() ,
1265 PortableServer::ObjectId * id = myNode->getId() ;
1266 obj = _poa->id_to_reference(*id);
1267 SUPERV::SNode_var iobject = SUPERV::SNode::_narrow(obj) ;
1268 myNode->SetObjRef( SUPERV::SNode::_duplicate( iobject ) ) ;
1270 else if ( anInNode->IsEndSwitchNode() ) {
1271 ESNode_Impl * myNode = new ESNode_Impl( _Orb , _Poa , _ContId ,
1272 instanceName() , interfaceName() ,
1275 PortableServer::ObjectId * id = myNode->getId() ;
1276 obj = _poa->id_to_reference(*id);
1277 SUPERV::ESNode_var iobject = SUPERV::ESNode::_narrow(obj) ;
1278 myNode->SetObjRef( SUPERV::ESNode::_duplicate( iobject ) ) ;
1282 SUPERV::ListOfNodes_var Graph_Impl::SetNode( SUPERV::ListOfNodes_var RetVal ,
1283 GraphBase::ComputingNode * aNode ) {
1285 // if ( _DataFlowExecutor ) {
1286 if ( DataFlowExecutor() ) {
1287 MESSAGE("Graph_Impl::SetNode " << aNode->Name() << " " << aNode->Kind() << " "
1288 << DataFlowExecutor()->StateName( DataFlowExecutor()->AutomatonState( aNode->Name() ) ) ) ;
1291 MESSAGE("Graph_Impl::SetNode " << aNode->Name() << " " << aNode->Kind() ) ;
1293 if ( aNode->IsComputingNode() ) {
1294 index = RetVal->CNodes.length() ;
1295 RetVal->CNodes.length( index+1 );
1297 else if ( aNode->IsFactoryNode() ) {
1298 index = RetVal->FNodes.length() ;
1299 RetVal->FNodes.length( index+1 );
1301 else if ( aNode->IsInLineNode() ) {
1302 index = RetVal->INodes.length() ;
1303 RetVal->INodes.length( index+1 );
1306 else if ( aNode->IsGOTONode() || aNode->IsMacroNode() ) {
1308 else if ( aNode->IsGOTONode() ) {
1310 index = RetVal->GNodes.length() ;
1311 RetVal->GNodes.length( index+1 );
1313 else if ( aNode->IsMacroNode() ) {
1314 index = RetVal->Graphs.length() ;
1315 RetVal->Graphs.length( index+1 );
1317 else if ( aNode->IsLoopNode() ) {
1318 index = RetVal->LNodes.length() ;
1319 RetVal->LNodes.length( index+1 );
1321 else if ( aNode->IsEndLoopNode() ) {
1322 index = RetVal->ELNodes.length() ;
1323 RetVal->ELNodes.length( index+1 );
1325 else if ( aNode->IsSwitchNode() ) {
1326 index = RetVal->SNodes.length() ;
1327 RetVal->SNodes.length( index+1 );
1329 else if ( aNode->IsEndSwitchNode() ) {
1330 index = RetVal->ESNodes.length() ;
1331 RetVal->ESNodes.length( index+1 );
1333 if ( CORBA::is_nil( aNode->ObjRef() ) ) {
1334 SetNodeObjRef( (GraphEditor::InNode * ) aNode->GetInNode() ) ;
1336 SUPERV::CNode_var aNodeObjRef = aNode->ObjRef() ;
1337 if ( aNode->IsComputingNode() ) {
1338 RetVal->CNodes[index] = SUPERV::CNode::_duplicate( aNodeObjRef ) ;
1340 else if ( aNode->IsFactoryNode() ) {
1341 RetVal->FNodes[index] = SUPERV::FNode::_duplicate( SUPERV::FNode::_narrow( aNodeObjRef ) ) ;
1343 else if ( aNode->IsInLineNode() ) {
1344 RetVal->INodes[index] = SUPERV::INode::_duplicate( SUPERV::INode::_narrow( aNodeObjRef ) ) ;
1347 else if ( aNode->IsGOTONode() || aNode->IsMacroNode() ) {
1349 else if ( aNode->IsGOTONode() ) {
1351 RetVal->GNodes[index] = SUPERV::GNode::_duplicate( SUPERV::GNode::_narrow( aNodeObjRef ) ) ;
1353 else if ( aNode->IsMacroNode() ) {
1354 RetVal->Graphs[index] = SUPERV::Graph::_duplicate( SUPERV::Graph::_narrow( aNodeObjRef ) ) ;
1356 else if ( aNode->IsLoopNode() ) {
1357 RetVal->LNodes[index] = SUPERV::LNode::_duplicate( SUPERV::LNode::_narrow( aNodeObjRef ) ) ;
1359 else if ( aNode->IsEndLoopNode() ) {
1360 RetVal->ELNodes[index] = SUPERV::ELNode::_duplicate( SUPERV::ELNode::_narrow( aNodeObjRef ) ) ;
1362 else if ( aNode->IsSwitchNode() ) {
1363 RetVal->SNodes[index] = SUPERV::SNode::_duplicate( SUPERV::SNode::_narrow( aNodeObjRef ) ) ;
1365 else if ( aNode->IsEndSwitchNode() ) {
1366 RetVal->ESNodes[index] = SUPERV::ESNode::_duplicate( SUPERV::ESNode::_narrow( aNodeObjRef ) ) ;
1368 return ( RetVal._retn() ) ;
1371 SUPERV::ListOfNodes * Graph_Impl::Nodes() {
1372 SUPERV::ListOfNodes_var RetVal = new SUPERV::ListOfNodes;
1373 beginService( "Graph_Impl::Nodes" );
1374 RetVal->CNodes.length(0) ;
1375 RetVal->FNodes.length(0) ;
1376 RetVal->INodes.length(0) ;
1377 RetVal->LNodes.length(0) ;
1378 RetVal->SNodes.length(0) ;
1379 RetVal->GNodes.length(0) ;
1380 RetVal->Graphs.length(0) ;
1383 cout << DataFlowEditor()->Graph()->GetGraphNodeSize() << " Nodes in the Map and "
1384 << DataFlowEditor()->Graph()->GraphNodesSize() << " Nodes int the Vector" << endl ;
1385 for ( i = 0 ; i < DataFlowEditor()->Graph()->GraphNodesSize() ; i++ ) {
1386 GraphBase::ComputingNode * aNode = DataFlowEditor()->Graph()->GraphNodes( i ) ;
1388 cout << i << ". Vector : " << aNode->Name() << " Map : "
1389 << DataFlowEditor()->Graph()->GetGraphNode( aNode->Name() )->Name()
1392 RetVal = SetNode( RetVal , aNode ) ;
1395 char * aStateG = "" ;
1396 if ( DataFlowExecutor() ) {
1397 aStateG = (char *) DataFlowExecutor()->StateName( DataFlowExecutor()->AutomatonState() ) ;
1399 MESSAGE("Graph_Impl::Nodes GraphState " << aStateG << " CNodes " << RetVal->CNodes.length() ) ;
1400 for ( i = 0 ; i < RetVal->CNodes.length() ; i++ ) {
1401 MESSAGE(" " << RetVal->CNodes[ i ] ->Name() ) ;
1403 MESSAGE("FNodes " << RetVal->FNodes.length() ) ;
1404 for ( i = 0 ; i < RetVal->FNodes.length() ; i++ ) {
1405 MESSAGE(" " << RetVal->FNodes[ i ] ->Name() ) ;
1407 MESSAGE("INodes " << RetVal->INodes.length() ) ;
1408 for ( i = 0 ; i < RetVal->INodes.length() ; i++ ) {
1409 MESSAGE(" " << RetVal->INodes[ i ] ->Name() ) ;
1411 MESSAGE("GNodes " << RetVal->GNodes.length() ) ;
1412 for ( i = 0 ; i < RetVal->GNodes.length() ; i++ ) {
1413 MESSAGE(" " << RetVal->GNodes[ i ] ->Name() ) ;
1415 MESSAGE("LNodes " << RetVal->LNodes.length() ) ;
1416 for ( i = 0 ; i < RetVal->LNodes.length() ; i++ ) {
1417 MESSAGE(" " << RetVal->LNodes[ i ] ->Name() ) ;
1419 MESSAGE("ELNodes " << RetVal->ELNodes.length() ) ;
1420 for ( i = 0 ; i < RetVal->ELNodes.length() ; i++ ) {
1421 MESSAGE(" " << RetVal->ELNodes[ i ] ->Name() ) ;
1423 MESSAGE("SNodes " << RetVal->SNodes.length() ) ;
1424 for ( i = 0 ; i < RetVal->SNodes.length() ; i++ ) {
1425 MESSAGE(" " << RetVal->SNodes[ i ] ->Name() ) ;
1427 MESSAGE("ESNodes " << RetVal->ESNodes.length() ) ;
1428 for ( i = 0 ; i < RetVal->ESNodes.length() ; i++ ) {
1429 MESSAGE(" " << RetVal->ESNodes[ i ] ->Name() ) ;
1431 MESSAGE("Graphs " << RetVal->Graphs.length() ) ;
1432 for ( i = 0 ; i < RetVal->Graphs.length() ; i++ ) {
1433 MESSAGE(" " << RetVal->Graphs[ i ] ->Name() ) ;
1435 if ( DataFlowExecutor() ) {
1436 DataFlowExecutor()->EventList() ;
1440 endService( "Graph_Impl::Nodes" );
1441 return ( RetVal._retn() ) ;
1444 SUPERV::ListOfLinks * Graph_Impl::GLinks() {
1445 return Links( NULL , NULL ) ;
1448 SUPERV::ListOfLinks * Graph_Impl::Links( GraphBase::ComputingNode * theNode ,
1449 const char * anInputParam ) {
1451 SUPERV::ListOfLinks_var RetVal = new SUPERV::ListOfLinks ;
1452 RetVal->length( 0 ) ;
1454 int i , j , countlink ;
1456 for ( i = 0 ; i < DataFlowEditor()->Graph()->GraphNodesSize() ; i++ ) {
1457 GraphEditor::InNode * aNode = NULL ;
1458 aNode = (GraphEditor::InNode * ) DataFlowEditor()->Graph()->GraphNodes( i )->GetInNode() ;
1459 bool ToProcess = false ;
1460 if ( theNode == NULL ) {
1464 if ( !strcmp( theNode->Name() , aNode->Name() ) ) {
1465 if ( !theNode->IsEndSwitchNode() ) {
1469 else if ( theNode->IsEndSwitchNode() ) {
1474 for ( j = 0 ; j < aNode->GetNodeInPortsSize() ; j++ ) {
1475 GraphBase::InPort * anInPort = NULL ;
1476 anInPort = aNode->GetChangeNodeInPort( j ) ;
1477 if ( anInputParam == NULL ||
1478 !strcmp( anInPort->PortName() , anInputParam ) ) {
1479 GraphBase::OutPort * anOutPort = NULL ;
1480 anOutPort = anInPort->GetOutPort() ;
1481 if ( anOutPort && !anOutPort->IsDataStream() ) {
1482 if ( strcmp( anOutPort->NodeName() , Name() ) ) {
1483 // MESSAGE("Graph_Impl::Links " << anOutPort->NodeName() << "("
1484 // << anOutPort->PortName() << ") --> " << aNode->Name() << "("
1485 // << anInPort->PortName() << ")" ) ;
1486 if ( theNode == NULL ||
1487 //JR 14.02.2005 : Debug : we must see also that links !
1488 // ( theNode != NULL && !theNode->IsEndSwitchNode() &&
1489 !strcmp( theNode->Name() , aNode->Name() ) ) {
1490 if ( anInPort->IsLoop() || anOutPort->IsLoop() ||
1491 ( aNode->IsEndLoopNode() && !strcmp( aNode->CoupledNode()->Name() ,
1492 anOutPort->NodeName() ) ) ) {
1493 // MESSAGE( "Link " << anOutPort->NodeName() << "("
1494 // << anOutPort->PortName() << ") --> " << aNode->Name() << "("
1495 // << anInPort->PortName() << ")" << " ignored" ) ;
1497 else if ( CORBA::is_nil( anOutPort->InPortObjRef( anInPort ) ) ) {
1499 beginService( "Graph_Impl::Links" );
1502 GraphEditor::InNode * anOutNode = NULL ;
1503 anOutNode = (GraphEditor::InNode * ) DataFlowEditor()->Graph()->GetChangeGraphNode( anOutPort->NodeName() )->GetInNode() ;
1506 Link_Impl * myLink = new Link_Impl( _Orb , _Poa , _ContId ,
1507 instanceName() , interfaceName() ,
1510 anInPort->PortName() ,
1512 anOutPort->PortName() ,
1513 false , true , Success ) ;
1515 PortableServer::ObjectId * id = myLink->getId() ;
1516 CORBA::Object_var obj = _poa->id_to_reference(*id);
1517 SUPERV::Link_var iobject ;
1518 iobject = SUPERV::Link::_narrow(obj) ;
1519 RetVal->length( countlink + 1 ) ;
1520 RetVal[ countlink++ ] = SUPERV::Link::_duplicate( iobject ) ;
1521 anOutPort->AddInPortObjRef( anInPort , SUPERV::Link::_duplicate( iobject ) ) ;
1526 RetVal->length( countlink + 1 ) ;
1527 RetVal[ countlink++ ] = SUPERV::Link::_duplicate( anOutPort->InPortObjRef( anInPort ) ) ;
1529 // MESSAGE( "Link " << anOutPort->NodeName() << "("
1530 // << anOutPort->PortName() << ") --> " << aNode->Name() << "("
1531 // << anInPort->PortName() << ")" << " selected" ) ;
1534 // MESSAGE( "Link " << anOutPort->NodeName() << "("
1535 // << anOutPort->PortName() << ") --> " << aNode->Name() << "("
1536 // << anInPort->PortName() << ")" << " skipped" ) ;
1543 for ( j = 0 ; j < aNode->GetNodeOutPortsSize() ; j++ ) {
1544 GraphBase::OutPort * anOutPort = aNode->GetChangeNodeOutPort( j ) ;
1545 // MESSAGE( "Graph_Impl::Links " << aNode->Name() << " Out" << j << " " << anOutPort->PortName() << " "
1546 // << anOutPort->PortStatus() << " PortConnected to " << anOutPort->InPortsSize() << " InPorts" ) ;
1548 for ( k = 0 ; k < anOutPort->InPortsSize() ; k++ ) {
1549 GraphBase::InPort * anInPort = anOutPort->ChangeInPorts( k ) ;
1550 // MESSAGE( " --> In" << k << " " << anInPort->NodeName() << " " << anInPort->PortName()
1551 // << " " << anInPort->PortStatus() ) ;
1552 if ( anInPort->IsPortConnected() ) {
1553 GraphBase::ComputingNode * aComputingNode = DataFlowEditor()->Graph()->GetChangeGraphNode( anInPort->NodeName() ) ;
1554 GraphEditor::InNode * toNode = (GraphEditor::InNode * ) aComputingNode->GetInNode() ;
1555 if ( theNode == NULL ||
1556 !strcmp( theNode->Name() , aNode->Name() ) ) {
1557 if ( !anInPort->IsDataStream() ) {
1558 //JR 14.02.2005 : Debug : we must see also that links !
1559 // if ( theNode || ( toNode->IsEndSwitchNode() && !aNode->IsSwitchNode() ) ) {
1560 if ( anInputParam == NULL ||
1561 !strcmp( anInPort->PortName() , anInputParam ) ) {
1562 if ( anInPort->IsLoop() || anOutPort->IsLoop() ||
1563 ( toNode->IsEndLoopNode() && !strcmp( toNode->CoupledNode()->Name() ,
1564 anOutPort->NodeName() ) ) ) {
1565 // MESSAGE( "Link " << anOutPort->NodeName() << "("
1566 // << anOutPort->PortName() << ") --> " << toNode->Name() << "("
1567 // << anInPort->PortName() << ")" << " ignored" ) ;
1569 else if ( CORBA::is_nil( anOutPort->InPortObjRef( anInPort ) ) ) {
1571 beginService( "Graph_Impl::Links" );
1575 Link_Impl * myLink = new Link_Impl( _Orb , _Poa , _ContId ,
1576 instanceName() , interfaceName() ,
1579 anInPort->PortName() ,
1581 anOutPort->PortName() ,
1582 false , true , Success ) ;
1584 PortableServer::ObjectId * id = myLink->getId() ;
1585 CORBA::Object_var obj = _poa->id_to_reference(*id);
1586 SUPERV::Link_var iobject ;
1587 iobject = SUPERV::Link::_narrow(obj) ;
1588 RetVal->length( countlink + 1 ) ;
1589 RetVal[ countlink++ ] = SUPERV::Link::_duplicate( iobject ) ;
1590 anOutPort->AddInPortObjRef( anInPort , SUPERV::Link::_duplicate( iobject ) ) ;
1594 RetVal->length( countlink + 1 ) ;
1595 RetVal[ countlink++ ] = SUPERV::Link::_duplicate( SUPERV::Link::_narrow( anOutPort->InPortObjRef( anInPort ) ) ) ;
1597 // MESSAGE( "Link " << anOutPort->NodeName() << "("
1598 // << anOutPort->PortName() << ") --> " << toNode->Name() << "("
1599 // << anInPort->PortName() << ")" << " selected" ) ;
1602 // MESSAGE( "Link " << anOutPort->NodeName() << "("
1603 // << anOutPort->PortName() << ") --> " << toNode->Name() << "("
1604 // << anInPort->PortName() << ")" << " skipped" ) ;
1615 const char * NodeName = "" ;
1616 const char * InputParamName = "" ;
1618 NodeName = theNode->Name() ;
1620 if ( anInputParam ) {
1621 InputParamName = anInputParam ;
1623 MESSAGE( RetVal->length() << " Links of Node " << NodeName << " and of InPort " << InputParamName ) ;
1624 for ( i = 0 ; i < (int ) RetVal->length() ; i++ ) {
1625 MESSAGE( "Link " << RetVal[i]->OutPort()->Node()->Name() << "("
1626 << RetVal[i]->OutPort()->Name() << ") --> "
1627 << RetVal[i]->InPort()->Node()->Name() << "("
1628 << RetVal[i]->InPort()->Name() << ")" ) ;
1632 endService( "Graph_Impl::Links" );
1635 return ( RetVal._retn() ) ;
1638 Engines::Component_ptr Graph_Impl::ComponentRef( const char * aComputerContainer ,
1639 const char * aComponentName ) {
1640 Engines::Component_var objComponent = Engines::Component::_nil() ;
1642 Engines::Container_var myContainer ;
1643 DataFlowEditor()->Graph()->StartComponent( 0 , aComputerContainer , aComponentName ,
1644 myContainer , objComponent ) ;
1646 return Engines::Component::_duplicate( objComponent ) ;
1649 bool Graph_Impl::IsValid() {
1650 // beginService( "Graph_Impl::IsValid" );
1651 bool RetVal = false ;
1653 RetVal = DataFlowEditor()->IsValid() ;
1655 // endService( "Graph_Impl::IsValid" );
1658 bool Graph_Impl::IsExecutable() {
1659 // beginService( "Graph_Impl::IsExecutable" );
1660 bool RetVal = false ;
1662 // asv : 15.11.04 : added "&& GraphMacroLevel() == 0" ->
1663 // subgraphs are not executable by themselves, RetVal = false..
1664 if ( !IsMacro() && DataFlowEditor()->Graph()->GraphMacroLevel() == 0 ) {
1665 RetVal = DataFlowEditor()->IsExecutable() ;
1667 // endService( "Graph_Impl::IsExecutable" );
1671 bool Graph_Impl::IsEditing() {
1673 bool RetVal = false ;
1675 RetVal = DataFlowEditor()->IsEditing() ;
1681 return !IsExecuting();
1684 bool Graph_Impl::IsExecuting() {
1686 bool RetVal = false ;
1688 RetVal = !DataFlowEditor()->IsEditing() ;
1692 return CNode_Impl::IsExecuting();
1695 bool Graph_Impl::IsReadOnly() {
1696 // beginService( "Graph_Impl::IsExecuting" );
1697 bool RetVal = false ;
1699 RetVal = DataFlowEditor()->IsReadOnly() ;
1701 // endService( "Graph_Impl::IsExecuting" );
1705 long Graph_Impl::LevelMax() {
1706 // beginService( "Graph_Impl::LevelMax" );
1709 RetVal = DataFlowEditor()->LevelMax() ;
1711 // endService( "Graph_Impl::LevelMax" );
1714 SUPERV::ListOfNodes * Graph_Impl::LevelNodes(long aLevel ) {
1715 // beginService( "Graph_Impl::LevelNodes" );
1716 SUPERV::ListOfNodes_var RetVal = new SUPERV::ListOfNodes;
1719 SUPERV::ListOfStrings_var Nodes = DataFlowEditor()->LevelNodes( aLevel ) ;
1720 // RetVal->length( Nodes->length() );
1721 for ( i = 0 ; i < (int ) Nodes->length() ; i++ ) {
1722 // char * aNode = Nodes[ i ] ;
1723 GraphBase::ComputingNode * aNode = DataFlowEditor()->Graph()->GetChangeGraphNode( Nodes[ i ] ) ;
1724 RetVal = SetNode( RetVal , aNode ) ;
1725 // cout << "Graph_Impl::LevelNodes( " << aLevel << " ) " << aNode->Name() << endl ;
1726 // CNode_Impl * myNode = new CNode_Impl( _Orb , _Poa , _ContId ,
1727 // instanceName() , interfaceName() ,
1728 // DataFlowEditor() ,
1729 // (GraphEditor::InNode * ) DataFlowEditor()->GetChangeGraphNode( aNode )->GetInNode() ) ;
1730 // PortableServer::ObjectId * id = myNode->getId() ;
1731 // CORBA::Object_var obj = _poa->id_to_reference(*id);
1732 // SUPERV::CNode_var iobject ;
1733 // iobject = SUPERV::CNode::_narrow(obj) ;
1734 // RetVal[i] = SUPERV::CNode::_duplicate( iobject ) ;
1737 // endService( "Graph_Impl::LevelNodes" );
1738 return ( RetVal._retn() ) ;
1740 long Graph_Impl::ThreadsMax() {
1741 // beginService( "Graph_Impl::ThreadsMax" );
1744 RetVal = DataFlowEditor()->ThreadsMax() ;
1746 // endService( "Graph_Impl::ThreadsMax" );
1749 long Graph_Impl::Threads() {
1750 // beginService( "Node_Impl::Threads" );
1751 long RetVal = false ;
1753 RetVal = DataFlowExecutor()->Threads() ;
1755 // endService( "Node_Impl::Threads" );
1758 long Graph_Impl::SuspendedThreads() {
1759 // beginService( "Node_Impl::SuspendedThreads" );
1760 long RetVal = false ;
1762 RetVal = DataFlowExecutor()->SuspendedThreads() ;
1764 // endService( "Node_Impl::SuspendedThreads" );
1768 bool Graph_Impl::Begin() {
1769 bool RetVal = false ;
1770 if ( DataFlowEditor()->IsEditing() ) {
1771 if ( pthread_mutex_lock( &_MutexExecutorWait ) ) {
1772 perror("pthread_mutex_lock _MutexExecutorWait") ;
1775 if ( DataFlowExecutor() ) {
1776 MESSAGE( "Graph_Impl::Begin " << DataFlowExecutor()->Threads() << " threads" )
1777 Editing(); // just in case it was not called before by GUI..
1779 if ( DataFlowEditor()->IsExecutable() ) {
1780 DataFlowEditor()->EditedAfterExecution( false ) ;
1781 GraphBase::ListOfSGraphs * myListOfGraphs = DataFlowEditor()->GetDataFlows() ;
1783 GraphExecutor::DataFlow * aDataFlowExecutor ;
1785 CreateExecutor( _Orb , instanceName() , (*myListOfGraphs)[ 0 ].Info.theName.c_str() , Kind() ,
1786 dbgfile , &aDataFlowExecutor ) ;
1788 MESSAGE( "Graph_Impl::Begin : DataFlowExecutor created" );
1789 if ( !CORBA::is_nil( LoadDataFlows( aDataFlowExecutor, myListOfGraphs , 0 ) ) )
1793 DataFlowExecutor()->Graph()->SetObjImpl( DataFlowEditor()->Graph()->ObjImpl() ) ;
1796 if ( pthread_mutex_unlock( &_MutexExecutorWait ) ) {
1797 perror("pthread_mutex_unlock _MutexExecutorWait") ;
1805 * run() : was created in order to reduce code dublication, Run() and Start() do the same thing
1806 * except for final call to Executor->Run( bool ) - Run() calls with AndSuspend=false
1807 * and Start() calls with AndSuspend=true flag. The rest of the actions are the same:
1808 * 1. if a MacroNode's coupled graph (MacroLevel>0) -> simply Run() it.
1809 * 2. if a Supergraph -> create executor, load dataflow in it (done in Begin()), then - Run() it.
1811 bool Graph_Impl::run( const bool andSuspend ) {
1812 bool RetVal = false ;
1814 // if Editing or Finished state, and, naturally, 'this' is not a MacroNode.
1815 if ( ( DataFlowEditor()->IsEditing() || IsDone() ) && !IsMacro() ) {
1817 if ( DataFlowEditor()->Graph()->GraphMacroLevel() ) {
1818 // MacroGraph's Executor was created in recursive function LoadDataflows(Executor), called from
1819 // Begin() of Supergraph. See Begin() and LoadDataflows(Executor) for details.
1823 // Create Executor instance and its datamodel
1827 // Set Executing flag to avoid edition operations during execution, EditedAfterExecution=false
1828 DataFlowEditor()->Executing() ;
1829 DataFlowEditor()->EditedAfterExecution( false );
1831 // THE MAIN RUN METHOD
1832 RetVal = DataFlowExecutor()->Run( andSuspend );
1840 * Run() - called on "Execute" command
1842 bool Graph_Impl::Run() {
1843 beginService( "Graph_Impl::Run" );
1844 bool RetVal = run( /*andSuspend=*/false ) ;
1845 MESSAGE( "Graph_Impl::Run " << DataFlowEditor()->Graph()->Name() << " RetVal " << RetVal ) ;
1846 endService( "Graph_Impl::Run" );
1851 * Run() - called on "Execute step-by-step" command
1853 bool Graph_Impl::Start() {
1854 beginService( "Graph_Impl::Start" );
1855 bool RetVal = run( /*andSuspend=*/true ) ;
1856 MESSAGE( "Graph_Impl::Start " << DataFlowEditor()->Graph()->Name() << " RetVal " << RetVal ) ;
1857 endService( "Graph_Impl::Start" );
1861 bool Graph_Impl::EventNoW( SUPERV::CNode_out aNode ,
1862 SUPERV::GraphEvent & anEvent ,
1863 SUPERV::GraphState & aState ) {
1864 bool RetVal = false ;
1865 char * aNodeName = NULL ;
1866 SUPERV::GraphEvent theEvent = SUPERV::UndefinedEvent ;
1867 SUPERV::GraphState theState = SUPERV::UndefinedState ;
1868 if ( pthread_mutex_lock( &_MutexExecutorWait ) ) {
1869 perror("pthread_mutex_lock _MutexExecutorWait") ;
1872 if ( DataFlowExecutor() && !IsMacro() &&
1873 ( DataFlowExecutor()->GetListSize() || !DataFlowEditor()->IsEditing() ) ) {
1874 RetVal = DataFlowExecutor()->Event( & aNodeName , theEvent , theState , false ) ;
1875 // endService( "Graph_Impl::Event" );
1876 if ( strlen( aNodeName ) ) {
1877 if ( strcmp( aNodeName , Name() ) ) {
1878 aNode = Node( aNodeName ) ;
1885 aNode = SUPERV::Graph::_duplicate( SUPERV::Graph::_nil() ) ;
1887 // cout << "Graph_Impl::EventNoW " << aNode->Name() << " QSize " << DataFlowExecutor()->GetListSize() << endl ;
1890 // cout << "Graph_Impl::EventNoW NO DataFlowExecutor() or QSize=0 " << endl ;
1892 if ( pthread_mutex_unlock( &_MutexExecutorWait ) ) {
1893 perror("pthread_mutex_unlock _MutexExecutorWait") ;
1896 anEvent = theEvent ;
1901 bool Graph_Impl::Event( SUPERV::CNode_out aNode ,
1902 SUPERV::GraphEvent & anEvent ,
1903 SUPERV::GraphState & aState ) {
1904 // beginService( "Graph_Impl::Event" );
1905 bool RetVal = false ;
1906 char * aNodeName = NULL ;
1907 SUPERV::GraphEvent theEvent = SUPERV::UndefinedEvent ;
1908 SUPERV::GraphState theState = SUPERV::UndefinedState ;
1909 if ( pthread_mutex_lock( &_MutexExecutorWait ) ) {
1910 perror("pthread_mutex_lock _MutexExecutorWait") ;
1913 if ( DataFlowExecutor() && !IsMacro() &&
1914 ( DataFlowExecutor()->GetListSize() || !DataFlowEditor()->IsEditing() ) ){
1915 RetVal = DataFlowExecutor()->Event( & aNodeName , theEvent , theState ) ;
1916 // endService( "Graph_Impl::Event" );
1917 if ( strlen( aNodeName ) ) {
1918 if ( strcmp( aNodeName , Name() ) ) {
1919 aNode = Node( aNodeName ) ;
1926 aNode = SUPERV::Graph::_duplicate( SUPERV::Graph::_nil() ) ;
1928 // cout << "Graph_Impl::Event " << aNode->Name() << " QSize " << DataFlowExecutor()->GetListSize() << endl ;
1931 // cout << "Graph_Impl::Event NO DataFlowExecutor() or QSize=0 " << endl ;
1933 if ( pthread_mutex_unlock( &_MutexExecutorWait ) ) {
1934 perror("pthread_mutex_unlock _MutexExecutorWait") ;
1937 anEvent = theEvent ;
1943 bool Graph_Impl::EventW( SUPERV::CNode_out aNode ,
1944 SUPERV::GraphEvent & anEvent ,
1945 SUPERV::GraphState & aState ) {
1946 // beginService( "Graph_Impl::EventW" );
1947 bool RetVal = false ;
1948 char * aNodeName = NULL ;
1949 SUPERV::GraphEvent theEvent = SUPERV::UndefinedEvent ;
1950 SUPERV::GraphState theState = SUPERV::UndefinedState ;
1951 if ( pthread_mutex_lock( &_MutexExecutorWait ) ) {
1952 perror("pthread_mutex_lock _MutexExecutorWait") ;
1955 if ( DataFlowExecutor() && !IsMacro() &&
1956 ( DataFlowExecutor()->GetListSize() || !DataFlowEditor()->IsEditing() ) ) {
1957 RetVal = DataFlowExecutor()->EventW( & aNodeName , theEvent , theState ) ;
1958 if ( RetVal && strcmp( aNodeName , Name() ) ) {
1959 aNode = Node( aNodeName ) ;
1965 if ( pthread_mutex_unlock( &_MutexExecutorWait ) ) {
1966 perror("pthread_mutex_unlock _MutexExecutorWait") ;
1969 anEvent = theEvent ;
1971 // endService( "Graph_Impl::EventW" );
1975 long Graph_Impl::EventQSize() {
1976 // beginService( "Graph_Impl::EventQSize" );
1978 if ( pthread_mutex_lock( &_MutexExecutorWait ) ) {
1979 perror("pthread_mutex_lock _MutexExecutorWait") ;
1982 if ( DataFlowExecutor() && !IsMacro() ) {
1983 QSize = DataFlowExecutor()->EventQSize() ;
1985 if ( pthread_mutex_unlock( &_MutexExecutorWait ) ) {
1986 perror("pthread_mutex_unlock _MutexExecutorWait") ;
1989 // endService( "Graph_Impl::EventQSize" );
1993 long Graph_Impl::LastLevelDone() {
1994 // beginService( "Graph_Impl::LastLevelDone" );
1995 if ( pthread_mutex_lock( &_MutexExecutorWait ) ) {
1996 perror("pthread_mutex_lock _MutexExecutorWait") ;
2000 if ( DataFlowExecutor() && !IsMacro() ) {
2001 RetVal = DataFlowExecutor()->LastLevelDone() ;
2003 if ( pthread_mutex_unlock( &_MutexExecutorWait ) ) {
2004 perror("pthread_mutex_unlock _MutexExecutorWait") ;
2007 // endService( "Graph_Impl::LastLevelDone" );
2011 long Graph_Impl::SubGraphsNumber() {
2012 // beginService( "Graph_Impl::SubGraphsNumber" );
2014 if ( DataFlowEditor()->IsExecutable() && !IsMacro() ) {
2015 RetVal = DataFlowEditor()->SubGraphsNumber() ;
2017 // endService( "Graph_Impl::SubGraphsNumber" );
2021 SUPERV::ListOfNodes * Graph_Impl::SubGraphsNodes( const long aSubGraphNumber ) {
2022 beginService( "Graph_Impl::SubGraphsNodes" );
2023 SUPERV::ListOfNodes_var RetVal = new SUPERV::ListOfNodes ;
2024 if ( DataFlowEditor()->IsEditing() && !IsMacro() ) {
2025 SUPERV::ListOfNodes * aGraphNodes = Nodes() ;
2028 for ( i = 0 ; i < (int ) aGraphNodes->CNodes.length() ; i++ ) {
2029 SUPERV::CNode_var aNode = (aGraphNodes->CNodes)[ i ] ;
2030 if ( aNode->SubGraph() == aSubGraphNumber ) {
2031 RetVal = SetNode( RetVal , DataFlowEditor()->Graph()->GetChangeGraphNode( aNode->Name() ) ) ;
2035 for ( i = 0 ; i < (int ) aGraphNodes->FNodes.length() ; i++ ) {
2036 SUPERV::FNode_var aNode = (aGraphNodes->FNodes)[ i ] ;
2037 if ( aNode->SubGraph() == aSubGraphNumber ) {
2038 RetVal = SetNode( RetVal , DataFlowEditor()->Graph()->GetChangeGraphNode( aNode->Name() ) ) ;
2042 for ( i = 0 ; i < (int ) aGraphNodes->INodes.length() ; i++ ) {
2043 SUPERV::INode_var aNode = (aGraphNodes->INodes)[ i ] ;
2044 if ( aNode->SubGraph() == aSubGraphNumber ) {
2045 RetVal = SetNode( RetVal , DataFlowEditor()->Graph()->GetChangeGraphNode( aNode->Name() ) ) ;
2049 for ( i = 0 ; i < (int ) aGraphNodes->GNodes.length() ; i++ ) {
2050 SUPERV::GNode_var aNode = (aGraphNodes->GNodes)[ i ] ;
2051 if ( aNode->SubGraph() == aSubGraphNumber ) {
2052 RetVal = SetNode( RetVal , DataFlowEditor()->Graph()->GetChangeGraphNode( aNode->Name() ) ) ;
2056 for ( i = 0 ; i < (int ) aGraphNodes->LNodes.length() ; i++ ) {
2057 SUPERV::LNode_var aNode = (aGraphNodes->LNodes)[ i ] ;
2058 if ( aNode->SubGraph() == aSubGraphNumber ) {
2059 RetVal = SetNode( RetVal , DataFlowEditor()->Graph()->GetChangeGraphNode( aNode->Name() ) ) ;
2063 for ( i = 0 ; i < (int ) aGraphNodes->ELNodes.length() ; i++ ) {
2064 SUPERV::ELNode_var aNode = (aGraphNodes->ELNodes)[ i ] ;
2065 if ( aNode->SubGraph() == aSubGraphNumber ) {
2066 RetVal = SetNode( RetVal , DataFlowEditor()->Graph()->GetChangeGraphNode( aNode->Name() ) ) ;
2070 for ( i = 0 ; i < (int ) aGraphNodes->SNodes.length() ; i++ ) {
2071 SUPERV::SNode_var aNode = (aGraphNodes->SNodes)[ i ] ;
2072 if ( aNode->SubGraph() == aSubGraphNumber ) {
2073 RetVal = SetNode( RetVal , DataFlowEditor()->Graph()->GetChangeGraphNode( aNode->Name() ) ) ;
2077 for ( i = 0 ; i < (int ) aGraphNodes->ESNodes.length() ; i++ ) {
2078 SUPERV::ESNode_var aNode = (aGraphNodes->ESNodes)[ i ] ;
2079 if ( aNode->SubGraph() == aSubGraphNumber ) {
2080 RetVal = SetNode( RetVal , DataFlowEditor()->Graph()->GetChangeGraphNode( aNode->Name() ) ) ;
2084 endService( "Graph_Impl::SubGraphsNodes" );
2085 return ( RetVal._retn() ) ;
2088 bool Graph_Impl::Merge(const SUPERV::Graph_ptr aGraph ) {
2089 // beginService( "Graph_Impl::Merge" );
2090 bool RetVal = true ;
2092 map< string , int > aMapOfNodes ;
2093 RetVal = Merge( aGraph , aMapOfNodes ) ;
2095 // endService( "Graph_Impl::Merge" );
2099 bool Graph_Impl::Merge(const SUPERV::Graph_ptr aGraph , map< string , int > & aMapOfNodes ) {
2100 beginService( "Graph_Impl::Merge" );
2101 bool RetVal = true ;
2102 if ( DataFlowEditor()->IsEditing() && !IsMacro() ) {
2103 SUPERV::ListOfNodes * aGraphNodes = aGraph->Nodes() ;
2105 SUPERV::Port_ptr aPort ;
2106 // SUPERV::StreamPort_ptr aStreamPort ;
2108 for ( i = 0 ; i < (int ) aGraphNodes->CNodes.length() ; i++ ) {
2109 SUPERV::CNode_var aNode = (aGraphNodes->CNodes)[ i ] ;
2110 SUPERV::CNode_ptr myNode = CNode( *(aNode->Service()) ) ;
2111 if ( !CORBA::is_nil( myNode ) ) {
2112 myNode->SetName( aNode->Name() ) ;
2113 myNode->SetAuthor( aNode->Author() ) ;
2114 myNode->SetComment( aNode->Comment() ) ;
2115 myNode->Coords( aNode->X() , aNode->Y() ) ;
2116 string * aNodetheName = new string( aNode->Name() ) ;
2117 aMapOfNodes[ *aNodetheName ] = DataFlowEditor()->Graph()->GetGraphNodeIndex( myNode->Name() ) ;
2118 delete aNodetheName ;
2125 // The following informations are now in the service from SALOME_ModuleCatalog
2126 // SUPERV::ListOfStreamPorts myStreamPorts = *(aNode->StreamPorts()) ;
2128 // for ( j = 0 ; j < (int ) myStreamPorts.length() ; j++ ) {
2129 // if ( myStreamPorts[ j ]->IsInput() && myStreamPorts[ j ]->IsDataStream() ) {
2130 // aStreamPort = myNode->InStreamPort( myStreamPorts[ j ]->Name() , myStreamPorts[ j ]->Type() ) ;
2132 // else if ( myStreamPorts[ j ]->IsDataStream() ) {
2133 // aStreamPort = myNode->OutStreamPort( myStreamPorts[ j ]->Name() , myStreamPorts[ j ]->Type() ) ;
2139 for ( i = 0 ; i < (int ) aGraphNodes->FNodes.length() ; i++ ) {
2140 SUPERV::FNode_var aNode = (aGraphNodes->FNodes)[ i ] ;
2141 SUPERV::FNode_ptr myNode = FNode( aNode->GetComponentName() ,
2142 aNode->GetInterfaceName() ,
2143 *(aNode->Service()) ) ;
2144 if ( !CORBA::is_nil( myNode ) ) {
2145 myNode->SetName( aNode->Name() ) ;
2146 myNode->SetAuthor( aNode->Author() ) ;
2147 myNode->SetComment( aNode->Comment() ) ;
2148 myNode->Coords( aNode->X() , aNode->Y() ) ;
2149 string * aNodetheName = new string( aNode->Name() ) ;
2150 aMapOfNodes[ *aNodetheName ] = DataFlowEditor()->Graph()->GetGraphNodeIndex( myNode->Name() ) ;
2151 delete aNodetheName ;
2158 // The following informations are now in the service from SALOME_ModuleCatalog
2159 // SUPERV::ListOfStreamPorts myStreamPorts = *(aNode->StreamPorts()) ;
2161 // for ( j = 0 ; j < (int ) myStreamPorts.length() ; j++ ) {
2162 // if ( myStreamPorts[ j ]->IsInput() && myStreamPorts[ j ]->IsDataStream() ) {
2163 // aStreamPort = myNode->InStreamPort( myStreamPorts[ j ]->Name() , myStreamPorts[ j ]->Type() ) ;
2165 // else if ( myStreamPorts[ j ]->IsDataStream() ) {
2166 // aStreamPort = myNode->OutStreamPort( myStreamPorts[ j ]->Name() , myStreamPorts[ j ]->Type() ) ;
2173 for ( i = 0 ; i < (int ) aGraphNodes->INodes.length() ; i++ ) {
2174 SUPERV::INode_var aNode = (aGraphNodes->INodes)[ i ] ;
2175 SUPERV::INode_ptr myNode = INode( aNode->PyFuncName() , *(aNode->PyFunction()) ) ;
2176 if ( !CORBA::is_nil( myNode ) ) {
2177 myNode->SetName( aNode->Name() ) ;
2178 myNode->SetAuthor( aNode->Author() ) ;
2179 myNode->SetComment( aNode->Comment() ) ;
2180 myNode->Coords( aNode->X() , aNode->Y() ) ;
2181 string * aNodetheName = new string( aNode->Name() ) ;
2182 aMapOfNodes[ *aNodetheName ] = DataFlowEditor()->Graph()->GetGraphNodeIndex( myNode->Name() ) ;
2183 delete aNodetheName ;
2184 SUPERV::ListOfPorts myPorts = *(aNode->Ports()) ;
2186 for ( j = 0 ; j < (int ) myPorts.length() ; j++ ) {
2187 if ( myPorts[ j ]->IsInput() ) {
2188 aPort = myNode->InPort( myPorts[ j ]->Name() , myPorts[ j ]->Type() ) ;
2191 aPort = myNode->OutPort( myPorts[ j ]->Name() , myPorts[ j ]->Type() ) ;
2194 if ( DataFlowEditor()->Graph()->IsDataStreamNode() ) {
2195 SUPERV::ListOfStreamPorts myStreamPorts = *(aNode->StreamPorts()) ;
2196 for ( j = 0 ; j < (int ) myStreamPorts.length() ; j++ ) {
2197 if ( myStreamPorts[ j ]->IsInput() ) {
2198 aPort = myNode->InStreamPort( myStreamPorts[ j ]->Name() , StringToDataStreamType( myStreamPorts[ j ]->Type() ) , myStreamPorts[ j ]->Dependency() ) ;
2201 aPort = myNode->OutStreamPort( myStreamPorts[ j ]->Name() , StringToDataStreamType( myStreamPorts[ j ]->Type() ) , myStreamPorts[ j ]->Dependency() ) ;
2215 for ( i = 0 ; i < (int ) aGraphNodes->GNodes.length() ; i++ ) {
2216 SUPERV::GNode_var aNode = (aGraphNodes->GNodes)[ i ] ;
2217 SUPERV::GNode_ptr myNode = GNode( aNode->PyFuncName() , *(aNode->PyFunction()) , aNode->Coupled()->Name() ) ;
2218 if ( !CORBA::is_nil( myNode ) ) {
2219 myNode->SetName( aNode->Name() ) ;
2220 myNode->SetAuthor( aNode->Author() ) ;
2221 myNode->SetComment( aNode->Comment() ) ;
2222 myNode->Coords( aNode->X() , aNode->Y() ) ;
2223 string * aNodetheName = new string( aNode->Name() ) ;
2224 aMapOfNodes[ *aNodetheName ] = DataFlowEditor()->Graph()->GetGraphNodeIndex( myNode->Name() ) ;
2225 delete aNodetheName ;
2226 SUPERV::ListOfPorts myPorts = *(aNode->Ports()) ;
2228 for ( j = 0 ; j < (int ) myPorts.length() ; j++ ) {
2229 if ( myPorts[ j ]->IsInput() ) {
2230 aPort = myNode->InPort( myPorts[ j ]->Name() , myPorts[ j ]->Type() ) ;
2233 aPort = myNode->OutPort( myPorts[ j ]->Name() , myPorts[ j ]->Type() ) ;
2236 if ( DataFlowEditor()->Graph()->IsDataStreamNode() ) {
2237 SUPERV::ListOfStreamPorts myStreamPorts = *(aNode->StreamPorts()) ;
2238 for ( j = 0 ; j < (int ) myStreamPorts.length() ; j++ ) {
2239 if ( myStreamPorts[ j ]->IsInput() ) {
2240 aPort = myNode->InStreamPort( myStreamPorts[ j ]->Name() , StringToDataStreamType( myStreamPorts[ j ]->Type() ) , myStreamPorts[ j ]->Dependency() ) ;
2243 aPort = myNode->OutStreamPort( myStreamPorts[ j ]->Name() , StringToDataStreamType( myStreamPorts[ j ]->Type() ) , myStreamPorts[ j ]->Dependency() ) ;
2257 for ( i = 0 ; i < (int ) aGraphNodes->LNodes.length() ; i++ ) {
2258 SUPERV::LNode_var aNode = (aGraphNodes->LNodes)[ i ] ;
2259 SUPERV::INode_ptr anEndOfLoop ;
2260 SUPERV::LNode_ptr myNode = LNode( aNode->PyInitName() ,
2261 *(aNode->PyInit()) ,
2262 aNode->PyMoreName() ,
2263 *(aNode->PyMore()) ,
2264 aNode->PyNextName() ,
2265 *(aNode->PyNext()) ,
2267 if ( !CORBA::is_nil( myNode ) ) {
2268 myNode->SetName( aNode->Name() ) ;
2269 myNode->SetAuthor( aNode->Author() ) ;
2270 myNode->SetComment( aNode->Comment() ) ;
2271 myNode->Coords( aNode->X() , aNode->Y() ) ;
2272 string * aNodetheName = new string( aNode->Name() ) ;
2273 aMapOfNodes[ *aNodetheName ] = DataFlowEditor()->Graph()->GetGraphNodeIndex( myNode->Name() ) ;
2274 delete aNodetheName ;
2275 SUPERV::ListOfPorts myPorts = *(aNode->Ports()) ;
2277 for ( j = 0 ; j < (int ) myPorts.length() ; j++ ) {
2278 if ( myPorts[ j ]->IsInput() ) {
2279 aPort = myNode->InPort( myPorts[ j ]->Name() , myPorts[ j ]->Type() ) ;
2282 aPort = myNode->OutPort( myPorts[ j ]->Name() , myPorts[ j ]->Type() ) ;
2285 if ( DataFlowEditor()->Graph()->IsDataStreamNode() ) {
2286 SUPERV::ListOfStreamPorts myStreamPorts = *(aNode->StreamPorts()) ;
2287 for ( j = 0 ; j < (int ) myStreamPorts.length() ; j++ ) {
2288 if ( myStreamPorts[ j ]->IsInput() ) {
2289 aPort = myNode->InStreamPort( myStreamPorts[ j ]->Name() , StringToDataStreamType( myStreamPorts[ j ]->Type() ) , myStreamPorts[ j ]->Dependency() ) ;
2292 aPort = myNode->OutStreamPort( myStreamPorts[ j ]->Name() , StringToDataStreamType( myStreamPorts[ j ]->Type() ) , myStreamPorts[ j ]->Dependency() ) ;
2296 SUPERV::INode_ptr myEndOfLoop = aNode->Coupled() ;
2297 anEndOfLoop->SetName( myEndOfLoop->Name() ) ;
2298 anEndOfLoop->SetAuthor( myEndOfLoop->Author() ) ;
2299 anEndOfLoop->SetComment( myEndOfLoop->Comment() ) ;
2300 anEndOfLoop->Coords( myEndOfLoop->X() , myEndOfLoop->Y() ) ;
2301 anEndOfLoop->SetPyFunction( myEndOfLoop->PyFuncName() , *(myEndOfLoop->PyFunction()) ) ;
2302 aNodetheName = new string( myEndOfLoop->Name() ) ;
2303 aMapOfNodes[ *aNodetheName ] = DataFlowEditor()->Graph()->GetGraphNodeIndex( anEndOfLoop->Name() ) ;
2304 if ( DataFlowEditor()->Graph()->IsDataStreamNode() ) {
2305 SUPERV::ListOfStreamPorts myStreamLoopPorts = *(myEndOfLoop->StreamPorts()) ;
2306 for ( j = 0 ; j < (int ) myStreamLoopPorts.length() ; j++ ) {
2307 if ( myStreamLoopPorts[ j ]->IsInput() ) {
2308 aPort = myNode->InStreamPort( myStreamLoopPorts[ j ]->Name() , StringToDataStreamType( myStreamLoopPorts[ j ]->Type() ) , myStreamLoopPorts[ j ]->Dependency() ) ;
2311 aPort = myNode->OutStreamPort( myStreamLoopPorts[ j ]->Name() , StringToDataStreamType( myStreamLoopPorts[ j ]->Type() ) , myStreamLoopPorts[ j ]->Dependency() ) ;
2315 delete aNodetheName ;
2326 for ( i = 0 ; i < (int ) aGraphNodes->SNodes.length() ; i++ ) {
2327 SUPERV::SNode_var aNode = (aGraphNodes->SNodes)[ i ] ;
2328 SUPERV::INode_ptr anEndOfSwitch ;
2329 SUPERV::SNode_ptr myNode = SNode( aNode->PyFuncName() , *(aNode->PyFunction()) , anEndOfSwitch ) ;
2330 if ( !CORBA::is_nil( myNode ) ) {
2331 myNode->SetName( aNode->Name() ) ;
2332 myNode->SetAuthor( aNode->Author() ) ;
2333 myNode->SetComment( aNode->Comment() ) ;
2334 myNode->Coords( aNode->X() , aNode->Y() ) ;
2335 string * aNodetheName = new string( aNode->Name() ) ;
2336 aMapOfNodes[ *aNodetheName ] = DataFlowEditor()->Graph()->GetGraphNodeIndex( myNode->Name() ) ;
2337 delete aNodetheName ;
2338 SUPERV::ListOfPorts myPorts = *(aNode->Ports()) ;
2340 for ( j = 0 ; j < (int ) myPorts.length() ; j++ ) {
2341 if ( myPorts[ j ]->IsInput() ) {
2342 aPort = myNode->InPort( myPorts[ j ]->Name() , myPorts[ j ]->Type() ) ;
2345 aPort = myNode->OutPort( myPorts[ j ]->Name() , myPorts[ j ]->Type() ) ;
2348 if ( DataFlowEditor()->Graph()->IsDataStreamNode() ) {
2349 SUPERV::ListOfStreamPorts myStreamPorts = *(aNode->StreamPorts()) ;
2350 for ( j = 0 ; j < (int ) myStreamPorts.length() ; j++ ) {
2351 if ( myStreamPorts[ j ]->IsInput() ) {
2352 aPort = myNode->InStreamPort( myStreamPorts[ j ]->Name() , StringToDataStreamType( myStreamPorts[ j ]->Type() ) , myStreamPorts[ j ]->Dependency() ) ;
2355 aPort = myNode->OutStreamPort( myStreamPorts[ j ]->Name() , StringToDataStreamType( myStreamPorts[ j ]->Type() ) , myStreamPorts[ j ]->Dependency() ) ;
2359 SUPERV::INode_ptr myEndOfSwitch = aNode->Coupled() ;
2360 anEndOfSwitch->SetName( myEndOfSwitch->Name() ) ;
2361 anEndOfSwitch->SetAuthor( myEndOfSwitch->Author() ) ;
2362 anEndOfSwitch->SetComment( myEndOfSwitch->Comment() ) ;
2363 anEndOfSwitch->Coords( myEndOfSwitch->X() , myEndOfSwitch->Y() ) ;
2364 anEndOfSwitch->SetPyFunction( myEndOfSwitch->PyFuncName() , *(myEndOfSwitch->PyFunction()) ) ;
2365 aNodetheName = new string( myEndOfSwitch->Name() ) ;
2366 aMapOfNodes[ *aNodetheName ] = DataFlowEditor()->Graph()->GetGraphNodeIndex( anEndOfSwitch->Name() ) ;
2367 delete aNodetheName ;
2368 myPorts = *(myEndOfSwitch->Ports()) ;
2369 for ( j = 0 ; j < (int ) myPorts.length() ; j++ ) {
2370 if ( myPorts[ j ]->IsInput() ) {
2371 aPort = myNode->InPort( myPorts[ j ]->Name() , myPorts[ j ]->Type() ) ;
2374 aPort = myNode->OutPort( myPorts[ j ]->Name() , myPorts[ j ]->Type() ) ;
2377 if ( DataFlowEditor()->Graph()->IsDataStreamNode() ) {
2378 SUPERV::ListOfStreamPorts myStreamSwitchPorts = *(myEndOfSwitch->StreamPorts()) ;
2379 for ( j = 0 ; j < (int ) myStreamSwitchPorts.length() ; j++ ) {
2380 if ( myStreamSwitchPorts[ j ]->IsInput() ) {
2381 aPort = myNode->InStreamPort( myStreamSwitchPorts[ j ]->Name() , StringToDataStreamType( myStreamSwitchPorts[ j ]->Type() ) , myStreamSwitchPorts[ j ]->Dependency() ) ;
2384 aPort = myNode->OutStreamPort( myStreamSwitchPorts[ j ]->Name() , StringToDataStreamType( myStreamSwitchPorts[ j ]->Type() ) , myStreamSwitchPorts[ j ]->Dependency() ) ;
2397 SUPERV::ListOfLinks * aGraphLinks = aGraph->GLinks() ;
2398 SUPERV::ListOfPorts * aGraphPorts = aGraph->Ports() ;
2399 // cout << "Graph_Impl::Merge " << aGraphLinks->length() << " links " << aGraphPorts->length() << " GraphPorts"
2401 for ( i = 0 ; i < (int ) aGraphLinks->length() ; i++ ) {
2402 SUPERV::Link_var aLink = (*aGraphLinks)[ i ] ;
2403 SUPERV::Port_var OutPort = aLink->OutPort() ;
2404 SUPERV::Port_var InPort = aLink->InPort() ;
2405 string * aLinkFromNodeName = new string( OutPort->Node()->Name() ) ;
2406 string * aLinkToNodeName = new string( InPort->Node()->Name() ) ;
2407 RetVal = DataFlowEditor()->AddLink( DataFlowEditor()->Graph()->GetGraphNode( aMapOfNodes[ aLinkFromNodeName->c_str() ] )->Name() ,
2409 DataFlowEditor()->Graph()->GetGraphNode( aMapOfNodes[ aLinkToNodeName->c_str() ] )->Name() ,
2413 for ( j = 1 ; j <= aLink->CoordsSize() ; j++ ) {
2415 RetVal = aLink->Coords( j , X , Y ) ;
2418 RetVal = DataFlowEditor()->AddLinkCoord( DataFlowEditor()->Graph()->GetGraphNode( aMapOfNodes[ aLinkFromNodeName->c_str() ] )->Name() ,
2420 DataFlowEditor()->Graph()->GetGraphNode( aMapOfNodes[ aLinkToNodeName->c_str() ] )->Name() ,
2428 delete aLinkFromNodeName ;
2429 delete aLinkToNodeName ;
2435 for ( i = 0 ; i < (int ) aGraphPorts->length() ; i++ ) {
2436 SUPERV::Port_var aPort = (*aGraphPorts)[ i ] ;
2437 if ( !aPort->IsGate() ) {
2438 MESSAGE( "Graph_Impl::Merge " << i << ". " << aPort->Node()->Name() << " " << aPort->Name() ) ;
2439 char * aPortName = aPort->Name() ;
2440 char * aNodeName = new char[ strlen( aPortName ) + 1 ] ;
2441 strcpy( aNodeName , aPortName ) ;
2442 // char * thePortName = strchr( aNodeName , '\\' ) ;
2443 char * thePortName = aNodeName ;
2444 while ( ( thePortName = strchr( thePortName , '_' ) ) ) {
2445 if ( thePortName[1] == '_' ) {
2446 thePortName[ 0 ] = '\0' ;
2450 thePortName = &thePortName[2] ;
2453 bool hasinput = aGraph->Node( aNodeName )->Port( thePortName + 2 )->HasInput() ;
2454 // cout << "Graph_Impl::Merge " << " aNodeName " << aNodeName << " aPort " << thePortName + 1
2455 // << " HasInput " << hasinput << endl ;
2457 RetVal = DataFlowEditor()->AddInputData( DataFlowEditor()->Graph()->GetGraphNode( aMapOfNodes[ aNodeName ] )->Name() ,
2459 *(aPort->ToAny()) ) ;
2461 delete [] aNodeName ;
2470 MESSAGE( "Graph_Impl::Merge returns " << RetVal ) ;
2471 endService( "Graph_Impl::Merge" );
2475 SUPERV::StreamGraph_ptr Graph_Impl::ToStreamGraph() {
2476 SUPERV::StreamGraph_var iobject = SUPERV::StreamGraph::_nil() ;
2477 beginService( "Graph_Impl::ToStreamGraph" );
2478 if ( IsStreamGraph() && !IsMacro() ) {
2479 // StreamGraph_Impl * myStreamGraph = new StreamGraph_Impl( _Orb , _Poa , _ContId ,
2480 // instanceName() , interfaceName() ) ;
2481 // PortableServer::ObjectId * id = myStreamGraph->getId() ;
2482 // CORBA::Object_var obj = _poa->id_to_reference(*id);
2483 iobject = SUPERV::StreamGraph::_narrow( ObjRef() ) ;
2484 if ( CORBA::is_nil( iobject ) ) {
2485 MESSAGE( "ToStreamGraph of " << Name() << " (IsStreamGraph) --> nil reference" ) ;
2489 MESSAGE( "ToStreamGraph of " << Name() << " (IsNOTStreamGraph) --> nil reference" ) ;
2491 endService( "Graph_Impl::ToStreamGraph" );
2492 return SUPERV::StreamGraph::_duplicate( iobject ) ;
2496 * Destroy Executor and use only Editor and its data model
2498 void Graph_Impl::Editing() {
2499 if ( DataFlowEditor() && DataFlowExecutor() ) {
2500 delete DataFlowExecutor() ;
2501 DataFlowEditor()->Executor( NULL );