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 //JR 30.03.2005 if ( !aMacroGraphExecutor->InputOfAny( aMacroGraphInPortName, *anInPort->GetOutPort()->Value(),false ) ) {
826 if ( !aMacroGraphExecutor->InputOfAny( aMacroGraphInPortName, anInPort->GetOutPort()->Value(),false ) ) {
827 return SUPERV::Graph::_duplicate( SUPERV::Graph::_nil() ) ;
830 MESSAGE( "LoadDataFlows(Executor) " << aMacroGraph->Name() << "->InputOfAny( "
831 << aMacroGraphInPortName << " , Value )" ) ;
834 } // end of init MacroNode's InPorts
836 aMacroGraphImpl->Run() ;
839 } // end of for( get nodes of the graph...)
841 } // end of setting initial graph's structure..
843 endService( "Graph_Impl::ExecutorLoadDataFlows" );
845 PortableServer::ObjectId * id = getId();
846 CORBA::Object_var obj = _poa->id_to_reference( *id );
847 SUPERV::Graph_var iobject = SUPERV::Graph::_narrow( obj ) ;
848 return SUPERV::Graph::_duplicate( iobject ) ;
851 SUPERV::Graph_ptr Graph_Impl::MNode( const char * aXmlFileName ) {
852 beginService( "Graph_Impl::MNode" );
853 SUPERV::Graph_var iobject = SUPERV::Graph::_nil() ;
854 MESSAGE( "Graph_Impl::MNode( " << aXmlFileName << " )" ) ;
856 GraphBase::ListOfSGraphs aListOfDataFlows ;
858 // At first create the editor and a StreamGraph with the xml file
859 GraphEditor::DataFlow * aDataFlowEditor ;
860 CreateEditor( _Orb , instanceName() , aXmlFileName , SUPERV::DataStreamGraph ,
861 dbgfile , &aDataFlowEditor ) ;
863 if ( _DebugFileName ) {
864 delete [] _DebugFileName ;
866 _DebugFileName = new char[ strlen( dbgfile.c_str() )+1 ] ;
867 strcpy( _DebugFileName , dbgfile.c_str() ) ;
869 int lenname = strlen( aXmlFileName ) ;
870 bool loaded = false ;
871 // Import of the xml file
872 if ( lenname > 4 && !strcmp( &aXmlFileName[ lenname - 4 ] , ".xml" ) ) {
873 loaded = aDataFlowEditor->LoadXml( aXmlFileName , aListOfDataFlows ) ;
875 iobject = MNode( aDataFlowEditor , &aListOfDataFlows ) ;
882 // WARNING : THIS IS COMPLICATED :
883 // I should have to remove duplicated code ...
884 SUPERV::Graph_ptr Graph_Impl::MNode( GraphEditor::DataFlow * aMacroGraphDataFlowEditor ,
885 GraphBase::ListOfSGraphs * aListOfDataFlows ) {
886 beginService( "Graph_Impl::MNode" ) ;
887 SUPERV::Graph_var iobject = SUPERV::Graph::_nil() ;
888 SUPERV::Graph_var macroiobject = SUPERV::Graph::_nil() ;
891 MESSAGE( "Graph_Impl::MNode DataFlowEditor->LoadDataFlow" ) ;
892 // if ( !aMacroGraphDataFlowEditor->LoadDataFlow( &aListOfDataFlows[ 0 ] ) ) {
893 iobject = LoadDataFlows( aMacroGraphDataFlowEditor , aListOfDataFlows , 0 ) ;
894 if ( CORBA::is_nil( iobject ) ) {
895 MESSAGE("Graph_Impl::MNode LoadDataFlow failed" ) ;
899 // That graph is not a StreamGraph :
900 else if ( !aMacroGraphDataFlowEditor->Graph()->HasDataStream() ) {
901 aMacroGraphDataFlowEditor->Graph()->Kind( SUPERV::DataFlowGraph ) ;
902 aMacroGraphDataFlowEditor->Graph()->GraphEditor( aMacroGraphDataFlowEditor ) ;
904 Graph_Impl * myMacroGraph = (Graph_Impl * ) aMacroGraphDataFlowEditor->Graph()->ObjImpl() ;
905 // Creation of a GraphMacroNode in the current editor
906 string aMacroNodeName = string( "Macro_" ) + string( myMacroGraph->Name() ) ;
907 Graph_Impl * myMacroNode ;
908 myMacroNode = new Graph_Impl( _Orb , _Poa, _ContId,
909 instanceName() , interfaceName() ,
910 aMacroNodeName.c_str() , SUPERV::MacroNode ) ;
911 PortableServer::ObjectId * id = myMacroNode->getId() ;
912 CORBA::Object_var obj = _poa->id_to_reference(*id);
913 macroiobject = SUPERV::Graph::_narrow( obj ) ;
914 myMacroNode->DataFlowEditor( DataFlowEditor() ) ;
916 // Creation of the MacroNode itself in the current Graph
917 GraphBase::ListOfFuncName aFuncName ;
918 aFuncName.resize( 1 ) ;
920 SUPERV::ListOfStrings aListOfStrings ;
921 aListOfStrings.length( 1 ) ;
922 aListOfStrings[0] = "" ;
923 GraphBase::ListOfPythonFunctions aPythonFunction ;
924 aPythonFunction.resize( 1 ) ;
925 aPythonFunction[0] = &aListOfStrings ;
926 SALOME_ModuleCatalog::Service * aMacroNodeService = myMacroGraph->Service() ;
927 GraphEditor::InNode * aDataFlowNode = DataFlowEditor()->AddNode( *aMacroNodeService , "" , "" ,
928 aMacroNodeName.c_str() , SUPERV::MacroNode ,
929 aFuncName , aPythonFunction ) ;
930 aDataFlowNode->SetPythonFunction( "" , aListOfStrings ) ;
931 myMacroNode->DataFlowNode( aDataFlowNode ) ;
932 aDataFlowNode->ComputingNode()->SetService( *aMacroNodeService ) ;
933 aDataFlowNode->SetObjRef( SUPERV::CNode::_duplicate( SUPERV::CNode::_narrow( obj ) ) ) ;
934 aDataFlowNode->SetObjImpl( this ) ;
936 GraphBase::Graph * aGraph = myMacroGraph->DataFlowEditor()->Graph() ;
937 GraphBase::Graph * aGraphOfMacroGraph = myMacroNode->DataFlowEditor()->Graph() ;
938 GraphBase::Graph * aMacroGraph = myMacroNode->DataFlowNode()->GraphMacroNode() ;
939 aMacroGraph->Kind( SUPERV::MacroNode ) ;
940 aMacroGraph->GraphEditor( DataFlowEditor() ) ;
941 // Creation of the Ports of the MacroNode from the ports of the GraphMacroNode
942 aMacroGraph->SetMacroPorts( aGraph ) ;
943 // Valid ==> creation of Service and the ports of the current Graph
944 DataFlowEditor()->IsValid() ;
945 // Set the Input Datas from the GraphMacroNode to the current Graph
946 aMacroGraph->SetMacroDatas( aGraph , aGraphOfMacroGraph ) ;
947 aMacroGraphDataFlowEditor->UnValid() ;
948 // Set the MacroNode ObjRef in the GraphMacroNode
949 aGraph->CoupledNode( aMacroGraph ) ;
950 aGraph->MacroObject( SUPERV::Graph::_duplicate( macroiobject ) ) ;
951 // Set the GraphMacroNode ObjRef in the MacroNode
952 aDataFlowNode->GraphMacroNode()->GraphMacroLevel( aGraphOfMacroGraph->GraphMacroLevel() + 1 ) ;
953 aMacroGraph->CoupledNode( aGraph ) ;
954 // aGraphOfMacroGraph->CoupledNode( aGraph ) ;
955 aMacroGraph->MacroObject( SUPERV::Graph::_duplicate( iobject ) ) ;
956 // aGraphOfMacroGraph->MacroObject( SUPERV::Graph::_duplicate( iobject ) ) ;
957 // aDataFlowNode->CoupledNode( aGraph ) ;
958 // aDataFlowNode->ComputingNode()->MacroObject( SUPERV::Graph::_duplicate( iobject ) ) ;
959 // Set the MacroLevel of that graph
960 aGraph->GraphMacroLevel( aGraphOfMacroGraph->GraphMacroLevel() + 1 ) ;
961 aMacroGraph->Coordinates( 0 , 0 ) ;
962 MESSAGE( "DataFlowNode Graph " << this << " DataFlowEditor " << DataFlowEditor() << " aDataFlowNode "
963 << aDataFlowNode << " " << aDataFlowNode->Name() << " created" ) ;
964 MESSAGE( "MNode aGraph " << aGraph << " " << aGraph->Name()
965 << " coupled to " << aGraph->CoupledNode() << " "
966 << aGraph->CoupledNode()->Name() ) ;
967 MESSAGE( "MNode aMacroGraph " << aMacroGraph << " " << aMacroGraph->Name()
968 << " coupled to " << aMacroGraph->CoupledNode() << " "
969 << aMacroGraph->CoupledNode()->Name() ) ;
970 MESSAGE( "MNode aMacroGraph " << myMacroNode->DataFlowEditor()->Graph() << " "
971 << myMacroNode->DataFlowEditor()->Graph()->Name()
972 << " coupled to " << myMacroNode->DataFlowEditor()->Graph()->CoupledNode() ) ;
975 delete aMacroGraphDataFlowEditor ;
978 endService( "Graph_Impl::MNode" );
979 return SUPERV::Graph::_duplicate( macroiobject ) ;
982 // For python supergraph
983 SUPERV::Graph_ptr Graph_Impl::GraphMNode( SUPERV::Graph_ptr myMacroGraph ) {
984 SUPERV::Graph_var iobject = myMacroGraph ;
985 beginService( "Graph_Impl::GraphMNode" ) ;
987 // GraphBase::Graph * myMacroGraph = aGraph;
988 SUPERV::Graph_var macroiobject = SUPERV::StreamGraph::_nil() ;
989 // Creation of a GraphMacroNode in the current editor
991 string aMacroNodeName = string( "Macro_" ) + string( myMacroGraph->Name() ) ;
992 //string aMacroNodeName = string( myMacroGraph->CoupledName() ) ;
993 MESSAGE( "GraphMNode( " << myMacroGraph->Name() << " )" ) ;
994 Graph_Impl * myMacroNode ;
995 myMacroNode = new Graph_Impl( _Orb , _Poa, _ContId,
996 instanceName() , interfaceName() ,
997 aMacroNodeName.c_str() , SUPERV::MacroNode ) ;
998 PortableServer::ObjectId * id = myMacroNode->getId() ;
999 CORBA::Object_var obj = _poa->id_to_reference(*id);
1000 macroiobject = SUPERV::Graph::_narrow( obj ) ;
1001 myMacroNode->DataFlowEditor( DataFlowEditor() ) ;
1003 // Creation of the MacroNode itself in the current Graph
1004 GraphBase::ListOfFuncName aFuncName ;
1005 aFuncName.resize( 1 ) ;
1007 SUPERV::ListOfStrings aListOfStrings ;
1008 aListOfStrings.length( 1 ) ;
1009 aListOfStrings[0] = "" ;
1010 GraphBase::ListOfPythonFunctions aPythonFunction ;
1011 aPythonFunction.resize( 1 ) ;
1012 aPythonFunction[0] = &aListOfStrings ;
1013 SALOME_ModuleCatalog::Service * aMacroNodeService = myMacroGraph->Service() ;
1014 GraphEditor::InNode * aDataFlowNode ;
1015 aDataFlowNode = DataFlowEditor()->AddNode( *aMacroNodeService , "" , "" ,
1016 aMacroNodeName.c_str() , SUPERV::MacroNode ,
1017 aFuncName , aPythonFunction ) ;
1018 aDataFlowNode->SetPythonFunction( "" , aListOfStrings ) ;
1019 myMacroNode->DataFlowNode( aDataFlowNode ) ;
1020 aDataFlowNode->ComputingNode()->SetService( *aMacroNodeService ) ;
1021 aDataFlowNode->SetObjRef( SUPERV::CNode::_duplicate( SUPERV::CNode::_narrow( obj ) ) ) ;
1022 aDataFlowNode->SetObjImpl( this ) ;
1024 // GraphBase::Graph * aGraph = DataFlowEditor()->Automaton()->MapGraph( myMacroGraph->Name() ) ;
1025 GraphBase::Graph * aGraph ;
1026 //DataFlowEditor()->Automaton()->GraphBase( &aGraph ) ;
1027 myMacroGraph->Coupled() ;
1028 GraphBase::Graph * aGraphOfMacroGraph = myMacroNode->DataFlowEditor()->Graph() ;
1029 GraphBase::Graph * aMacroGraph = myMacroNode->DataFlowNode()->GraphMacroNode() ;
1030 aMacroGraph->Kind( SUPERV::MacroNode ) ;
1031 aMacroGraph->GraphEditor( DataFlowEditor() ) ;
1032 // Creation of the Ports of the MacroNode from the ports of the GraphMacroNode
1033 aMacroGraph->SetMacroPorts( aGraph ) ;
1034 // Valid ==> creation of Service and the ports of the current Graph
1035 DataFlowEditor()->IsValid() ;
1036 // Set the Input Datas from the GraphMacroNode to the current Graph
1037 aMacroGraph->SetMacroDatas( aGraph , aGraphOfMacroGraph ) ;
1038 // aMacroGraphDataFlowEditor->UnValid() ;
1039 aGraph->GraphEditor()->UnValid() ;
1040 // Set the MacroNode ObjRef in the GraphMacroNode
1041 aGraph->CoupledNode( aMacroGraph ) ;
1042 aGraph->MacroObject( SUPERV::Graph::_duplicate( macroiobject ) ) ;
1043 // Set the GraphMacroNode ObjRef in the MacroNode
1044 aDataFlowNode->GraphMacroNode()->GraphMacroLevel( aGraphOfMacroGraph->GraphMacroLevel() + 1 ) ;
1045 aMacroGraph->CoupledNode( aGraph ) ;
1046 aMacroGraph->MacroObject( SUPERV::Graph::_duplicate( iobject ) ) ;
1047 // aDataFlowNode->CoupledNode( aGraph ) ;
1048 // aDataFlowNode->ComputingNode()->MacroObject( SUPERV::Graph::_duplicate( iobject ) ) ;
1049 // Set the MacroLevel of that graph
1050 aGraph->GraphMacroLevel( aGraphOfMacroGraph->GraphMacroLevel() + 1 ) ;
1051 aMacroGraph->Coordinates( 0 , 0 ) ;
1052 MESSAGE( aGraph->Name() << "->CoupledNode()->GraphEditor() : " << aGraph->CoupledNode()->GraphEditor() ) ;
1053 MESSAGE( aMacroGraph->Name() << "->CoupledNode()->GraphEditor() : "
1054 << aMacroGraph->CoupledNode()->GraphEditor() ) ;
1055 MESSAGE( "DataFlowNode Graph " << this << " DataFlowEditor " << DataFlowEditor() << " aDataFlowNode "
1056 << aDataFlowNode << " " << aDataFlowNode->Name() << " created" ) ;
1058 endService( "Graph_Impl::GraphMNode" ) ;
1059 return SUPERV::Graph::_duplicate( macroiobject ) ;
1062 SUPERV::Graph_ptr Graph_Impl::FlowObjRef() {
1063 beginService( "Graph_Impl::FlowObjRef" );
1064 SUPERV::Graph_var iobject = SUPERV::Graph::_nil() ;
1066 iobject = SUPERV::Graph::_narrow( DataFlowNode()->GraphMacroNode()->MacroObject() ) ;
1068 else if ( IsGraph() ) {
1069 iobject = SUPERV::Graph::_narrow( DataFlowEditor()->Graph()->MacroObject() ) ;
1071 if ( CORBA::is_nil( iobject ) ) {
1072 MESSAGE( "Graph_Impl::FlowObjRef() returns a NIL Object" ) ;
1074 endService( "Graph_Impl::FlowObjRef" );
1075 return SUPERV::Graph::_duplicate( iobject ) ;
1078 SUPERV::StreamGraph_ptr Graph_Impl::StreamObjRef() {
1079 beginService( "Graph_Impl::StreamObjRef" );
1080 SUPERV::StreamGraph_var iobject = SUPERV::StreamGraph::_nil() ;
1082 iobject = SUPERV::StreamGraph::_narrow( DataFlowNode()->GraphMacroNode()->MacroObject() ) ;
1084 else if ( IsGraph() || IsStreamGraph() ) {
1085 iobject = SUPERV::StreamGraph::_narrow( DataFlowEditor()->Graph()->MacroObject() ) ;
1087 if ( CORBA::is_nil( iobject ) ) {
1088 MESSAGE( "Graph_Impl::StreamObjRef() returns a NIL Object" ) ;
1090 endService( "Graph_Impl::StreamObjRef" );
1091 return SUPERV::StreamGraph::_duplicate( iobject ) ;
1094 SUPERV::CNode_ptr Graph_Impl::Node(char const * aNodeName ) {
1095 // beginService( "Graph_Impl::Node" );
1096 SUPERV::CNode_var iobject = SUPERV::CNode::_nil() ;
1098 if ( CORBA::is_nil( DataFlowEditor()->GetNode( aNodeName )->ObjRef() ) ) {
1099 CNode_Impl * myNode = new CNode_Impl( _Orb , _Poa , _ContId ,
1100 instanceName() , interfaceName() ,
1102 DataFlowEditor()->GetNode( aNodeName ) ) ;
1103 PortableServer::ObjectId * id = myNode->getId() ;
1104 CORBA::Object_var obj = _poa->id_to_reference(*id);
1105 iobject = SUPERV::CNode::_narrow(obj) ;
1106 myNode->SetObjRef( SUPERV::CNode::_duplicate( iobject ) ) ;
1109 iobject = DataFlowEditor()->GetNode( aNodeName )->ObjRef() ;
1112 GraphEditor::InNode * anInNode = DataFlowEditor()->GetNode( aNodeName ) ;
1114 if ( CORBA::is_nil( anInNode->ObjRef() ) ) {
1115 SetNodeObjRef( anInNode ) ;
1117 iobject = anInNode->ObjRef() ;
1120 // endService( "Graph_Impl::Node" );
1121 return SUPERV::CNode::_duplicate( iobject ) ;
1124 SUPERV::Link_ptr Graph_Impl::Link( SUPERV::Port_ptr OutPort ,
1125 SUPERV::Port_ptr InPort ) {
1126 // beginService( "Graph_Impl::Link" );
1127 SUPERV::Link_var iobject = SUPERV::Link::_nil() ;
1128 if ( DataFlowEditor()->IsEditing() && !DataFlowEditor()->IsReadOnly() &&
1129 !OutPort->IsDataStream() && !InPort->IsDataStream() && !IsMacro() ) {
1130 MESSAGE( "Graph_Impl::Link( " << OutPort->Node()->Name() << "( " << OutPort->Name() << " ) --> "
1131 << InPort->Node()->Name() << "( " << InPort->Name() << " )" ) ;
1132 GraphEditor::InNode * anInNode = DataFlowEditor()->GetNode( InPort->Node()->Name() ) ;
1133 GraphEditor::InNode * anOutNode = DataFlowEditor()->GetNode( OutPort->Node()->Name() ) ;
1134 if ( anInNode == NULL || anOutNode== NULL ) {
1135 MESSAGE( "Graph_Impl::Link( " << OutPort->Node()->Name() << " " << anOutNode << " , "
1136 << InPort->Node()->Name() << " " << anInNode << " ) Node(s) not found in " << Name() ) ;
1139 GraphBase::InPort * anInPort = anInNode->ComputingNode()->GetChangeInPort( InPort->Name() ) ;
1140 GraphBase::OutPort * anOutPort = anOutNode->ComputingNode()->GetChangeOutPort( OutPort->Name() ) ;
1141 if ( anInPort == NULL || anOutPort== NULL ) {
1142 MESSAGE( "Graph_Impl::Link( " << OutPort->Name() << " " << anOutPort << " , "
1143 << InPort->Name() << " " << anInPort << " ) Port(s) not found" ) ;
1145 else if ( CORBA::is_nil( anOutPort->InPortObjRef( anInPort ) ) ) {
1146 const char * DataFlowOutNodeName = OutPort->Node()->Name() ;
1147 GraphEditor::InNode * DataFlowOutNode = DataFlowEditor()->GetNode( DataFlowOutNodeName ) ;
1148 const char * DataFlowInNodeName = InPort->Node()->Name() ;
1149 GraphEditor::InNode * DataFlowInNode = DataFlowEditor()->GetNode( DataFlowInNodeName ) ;
1150 if ( DataFlowOutNode && DataFlowInNode ) {
1152 Link_Impl * myLink = new Link_Impl( _Orb , _Poa , _ContId ,
1153 instanceName() , interfaceName() ,
1159 true , false , Success ) ;
1161 PortableServer::ObjectId * id = myLink->getId() ;
1162 CORBA::Object_var obj = _poa->id_to_reference(*id);
1163 iobject = SUPERV::Link::_narrow(obj) ;
1164 anOutPort->AddInPortObjRef( anInPort , SUPERV::Link::_duplicate( iobject ) ) ;
1169 iobject = anOutPort->InPortObjRef( anInPort ) ;
1173 DataFlowEditor()->UnValid() ;
1174 // endService( "Graph_Impl::Link" );
1175 return SUPERV::Link::_duplicate( iobject ) ;
1178 // Only to see MacroNodes with actual GUI ... :
1179 #define GOTOMacroNode 0
1181 void Graph_Impl::SetNodeObjRef( GraphEditor::InNode * anInNode ) {
1182 MESSAGE("Graph_Impl::SetNodeObjRef " << anInNode->Name() << " " << anInNode->Kind() ) ;
1183 CORBA::Object_var obj ;
1184 if ( anInNode->IsComputingNode() ) {
1185 CNode_Impl * myNode = new CNode_Impl( _Orb , _Poa , _ContId ,
1186 instanceName() , interfaceName() ,
1189 PortableServer::ObjectId * id = myNode->getId() ;
1190 obj = _poa->id_to_reference(*id);
1191 SUPERV::CNode_var iobject = SUPERV::CNode::_narrow(obj) ;
1192 myNode->SetObjRef( SUPERV::CNode::_duplicate( iobject ) ) ;
1194 else if ( anInNode->IsFactoryNode() ) {
1195 FNode_Impl * myNode = new FNode_Impl( _Orb , _Poa , _ContId ,
1196 instanceName() , interfaceName() ,
1199 PortableServer::ObjectId * id = myNode->getId() ;
1200 obj = _poa->id_to_reference(*id);
1201 SUPERV::FNode_var iobject = SUPERV::FNode::_narrow(obj) ;
1202 myNode->SetObjRef( SUPERV::FNode::_duplicate( iobject ) ) ;
1204 else if ( anInNode->IsInLineNode() ) {
1205 INode_Impl * myNode = new INode_Impl( _Orb , _Poa , _ContId ,
1206 instanceName() , interfaceName() ,
1209 PortableServer::ObjectId * id = myNode->getId() ;
1210 obj = _poa->id_to_reference(*id);
1211 SUPERV::INode_var iobject = SUPERV::INode::_narrow(obj) ;
1212 myNode->SetObjRef( SUPERV::INode::_duplicate( iobject ) ) ;
1215 else if ( anInNode->IsGOTONode() || anInNode->IsMacroNode() ) {
1216 if ( anInNode->IsMacroNode() ) {
1217 anInNode->ComputingNode()->Kind( SUPERV::GOTONode ) ;
1220 else if ( anInNode->IsGOTONode() ) {
1222 GNode_Impl * myNode = new GNode_Impl( _Orb , _Poa , _ContId ,
1223 instanceName() , interfaceName() ,
1226 PortableServer::ObjectId * id = myNode->getId() ;
1227 obj = _poa->id_to_reference(*id);
1228 SUPERV::GNode_var iobject = SUPERV::GNode::_narrow(obj) ;
1229 myNode->SetObjRef( SUPERV::GNode::_duplicate( iobject ) ) ;
1231 else if ( anInNode->IsMacroNode() ) {
1232 Graph_Impl * myNode = new Graph_Impl( _Orb , _Poa , _ContId ,
1233 instanceName() , interfaceName() ,
1236 PortableServer::ObjectId * id = myNode->getId() ;
1237 obj = _poa->id_to_reference(*id);
1238 SUPERV::Graph_var iobject = SUPERV::Graph::_narrow(obj) ;
1239 myNode->SetObjRef( SUPERV::Graph::_duplicate( iobject ) ) ;
1241 else if ( anInNode->IsLoopNode() ) {
1242 LNode_Impl * myNode = new LNode_Impl( _Orb , _Poa , _ContId ,
1243 instanceName() , interfaceName() ,
1246 PortableServer::ObjectId * id = myNode->getId() ;
1247 obj = _poa->id_to_reference(*id);
1248 SUPERV::LNode_var iobject = SUPERV::LNode::_narrow(obj) ;
1249 myNode->SetObjRef( SUPERV::LNode::_duplicate( iobject ) ) ;
1251 else if ( anInNode->IsEndLoopNode() ) {
1252 ELNode_Impl * myNode = new ELNode_Impl( _Orb , _Poa , _ContId ,
1253 instanceName() , interfaceName() ,
1256 PortableServer::ObjectId * id = myNode->getId() ;
1257 obj = _poa->id_to_reference(*id);
1258 SUPERV::ELNode_var iobject = SUPERV::ELNode::_narrow(obj) ;
1259 myNode->SetObjRef( SUPERV::ELNode::_duplicate( iobject ) ) ;
1261 else if ( anInNode->IsSwitchNode() ) {
1262 SNode_Impl * myNode = new SNode_Impl( _Orb , _Poa , _ContId ,
1263 instanceName() , interfaceName() ,
1266 PortableServer::ObjectId * id = myNode->getId() ;
1267 obj = _poa->id_to_reference(*id);
1268 SUPERV::SNode_var iobject = SUPERV::SNode::_narrow(obj) ;
1269 myNode->SetObjRef( SUPERV::SNode::_duplicate( iobject ) ) ;
1271 else if ( anInNode->IsEndSwitchNode() ) {
1272 ESNode_Impl * myNode = new ESNode_Impl( _Orb , _Poa , _ContId ,
1273 instanceName() , interfaceName() ,
1276 PortableServer::ObjectId * id = myNode->getId() ;
1277 obj = _poa->id_to_reference(*id);
1278 SUPERV::ESNode_var iobject = SUPERV::ESNode::_narrow(obj) ;
1279 myNode->SetObjRef( SUPERV::ESNode::_duplicate( iobject ) ) ;
1283 SUPERV::ListOfNodes_var Graph_Impl::SetNode( SUPERV::ListOfNodes_var RetVal ,
1284 GraphBase::ComputingNode * aNode ) {
1286 // if ( _DataFlowExecutor ) {
1287 if ( DataFlowExecutor() ) {
1288 MESSAGE("Graph_Impl::SetNode " << aNode->Name() << " " << aNode->Kind() << " "
1289 << DataFlowExecutor()->StateName( DataFlowExecutor()->AutomatonState( aNode->Name() ) ) ) ;
1292 MESSAGE("Graph_Impl::SetNode " << aNode->Name() << " " << aNode->Kind() ) ;
1294 if ( aNode->IsComputingNode() ) {
1295 index = RetVal->CNodes.length() ;
1296 RetVal->CNodes.length( index+1 );
1298 else if ( aNode->IsFactoryNode() ) {
1299 index = RetVal->FNodes.length() ;
1300 RetVal->FNodes.length( index+1 );
1302 else if ( aNode->IsInLineNode() ) {
1303 index = RetVal->INodes.length() ;
1304 RetVal->INodes.length( index+1 );
1307 else if ( aNode->IsGOTONode() || aNode->IsMacroNode() ) {
1309 else if ( aNode->IsGOTONode() ) {
1311 index = RetVal->GNodes.length() ;
1312 RetVal->GNodes.length( index+1 );
1314 else if ( aNode->IsMacroNode() ) {
1315 index = RetVal->Graphs.length() ;
1316 RetVal->Graphs.length( index+1 );
1318 else if ( aNode->IsLoopNode() ) {
1319 index = RetVal->LNodes.length() ;
1320 RetVal->LNodes.length( index+1 );
1322 else if ( aNode->IsEndLoopNode() ) {
1323 index = RetVal->ELNodes.length() ;
1324 RetVal->ELNodes.length( index+1 );
1326 else if ( aNode->IsSwitchNode() ) {
1327 index = RetVal->SNodes.length() ;
1328 RetVal->SNodes.length( index+1 );
1330 else if ( aNode->IsEndSwitchNode() ) {
1331 index = RetVal->ESNodes.length() ;
1332 RetVal->ESNodes.length( index+1 );
1334 if ( CORBA::is_nil( aNode->ObjRef() ) ) {
1335 SetNodeObjRef( (GraphEditor::InNode * ) aNode->GetInNode() ) ;
1337 SUPERV::CNode_var aNodeObjRef = aNode->ObjRef() ;
1338 if ( aNode->IsComputingNode() ) {
1339 RetVal->CNodes[index] = SUPERV::CNode::_duplicate( aNodeObjRef ) ;
1341 else if ( aNode->IsFactoryNode() ) {
1342 RetVal->FNodes[index] = SUPERV::FNode::_duplicate( SUPERV::FNode::_narrow( aNodeObjRef ) ) ;
1344 else if ( aNode->IsInLineNode() ) {
1345 RetVal->INodes[index] = SUPERV::INode::_duplicate( SUPERV::INode::_narrow( aNodeObjRef ) ) ;
1348 else if ( aNode->IsGOTONode() || aNode->IsMacroNode() ) {
1350 else if ( aNode->IsGOTONode() ) {
1352 RetVal->GNodes[index] = SUPERV::GNode::_duplicate( SUPERV::GNode::_narrow( aNodeObjRef ) ) ;
1354 else if ( aNode->IsMacroNode() ) {
1355 RetVal->Graphs[index] = SUPERV::Graph::_duplicate( SUPERV::Graph::_narrow( aNodeObjRef ) ) ;
1357 else if ( aNode->IsLoopNode() ) {
1358 RetVal->LNodes[index] = SUPERV::LNode::_duplicate( SUPERV::LNode::_narrow( aNodeObjRef ) ) ;
1360 else if ( aNode->IsEndLoopNode() ) {
1361 RetVal->ELNodes[index] = SUPERV::ELNode::_duplicate( SUPERV::ELNode::_narrow( aNodeObjRef ) ) ;
1363 else if ( aNode->IsSwitchNode() ) {
1364 RetVal->SNodes[index] = SUPERV::SNode::_duplicate( SUPERV::SNode::_narrow( aNodeObjRef ) ) ;
1366 else if ( aNode->IsEndSwitchNode() ) {
1367 RetVal->ESNodes[index] = SUPERV::ESNode::_duplicate( SUPERV::ESNode::_narrow( aNodeObjRef ) ) ;
1369 return ( RetVal._retn() ) ;
1372 SUPERV::ListOfNodes * Graph_Impl::Nodes() {
1373 SUPERV::ListOfNodes_var RetVal = new SUPERV::ListOfNodes;
1374 beginService( "Graph_Impl::Nodes" );
1375 RetVal->CNodes.length(0) ;
1376 RetVal->FNodes.length(0) ;
1377 RetVal->INodes.length(0) ;
1378 RetVal->LNodes.length(0) ;
1379 RetVal->SNodes.length(0) ;
1380 RetVal->GNodes.length(0) ;
1381 RetVal->Graphs.length(0) ;
1384 cout << DataFlowEditor()->Graph()->GetGraphNodeSize() << " Nodes in the Map and "
1385 << DataFlowEditor()->Graph()->GraphNodesSize() << " Nodes int the Vector" << endl ;
1386 for ( i = 0 ; i < DataFlowEditor()->Graph()->GraphNodesSize() ; i++ ) {
1387 GraphBase::ComputingNode * aNode = DataFlowEditor()->Graph()->GraphNodes( i ) ;
1389 cout << i << ". Vector : " << aNode->Name() << " Map : "
1390 << DataFlowEditor()->Graph()->GetGraphNode( aNode->Name() )->Name()
1393 RetVal = SetNode( RetVal , aNode ) ;
1396 char * aStateG = "" ;
1397 if ( DataFlowExecutor() ) {
1398 aStateG = (char *) DataFlowExecutor()->StateName( DataFlowExecutor()->AutomatonState() ) ;
1400 MESSAGE("Graph_Impl::Nodes GraphState " << aStateG << " CNodes " << RetVal->CNodes.length() ) ;
1401 for ( i = 0 ; i < RetVal->CNodes.length() ; i++ ) {
1402 MESSAGE(" " << RetVal->CNodes[ i ] ->Name() ) ;
1404 MESSAGE("FNodes " << RetVal->FNodes.length() ) ;
1405 for ( i = 0 ; i < RetVal->FNodes.length() ; i++ ) {
1406 MESSAGE(" " << RetVal->FNodes[ i ] ->Name() ) ;
1408 MESSAGE("INodes " << RetVal->INodes.length() ) ;
1409 for ( i = 0 ; i < RetVal->INodes.length() ; i++ ) {
1410 MESSAGE(" " << RetVal->INodes[ i ] ->Name() ) ;
1412 MESSAGE("GNodes " << RetVal->GNodes.length() ) ;
1413 for ( i = 0 ; i < RetVal->GNodes.length() ; i++ ) {
1414 MESSAGE(" " << RetVal->GNodes[ i ] ->Name() ) ;
1416 MESSAGE("LNodes " << RetVal->LNodes.length() ) ;
1417 for ( i = 0 ; i < RetVal->LNodes.length() ; i++ ) {
1418 MESSAGE(" " << RetVal->LNodes[ i ] ->Name() ) ;
1420 MESSAGE("ELNodes " << RetVal->ELNodes.length() ) ;
1421 for ( i = 0 ; i < RetVal->ELNodes.length() ; i++ ) {
1422 MESSAGE(" " << RetVal->ELNodes[ i ] ->Name() ) ;
1424 MESSAGE("SNodes " << RetVal->SNodes.length() ) ;
1425 for ( i = 0 ; i < RetVal->SNodes.length() ; i++ ) {
1426 MESSAGE(" " << RetVal->SNodes[ i ] ->Name() ) ;
1428 MESSAGE("ESNodes " << RetVal->ESNodes.length() ) ;
1429 for ( i = 0 ; i < RetVal->ESNodes.length() ; i++ ) {
1430 MESSAGE(" " << RetVal->ESNodes[ i ] ->Name() ) ;
1432 MESSAGE("Graphs " << RetVal->Graphs.length() ) ;
1433 for ( i = 0 ; i < RetVal->Graphs.length() ; i++ ) {
1434 MESSAGE(" " << RetVal->Graphs[ i ] ->Name() ) ;
1436 if ( DataFlowExecutor() ) {
1437 DataFlowExecutor()->EventList() ;
1441 endService( "Graph_Impl::Nodes" );
1442 return ( RetVal._retn() ) ;
1445 SUPERV::ListOfLinks * Graph_Impl::GLinks() {
1446 return Links( NULL , NULL ) ;
1449 SUPERV::ListOfLinks * Graph_Impl::Links( GraphBase::ComputingNode * theNode ,
1450 const char * anInputParam ) {
1452 SUPERV::ListOfLinks_var RetVal = new SUPERV::ListOfLinks ;
1453 RetVal->length( 0 ) ;
1455 int i , j , countlink ;
1457 for ( i = 0 ; i < DataFlowEditor()->Graph()->GraphNodesSize() ; i++ ) {
1458 GraphEditor::InNode * aNode = NULL ;
1459 aNode = (GraphEditor::InNode * ) DataFlowEditor()->Graph()->GraphNodes( i )->GetInNode() ;
1460 bool ToProcess = false ;
1461 if ( theNode == NULL ) {
1465 if ( !strcmp( theNode->Name() , aNode->Name() ) ) {
1466 if ( !theNode->IsEndSwitchNode() ) {
1470 else if ( theNode->IsEndSwitchNode() ) {
1475 for ( j = 0 ; j < aNode->GetNodeInPortsSize() ; j++ ) {
1476 GraphBase::InPort * anInPort = NULL ;
1477 anInPort = aNode->GetChangeNodeInPort( j ) ;
1478 if ( anInputParam == NULL ||
1479 !strcmp( anInPort->PortName() , anInputParam ) ) {
1480 GraphBase::OutPort * anOutPort = NULL ;
1481 anOutPort = anInPort->GetOutPort() ;
1482 if ( anOutPort && !anOutPort->IsDataStream() ) {
1483 if ( strcmp( anOutPort->NodeName() , Name() ) ) {
1484 // MESSAGE("Graph_Impl::Links " << anOutPort->NodeName() << "("
1485 // << anOutPort->PortName() << ") --> " << aNode->Name() << "("
1486 // << anInPort->PortName() << ")" ) ;
1487 if ( theNode == NULL ||
1489 //JR 14.02.2005 : Debug : we must see also that links !
1490 // ( theNode != NULL && !theNode->IsEndSwitchNode() &&
1491 !strcmp( theNode->Name() , aNode->Name() ) ) {
1492 if ( anInPort->IsLoop() || anOutPort->IsLoop() ||
1493 ( aNode->IsEndLoopNode() && !strcmp( aNode->CoupledNode()->Name() ,
1494 anOutPort->NodeName() ) ) ) {
1495 // MESSAGE( "Link " << anOutPort->NodeName() << "("
1496 // << anOutPort->PortName() << ") --> " << aNode->Name() << "("
1497 // << anInPort->PortName() << ")" << " ignored" ) ;
1499 else if ( CORBA::is_nil( anOutPort->InPortObjRef( anInPort ) ) ) {
1501 beginService( "Graph_Impl::Links" );
1504 GraphEditor::InNode * anOutNode = NULL ;
1505 anOutNode = (GraphEditor::InNode * ) DataFlowEditor()->Graph()->GetChangeGraphNode( anOutPort->NodeName() )->GetInNode() ;
1508 Link_Impl * myLink = new Link_Impl( _Orb , _Poa , _ContId ,
1509 instanceName() , interfaceName() ,
1512 anInPort->PortName() ,
1514 anOutPort->PortName() ,
1515 false , true , Success ) ;
1517 PortableServer::ObjectId * id = myLink->getId() ;
1518 CORBA::Object_var obj = _poa->id_to_reference(*id);
1519 SUPERV::Link_var iobject ;
1520 iobject = SUPERV::Link::_narrow(obj) ;
1521 RetVal->length( countlink + 1 ) ;
1522 RetVal[ countlink++ ] = SUPERV::Link::_duplicate( iobject ) ;
1523 anOutPort->AddInPortObjRef( anInPort , SUPERV::Link::_duplicate( iobject ) ) ;
1528 RetVal->length( countlink + 1 ) ;
1529 RetVal[ countlink++ ] = SUPERV::Link::_duplicate( anOutPort->InPortObjRef( anInPort ) ) ;
1531 // MESSAGE( "Link " << anOutPort->NodeName() << "("
1532 // << anOutPort->PortName() << ") --> " << aNode->Name() << "("
1533 // << anInPort->PortName() << ")" << " selected" ) ;
1536 // MESSAGE( "Link " << anOutPort->NodeName() << "("
1537 // << anOutPort->PortName() << ") --> " << aNode->Name() << "("
1538 // << anInPort->PortName() << ")" << " skipped" ) ;
1545 for ( j = 0 ; j < aNode->GetNodeOutPortsSize() ; j++ ) {
1546 GraphBase::OutPort * anOutPort = aNode->GetChangeNodeOutPort( j ) ;
1547 // MESSAGE( "Graph_Impl::Links " << aNode->Name() << " Out" << j << " " << anOutPort->PortName() << " "
1548 // << anOutPort->PortStatus() << " PortConnected to " << anOutPort->InPortsSize() << " InPorts" ) ;
1550 for ( k = 0 ; k < anOutPort->InPortsSize() ; k++ ) {
1551 GraphBase::InPort * anInPort = anOutPort->ChangeInPorts( k ) ;
1552 // MESSAGE( " --> In" << k << " " << anInPort->NodeName() << " " << anInPort->PortName()
1553 // << " " << anInPort->PortStatus() ) ;
1554 if ( anInPort->IsPortConnected() ) {
1555 GraphBase::ComputingNode * aComputingNode = DataFlowEditor()->Graph()->GetChangeGraphNode( anInPort->NodeName() ) ;
1556 GraphEditor::InNode * toNode = (GraphEditor::InNode * ) aComputingNode->GetInNode() ;
1557 if ( theNode == NULL ||
1558 !strcmp( theNode->Name() , aNode->Name() ) ) {
1559 if ( !anInPort->IsDataStream() ) {
1561 //JR 14.02.2005 : Debug : we must see also that links !
1562 // if ( theNode || ( toNode->IsEndSwitchNode() && !aNode->IsSwitchNode() ) ) {
1563 if ( anInputParam == NULL ||
1564 !strcmp( anInPort->PortName() , anInputParam ) ) {
1565 if ( anInPort->IsLoop() || anOutPort->IsLoop() ||
1566 ( toNode->IsEndLoopNode() && !strcmp( toNode->CoupledNode()->Name() ,
1567 anOutPort->NodeName() ) ) ) {
1568 // MESSAGE( "Link " << anOutPort->NodeName() << "("
1569 // << anOutPort->PortName() << ") --> " << toNode->Name() << "("
1570 // << anInPort->PortName() << ")" << " ignored" ) ;
1572 else if ( CORBA::is_nil( anOutPort->InPortObjRef( anInPort ) ) ) {
1574 beginService( "Graph_Impl::Links" );
1578 Link_Impl * myLink = new Link_Impl( _Orb , _Poa , _ContId ,
1579 instanceName() , interfaceName() ,
1582 anInPort->PortName() ,
1584 anOutPort->PortName() ,
1585 false , true , Success ) ;
1587 PortableServer::ObjectId * id = myLink->getId() ;
1588 CORBA::Object_var obj = _poa->id_to_reference(*id);
1589 SUPERV::Link_var iobject ;
1590 iobject = SUPERV::Link::_narrow(obj) ;
1591 RetVal->length( countlink + 1 ) ;
1592 RetVal[ countlink++ ] = SUPERV::Link::_duplicate( iobject ) ;
1593 anOutPort->AddInPortObjRef( anInPort , SUPERV::Link::_duplicate( iobject ) ) ;
1597 RetVal->length( countlink + 1 ) ;
1598 RetVal[ countlink++ ] = SUPERV::Link::_duplicate( SUPERV::Link::_narrow( anOutPort->InPortObjRef( anInPort ) ) ) ;
1600 // MESSAGE( "Link " << anOutPort->NodeName() << "("
1601 // << anOutPort->PortName() << ") --> " << toNode->Name() << "("
1602 // << anInPort->PortName() << ")" << " selected" ) ;
1605 // MESSAGE( "Link " << anOutPort->NodeName() << "("
1606 // << anOutPort->PortName() << ") --> " << toNode->Name() << "("
1607 // << anInPort->PortName() << ")" << " skipped" ) ;
1618 const char * NodeName = "" ;
1619 const char * InputParamName = "" ;
1621 NodeName = theNode->Name() ;
1623 if ( anInputParam ) {
1624 InputParamName = anInputParam ;
1626 MESSAGE( RetVal->length() << " Links of Node " << NodeName << " and of InPort " << InputParamName ) ;
1627 for ( i = 0 ; i < (int ) RetVal->length() ; i++ ) {
1628 MESSAGE( "Link " << RetVal[i]->OutPort()->Node()->Name() << "("
1629 << RetVal[i]->OutPort()->Name() << ") --> "
1630 << RetVal[i]->InPort()->Node()->Name() << "("
1631 << RetVal[i]->InPort()->Name() << ")" ) ;
1635 endService( "Graph_Impl::Links" );
1638 return ( RetVal._retn() ) ;
1641 Engines::Component_ptr Graph_Impl::ComponentRef( const char * aComputerContainer ,
1642 const char * aComponentName ) {
1643 Engines::Component_var objComponent = Engines::Component::_nil() ;
1645 Engines::Container_var myContainer ;
1646 DataFlowEditor()->Graph()->StartComponent( 0 , aComputerContainer , aComponentName ,
1647 myContainer , objComponent ) ;
1649 return Engines::Component::_duplicate( objComponent ) ;
1652 bool Graph_Impl::IsValid() {
1653 // beginService( "Graph_Impl::IsValid" );
1654 bool RetVal = false ;
1656 RetVal = DataFlowEditor()->IsValid() ;
1658 // endService( "Graph_Impl::IsValid" );
1661 bool Graph_Impl::IsExecutable() {
1662 // beginService( "Graph_Impl::IsExecutable" );
1663 bool RetVal = false ;
1665 // asv : 15.11.04 : added "&& GraphMacroLevel() == 0" ->
1666 // subgraphs are not executable by themselves, RetVal = false..
1667 if ( !IsMacro() && DataFlowEditor()->Graph()->GraphMacroLevel() == 0 ) {
1668 RetVal = DataFlowEditor()->IsExecutable() ;
1670 // endService( "Graph_Impl::IsExecutable" );
1674 bool Graph_Impl::IsEditing() {
1676 bool RetVal = false ;
1678 RetVal = DataFlowEditor()->IsEditing() ;
1684 return !IsExecuting();
1687 bool Graph_Impl::IsExecuting() {
1689 bool RetVal = false ;
1691 RetVal = !DataFlowEditor()->IsEditing() ;
1695 return CNode_Impl::IsExecuting();
1698 bool Graph_Impl::IsReadOnly() {
1699 // beginService( "Graph_Impl::IsExecuting" );
1700 bool RetVal = false ;
1702 RetVal = DataFlowEditor()->IsReadOnly() ;
1704 // endService( "Graph_Impl::IsExecuting" );
1708 long Graph_Impl::LevelMax() {
1709 // beginService( "Graph_Impl::LevelMax" );
1712 RetVal = DataFlowEditor()->LevelMax() ;
1714 // endService( "Graph_Impl::LevelMax" );
1717 SUPERV::ListOfNodes * Graph_Impl::LevelNodes(long aLevel ) {
1718 // beginService( "Graph_Impl::LevelNodes" );
1719 SUPERV::ListOfNodes_var RetVal = new SUPERV::ListOfNodes;
1722 SUPERV::ListOfStrings_var Nodes = DataFlowEditor()->LevelNodes( aLevel ) ;
1723 // RetVal->length( Nodes->length() );
1724 for ( i = 0 ; i < (int ) Nodes->length() ; i++ ) {
1725 // char * aNode = Nodes[ i ] ;
1726 GraphBase::ComputingNode * aNode = DataFlowEditor()->Graph()->GetChangeGraphNode( Nodes[ i ] ) ;
1727 RetVal = SetNode( RetVal , aNode ) ;
1728 // cout << "Graph_Impl::LevelNodes( " << aLevel << " ) " << aNode->Name() << endl ;
1729 // CNode_Impl * myNode = new CNode_Impl( _Orb , _Poa , _ContId ,
1730 // instanceName() , interfaceName() ,
1731 // DataFlowEditor() ,
1732 // (GraphEditor::InNode * ) DataFlowEditor()->GetChangeGraphNode( aNode )->GetInNode() ) ;
1733 // PortableServer::ObjectId * id = myNode->getId() ;
1734 // CORBA::Object_var obj = _poa->id_to_reference(*id);
1735 // SUPERV::CNode_var iobject ;
1736 // iobject = SUPERV::CNode::_narrow(obj) ;
1737 // RetVal[i] = SUPERV::CNode::_duplicate( iobject ) ;
1740 // endService( "Graph_Impl::LevelNodes" );
1741 return ( RetVal._retn() ) ;
1743 long Graph_Impl::ThreadsMax() {
1744 // beginService( "Graph_Impl::ThreadsMax" );
1747 RetVal = DataFlowEditor()->ThreadsMax() ;
1749 // endService( "Graph_Impl::ThreadsMax" );
1752 long Graph_Impl::Threads() {
1753 // beginService( "Node_Impl::Threads" );
1754 long RetVal = false ;
1756 RetVal = DataFlowExecutor()->Threads() ;
1758 // endService( "Node_Impl::Threads" );
1761 long Graph_Impl::SuspendedThreads() {
1762 // beginService( "Node_Impl::SuspendedThreads" );
1763 long RetVal = false ;
1765 RetVal = DataFlowExecutor()->SuspendedThreads() ;
1767 // endService( "Node_Impl::SuspendedThreads" );
1771 bool Graph_Impl::Begin() {
1772 bool RetVal = false ;
1773 if ( DataFlowEditor()->IsEditing() ) {
1774 if ( pthread_mutex_lock( &_MutexExecutorWait ) ) {
1775 perror("pthread_mutex_lock _MutexExecutorWait") ;
1778 if ( DataFlowExecutor() ) {
1779 MESSAGE( "Graph_Impl::Begin " << DataFlowExecutor()->Threads() << " threads" )
1780 Editing(); // just in case it was not called before by GUI..
1782 if ( DataFlowEditor()->IsExecutable() ) {
1783 DataFlowEditor()->EditedAfterExecution( false ) ;
1784 GraphBase::ListOfSGraphs * myListOfGraphs = DataFlowEditor()->GetDataFlows() ;
1786 GraphExecutor::DataFlow * aDataFlowExecutor ;
1788 CreateExecutor( _Orb , instanceName() , (*myListOfGraphs)[ 0 ].Info.theName.c_str() , Kind() ,
1789 dbgfile , &aDataFlowExecutor ) ;
1791 MESSAGE( "Graph_Impl::Begin : DataFlowExecutor created" );
1792 if ( !CORBA::is_nil( LoadDataFlows( aDataFlowExecutor, myListOfGraphs , 0 ) ) )
1796 DataFlowExecutor()->Graph()->SetObjImpl( DataFlowEditor()->Graph()->ObjImpl() ) ;
1799 if ( pthread_mutex_unlock( &_MutexExecutorWait ) ) {
1800 perror("pthread_mutex_unlock _MutexExecutorWait") ;
1808 * run() : was created in order to reduce code dublication, Run() and Start() do the same thing
1809 * except for final call to Executor->Run( bool ) - Run() calls with AndSuspend=false
1810 * and Start() calls with AndSuspend=true flag. The rest of the actions are the same:
1811 * 1. if a MacroNode's coupled graph (MacroLevel>0) -> simply Run() it.
1812 * 2. if a Supergraph -> create executor, load dataflow in it (done in Begin()), then - Run() it.
1814 bool Graph_Impl::run( const bool andSuspend ) {
1815 bool RetVal = false ;
1817 // if Editing or Finished state, and, naturally, 'this' is not a MacroNode.
1818 if ( ( DataFlowEditor()->IsEditing() || IsDone() ) && !IsMacro() ) {
1820 if ( DataFlowEditor()->Graph()->GraphMacroLevel() ) {
1821 // MacroGraph's Executor was created in recursive function LoadDataflows(Executor), called from
1822 // Begin() of Supergraph. See Begin() and LoadDataflows(Executor) for details.
1826 // Create Executor instance and its datamodel
1830 // Set Executing flag to avoid edition operations during execution, EditedAfterExecution=false
1831 DataFlowEditor()->Executing() ;
1832 DataFlowEditor()->EditedAfterExecution( false );
1834 // THE MAIN RUN METHOD
1835 RetVal = DataFlowExecutor()->Run( andSuspend );
1843 * Run() - called on "Execute" command
1845 bool Graph_Impl::Run() {
1846 beginService( "Graph_Impl::Run" );
1847 bool RetVal = run( /*andSuspend=*/false ) ;
1848 MESSAGE( "Graph_Impl::Run " << DataFlowEditor()->Graph()->Name() << " RetVal " << RetVal ) ;
1849 endService( "Graph_Impl::Run" );
1854 * Run() - called on "Execute step-by-step" command
1856 bool Graph_Impl::Start() {
1857 beginService( "Graph_Impl::Start" );
1858 bool RetVal = run( /*andSuspend=*/true ) ;
1859 MESSAGE( "Graph_Impl::Start " << DataFlowEditor()->Graph()->Name() << " RetVal " << RetVal ) ;
1860 endService( "Graph_Impl::Start" );
1864 bool Graph_Impl::EventNoW( SUPERV::CNode_out aNode ,
1865 SUPERV::GraphEvent & anEvent ,
1866 SUPERV::GraphState & aState ) {
1867 bool RetVal = false ;
1868 char * aNodeName = NULL ;
1869 SUPERV::GraphEvent theEvent = SUPERV::UndefinedEvent ;
1870 SUPERV::GraphState theState = SUPERV::UndefinedState ;
1871 if ( pthread_mutex_lock( &_MutexExecutorWait ) ) {
1872 perror("pthread_mutex_lock _MutexExecutorWait") ;
1875 if ( DataFlowExecutor() && !IsMacro() &&
1876 ( DataFlowExecutor()->GetListSize() || !DataFlowEditor()->IsEditing() ) ) {
1877 RetVal = DataFlowExecutor()->Event( & aNodeName , theEvent , theState , false ) ;
1878 // endService( "Graph_Impl::Event" );
1879 if ( strlen( aNodeName ) ) {
1880 if ( strcmp( aNodeName , Name() ) ) {
1881 aNode = Node( aNodeName ) ;
1888 aNode = SUPERV::Graph::_duplicate( SUPERV::Graph::_nil() ) ;
1890 // cout << "Graph_Impl::EventNoW " << aNode->Name() << " QSize " << DataFlowExecutor()->GetListSize() << endl ;
1893 // cout << "Graph_Impl::EventNoW NO DataFlowExecutor() or QSize=0 " << endl ;
1895 if ( pthread_mutex_unlock( &_MutexExecutorWait ) ) {
1896 perror("pthread_mutex_unlock _MutexExecutorWait") ;
1899 anEvent = theEvent ;
1904 bool Graph_Impl::Event( SUPERV::CNode_out aNode ,
1905 SUPERV::GraphEvent & anEvent ,
1906 SUPERV::GraphState & aState ) {
1907 // beginService( "Graph_Impl::Event" );
1908 bool RetVal = false ;
1909 char * aNodeName = NULL ;
1910 SUPERV::GraphEvent theEvent = SUPERV::UndefinedEvent ;
1911 SUPERV::GraphState theState = SUPERV::UndefinedState ;
1912 if ( pthread_mutex_lock( &_MutexExecutorWait ) ) {
1913 perror("pthread_mutex_lock _MutexExecutorWait") ;
1916 if ( DataFlowExecutor() && !IsMacro() &&
1917 ( DataFlowExecutor()->GetListSize() || !DataFlowEditor()->IsEditing() ) ){
1918 RetVal = DataFlowExecutor()->Event( & aNodeName , theEvent , theState ) ;
1919 // endService( "Graph_Impl::Event" );
1920 if ( strlen( aNodeName ) ) {
1921 if ( strcmp( aNodeName , Name() ) ) {
1922 aNode = Node( aNodeName ) ;
1929 aNode = SUPERV::Graph::_duplicate( SUPERV::Graph::_nil() ) ;
1931 // cout << "Graph_Impl::Event " << aNode->Name() << " QSize " << DataFlowExecutor()->GetListSize() << endl ;
1934 // cout << "Graph_Impl::Event NO DataFlowExecutor() or QSize=0 " << endl ;
1936 if ( pthread_mutex_unlock( &_MutexExecutorWait ) ) {
1937 perror("pthread_mutex_unlock _MutexExecutorWait") ;
1940 anEvent = theEvent ;
1946 bool Graph_Impl::EventW( SUPERV::CNode_out aNode ,
1947 SUPERV::GraphEvent & anEvent ,
1948 SUPERV::GraphState & aState ) {
1949 // beginService( "Graph_Impl::EventW" );
1950 bool RetVal = false ;
1951 char * aNodeName = NULL ;
1952 SUPERV::GraphEvent theEvent = SUPERV::UndefinedEvent ;
1953 SUPERV::GraphState theState = SUPERV::UndefinedState ;
1954 if ( pthread_mutex_lock( &_MutexExecutorWait ) ) {
1955 perror("pthread_mutex_lock _MutexExecutorWait") ;
1958 if ( DataFlowExecutor() && !IsMacro() &&
1959 ( DataFlowExecutor()->GetListSize() || !DataFlowEditor()->IsEditing() ) ) {
1960 RetVal = DataFlowExecutor()->EventW( & aNodeName , theEvent , theState ) ;
1961 if ( RetVal && strcmp( aNodeName , Name() ) ) {
1962 aNode = Node( aNodeName ) ;
1968 if ( pthread_mutex_unlock( &_MutexExecutorWait ) ) {
1969 perror("pthread_mutex_unlock _MutexExecutorWait") ;
1972 anEvent = theEvent ;
1974 // endService( "Graph_Impl::EventW" );
1978 long Graph_Impl::EventQSize() {
1979 // beginService( "Graph_Impl::EventQSize" );
1981 if ( pthread_mutex_lock( &_MutexExecutorWait ) ) {
1982 perror("pthread_mutex_lock _MutexExecutorWait") ;
1985 if ( DataFlowExecutor() && !IsMacro() ) {
1986 QSize = DataFlowExecutor()->EventQSize() ;
1988 if ( pthread_mutex_unlock( &_MutexExecutorWait ) ) {
1989 perror("pthread_mutex_unlock _MutexExecutorWait") ;
1992 // endService( "Graph_Impl::EventQSize" );
1996 long Graph_Impl::LastLevelDone() {
1997 // beginService( "Graph_Impl::LastLevelDone" );
1998 if ( pthread_mutex_lock( &_MutexExecutorWait ) ) {
1999 perror("pthread_mutex_lock _MutexExecutorWait") ;
2003 if ( DataFlowExecutor() && !IsMacro() ) {
2004 RetVal = DataFlowExecutor()->LastLevelDone() ;
2006 if ( pthread_mutex_unlock( &_MutexExecutorWait ) ) {
2007 perror("pthread_mutex_unlock _MutexExecutorWait") ;
2010 // endService( "Graph_Impl::LastLevelDone" );
2014 long Graph_Impl::SubGraphsNumber() {
2015 // beginService( "Graph_Impl::SubGraphsNumber" );
2017 if ( DataFlowEditor()->IsExecutable() && !IsMacro() ) {
2018 RetVal = DataFlowEditor()->SubGraphsNumber() ;
2020 // endService( "Graph_Impl::SubGraphsNumber" );
2024 SUPERV::ListOfNodes * Graph_Impl::SubGraphsNodes( const long aSubGraphNumber ) {
2025 beginService( "Graph_Impl::SubGraphsNodes" );
2026 SUPERV::ListOfNodes_var RetVal = new SUPERV::ListOfNodes ;
2027 if ( DataFlowEditor()->IsEditing() && !IsMacro() ) {
2028 SUPERV::ListOfNodes * aGraphNodes = Nodes() ;
2031 for ( i = 0 ; i < (int ) aGraphNodes->CNodes.length() ; i++ ) {
2032 SUPERV::CNode_var aNode = (aGraphNodes->CNodes)[ i ] ;
2033 if ( aNode->SubGraph() == aSubGraphNumber ) {
2034 RetVal = SetNode( RetVal , DataFlowEditor()->Graph()->GetChangeGraphNode( aNode->Name() ) ) ;
2038 for ( i = 0 ; i < (int ) aGraphNodes->FNodes.length() ; i++ ) {
2039 SUPERV::FNode_var aNode = (aGraphNodes->FNodes)[ i ] ;
2040 if ( aNode->SubGraph() == aSubGraphNumber ) {
2041 RetVal = SetNode( RetVal , DataFlowEditor()->Graph()->GetChangeGraphNode( aNode->Name() ) ) ;
2045 for ( i = 0 ; i < (int ) aGraphNodes->INodes.length() ; i++ ) {
2046 SUPERV::INode_var aNode = (aGraphNodes->INodes)[ i ] ;
2047 if ( aNode->SubGraph() == aSubGraphNumber ) {
2048 RetVal = SetNode( RetVal , DataFlowEditor()->Graph()->GetChangeGraphNode( aNode->Name() ) ) ;
2052 for ( i = 0 ; i < (int ) aGraphNodes->GNodes.length() ; i++ ) {
2053 SUPERV::GNode_var aNode = (aGraphNodes->GNodes)[ i ] ;
2054 if ( aNode->SubGraph() == aSubGraphNumber ) {
2055 RetVal = SetNode( RetVal , DataFlowEditor()->Graph()->GetChangeGraphNode( aNode->Name() ) ) ;
2059 for ( i = 0 ; i < (int ) aGraphNodes->LNodes.length() ; i++ ) {
2060 SUPERV::LNode_var aNode = (aGraphNodes->LNodes)[ i ] ;
2061 if ( aNode->SubGraph() == aSubGraphNumber ) {
2062 RetVal = SetNode( RetVal , DataFlowEditor()->Graph()->GetChangeGraphNode( aNode->Name() ) ) ;
2066 for ( i = 0 ; i < (int ) aGraphNodes->ELNodes.length() ; i++ ) {
2067 SUPERV::ELNode_var aNode = (aGraphNodes->ELNodes)[ i ] ;
2068 if ( aNode->SubGraph() == aSubGraphNumber ) {
2069 RetVal = SetNode( RetVal , DataFlowEditor()->Graph()->GetChangeGraphNode( aNode->Name() ) ) ;
2073 for ( i = 0 ; i < (int ) aGraphNodes->SNodes.length() ; i++ ) {
2074 SUPERV::SNode_var aNode = (aGraphNodes->SNodes)[ i ] ;
2075 if ( aNode->SubGraph() == aSubGraphNumber ) {
2076 RetVal = SetNode( RetVal , DataFlowEditor()->Graph()->GetChangeGraphNode( aNode->Name() ) ) ;
2080 for ( i = 0 ; i < (int ) aGraphNodes->ESNodes.length() ; i++ ) {
2081 SUPERV::ESNode_var aNode = (aGraphNodes->ESNodes)[ i ] ;
2082 if ( aNode->SubGraph() == aSubGraphNumber ) {
2083 RetVal = SetNode( RetVal , DataFlowEditor()->Graph()->GetChangeGraphNode( aNode->Name() ) ) ;
2087 endService( "Graph_Impl::SubGraphsNodes" );
2088 return ( RetVal._retn() ) ;
2091 bool Graph_Impl::Merge(const SUPERV::Graph_ptr aGraph ) {
2092 // beginService( "Graph_Impl::Merge" );
2093 bool RetVal = true ;
2095 map< string , int > aMapOfNodes ;
2096 RetVal = Merge( aGraph , aMapOfNodes ) ;
2098 // endService( "Graph_Impl::Merge" );
2102 bool Graph_Impl::Merge(const SUPERV::Graph_ptr aGraph , map< string , int > & aMapOfNodes ) {
2103 beginService( "Graph_Impl::Merge" );
2104 bool RetVal = true ;
2105 if ( DataFlowEditor()->IsEditing() && !IsMacro() ) {
2106 SUPERV::ListOfNodes * aGraphNodes = aGraph->Nodes() ;
2108 SUPERV::Port_ptr aPort ;
2109 // SUPERV::StreamPort_ptr aStreamPort ;
2111 for ( i = 0 ; i < (int ) aGraphNodes->CNodes.length() ; i++ ) {
2112 SUPERV::CNode_var aNode = (aGraphNodes->CNodes)[ i ] ;
2113 SUPERV::CNode_ptr myNode = CNode( *(aNode->Service()) ) ;
2114 if ( !CORBA::is_nil( myNode ) ) {
2115 myNode->SetName( aNode->Name() ) ;
2116 myNode->SetAuthor( aNode->Author() ) ;
2117 myNode->SetComment( aNode->Comment() ) ;
2118 myNode->Coords( aNode->X() , aNode->Y() ) ;
2119 string * aNodetheName = new string( aNode->Name() ) ;
2120 aMapOfNodes[ *aNodetheName ] = DataFlowEditor()->Graph()->GetGraphNodeIndex( myNode->Name() ) ;
2121 delete aNodetheName ;
2128 // The following informations are now in the service from SALOME_ModuleCatalog
2129 // SUPERV::ListOfStreamPorts myStreamPorts = *(aNode->StreamPorts()) ;
2131 // for ( j = 0 ; j < (int ) myStreamPorts.length() ; j++ ) {
2132 // if ( myStreamPorts[ j ]->IsInput() && myStreamPorts[ j ]->IsDataStream() ) {
2133 // aStreamPort = myNode->InStreamPort( myStreamPorts[ j ]->Name() , myStreamPorts[ j ]->Type() ) ;
2135 // else if ( myStreamPorts[ j ]->IsDataStream() ) {
2136 // aStreamPort = myNode->OutStreamPort( myStreamPorts[ j ]->Name() , myStreamPorts[ j ]->Type() ) ;
2142 for ( i = 0 ; i < (int ) aGraphNodes->FNodes.length() ; i++ ) {
2143 SUPERV::FNode_var aNode = (aGraphNodes->FNodes)[ i ] ;
2144 SUPERV::FNode_ptr myNode = FNode( aNode->GetComponentName() ,
2145 aNode->GetInterfaceName() ,
2146 *(aNode->Service()) ) ;
2147 if ( !CORBA::is_nil( myNode ) ) {
2148 myNode->SetName( aNode->Name() ) ;
2149 myNode->SetAuthor( aNode->Author() ) ;
2150 myNode->SetComment( aNode->Comment() ) ;
2151 myNode->Coords( aNode->X() , aNode->Y() ) ;
2152 string * aNodetheName = new string( aNode->Name() ) ;
2153 aMapOfNodes[ *aNodetheName ] = DataFlowEditor()->Graph()->GetGraphNodeIndex( myNode->Name() ) ;
2154 delete aNodetheName ;
2161 // The following informations are now in the service from SALOME_ModuleCatalog
2162 // SUPERV::ListOfStreamPorts myStreamPorts = *(aNode->StreamPorts()) ;
2164 // for ( j = 0 ; j < (int ) myStreamPorts.length() ; j++ ) {
2165 // if ( myStreamPorts[ j ]->IsInput() && myStreamPorts[ j ]->IsDataStream() ) {
2166 // aStreamPort = myNode->InStreamPort( myStreamPorts[ j ]->Name() , myStreamPorts[ j ]->Type() ) ;
2168 // else if ( myStreamPorts[ j ]->IsDataStream() ) {
2169 // aStreamPort = myNode->OutStreamPort( myStreamPorts[ j ]->Name() , myStreamPorts[ j ]->Type() ) ;
2176 for ( i = 0 ; i < (int ) aGraphNodes->INodes.length() ; i++ ) {
2177 SUPERV::INode_var aNode = (aGraphNodes->INodes)[ i ] ;
2178 SUPERV::INode_ptr myNode = INode( aNode->PyFuncName() , *(aNode->PyFunction()) ) ;
2179 if ( !CORBA::is_nil( myNode ) ) {
2180 myNode->SetName( aNode->Name() ) ;
2181 myNode->SetAuthor( aNode->Author() ) ;
2182 myNode->SetComment( aNode->Comment() ) ;
2183 myNode->Coords( aNode->X() , aNode->Y() ) ;
2184 string * aNodetheName = new string( aNode->Name() ) ;
2185 aMapOfNodes[ *aNodetheName ] = DataFlowEditor()->Graph()->GetGraphNodeIndex( myNode->Name() ) ;
2186 delete aNodetheName ;
2187 SUPERV::ListOfPorts myPorts = *(aNode->Ports()) ;
2189 for ( j = 0 ; j < (int ) myPorts.length() ; j++ ) {
2190 if ( myPorts[ j ]->IsInput() ) {
2191 aPort = myNode->InPort( myPorts[ j ]->Name() , myPorts[ j ]->Type() ) ;
2194 aPort = myNode->OutPort( myPorts[ j ]->Name() , myPorts[ j ]->Type() ) ;
2197 if ( DataFlowEditor()->Graph()->IsDataStreamNode() ) {
2198 SUPERV::ListOfStreamPorts myStreamPorts = *(aNode->StreamPorts()) ;
2199 for ( j = 0 ; j < (int ) myStreamPorts.length() ; j++ ) {
2200 if ( myStreamPorts[ j ]->IsInput() ) {
2201 aPort = myNode->InStreamPort( myStreamPorts[ j ]->Name() , StringToDataStreamType( myStreamPorts[ j ]->Type() ) , myStreamPorts[ j ]->Dependency() ) ;
2204 aPort = myNode->OutStreamPort( myStreamPorts[ j ]->Name() , StringToDataStreamType( myStreamPorts[ j ]->Type() ) , myStreamPorts[ j ]->Dependency() ) ;
2218 for ( i = 0 ; i < (int ) aGraphNodes->GNodes.length() ; i++ ) {
2219 SUPERV::GNode_var aNode = (aGraphNodes->GNodes)[ i ] ;
2220 SUPERV::GNode_ptr myNode = GNode( aNode->PyFuncName() , *(aNode->PyFunction()) , aNode->Coupled()->Name() ) ;
2221 if ( !CORBA::is_nil( myNode ) ) {
2222 myNode->SetName( aNode->Name() ) ;
2223 myNode->SetAuthor( aNode->Author() ) ;
2224 myNode->SetComment( aNode->Comment() ) ;
2225 myNode->Coords( aNode->X() , aNode->Y() ) ;
2226 string * aNodetheName = new string( aNode->Name() ) ;
2227 aMapOfNodes[ *aNodetheName ] = DataFlowEditor()->Graph()->GetGraphNodeIndex( myNode->Name() ) ;
2228 delete aNodetheName ;
2229 SUPERV::ListOfPorts myPorts = *(aNode->Ports()) ;
2231 for ( j = 0 ; j < (int ) myPorts.length() ; j++ ) {
2232 if ( myPorts[ j ]->IsInput() ) {
2233 aPort = myNode->InPort( myPorts[ j ]->Name() , myPorts[ j ]->Type() ) ;
2236 aPort = myNode->OutPort( myPorts[ j ]->Name() , myPorts[ j ]->Type() ) ;
2239 if ( DataFlowEditor()->Graph()->IsDataStreamNode() ) {
2240 SUPERV::ListOfStreamPorts myStreamPorts = *(aNode->StreamPorts()) ;
2241 for ( j = 0 ; j < (int ) myStreamPorts.length() ; j++ ) {
2242 if ( myStreamPorts[ j ]->IsInput() ) {
2243 aPort = myNode->InStreamPort( myStreamPorts[ j ]->Name() , StringToDataStreamType( myStreamPorts[ j ]->Type() ) , myStreamPorts[ j ]->Dependency() ) ;
2246 aPort = myNode->OutStreamPort( myStreamPorts[ j ]->Name() , StringToDataStreamType( myStreamPorts[ j ]->Type() ) , myStreamPorts[ j ]->Dependency() ) ;
2260 for ( i = 0 ; i < (int ) aGraphNodes->LNodes.length() ; i++ ) {
2261 SUPERV::LNode_var aNode = (aGraphNodes->LNodes)[ i ] ;
2262 SUPERV::INode_ptr anEndOfLoop ;
2263 SUPERV::LNode_ptr myNode = LNode( aNode->PyInitName() ,
2264 *(aNode->PyInit()) ,
2265 aNode->PyMoreName() ,
2266 *(aNode->PyMore()) ,
2267 aNode->PyNextName() ,
2268 *(aNode->PyNext()) ,
2270 if ( !CORBA::is_nil( myNode ) ) {
2271 myNode->SetName( aNode->Name() ) ;
2272 myNode->SetAuthor( aNode->Author() ) ;
2273 myNode->SetComment( aNode->Comment() ) ;
2274 myNode->Coords( aNode->X() , aNode->Y() ) ;
2275 string * aNodetheName = new string( aNode->Name() ) ;
2276 aMapOfNodes[ *aNodetheName ] = DataFlowEditor()->Graph()->GetGraphNodeIndex( myNode->Name() ) ;
2277 delete aNodetheName ;
2278 SUPERV::ListOfPorts myPorts = *(aNode->Ports()) ;
2280 for ( j = 0 ; j < (int ) myPorts.length() ; j++ ) {
2281 if ( myPorts[ j ]->IsInput() ) {
2282 aPort = myNode->InPort( myPorts[ j ]->Name() , myPorts[ j ]->Type() ) ;
2285 aPort = myNode->OutPort( myPorts[ j ]->Name() , myPorts[ j ]->Type() ) ;
2288 if ( DataFlowEditor()->Graph()->IsDataStreamNode() ) {
2289 SUPERV::ListOfStreamPorts myStreamPorts = *(aNode->StreamPorts()) ;
2290 for ( j = 0 ; j < (int ) myStreamPorts.length() ; j++ ) {
2291 if ( myStreamPorts[ j ]->IsInput() ) {
2292 aPort = myNode->InStreamPort( myStreamPorts[ j ]->Name() , StringToDataStreamType( myStreamPorts[ j ]->Type() ) , myStreamPorts[ j ]->Dependency() ) ;
2295 aPort = myNode->OutStreamPort( myStreamPorts[ j ]->Name() , StringToDataStreamType( myStreamPorts[ j ]->Type() ) , myStreamPorts[ j ]->Dependency() ) ;
2299 SUPERV::INode_ptr myEndOfLoop = aNode->Coupled() ;
2300 anEndOfLoop->SetName( myEndOfLoop->Name() ) ;
2301 anEndOfLoop->SetAuthor( myEndOfLoop->Author() ) ;
2302 anEndOfLoop->SetComment( myEndOfLoop->Comment() ) ;
2303 anEndOfLoop->Coords( myEndOfLoop->X() , myEndOfLoop->Y() ) ;
2304 anEndOfLoop->SetPyFunction( myEndOfLoop->PyFuncName() , *(myEndOfLoop->PyFunction()) ) ;
2305 aNodetheName = new string( myEndOfLoop->Name() ) ;
2306 aMapOfNodes[ *aNodetheName ] = DataFlowEditor()->Graph()->GetGraphNodeIndex( anEndOfLoop->Name() ) ;
2307 if ( DataFlowEditor()->Graph()->IsDataStreamNode() ) {
2308 SUPERV::ListOfStreamPorts myStreamLoopPorts = *(myEndOfLoop->StreamPorts()) ;
2309 for ( j = 0 ; j < (int ) myStreamLoopPorts.length() ; j++ ) {
2310 if ( myStreamLoopPorts[ j ]->IsInput() ) {
2311 aPort = myNode->InStreamPort( myStreamLoopPorts[ j ]->Name() , StringToDataStreamType( myStreamLoopPorts[ j ]->Type() ) , myStreamLoopPorts[ j ]->Dependency() ) ;
2314 aPort = myNode->OutStreamPort( myStreamLoopPorts[ j ]->Name() , StringToDataStreamType( myStreamLoopPorts[ j ]->Type() ) , myStreamLoopPorts[ j ]->Dependency() ) ;
2318 delete aNodetheName ;
2329 for ( i = 0 ; i < (int ) aGraphNodes->SNodes.length() ; i++ ) {
2330 SUPERV::SNode_var aNode = (aGraphNodes->SNodes)[ i ] ;
2331 SUPERV::INode_ptr anEndOfSwitch ;
2332 SUPERV::SNode_ptr myNode = SNode( aNode->PyFuncName() , *(aNode->PyFunction()) , anEndOfSwitch ) ;
2333 if ( !CORBA::is_nil( myNode ) ) {
2334 myNode->SetName( aNode->Name() ) ;
2335 myNode->SetAuthor( aNode->Author() ) ;
2336 myNode->SetComment( aNode->Comment() ) ;
2337 myNode->Coords( aNode->X() , aNode->Y() ) ;
2338 string * aNodetheName = new string( aNode->Name() ) ;
2339 aMapOfNodes[ *aNodetheName ] = DataFlowEditor()->Graph()->GetGraphNodeIndex( myNode->Name() ) ;
2340 delete aNodetheName ;
2341 SUPERV::ListOfPorts myPorts = *(aNode->Ports()) ;
2343 for ( j = 0 ; j < (int ) myPorts.length() ; j++ ) {
2344 if ( myPorts[ j ]->IsInput() ) {
2345 aPort = myNode->InPort( myPorts[ j ]->Name() , myPorts[ j ]->Type() ) ;
2348 aPort = myNode->OutPort( myPorts[ j ]->Name() , myPorts[ j ]->Type() ) ;
2351 if ( DataFlowEditor()->Graph()->IsDataStreamNode() ) {
2352 SUPERV::ListOfStreamPorts myStreamPorts = *(aNode->StreamPorts()) ;
2353 for ( j = 0 ; j < (int ) myStreamPorts.length() ; j++ ) {
2354 if ( myStreamPorts[ j ]->IsInput() ) {
2355 aPort = myNode->InStreamPort( myStreamPorts[ j ]->Name() , StringToDataStreamType( myStreamPorts[ j ]->Type() ) , myStreamPorts[ j ]->Dependency() ) ;
2358 aPort = myNode->OutStreamPort( myStreamPorts[ j ]->Name() , StringToDataStreamType( myStreamPorts[ j ]->Type() ) , myStreamPorts[ j ]->Dependency() ) ;
2362 SUPERV::INode_ptr myEndOfSwitch = aNode->Coupled() ;
2363 anEndOfSwitch->SetName( myEndOfSwitch->Name() ) ;
2364 anEndOfSwitch->SetAuthor( myEndOfSwitch->Author() ) ;
2365 anEndOfSwitch->SetComment( myEndOfSwitch->Comment() ) ;
2366 anEndOfSwitch->Coords( myEndOfSwitch->X() , myEndOfSwitch->Y() ) ;
2367 anEndOfSwitch->SetPyFunction( myEndOfSwitch->PyFuncName() , *(myEndOfSwitch->PyFunction()) ) ;
2368 aNodetheName = new string( myEndOfSwitch->Name() ) ;
2369 aMapOfNodes[ *aNodetheName ] = DataFlowEditor()->Graph()->GetGraphNodeIndex( anEndOfSwitch->Name() ) ;
2370 delete aNodetheName ;
2371 myPorts = *(myEndOfSwitch->Ports()) ;
2372 for ( j = 0 ; j < (int ) myPorts.length() ; j++ ) {
2373 if ( myPorts[ j ]->IsInput() ) {
2374 aPort = myNode->InPort( myPorts[ j ]->Name() , myPorts[ j ]->Type() ) ;
2377 aPort = myNode->OutPort( myPorts[ j ]->Name() , myPorts[ j ]->Type() ) ;
2380 if ( DataFlowEditor()->Graph()->IsDataStreamNode() ) {
2381 SUPERV::ListOfStreamPorts myStreamSwitchPorts = *(myEndOfSwitch->StreamPorts()) ;
2382 for ( j = 0 ; j < (int ) myStreamSwitchPorts.length() ; j++ ) {
2383 if ( myStreamSwitchPorts[ j ]->IsInput() ) {
2384 aPort = myNode->InStreamPort( myStreamSwitchPorts[ j ]->Name() , StringToDataStreamType( myStreamSwitchPorts[ j ]->Type() ) , myStreamSwitchPorts[ j ]->Dependency() ) ;
2387 aPort = myNode->OutStreamPort( myStreamSwitchPorts[ j ]->Name() , StringToDataStreamType( myStreamSwitchPorts[ j ]->Type() ) , myStreamSwitchPorts[ j ]->Dependency() ) ;
2400 SUPERV::ListOfLinks * aGraphLinks = aGraph->GLinks() ;
2401 SUPERV::ListOfPorts * aGraphPorts = aGraph->Ports() ;
2402 // cout << "Graph_Impl::Merge " << aGraphLinks->length() << " links " << aGraphPorts->length() << " GraphPorts"
2404 for ( i = 0 ; i < (int ) aGraphLinks->length() ; i++ ) {
2405 SUPERV::Link_var aLink = (*aGraphLinks)[ i ] ;
2406 SUPERV::Port_var OutPort = aLink->OutPort() ;
2407 SUPERV::Port_var InPort = aLink->InPort() ;
2408 string * aLinkFromNodeName = new string( OutPort->Node()->Name() ) ;
2409 string * aLinkToNodeName = new string( InPort->Node()->Name() ) ;
2410 RetVal = DataFlowEditor()->AddLink( DataFlowEditor()->Graph()->GetGraphNode( aMapOfNodes[ aLinkFromNodeName->c_str() ] )->Name() ,
2412 DataFlowEditor()->Graph()->GetGraphNode( aMapOfNodes[ aLinkToNodeName->c_str() ] )->Name() ,
2416 for ( j = 1 ; j <= aLink->CoordsSize() ; j++ ) {
2418 RetVal = aLink->Coords( j , X , Y ) ;
2421 RetVal = DataFlowEditor()->AddLinkCoord( DataFlowEditor()->Graph()->GetGraphNode( aMapOfNodes[ aLinkFromNodeName->c_str() ] )->Name() ,
2423 DataFlowEditor()->Graph()->GetGraphNode( aMapOfNodes[ aLinkToNodeName->c_str() ] )->Name() ,
2431 delete aLinkFromNodeName ;
2432 delete aLinkToNodeName ;
2438 for ( i = 0 ; i < (int ) aGraphPorts->length() ; i++ ) {
2439 SUPERV::Port_var aPort = (*aGraphPorts)[ i ] ;
2440 if ( !aPort->IsGate() ) {
2441 MESSAGE( "Graph_Impl::Merge " << i << ". " << aPort->Node()->Name() << " " << aPort->Name() ) ;
2442 char * aPortName = aPort->Name() ;
2443 char * aNodeName = new char[ strlen( aPortName ) + 1 ] ;
2444 strcpy( aNodeName , aPortName ) ;
2445 // char * thePortName = strchr( aNodeName , '\\' ) ;
2446 char * thePortName = aNodeName ;
2447 while ( ( thePortName = strchr( thePortName , '_' ) ) ) {
2448 if ( thePortName[1] == '_' ) {
2449 thePortName[ 0 ] = '\0' ;
2453 thePortName = &thePortName[2] ;
2456 bool hasinput = aGraph->Node( aNodeName )->Port( thePortName + 2 )->HasInput() ;
2457 // cout << "Graph_Impl::Merge " << " aNodeName " << aNodeName << " aPort " << thePortName + 1
2458 // << " HasInput " << hasinput << endl ;
2460 RetVal = DataFlowEditor()->AddInputData( DataFlowEditor()->Graph()->GetGraphNode( aMapOfNodes[ aNodeName ] )->Name() ,
2462 *(aPort->ToAny()) ) ;
2464 delete [] aNodeName ;
2473 MESSAGE( "Graph_Impl::Merge returns " << RetVal ) ;
2474 endService( "Graph_Impl::Merge" );
2478 SUPERV::StreamGraph_ptr Graph_Impl::ToStreamGraph() {
2479 SUPERV::StreamGraph_var iobject = SUPERV::StreamGraph::_nil() ;
2480 beginService( "Graph_Impl::ToStreamGraph" );
2481 if ( IsStreamGraph() && !IsMacro() ) {
2482 // StreamGraph_Impl * myStreamGraph = new StreamGraph_Impl( _Orb , _Poa , _ContId ,
2483 // instanceName() , interfaceName() ) ;
2484 // PortableServer::ObjectId * id = myStreamGraph->getId() ;
2485 // CORBA::Object_var obj = _poa->id_to_reference(*id);
2486 iobject = SUPERV::StreamGraph::_narrow( ObjRef() ) ;
2487 if ( CORBA::is_nil( iobject ) ) {
2488 MESSAGE( "ToStreamGraph of " << Name() << " (IsStreamGraph) --> nil reference" ) ;
2492 MESSAGE( "ToStreamGraph of " << Name() << " (IsNOTStreamGraph) --> nil reference" ) ;
2494 endService( "Graph_Impl::ToStreamGraph" );
2495 return SUPERV::StreamGraph::_duplicate( iobject ) ;
2499 * Destroy Executor and use only Editor and its data model
2501 void Graph_Impl::Editing() {
2502 if ( DataFlowEditor() && DataFlowExecutor() ) {
2503 delete DataFlowExecutor() ;
2504 DataFlowEditor()->Executor( NULL );