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 Link( myNode->Port( "DoLoop" ) , myEndNode->Port( "DoLoop" ) ) ;
526 Link( myEndNode->Port( "DoLoop" ) , myNode->Port( "InitLoop" ) ) ;
529 anEndOfLoop = SUPERV::ELNode::_duplicate( iendobject ) ;
530 DataFlowEditor()->UnValid() ;
531 endService( "Graph_Impl::LNode" );
532 return SUPERV::LNode::_duplicate( iobject ) ;
535 SUPERV::SNode_ptr Graph_Impl::SNode( const char * FuncName ,
536 const SUPERV::ListOfStrings & PythonFunction ,
537 SUPERV::INode_out anEndOfSwitch ) {
538 beginService( "Graph_Impl::SNode" );
539 SUPERV::SNode_var iobject = SUPERV::SNode::_nil() ;
540 SUPERV::ESNode_var iendobject = SUPERV::ESNode::_nil() ;
541 if ( DataFlowEditor()->IsEditing() && !DataFlowEditor()->IsReadOnly() && !IsMacro() ) {
542 SNode_Impl * myNode = new SNode_Impl( _Orb , _Poa , _ContId ,
543 instanceName() , interfaceName() ,
545 FuncName , PythonFunction ,
546 SUPERV::SwitchNode ) ;
547 if ( myNode->DataFlowNode() ) {
548 PortableServer::ObjectId * id = myNode->getId() ;
549 CORBA::Object_var obj = _poa->id_to_reference(*id);
550 iobject = SUPERV::SNode::_narrow(obj) ;
551 myNode->SetObjRef( SUPERV::SNode::_duplicate( iobject ) ) ;
553 string anEndName = "End" ;
554 if ( strlen( FuncName ) ) {
555 anEndName += FuncName ;
558 anEndName += "Switch" ;
560 // cout << "Graph_Impl::SNode anEndName " << (void *) FuncName << " " << FuncName
561 // << " " << strlen(FuncName) << " " << (void *) anEndName.c_str() << " "
562 // << anEndName.c_str() << endl ;
563 ESNode_Impl * myEndNode = new ESNode_Impl( _Orb , _Poa , _ContId ,
564 instanceName() , interfaceName() ,
567 SUPERV::EndSwitchNode ) ;
568 // cout << "Graph_Impl::SNode returned anEndName " << (void *) FuncName << " "
569 // << FuncName << " " << strlen(FuncName) << " " << (void *) anEndName.c_str()
570 // << " " << anEndName.c_str() << endl ;
571 PortableServer::ObjectId * endid = myEndNode->getId() ;
572 CORBA::Object_var endobj = _poa->id_to_reference(*endid);
573 iendobject = SUPERV::ESNode::_narrow(endobj) ;
574 myEndNode->SetObjRef( SUPERV::ESNode::_duplicate( iendobject ) ) ;
575 myNode->SetCoupled( myEndNode->BaseNode()->Name() ) ;
576 myEndNode->SetCoupled( myNode->BaseNode()->Name() ) ;
577 if ( !Link( myNode->Port( "Default" ) , myEndNode->Port( "Default" ) ) ) {
578 iobject = SUPERV::SNode::_nil() ;
579 iendobject = SUPERV::ESNode::_nil() ;
583 anEndOfSwitch = SUPERV::ESNode::_duplicate( iendobject ) ;
584 DataFlowEditor()->UnValid() ;
585 endService( "Graph_Impl::SNode" );
586 return SUPERV::SNode::_duplicate( iobject ) ;
589 // WARNING : THIS IS COMPLICATED :
590 SUPERV::Graph_var Graph_Impl::LoadDataFlows( GraphEditor::DataFlow * aDataFlowEditor ,
591 GraphBase::ListOfSGraphs * aListOfDataFlows ,
593 beginService( "Graph_Impl::EditorLoadDataFlows" ) ;
594 MESSAGE("Graph_Impl::LoadDataFlows index " << index << " " << (*aListOfDataFlows)[index].Info.theName.c_str() ) ;
596 SUPERV::Graph_var iobject = SUPERV::Graph::_nil() ;
597 // That method is recursive :
598 // At first we load the supergraph with index = 0 :
599 // (After we load the graph corresponding to each MacroNode :)
600 if ( !aDataFlowEditor->LoadDataFlow( &(*aListOfDataFlows)[ index ] ) ) {
601 MESSAGE("Graph_Impl::LoadDataFlows failed " << (*aListOfDataFlows)[index].Info.theName.c_str() ) ;
602 return SUPERV::Graph::_duplicate( iobject ) ;
604 // That graph is not a StreamGraph :
605 else if ( !aDataFlowEditor->Graph()->HasDataStream() ) {
606 aDataFlowEditor->Graph()->Kind( SUPERV::DataFlowGraph ) ;
607 // aDataFlowEditor->Graph()->SetGraphEditor( aDataFlowEditor ) ;
608 Graph_Impl * myGraph ;
609 // We create a Graph ObjRef for that graph
610 myGraph = new Graph_Impl( _Orb , _Poa, _ContId,
611 instanceName() , interfaceName() ,
612 aDataFlowEditor , NULL ) ;
613 PortableServer::ObjectId * id = myGraph->getId() ;
614 CORBA::Object_var obj = _poa->id_to_reference(*id) ;
615 iobject = SUPERV::Graph::_narrow( obj ) ;
616 myGraph->SetObjRef( SUPERV::Graph::_duplicate( iobject ) ) ;
617 myGraph->SetObjImpl( (CNode_Impl * ) myGraph ) ;
618 GraphBase::Graph * aGraph = myGraph->DataFlowEditor()->Graph() ;
621 // asv: set Editor for the graph itself and for all its macro nodes
622 aGraph->GraphEditor( aDataFlowEditor );
624 // For the supergraph or each graph of MacroNodes we search MacroNodes recursively :
625 for ( i = 0 ; i < aGraph->GraphNodesSize() ; i++ ) {
626 if ( aGraph->GraphNodes( i )->IsMacroNode() ) {
627 GraphBase::GOTONode * aMacroNode = (GraphBase::GOTONode * ) aGraph->GraphNodes( i ) ;
629 // asv : 05.11.04 : fix of bug - "insert file" into existing graph with MacroNodes worked incorrectly!
630 // aMacroNode is an "old" node, and here we must analize only "new" nodes, that
631 // came from aListOfDataFlows and were loaded by aDataFlowEditor->LoadDataFlow( &(*aListOfDataFlows)[ index ] )
632 // so here we check if the node is "new" or "old"
633 if ( aMacroNode->GraphEditor() && aMacroNode->CoupledNode() )
636 // asv: set Editor for the graph itself and for all its macro nodes
637 aMacroNode->GraphEditor( aDataFlowEditor );
639 // Creation of a GraphMacroNode ObjRef in the current editor
640 SUPERV::Graph_var macroiobject = SUPERV::Graph::_nil() ;
641 Graph_Impl * myMacroNode ;
642 myMacroNode = new Graph_Impl( _Orb , _Poa, _ContId,
643 instanceName() , interfaceName() ,
644 aMacroNode->Name() , SUPERV::MacroNode ) ;
645 id = myMacroNode->getId() ;
646 obj = _poa->id_to_reference(*id);
647 macroiobject = SUPERV::Graph::_narrow( obj ) ;
648 myMacroNode->DataFlowEditor( aDataFlowEditor ) ;
649 GraphEditor::InNode * aDataFlowNode = (GraphEditor::InNode * ) aMacroNode->GetInNode() ;
650 myMacroNode->DataFlowNode( aDataFlowNode ) ;
651 aDataFlowNode->SetObjRef( SUPERV::CNode::_duplicate( SUPERV::CNode::_narrow( obj ) ) ) ;
652 aDataFlowNode->SetObjImpl( myMacroNode ) ;
654 char * aCoupledNodeName = aMacroNode->CoupledNodeName() ;
655 MESSAGE( "LoadDataFlows MacroNode " << aMacroNode->Name() << " --> " << aCoupledNodeName
656 << " to be searched among " << (*aListOfDataFlows).size() << " Graphs" ) ;
659 for ( index = 0 ; index < (int ) (*aListOfDataFlows).size() ; index++ ) {
660 MESSAGE( "LoadDataFlows Graph" << index << " " << (*aListOfDataFlows)[index].Info.theName.c_str() ) ;
661 if ( !strcmp( aCoupledNodeName , (*aListOfDataFlows)[index].Info.theName.c_str() ) ) {
664 // At first create the editor and a StreamGraph
665 GraphEditor::DataFlow * aMacroGraphDataFlowEditor ;
666 CreateEditor( _Orb , instanceName() , aCoupledNodeName , SUPERV::DataStreamGraph ,
667 dbgfile , &aMacroGraphDataFlowEditor ) ;
669 if ( _DebugFileName ) {
670 delete [] _DebugFileName ;
672 _DebugFileName = new char[ strlen( dbgfile.c_str() )+1 ] ;
673 strcpy( _DebugFileName , dbgfile.c_str() ) ;
675 MESSAGE( "RECURSIVE IMPORT OF GRAPHS OF MACRONODES :" << aCoupledNodeName ) ;
676 if ( CORBA::is_nil( LoadDataFlows( aMacroGraphDataFlowEditor , aListOfDataFlows , index ) ) ) {
677 MESSAGE("Graph_Impl::LoadDataFlows failed" ) ;
678 return SUPERV::Graph::_duplicate( iobject ) ;
681 // That graph is not a StreamGraph :
682 else if ( !aMacroGraphDataFlowEditor->Graph()->HasDataStream() ) {
683 Graph_Impl * myMacroGraph ;
684 // The Graph ObjRef for that graph was already created
685 myMacroGraph = (Graph_Impl * ) aMacroGraphDataFlowEditor->Graph()->ObjImpl() ;
687 GraphBase::Graph * aMacroGraph = myMacroGraph->DataFlowEditor()->Graph() ;
689 aMacroGraph->GraphMacroLevel( aGraph->GraphMacroLevel() + 1 ) ;
690 aMacroGraph->CoupledNode( aMacroNode ) ;
691 aMacroGraph->MacroObject( SUPERV::Graph::_duplicate( macroiobject ) ) ;
693 // Set the GraphMacroNode ObjRef in the MacroNode
694 aMacroNode->GraphMacroLevel( aGraph->GraphMacroLevel() + 1 ) ;
695 aMacroNode->CoupledNode( aMacroGraph ) ;
696 aMacroNode->MacroObject( SUPERV::Graph::_narrow( aMacroGraphDataFlowEditor->Graph()->ObjRef() ) ) ;
697 MESSAGE( "LoadDataFlows aMacroGraph " << aMacroGraph << " " << aMacroGraph->Name()
698 << " coupled to " << aMacroGraph->CoupledNode() << " "
699 << aMacroGraph->CoupledNode()->Name() << " Editor " << aMacroGraph->GraphEditor() ) ;
700 MESSAGE( "LoadDataFlows aMacroNode " << aMacroNode << " " << aMacroNode->Name()
701 << " coupled to " << aMacroNode->CoupledNode() << " "
702 << aMacroNode->CoupledNode()->Name() << " Editor " << aMacroNode->GraphEditor() ) ;
703 MESSAGE( "LoadDataFlows current Graph " << aGraph << " " << aGraph->Name()
704 << " coupled to " << aGraph->CoupledNode()
705 << " Editor " << aGraph->GraphEditor() << " " << aGraph->Name() ) ;
711 return SUPERV::Graph::_duplicate( SUPERV::Graph::_nil() ) ;
716 else if ( (*aListOfDataFlows).size() == 1 ) {
717 StreamGraph_Impl * myStreamGraph ;
718 // We create a Graph ObjRef for that graph
719 myStreamGraph = new StreamGraph_Impl( _Orb , _Poa, _ContId,
720 instanceName() , interfaceName() ,
721 aDataFlowEditor , NULL ) ;
722 PortableServer::ObjectId * id = myStreamGraph->getId() ;
723 CORBA::Object_var obj = _poa->id_to_reference(*id) ;
724 SUPERV::StreamGraph_var Streamiobject = SUPERV::StreamGraph::_nil() ;
725 Streamiobject = SUPERV::StreamGraph::_narrow( obj ) ;
726 myStreamGraph->SetObjRef( SUPERV::StreamGraph::_duplicate( Streamiobject ) ) ;
727 myStreamGraph->SetObjImpl( (CNode_Impl * ) myStreamGraph ) ;
728 // iobject = SUPERV::Graph::_narrow( obj ) ;
729 iobject = SUPERV::Graph::_narrow( Streamiobject ) ;
732 MESSAGE( "Graph_Impl::LoadDataFlows StreamGraph with MacroNodes not yet implemented" ) ;
735 endService( "Graph_Impl::EditorLoadDataFlows" );
736 return SUPERV::Graph::_duplicate( iobject ) ;
739 SUPERV::Graph_var Graph_Impl::LoadDataFlows( GraphExecutor::DataFlow * aDataFlowExecutor ,
740 GraphBase::ListOfSGraphs * aListOfDataFlows ,
742 beginService( "Graph_Impl::ExecutorLoadDataFlows" ) ;
743 MESSAGE("Graph_Impl::LoadDataFlows(Executor) index " << index << " " << (*aListOfDataFlows)[index].Info.theName.c_str() << " aDataFlowExecutor " << aDataFlowExecutor ) ;
745 // That method is recursive :
746 // At first we load the supergraph with index = 0 :
747 // (After we load the graph corresponding to each MacroNode :)
748 if ( !aDataFlowExecutor->LoadDataFlow( &(*aListOfDataFlows)[ index ] ) ) {
749 MESSAGE("Graph_Impl::LoadDataFlows(Executor) failed, could not LoadDataFlow(supergraph)" ) ;
750 return SUPERV::Graph::_duplicate( SUPERV::Graph::_nil() ) ;
753 // That graph is not a StreamGraph :
755 aDataFlowExecutor->Graph()->Kind( SUPERV::DataFlowGraph ) ;
756 GraphEditor::DataFlow * aDataFlowEditor ;
757 aDataFlowEditor = DataFlowEditor() ;
758 GraphBase::Graph * anEditorGraph = aDataFlowEditor->Graph() ;
759 GraphBase::Graph * anExecutorGraph = aDataFlowExecutor->Graph() ;
760 if ( aDataFlowEditor->Executor() ) {
761 delete aDataFlowEditor->Executor() ;
762 aDataFlowEditor->Executor( NULL ) ;
763 aDataFlowEditor->Editing() ;
765 aDataFlowEditor->Executor( aDataFlowExecutor ) ;
766 anExecutorGraph->GraphEditor( aDataFlowEditor ) ;
768 if ( !aDataFlowExecutor->Graph()->HasDataStream() ) {
769 // For the supergraph or each graph of MacroNodes we search MacroNodes recursively :
771 for ( i = 0 ; i < anExecutorGraph->GraphNodesSize() ; i++ ) {
772 if ( anExecutorGraph->GraphNodes( i )->IsMacroNode() ) {
773 GraphBase::GOTONode * aMacroNode = (GraphBase::GOTONode * ) anExecutorGraph->GraphNodes( i ) ;
774 aMacroNode->GraphEditor( aDataFlowEditor ) ;
776 // get the macro node's editor object
777 char * aMacroGraphName = aMacroNode->CoupledNodeName() ;
778 GraphBase::Graph* aMacroGraph = (GraphBase::Graph*)((GraphBase::GOTONode *)anEditorGraph->GetGraphNode( aMacroNode->Name() ))->CoupledNode() ;
779 GraphEditor::DataFlow* aMacroGraphEditor = aMacroGraph->GraphEditor();
781 MESSAGE( "LoadDataFlows(Executor) MacroNode " << aMacroNode->Name() << " Coupled to " << aMacroGraphName
782 << " to be searched among " << (*aListOfDataFlows).size() << " Graphs" << endl ) ;
785 for ( index = 0 ; index < (int ) (*aListOfDataFlows).size() && !found; index++ ) {
786 if ( !strcmp( aMacroGraphName , (*aListOfDataFlows)[index].Info.theName.c_str() ) )
790 MESSAGE("Graph_Impl::LoadDataFlows(Executor) failed, Macro node's coupled graph \"" << aMacroGraphName << "\" was not found" ) ;
791 return SUPERV::Graph::_duplicate( SUPERV::Graph::_nil() ) ;
793 index--; // it was incremented in "for ..." before last check ( !found ).
795 // At first create the editor and a StreamGraph
797 GraphExecutor::DataFlow * aMacroGraphExecutor ;
798 CreateExecutor( _Orb , instanceName() , aMacroGraphName , SUPERV::DataStreamGraph ,
799 dbgfile , &aMacroGraphExecutor );
801 // set GraphMacroLevel for Executor's graph
802 GraphBase::Graph* aMacroGraphExe = aMacroGraphExecutor->Graph();
803 aMacroGraphExe->GraphMacroLevel( anExecutorGraph->GraphMacroLevel() + 1 );
805 // load data flows in MacroGraph's executor
806 Graph_Impl* aMacroGraphImpl = (Graph_Impl*) aMacroGraphEditor->Graph()->ObjImpl();
807 MESSAGE( "RECURSIVE IMPORT OF GRAPHS OF MACRONODES : " << aMacroGraphName ) ;
808 if ( CORBA::is_nil( aMacroGraphImpl->LoadDataFlows( aMacroGraphExecutor, aListOfDataFlows , index ) ) ) {
809 MESSAGE("Graph_Impl::LoadDataFlows(Executor) failed, could not LoadDataFlow( MacroNodeGraph \"" <<aMacroGraphName << "\" )" ) ;
810 return SUPERV::Graph::_duplicate( SUPERV::Graph::_nil() ) ;
813 // set coupled pair MacroNode <--> MacroGraph
814 aMacroGraphExe->CoupledNode( aMacroNode ) ;
815 aMacroNode->CoupledNode( aMacroGraphExe ) ;
817 // initialize MacroNode's InPorts with corresponding "external" values
819 for ( q = 0 ; q < aMacroNode->GetNodeInPortsSize() ; q++ ) {
820 const GraphBase::InPort * anInPort = aMacroNode->GetNodeInPort( q ) ;
821 if ( anInPort->IsDataConnected() ) {
822 const char* aMacroGraphInPortName = aMacroGraph->GetNodeInPort( q )->PortName();
823 if ( !aMacroGraphExecutor->InputOfAny( aMacroGraphInPortName, *anInPort->GetOutPort()->Value(),false ) ) {
824 return SUPERV::Graph::_duplicate( SUPERV::Graph::_nil() ) ;
827 MESSAGE( "LoadDataFlows(Executor) " << aMacroGraph->Name() << "->InputOfAny( "
828 << aMacroGraphInPortName << " , Value )" ) ;
831 } // end of init MacroNode's InPorts
833 aMacroGraphImpl->Run() ;
836 } // end of for( get nodes of the graph...)
838 } // end of setting initial graph's structure..
840 endService( "Graph_Impl::ExecutorLoadDataFlows" );
842 PortableServer::ObjectId * id = getId();
843 CORBA::Object_var obj = _poa->id_to_reference( *id );
844 SUPERV::Graph_var iobject = SUPERV::Graph::_narrow( obj ) ;
845 return SUPERV::Graph::_duplicate( iobject ) ;
848 SUPERV::Graph_ptr Graph_Impl::MNode( const char * aXmlFileName ) {
849 beginService( "Graph_Impl::MNode" );
850 SUPERV::Graph_var iobject = SUPERV::Graph::_nil() ;
851 MESSAGE( "Graph_Impl::MNode( " << aXmlFileName << " )" ) ;
853 GraphBase::ListOfSGraphs aListOfDataFlows ;
855 // At first create the editor and a StreamGraph with the xml file
856 GraphEditor::DataFlow * aDataFlowEditor ;
857 CreateEditor( _Orb , instanceName() , aXmlFileName , SUPERV::DataStreamGraph ,
858 dbgfile , &aDataFlowEditor ) ;
860 if ( _DebugFileName ) {
861 delete [] _DebugFileName ;
863 _DebugFileName = new char[ strlen( dbgfile.c_str() )+1 ] ;
864 strcpy( _DebugFileName , dbgfile.c_str() ) ;
866 int lenname = strlen( aXmlFileName ) ;
867 bool loaded = false ;
868 // Import of the xml file
869 if ( lenname > 4 && !strcmp( &aXmlFileName[ lenname - 4 ] , ".xml" ) ) {
870 loaded = aDataFlowEditor->LoadXml( aXmlFileName , aListOfDataFlows ) ;
872 iobject = MNode( aDataFlowEditor , &aListOfDataFlows ) ;
879 // WARNING : THIS IS COMPLICATED :
880 // I should have to remove duplicated code ...
881 SUPERV::Graph_ptr Graph_Impl::MNode( GraphEditor::DataFlow * aMacroGraphDataFlowEditor ,
882 GraphBase::ListOfSGraphs * aListOfDataFlows ) {
883 beginService( "Graph_Impl::MNode" ) ;
884 SUPERV::Graph_var iobject = SUPERV::Graph::_nil() ;
885 SUPERV::Graph_var macroiobject = SUPERV::Graph::_nil() ;
888 MESSAGE( "Graph_Impl::MNode DataFlowEditor->LoadDataFlow" ) ;
889 // if ( !aMacroGraphDataFlowEditor->LoadDataFlow( &aListOfDataFlows[ 0 ] ) ) {
890 iobject = LoadDataFlows( aMacroGraphDataFlowEditor , aListOfDataFlows , 0 ) ;
891 if ( CORBA::is_nil( iobject ) ) {
892 MESSAGE("Graph_Impl::MNode LoadDataFlow failed" ) ;
896 // That graph is not a StreamGraph :
897 else if ( !aMacroGraphDataFlowEditor->Graph()->HasDataStream() ) {
898 aMacroGraphDataFlowEditor->Graph()->Kind( SUPERV::DataFlowGraph ) ;
899 aMacroGraphDataFlowEditor->Graph()->GraphEditor( aMacroGraphDataFlowEditor ) ;
901 Graph_Impl * myMacroGraph = (Graph_Impl * ) aMacroGraphDataFlowEditor->Graph()->ObjImpl() ;
902 // Creation of a GraphMacroNode in the current editor
903 string aMacroNodeName = string( "Macro_" ) + string( myMacroGraph->Name() ) ;
904 Graph_Impl * myMacroNode ;
905 myMacroNode = new Graph_Impl( _Orb , _Poa, _ContId,
906 instanceName() , interfaceName() ,
907 aMacroNodeName.c_str() , SUPERV::MacroNode ) ;
908 PortableServer::ObjectId * id = myMacroNode->getId() ;
909 CORBA::Object_var obj = _poa->id_to_reference(*id);
910 macroiobject = SUPERV::Graph::_narrow( obj ) ;
911 myMacroNode->DataFlowEditor( DataFlowEditor() ) ;
913 // Creation of the MacroNode itself in the current Graph
914 GraphBase::ListOfFuncName aFuncName ;
915 aFuncName.resize( 1 ) ;
917 SUPERV::ListOfStrings aListOfStrings ;
918 aListOfStrings.length( 1 ) ;
919 aListOfStrings[0] = "" ;
920 GraphBase::ListOfPythonFunctions aPythonFunction ;
921 aPythonFunction.resize( 1 ) ;
922 aPythonFunction[0] = &aListOfStrings ;
923 SALOME_ModuleCatalog::Service * aMacroNodeService = myMacroGraph->Service() ;
924 GraphEditor::InNode * aDataFlowNode = DataFlowEditor()->AddNode( *aMacroNodeService , "" , "" ,
925 aMacroNodeName.c_str() , SUPERV::MacroNode ,
926 aFuncName , aPythonFunction ) ;
927 aDataFlowNode->SetPythonFunction( "" , aListOfStrings ) ;
928 myMacroNode->DataFlowNode( aDataFlowNode ) ;
929 aDataFlowNode->ComputingNode()->SetService( *aMacroNodeService ) ;
930 aDataFlowNode->SetObjRef( SUPERV::CNode::_duplicate( SUPERV::CNode::_narrow( obj ) ) ) ;
931 aDataFlowNode->SetObjImpl( this ) ;
933 GraphBase::Graph * aGraph = myMacroGraph->DataFlowEditor()->Graph() ;
934 GraphBase::Graph * aGraphOfMacroGraph = myMacroNode->DataFlowEditor()->Graph() ;
935 GraphBase::Graph * aMacroGraph = myMacroNode->DataFlowNode()->GraphMacroNode() ;
936 aMacroGraph->Kind( SUPERV::MacroNode ) ;
937 aMacroGraph->GraphEditor( DataFlowEditor() ) ;
938 // Creation of the Ports of the MacroNode from the ports of the GraphMacroNode
939 aMacroGraph->SetMacroPorts( aGraph ) ;
940 // Valid ==> creation of Service and the ports of the current Graph
941 DataFlowEditor()->IsValid() ;
942 // Set the Input Datas from the GraphMacroNode to the current Graph
943 aMacroGraph->SetMacroDatas( aGraph , aGraphOfMacroGraph ) ;
944 aMacroGraphDataFlowEditor->UnValid() ;
945 // Set the MacroNode ObjRef in the GraphMacroNode
946 aGraph->CoupledNode( aMacroGraph ) ;
947 aGraph->MacroObject( SUPERV::Graph::_duplicate( macroiobject ) ) ;
948 // Set the GraphMacroNode ObjRef in the MacroNode
949 aDataFlowNode->GraphMacroNode()->GraphMacroLevel( aGraphOfMacroGraph->GraphMacroLevel() + 1 ) ;
950 aMacroGraph->CoupledNode( aGraph ) ;
951 // aGraphOfMacroGraph->CoupledNode( aGraph ) ;
952 aMacroGraph->MacroObject( SUPERV::Graph::_duplicate( iobject ) ) ;
953 // aGraphOfMacroGraph->MacroObject( SUPERV::Graph::_duplicate( iobject ) ) ;
954 // aDataFlowNode->CoupledNode( aGraph ) ;
955 // aDataFlowNode->ComputingNode()->MacroObject( SUPERV::Graph::_duplicate( iobject ) ) ;
956 // Set the MacroLevel of that graph
957 aGraph->GraphMacroLevel( aGraphOfMacroGraph->GraphMacroLevel() + 1 ) ;
958 aMacroGraph->Coordinates( 0 , 0 ) ;
959 MESSAGE( "DataFlowNode Graph " << this << " DataFlowEditor " << DataFlowEditor() << " aDataFlowNode "
960 << aDataFlowNode << " " << aDataFlowNode->Name() << " created" ) ;
961 MESSAGE( "MNode aGraph " << aGraph << " " << aGraph->Name()
962 << " coupled to " << aGraph->CoupledNode() << " "
963 << aGraph->CoupledNode()->Name() ) ;
964 MESSAGE( "MNode aMacroGraph " << aMacroGraph << " " << aMacroGraph->Name()
965 << " coupled to " << aMacroGraph->CoupledNode() << " "
966 << aMacroGraph->CoupledNode()->Name() ) ;
967 MESSAGE( "MNode aMacroGraph " << myMacroNode->DataFlowEditor()->Graph() << " "
968 << myMacroNode->DataFlowEditor()->Graph()->Name()
969 << " coupled to " << myMacroNode->DataFlowEditor()->Graph()->CoupledNode() ) ;
972 delete aMacroGraphDataFlowEditor ;
975 endService( "Graph_Impl::MNode" );
976 return SUPERV::Graph::_duplicate( macroiobject ) ;
979 // For python supergraph
980 SUPERV::Graph_ptr Graph_Impl::GraphMNode( SUPERV::Graph_ptr myMacroGraph ) {
981 SUPERV::Graph_var iobject = myMacroGraph ;
982 beginService( "Graph_Impl::GraphMNode" ) ;
984 // GraphBase::Graph * myMacroGraph = aGraph;
985 SUPERV::Graph_var macroiobject = SUPERV::StreamGraph::_nil() ;
986 // Creation of a GraphMacroNode in the current editor
988 string aMacroNodeName = string( "Macro_" ) + string( myMacroGraph->Name() ) ;
989 //string aMacroNodeName = string( myMacroGraph->CoupledName() ) ;
990 MESSAGE( "GraphMNode( " << myMacroGraph->Name() << " )" ) ;
991 Graph_Impl * myMacroNode ;
992 myMacroNode = new Graph_Impl( _Orb , _Poa, _ContId,
993 instanceName() , interfaceName() ,
994 aMacroNodeName.c_str() , SUPERV::MacroNode ) ;
995 PortableServer::ObjectId * id = myMacroNode->getId() ;
996 CORBA::Object_var obj = _poa->id_to_reference(*id);
997 macroiobject = SUPERV::Graph::_narrow( obj ) ;
998 myMacroNode->DataFlowEditor( DataFlowEditor() ) ;
1000 // Creation of the MacroNode itself in the current Graph
1001 GraphBase::ListOfFuncName aFuncName ;
1002 aFuncName.resize( 1 ) ;
1004 SUPERV::ListOfStrings aListOfStrings ;
1005 aListOfStrings.length( 1 ) ;
1006 aListOfStrings[0] = "" ;
1007 GraphBase::ListOfPythonFunctions aPythonFunction ;
1008 aPythonFunction.resize( 1 ) ;
1009 aPythonFunction[0] = &aListOfStrings ;
1010 SALOME_ModuleCatalog::Service * aMacroNodeService = myMacroGraph->Service() ;
1011 GraphEditor::InNode * aDataFlowNode ;
1012 aDataFlowNode = DataFlowEditor()->AddNode( *aMacroNodeService , "" , "" ,
1013 aMacroNodeName.c_str() , SUPERV::MacroNode ,
1014 aFuncName , aPythonFunction ) ;
1015 aDataFlowNode->SetPythonFunction( "" , aListOfStrings ) ;
1016 myMacroNode->DataFlowNode( aDataFlowNode ) ;
1017 aDataFlowNode->ComputingNode()->SetService( *aMacroNodeService ) ;
1018 aDataFlowNode->SetObjRef( SUPERV::CNode::_duplicate( SUPERV::CNode::_narrow( obj ) ) ) ;
1019 aDataFlowNode->SetObjImpl( this ) ;
1021 // GraphBase::Graph * aGraph = DataFlowEditor()->Automaton()->MapGraph( myMacroGraph->Name() ) ;
1022 GraphBase::Graph * aGraph ;
1023 //DataFlowEditor()->Automaton()->GraphBase( &aGraph ) ;
1024 myMacroGraph->Coupled() ;
1025 GraphBase::Graph * aGraphOfMacroGraph = myMacroNode->DataFlowEditor()->Graph() ;
1026 GraphBase::Graph * aMacroGraph = myMacroNode->DataFlowNode()->GraphMacroNode() ;
1027 aMacroGraph->Kind( SUPERV::MacroNode ) ;
1028 aMacroGraph->GraphEditor( DataFlowEditor() ) ;
1029 // Creation of the Ports of the MacroNode from the ports of the GraphMacroNode
1030 aMacroGraph->SetMacroPorts( aGraph ) ;
1031 // Valid ==> creation of Service and the ports of the current Graph
1032 DataFlowEditor()->IsValid() ;
1033 // Set the Input Datas from the GraphMacroNode to the current Graph
1034 aMacroGraph->SetMacroDatas( aGraph , aGraphOfMacroGraph ) ;
1035 // aMacroGraphDataFlowEditor->UnValid() ;
1036 aGraph->GraphEditor()->UnValid() ;
1037 // Set the MacroNode ObjRef in the GraphMacroNode
1038 aGraph->CoupledNode( aMacroGraph ) ;
1039 aGraph->MacroObject( SUPERV::Graph::_duplicate( macroiobject ) ) ;
1040 // Set the GraphMacroNode ObjRef in the MacroNode
1041 aDataFlowNode->GraphMacroNode()->GraphMacroLevel( aGraphOfMacroGraph->GraphMacroLevel() + 1 ) ;
1042 aMacroGraph->CoupledNode( aGraph ) ;
1043 aMacroGraph->MacroObject( SUPERV::Graph::_duplicate( iobject ) ) ;
1044 // aDataFlowNode->CoupledNode( aGraph ) ;
1045 // aDataFlowNode->ComputingNode()->MacroObject( SUPERV::Graph::_duplicate( iobject ) ) ;
1046 // Set the MacroLevel of that graph
1047 aGraph->GraphMacroLevel( aGraphOfMacroGraph->GraphMacroLevel() + 1 ) ;
1048 aMacroGraph->Coordinates( 0 , 0 ) ;
1049 MESSAGE( aGraph->Name() << "->CoupledNode()->GraphEditor() : " << aGraph->CoupledNode()->GraphEditor() ) ;
1050 MESSAGE( aMacroGraph->Name() << "->CoupledNode()->GraphEditor() : "
1051 << aMacroGraph->CoupledNode()->GraphEditor() ) ;
1052 MESSAGE( "DataFlowNode Graph " << this << " DataFlowEditor " << DataFlowEditor() << " aDataFlowNode "
1053 << aDataFlowNode << " " << aDataFlowNode->Name() << " created" ) ;
1055 endService( "Graph_Impl::GraphMNode" ) ;
1056 return SUPERV::Graph::_duplicate( macroiobject ) ;
1059 SUPERV::Graph_ptr Graph_Impl::FlowObjRef() {
1060 beginService( "Graph_Impl::FlowObjRef" );
1061 SUPERV::Graph_var iobject = SUPERV::Graph::_nil() ;
1063 iobject = SUPERV::Graph::_narrow( DataFlowNode()->GraphMacroNode()->MacroObject() ) ;
1065 else if ( IsGraph() ) {
1066 iobject = SUPERV::Graph::_narrow( DataFlowEditor()->Graph()->MacroObject() ) ;
1068 if ( CORBA::is_nil( iobject ) ) {
1069 MESSAGE( "Graph_Impl::FlowObjRef() returns a NIL Object" ) ;
1071 endService( "Graph_Impl::FlowObjRef" );
1072 return SUPERV::Graph::_duplicate( iobject ) ;
1075 SUPERV::StreamGraph_ptr Graph_Impl::StreamObjRef() {
1076 beginService( "Graph_Impl::StreamObjRef" );
1077 SUPERV::StreamGraph_var iobject = SUPERV::StreamGraph::_nil() ;
1079 iobject = SUPERV::StreamGraph::_narrow( DataFlowNode()->GraphMacroNode()->MacroObject() ) ;
1081 else if ( IsGraph() || IsStreamGraph() ) {
1082 iobject = SUPERV::StreamGraph::_narrow( DataFlowEditor()->Graph()->MacroObject() ) ;
1084 if ( CORBA::is_nil( iobject ) ) {
1085 MESSAGE( "Graph_Impl::StreamObjRef() returns a NIL Object" ) ;
1087 endService( "Graph_Impl::StreamObjRef" );
1088 return SUPERV::StreamGraph::_duplicate( iobject ) ;
1091 SUPERV::CNode_ptr Graph_Impl::Node(char const * aNodeName ) {
1092 // beginService( "Graph_Impl::Node" );
1093 SUPERV::CNode_var iobject = SUPERV::CNode::_nil() ;
1095 if ( CORBA::is_nil( DataFlowEditor()->GetNode( aNodeName )->ObjRef() ) ) {
1096 CNode_Impl * myNode = new CNode_Impl( _Orb , _Poa , _ContId ,
1097 instanceName() , interfaceName() ,
1099 DataFlowEditor()->GetNode( aNodeName ) ) ;
1100 PortableServer::ObjectId * id = myNode->getId() ;
1101 CORBA::Object_var obj = _poa->id_to_reference(*id);
1102 iobject = SUPERV::CNode::_narrow(obj) ;
1103 myNode->SetObjRef( SUPERV::CNode::_duplicate( iobject ) ) ;
1106 iobject = DataFlowEditor()->GetNode( aNodeName )->ObjRef() ;
1109 GraphEditor::InNode * anInNode = DataFlowEditor()->GetNode( aNodeName ) ;
1111 if ( CORBA::is_nil( anInNode->ObjRef() ) ) {
1112 SetNodeObjRef( anInNode ) ;
1114 iobject = anInNode->ObjRef() ;
1117 // endService( "Graph_Impl::Node" );
1118 return SUPERV::CNode::_duplicate( iobject ) ;
1121 SUPERV::Link_ptr Graph_Impl::Link( SUPERV::Port_ptr OutPort ,
1122 SUPERV::Port_ptr InPort ) {
1123 // beginService( "Graph_Impl::Link" );
1124 SUPERV::Link_var iobject = SUPERV::Link::_nil() ;
1125 if ( DataFlowEditor()->IsEditing() && !DataFlowEditor()->IsReadOnly() &&
1126 !OutPort->IsDataStream() && !InPort->IsDataStream() && !IsMacro() ) {
1127 MESSAGE( "Graph_Impl::Link( " << OutPort->Node()->Name() << "( " << OutPort->Name() << " ) --> "
1128 << InPort->Node()->Name() << "( " << InPort->Name() << " )" ) ;
1129 GraphEditor::InNode * anInNode = DataFlowEditor()->GetNode( InPort->Node()->Name() ) ;
1130 GraphEditor::InNode * anOutNode = DataFlowEditor()->GetNode( OutPort->Node()->Name() ) ;
1131 if ( anInNode == NULL || anOutNode== NULL ) {
1132 MESSAGE( "Graph_Impl::Link( " << OutPort->Node()->Name() << " " << anOutNode << " , "
1133 << InPort->Node()->Name() << " " << anInNode << " ) Node(s) not found in " << Name() ) ;
1136 GraphBase::InPort * anInPort = anInNode->ComputingNode()->GetChangeInPort( InPort->Name() ) ;
1137 GraphBase::OutPort * anOutPort = anOutNode->ComputingNode()->GetChangeOutPort( OutPort->Name() ) ;
1138 if ( anInPort == NULL || anOutPort== NULL ) {
1139 MESSAGE( "Graph_Impl::Link( " << OutPort->Name() << " " << anOutPort << " , "
1140 << InPort->Name() << " " << anInPort << " ) Port(s) not found" ) ;
1142 else if ( CORBA::is_nil( anOutPort->InPortObjRef( anInPort ) ) ) {
1143 const char * DataFlowOutNodeName = OutPort->Node()->Name() ;
1144 GraphEditor::InNode * DataFlowOutNode = DataFlowEditor()->GetNode( DataFlowOutNodeName ) ;
1145 const char * DataFlowInNodeName = InPort->Node()->Name() ;
1146 GraphEditor::InNode * DataFlowInNode = DataFlowEditor()->GetNode( DataFlowInNodeName ) ;
1147 if ( DataFlowOutNode && DataFlowInNode ) {
1149 Link_Impl * myLink = new Link_Impl( _Orb , _Poa , _ContId ,
1150 instanceName() , interfaceName() ,
1156 true , false , Success ) ;
1158 PortableServer::ObjectId * id = myLink->getId() ;
1159 CORBA::Object_var obj = _poa->id_to_reference(*id);
1160 iobject = SUPERV::Link::_narrow(obj) ;
1161 anOutPort->AddInPortObjRef( anInPort , SUPERV::Link::_duplicate( iobject ) ) ;
1166 iobject = anOutPort->InPortObjRef( anInPort ) ;
1170 DataFlowEditor()->UnValid() ;
1171 // endService( "Graph_Impl::Link" );
1172 return SUPERV::Link::_duplicate( iobject ) ;
1175 // Only to see MacroNodes with actual GUI ... :
1176 #define GOTOMacroNode 0
1178 void Graph_Impl::SetNodeObjRef( GraphEditor::InNode * anInNode ) {
1179 MESSAGE("Graph_Impl::SetNodeObjRef " << anInNode->Name() << " " << anInNode->Kind() ) ;
1180 CORBA::Object_var obj ;
1181 if ( anInNode->IsComputingNode() ) {
1182 CNode_Impl * myNode = new CNode_Impl( _Orb , _Poa , _ContId ,
1183 instanceName() , interfaceName() ,
1186 PortableServer::ObjectId * id = myNode->getId() ;
1187 obj = _poa->id_to_reference(*id);
1188 SUPERV::CNode_var iobject = SUPERV::CNode::_narrow(obj) ;
1189 myNode->SetObjRef( SUPERV::CNode::_duplicate( iobject ) ) ;
1191 else if ( anInNode->IsFactoryNode() ) {
1192 FNode_Impl * myNode = new FNode_Impl( _Orb , _Poa , _ContId ,
1193 instanceName() , interfaceName() ,
1196 PortableServer::ObjectId * id = myNode->getId() ;
1197 obj = _poa->id_to_reference(*id);
1198 SUPERV::FNode_var iobject = SUPERV::FNode::_narrow(obj) ;
1199 myNode->SetObjRef( SUPERV::FNode::_duplicate( iobject ) ) ;
1201 else if ( anInNode->IsInLineNode() ) {
1202 INode_Impl * myNode = new INode_Impl( _Orb , _Poa , _ContId ,
1203 instanceName() , interfaceName() ,
1206 PortableServer::ObjectId * id = myNode->getId() ;
1207 obj = _poa->id_to_reference(*id);
1208 SUPERV::INode_var iobject = SUPERV::INode::_narrow(obj) ;
1209 myNode->SetObjRef( SUPERV::INode::_duplicate( iobject ) ) ;
1212 else if ( anInNode->IsGOTONode() || anInNode->IsMacroNode() ) {
1213 if ( anInNode->IsMacroNode() ) {
1214 anInNode->ComputingNode()->Kind( SUPERV::GOTONode ) ;
1217 else if ( anInNode->IsGOTONode() ) {
1219 GNode_Impl * myNode = new GNode_Impl( _Orb , _Poa , _ContId ,
1220 instanceName() , interfaceName() ,
1223 PortableServer::ObjectId * id = myNode->getId() ;
1224 obj = _poa->id_to_reference(*id);
1225 SUPERV::GNode_var iobject = SUPERV::GNode::_narrow(obj) ;
1226 myNode->SetObjRef( SUPERV::GNode::_duplicate( iobject ) ) ;
1228 else if ( anInNode->IsMacroNode() ) {
1229 Graph_Impl * myNode = new Graph_Impl( _Orb , _Poa , _ContId ,
1230 instanceName() , interfaceName() ,
1233 PortableServer::ObjectId * id = myNode->getId() ;
1234 obj = _poa->id_to_reference(*id);
1235 SUPERV::Graph_var iobject = SUPERV::Graph::_narrow(obj) ;
1236 myNode->SetObjRef( SUPERV::Graph::_duplicate( iobject ) ) ;
1238 else if ( anInNode->IsLoopNode() ) {
1239 LNode_Impl * myNode = new LNode_Impl( _Orb , _Poa , _ContId ,
1240 instanceName() , interfaceName() ,
1243 PortableServer::ObjectId * id = myNode->getId() ;
1244 obj = _poa->id_to_reference(*id);
1245 SUPERV::LNode_var iobject = SUPERV::LNode::_narrow(obj) ;
1246 myNode->SetObjRef( SUPERV::LNode::_duplicate( iobject ) ) ;
1248 else if ( anInNode->IsEndLoopNode() ) {
1249 ELNode_Impl * myNode = new ELNode_Impl( _Orb , _Poa , _ContId ,
1250 instanceName() , interfaceName() ,
1253 PortableServer::ObjectId * id = myNode->getId() ;
1254 obj = _poa->id_to_reference(*id);
1255 SUPERV::ELNode_var iobject = SUPERV::ELNode::_narrow(obj) ;
1256 myNode->SetObjRef( SUPERV::ELNode::_duplicate( iobject ) ) ;
1258 else if ( anInNode->IsSwitchNode() ) {
1259 SNode_Impl * myNode = new SNode_Impl( _Orb , _Poa , _ContId ,
1260 instanceName() , interfaceName() ,
1263 PortableServer::ObjectId * id = myNode->getId() ;
1264 obj = _poa->id_to_reference(*id);
1265 SUPERV::SNode_var iobject = SUPERV::SNode::_narrow(obj) ;
1266 myNode->SetObjRef( SUPERV::SNode::_duplicate( iobject ) ) ;
1268 else if ( anInNode->IsEndSwitchNode() ) {
1269 ESNode_Impl * myNode = new ESNode_Impl( _Orb , _Poa , _ContId ,
1270 instanceName() , interfaceName() ,
1273 PortableServer::ObjectId * id = myNode->getId() ;
1274 obj = _poa->id_to_reference(*id);
1275 SUPERV::ESNode_var iobject = SUPERV::ESNode::_narrow(obj) ;
1276 myNode->SetObjRef( SUPERV::ESNode::_duplicate( iobject ) ) ;
1280 SUPERV::ListOfNodes_var Graph_Impl::SetNode( SUPERV::ListOfNodes_var RetVal ,
1281 GraphBase::ComputingNode * aNode ) {
1283 // if ( _DataFlowExecutor ) {
1284 if ( DataFlowExecutor() ) {
1285 MESSAGE("Graph_Impl::SetNode " << aNode->Name() << " " << aNode->Kind() << " "
1286 << DataFlowExecutor()->StateName( DataFlowExecutor()->AutomatonState( aNode->Name() ) ) ) ;
1289 MESSAGE("Graph_Impl::SetNode " << aNode->Name() << " " << aNode->Kind() ) ;
1291 if ( aNode->IsComputingNode() ) {
1292 index = RetVal->CNodes.length() ;
1293 RetVal->CNodes.length( index+1 );
1295 else if ( aNode->IsFactoryNode() ) {
1296 index = RetVal->FNodes.length() ;
1297 RetVal->FNodes.length( index+1 );
1299 else if ( aNode->IsInLineNode() ) {
1300 index = RetVal->INodes.length() ;
1301 RetVal->INodes.length( index+1 );
1304 else if ( aNode->IsGOTONode() || aNode->IsMacroNode() ) {
1306 else if ( aNode->IsGOTONode() ) {
1308 index = RetVal->GNodes.length() ;
1309 RetVal->GNodes.length( index+1 );
1311 else if ( aNode->IsMacroNode() ) {
1312 index = RetVal->Graphs.length() ;
1313 RetVal->Graphs.length( index+1 );
1315 else if ( aNode->IsLoopNode() ) {
1316 index = RetVal->LNodes.length() ;
1317 RetVal->LNodes.length( index+1 );
1319 else if ( aNode->IsEndLoopNode() ) {
1320 index = RetVal->ELNodes.length() ;
1321 RetVal->ELNodes.length( index+1 );
1323 else if ( aNode->IsSwitchNode() ) {
1324 index = RetVal->SNodes.length() ;
1325 RetVal->SNodes.length( index+1 );
1327 else if ( aNode->IsEndSwitchNode() ) {
1328 index = RetVal->ESNodes.length() ;
1329 RetVal->ESNodes.length( index+1 );
1331 if ( CORBA::is_nil( aNode->ObjRef() ) ) {
1332 SetNodeObjRef( (GraphEditor::InNode * ) aNode->GetInNode() ) ;
1334 SUPERV::CNode_var aNodeObjRef = aNode->ObjRef() ;
1335 if ( aNode->IsComputingNode() ) {
1336 RetVal->CNodes[index] = SUPERV::CNode::_duplicate( aNodeObjRef ) ;
1338 else if ( aNode->IsFactoryNode() ) {
1339 RetVal->FNodes[index] = SUPERV::FNode::_duplicate( SUPERV::FNode::_narrow( aNodeObjRef ) ) ;
1341 else if ( aNode->IsInLineNode() ) {
1342 RetVal->INodes[index] = SUPERV::INode::_duplicate( SUPERV::INode::_narrow( aNodeObjRef ) ) ;
1345 else if ( aNode->IsGOTONode() || aNode->IsMacroNode() ) {
1347 else if ( aNode->IsGOTONode() ) {
1349 RetVal->GNodes[index] = SUPERV::GNode::_duplicate( SUPERV::GNode::_narrow( aNodeObjRef ) ) ;
1351 else if ( aNode->IsMacroNode() ) {
1352 RetVal->Graphs[index] = SUPERV::Graph::_duplicate( SUPERV::Graph::_narrow( aNodeObjRef ) ) ;
1354 else if ( aNode->IsLoopNode() ) {
1355 RetVal->LNodes[index] = SUPERV::LNode::_duplicate( SUPERV::LNode::_narrow( aNodeObjRef ) ) ;
1357 else if ( aNode->IsEndLoopNode() ) {
1358 RetVal->ELNodes[index] = SUPERV::ELNode::_duplicate( SUPERV::ELNode::_narrow( aNodeObjRef ) ) ;
1360 else if ( aNode->IsSwitchNode() ) {
1361 RetVal->SNodes[index] = SUPERV::SNode::_duplicate( SUPERV::SNode::_narrow( aNodeObjRef ) ) ;
1363 else if ( aNode->IsEndSwitchNode() ) {
1364 RetVal->ESNodes[index] = SUPERV::ESNode::_duplicate( SUPERV::ESNode::_narrow( aNodeObjRef ) ) ;
1366 return ( RetVal._retn() ) ;
1369 SUPERV::ListOfNodes * Graph_Impl::Nodes() {
1370 SUPERV::ListOfNodes_var RetVal = new SUPERV::ListOfNodes;
1371 beginService( "Graph_Impl::Nodes" );
1372 RetVal->CNodes.length(0) ;
1373 RetVal->FNodes.length(0) ;
1374 RetVal->INodes.length(0) ;
1375 RetVal->LNodes.length(0) ;
1376 RetVal->SNodes.length(0) ;
1377 RetVal->GNodes.length(0) ;
1378 RetVal->Graphs.length(0) ;
1381 for ( i = 0 ; i < DataFlowEditor()->Graph()->GraphNodesSize() ; i++ ) {
1382 GraphBase::ComputingNode * aNode = DataFlowEditor()->Graph()->GraphNodes( i ) ;
1383 RetVal = SetNode( RetVal , aNode ) ;
1386 char * aStateG = "" ;
1387 if ( DataFlowExecutor() ) {
1388 aStateG = (char *) DataFlowExecutor()->StateName( DataFlowExecutor()->AutomatonState() ) ;
1390 MESSAGE("Graph_Impl::Nodes GraphState " << aStateG << " CNodes " << RetVal->CNodes.length() ) ;
1391 for ( i = 0 ; i < RetVal->CNodes.length() ; i++ ) {
1392 MESSAGE(" " << RetVal->CNodes[ i ] ->Name() ) ;
1394 MESSAGE("FNodes " << RetVal->FNodes.length() ) ;
1395 for ( i = 0 ; i < RetVal->FNodes.length() ; i++ ) {
1396 MESSAGE(" " << RetVal->FNodes[ i ] ->Name() ) ;
1398 MESSAGE("INodes " << RetVal->INodes.length() ) ;
1399 for ( i = 0 ; i < RetVal->INodes.length() ; i++ ) {
1400 MESSAGE(" " << RetVal->INodes[ i ] ->Name() ) ;
1402 MESSAGE("GNodes " << RetVal->GNodes.length() ) ;
1403 for ( i = 0 ; i < RetVal->GNodes.length() ; i++ ) {
1404 MESSAGE(" " << RetVal->GNodes[ i ] ->Name() ) ;
1406 MESSAGE("LNodes " << RetVal->LNodes.length() ) ;
1407 for ( i = 0 ; i < RetVal->LNodes.length() ; i++ ) {
1408 MESSAGE(" " << RetVal->LNodes[ i ] ->Name() ) ;
1410 MESSAGE("ELNodes " << RetVal->ELNodes.length() ) ;
1411 for ( i = 0 ; i < RetVal->ELNodes.length() ; i++ ) {
1412 MESSAGE(" " << RetVal->ELNodes[ i ] ->Name() ) ;
1414 MESSAGE("SNodes " << RetVal->SNodes.length() ) ;
1415 for ( i = 0 ; i < RetVal->SNodes.length() ; i++ ) {
1416 MESSAGE(" " << RetVal->SNodes[ i ] ->Name() ) ;
1418 MESSAGE("ESNodes " << RetVal->ESNodes.length() ) ;
1419 for ( i = 0 ; i < RetVal->ESNodes.length() ; i++ ) {
1420 MESSAGE(" " << RetVal->ESNodes[ i ] ->Name() ) ;
1422 MESSAGE("Graphs " << RetVal->Graphs.length() ) ;
1423 for ( i = 0 ; i < RetVal->Graphs.length() ; i++ ) {
1424 MESSAGE(" " << RetVal->Graphs[ i ] ->Name() ) ;
1426 if ( DataFlowExecutor() ) {
1427 DataFlowExecutor()->EventList() ;
1431 endService( "Graph_Impl::Nodes" );
1432 return ( RetVal._retn() ) ;
1435 SUPERV::ListOfLinks * Graph_Impl::GLinks() {
1436 return Links( NULL , NULL ) ;
1439 SUPERV::ListOfLinks * Graph_Impl::Links( GraphBase::ComputingNode * theNode ,
1440 const char * anInputParam ) {
1442 SUPERV::ListOfLinks_var RetVal = new SUPERV::ListOfLinks ;
1443 RetVal->length( 0 ) ;
1445 int i , j , countlink ;
1447 for ( i = 0 ; i < DataFlowEditor()->Graph()->GraphNodesSize() ; i++ ) {
1448 GraphEditor::InNode * aNode = NULL ;
1449 aNode = (GraphEditor::InNode * ) DataFlowEditor()->Graph()->GraphNodes( i )->GetInNode() ;
1450 bool ToProcess = false ;
1451 if ( theNode == NULL ) {
1455 if ( !strcmp( theNode->Name() , aNode->Name() ) ) {
1456 if ( !theNode->IsEndSwitchNode() ) {
1460 else if ( theNode->IsEndSwitchNode() ) {
1465 for ( j = 0 ; j < aNode->GetNodeInPortsSize() ; j++ ) {
1466 GraphBase::InPort * anInPort = NULL ;
1467 anInPort = aNode->GetChangeNodeInPort( j ) ;
1468 if ( anInputParam == NULL ||
1469 !strcmp( anInPort->PortName() , anInputParam ) ) {
1470 GraphBase::OutPort * anOutPort = NULL ;
1471 anOutPort = anInPort->GetOutPort() ;
1472 if ( anOutPort && !anOutPort->IsDataStream() ) {
1473 if ( strcmp( anOutPort->NodeName() , Name() ) ) {
1474 // MESSAGE("Graph_Impl::Links " << anOutPort->NodeName() << "("
1475 // << anOutPort->PortName() << ") --> " << aNode->Name() << "("
1476 // << anInPort->PortName() << ")" ) ;
1477 if ( theNode == NULL ||
1478 ( theNode != NULL && !theNode->IsEndSwitchNode() &&
1479 !strcmp( theNode->Name() , aNode->Name() ) ) ) {
1480 if ( anInPort->IsLoop() || anOutPort->IsLoop() ||
1481 ( aNode->IsEndLoopNode() && !strcmp( aNode->CoupledNode()->Name() ,
1482 anOutPort->NodeName() ) ) ) {
1483 // MESSAGE( "Link " << anOutPort->NodeName() << "("
1484 // << anOutPort->PortName() << ") --> " << aNode->Name() << "("
1485 // << anInPort->PortName() << ")" << " ignored" ) ;
1487 else if ( CORBA::is_nil( anOutPort->InPortObjRef( anInPort ) ) ) {
1489 beginService( "Graph_Impl::Links" );
1492 GraphEditor::InNode * anOutNode = NULL ;
1493 anOutNode = (GraphEditor::InNode * ) DataFlowEditor()->Graph()->GetChangeGraphNode( anOutPort->NodeName() )->GetInNode() ;
1496 Link_Impl * myLink = new Link_Impl( _Orb , _Poa , _ContId ,
1497 instanceName() , interfaceName() ,
1500 anInPort->PortName() ,
1502 anOutPort->PortName() ,
1503 false , true , Success ) ;
1505 PortableServer::ObjectId * id = myLink->getId() ;
1506 CORBA::Object_var obj = _poa->id_to_reference(*id);
1507 SUPERV::Link_var iobject ;
1508 iobject = SUPERV::Link::_narrow(obj) ;
1509 RetVal->length( countlink + 1 ) ;
1510 RetVal[ countlink++ ] = SUPERV::Link::_duplicate( iobject ) ;
1511 anOutPort->AddInPortObjRef( anInPort , SUPERV::Link::_duplicate( iobject ) ) ;
1516 RetVal->length( countlink + 1 ) ;
1517 RetVal[ countlink++ ] = SUPERV::Link::_duplicate( anOutPort->InPortObjRef( anInPort ) ) ;
1519 // MESSAGE( "Link " << anOutPort->NodeName() << "("
1520 // << anOutPort->PortName() << ") --> " << aNode->Name() << "("
1521 // << anInPort->PortName() << ")" << " selected" ) ;
1524 // MESSAGE( "Link " << anOutPort->NodeName() << "("
1525 // << anOutPort->PortName() << ") --> " << aNode->Name() << "("
1526 // << anInPort->PortName() << ")" << " skipped" ) ;
1533 for ( j = 0 ; j < aNode->GetNodeOutPortsSize() ; j++ ) {
1534 GraphBase::OutPort * anOutPort = aNode->GetChangeNodeOutPort( j ) ;
1535 // MESSAGE( "Graph_Impl::Links " << aNode->Name() << " Out" << j << " " << anOutPort->PortName() << " "
1536 // << anOutPort->PortStatus() << " PortConnected to " << anOutPort->InPortsSize() << " InPorts" ) ;
1538 for ( k = 0 ; k < anOutPort->InPortsSize() ; k++ ) {
1539 GraphBase::InPort * anInPort = anOutPort->ChangeInPorts( k ) ;
1540 // MESSAGE( " --> In" << k << " " << anInPort->NodeName() << " " << anInPort->PortName()
1541 // << " " << anInPort->PortStatus() ) ;
1542 if ( anInPort->IsPortConnected() ) {
1543 GraphBase::ComputingNode * aComputingNode = DataFlowEditor()->Graph()->GetChangeGraphNode( anInPort->NodeName() ) ;
1544 GraphEditor::InNode * toNode = (GraphEditor::InNode * ) aComputingNode->GetInNode() ;
1545 if ( theNode == NULL ||
1546 !strcmp( theNode->Name() , aNode->Name() ) ) {
1547 if ( !anInPort->IsDataStream() ) {
1548 if ( theNode || ( toNode->IsEndSwitchNode() && !aNode->IsSwitchNode() ) ) {
1549 if ( anInputParam == NULL ||
1550 !strcmp( anInPort->PortName() , anInputParam ) ) {
1551 if ( anInPort->IsLoop() || anOutPort->IsLoop() ||
1552 ( toNode->IsEndLoopNode() && !strcmp( toNode->CoupledNode()->Name() ,
1553 anOutPort->NodeName() ) ) ) {
1554 // MESSAGE( "Link " << anOutPort->NodeName() << "("
1555 // << anOutPort->PortName() << ") --> " << toNode->Name() << "("
1556 // << anInPort->PortName() << ")" << " ignored" ) ;
1558 else if ( CORBA::is_nil( anOutPort->InPortObjRef( anInPort ) ) ) {
1560 beginService( "Graph_Impl::Links" );
1564 Link_Impl * myLink = new Link_Impl( _Orb , _Poa , _ContId ,
1565 instanceName() , interfaceName() ,
1568 anInPort->PortName() ,
1570 anOutPort->PortName() ,
1571 false , true , Success ) ;
1573 PortableServer::ObjectId * id = myLink->getId() ;
1574 CORBA::Object_var obj = _poa->id_to_reference(*id);
1575 SUPERV::Link_var iobject ;
1576 iobject = SUPERV::Link::_narrow(obj) ;
1577 RetVal->length( countlink + 1 ) ;
1578 RetVal[ countlink++ ] = SUPERV::Link::_duplicate( iobject ) ;
1579 anOutPort->AddInPortObjRef( anInPort , SUPERV::Link::_duplicate( iobject ) ) ;
1583 RetVal->length( countlink + 1 ) ;
1584 RetVal[ countlink++ ] = SUPERV::Link::_duplicate( SUPERV::Link::_narrow( anOutPort->InPortObjRef( anInPort ) ) ) ;
1586 // MESSAGE( "Link " << anOutPort->NodeName() << "("
1587 // << anOutPort->PortName() << ") --> " << toNode->Name() << "("
1588 // << anInPort->PortName() << ")" << " selected" ) ;
1591 // MESSAGE( "Link " << anOutPort->NodeName() << "("
1592 // << anOutPort->PortName() << ") --> " << toNode->Name() << "("
1593 // << anInPort->PortName() << ")" << " skipped" ) ;
1604 const char * NodeName = "" ;
1605 const char * InputParamName = "" ;
1607 NodeName = theNode->Name() ;
1609 if ( anInputParam ) {
1610 InputParamName = anInputParam ;
1612 MESSAGE( RetVal->length() << " Links of Node " << NodeName << " and of InPort " << InputParamName ) ;
1613 for ( i = 0 ; i < (int ) RetVal->length() ; i++ ) {
1614 MESSAGE( "Link " << RetVal[i]->OutPort()->Node()->Name() << "("
1615 << RetVal[i]->OutPort()->Name() << ") --> "
1616 << RetVal[i]->InPort()->Node()->Name() << "("
1617 << RetVal[i]->InPort()->Name() << ")" ) ;
1621 endService( "Graph_Impl::Links" );
1624 return ( RetVal._retn() ) ;
1627 Engines::Component_ptr Graph_Impl::ComponentRef( const char * aComputerContainer ,
1628 const char * aComponentName ) {
1629 Engines::Component_var objComponent = Engines::Component::_nil() ;
1631 Engines::Container_var myContainer ;
1632 DataFlowEditor()->Graph()->StartComponent( 0 , aComputerContainer , aComponentName ,
1633 myContainer , objComponent ) ;
1635 return Engines::Component::_duplicate( objComponent ) ;
1638 bool Graph_Impl::IsValid() {
1639 // beginService( "Graph_Impl::IsValid" );
1640 bool RetVal = false ;
1642 RetVal = DataFlowEditor()->IsValid() ;
1644 // endService( "Graph_Impl::IsValid" );
1647 bool Graph_Impl::IsExecutable() {
1648 // beginService( "Graph_Impl::IsExecutable" );
1649 bool RetVal = false ;
1651 // asv : 15.11.04 : added "&& GraphMacroLevel() == 0" ->
1652 // subgraphs are not executable by themselves, RetVal = false..
1653 if ( !IsMacro() && DataFlowEditor()->Graph()->GraphMacroLevel() == 0 ) {
1654 RetVal = DataFlowEditor()->IsExecutable() ;
1656 // endService( "Graph_Impl::IsExecutable" );
1660 bool Graph_Impl::IsEditing() {
1662 bool RetVal = false ;
1664 RetVal = DataFlowEditor()->IsEditing() ;
1670 return !IsExecuting();
1673 bool Graph_Impl::IsExecuting() {
1675 bool RetVal = false ;
1677 RetVal = !DataFlowEditor()->IsEditing() ;
1681 return CNode_Impl::IsExecuting();
1684 bool Graph_Impl::IsReadOnly() {
1685 // beginService( "Graph_Impl::IsExecuting" );
1686 bool RetVal = false ;
1688 RetVal = DataFlowEditor()->IsReadOnly() ;
1690 // endService( "Graph_Impl::IsExecuting" );
1694 long Graph_Impl::LevelMax() {
1695 // beginService( "Graph_Impl::LevelMax" );
1698 RetVal = DataFlowEditor()->LevelMax() ;
1700 // endService( "Graph_Impl::LevelMax" );
1703 SUPERV::ListOfNodes * Graph_Impl::LevelNodes(long aLevel ) {
1704 // beginService( "Graph_Impl::LevelNodes" );
1705 SUPERV::ListOfNodes_var RetVal = new SUPERV::ListOfNodes;
1708 SUPERV::ListOfStrings_var Nodes = DataFlowEditor()->LevelNodes( aLevel ) ;
1709 // RetVal->length( Nodes->length() );
1710 for ( i = 0 ; i < (int ) Nodes->length() ; i++ ) {
1711 // char * aNode = Nodes[ i ] ;
1712 GraphBase::ComputingNode * aNode = DataFlowEditor()->Graph()->GetChangeGraphNode( Nodes[ i ] ) ;
1713 RetVal = SetNode( RetVal , aNode ) ;
1714 // cout << "Graph_Impl::LevelNodes( " << aLevel << " ) " << aNode->Name() << endl ;
1715 // CNode_Impl * myNode = new CNode_Impl( _Orb , _Poa , _ContId ,
1716 // instanceName() , interfaceName() ,
1717 // DataFlowEditor() ,
1718 // (GraphEditor::InNode * ) DataFlowEditor()->GetChangeGraphNode( aNode )->GetInNode() ) ;
1719 // PortableServer::ObjectId * id = myNode->getId() ;
1720 // CORBA::Object_var obj = _poa->id_to_reference(*id);
1721 // SUPERV::CNode_var iobject ;
1722 // iobject = SUPERV::CNode::_narrow(obj) ;
1723 // RetVal[i] = SUPERV::CNode::_duplicate( iobject ) ;
1726 // endService( "Graph_Impl::LevelNodes" );
1727 return ( RetVal._retn() ) ;
1729 long Graph_Impl::ThreadsMax() {
1730 // beginService( "Graph_Impl::ThreadsMax" );
1733 RetVal = DataFlowEditor()->ThreadsMax() ;
1735 // endService( "Graph_Impl::ThreadsMax" );
1738 long Graph_Impl::Threads() {
1739 // beginService( "Node_Impl::Threads" );
1740 long RetVal = false ;
1742 RetVal = DataFlowExecutor()->Threads() ;
1744 // endService( "Node_Impl::Threads" );
1747 long Graph_Impl::SuspendedThreads() {
1748 // beginService( "Node_Impl::SuspendedThreads" );
1749 long RetVal = false ;
1751 RetVal = DataFlowExecutor()->SuspendedThreads() ;
1753 // endService( "Node_Impl::SuspendedThreads" );
1757 bool Graph_Impl::Begin() {
1758 bool RetVal = false ;
1759 if ( DataFlowEditor()->IsEditing() ) {
1760 if ( pthread_mutex_lock( &_MutexExecutorWait ) ) {
1761 perror("pthread_mutex_lock _MutexExecutorWait") ;
1764 if ( DataFlowExecutor() ) {
1765 MESSAGE( "Graph_Impl::Begin " << DataFlowExecutor()->Threads() << " threads" )
1766 Editing(); // just in case it was not called before by GUI..
1768 if ( DataFlowEditor()->IsExecutable() ) {
1769 DataFlowEditor()->EditedAfterExecution( false ) ;
1770 GraphBase::ListOfSGraphs * myListOfGraphs = DataFlowEditor()->GetDataFlows() ;
1772 GraphExecutor::DataFlow * aDataFlowExecutor ;
1774 CreateExecutor( _Orb , instanceName() , (*myListOfGraphs)[ 0 ].Info.theName.c_str() , Kind() ,
1775 dbgfile , &aDataFlowExecutor ) ;
1777 MESSAGE( "Graph_Impl::Begin : DataFlowExecutor created" );
1778 if ( !CORBA::is_nil( LoadDataFlows( aDataFlowExecutor, myListOfGraphs , 0 ) ) )
1782 DataFlowExecutor()->Graph()->SetObjImpl( DataFlowEditor()->Graph()->ObjImpl() ) ;
1785 if ( pthread_mutex_unlock( &_MutexExecutorWait ) ) {
1786 perror("pthread_mutex_unlock _MutexExecutorWait") ;
1794 * run() : was created in order to reduce code dublication, Run() and Start() do the same thing
1795 * except for final call to Executor->Run( bool ) - Run() calls with AndSuspend=false
1796 * and Start() calls with AndSuspend=true flag. The rest of the actions are the same:
1797 * 1. if a MacroNode's coupled graph (MacroLevel>0) -> simply Run() it.
1798 * 2. if a Supergraph -> create executor, load dataflow in it (done in Begin()), then - Run() it.
1800 bool Graph_Impl::run( const bool andSuspend ) {
1801 bool RetVal = false ;
1803 // if Editing or Finished state, and, naturally, 'this' is not a MacroNode.
1804 if ( ( DataFlowEditor()->IsEditing() || IsDone() ) && !IsMacro() ) {
1806 if ( DataFlowEditor()->Graph()->GraphMacroLevel() ) {
1807 // MacroGraph's Executor was created in recursive function LoadDataflows(Executor), called from
1808 // Begin() of Supergraph. See Begin() and LoadDataflows(Executor) for details.
1812 // Create Executor instance and its datamodel
1816 // Set Executing flag to avoid edition operations during execution, EditedAfterExecution=false
1817 DataFlowEditor()->Executing() ;
1818 DataFlowEditor()->EditedAfterExecution( false );
1820 // THE MAIN RUN METHOD
1821 RetVal = DataFlowExecutor()->Run( andSuspend );
1829 * Run() - called on "Execute" command
1831 bool Graph_Impl::Run() {
1832 beginService( "Graph_Impl::Run" );
1833 bool RetVal = run( /*andSuspend=*/false ) ;
1834 MESSAGE( "Graph_Impl::Run " << DataFlowEditor()->Graph()->Name() << " RetVal " << RetVal ) ;
1835 endService( "Graph_Impl::Run" );
1840 * Run() - called on "Execute step-by-step" command
1842 bool Graph_Impl::Start() {
1843 beginService( "Graph_Impl::Start" );
1844 bool RetVal = run( /*andSuspend=*/true ) ;
1845 MESSAGE( "Graph_Impl::Start " << DataFlowEditor()->Graph()->Name() << " RetVal " << RetVal ) ;
1846 endService( "Graph_Impl::Start" );
1850 bool Graph_Impl::EventNoW( SUPERV::CNode_out aNode ,
1851 SUPERV::GraphEvent & anEvent ,
1852 SUPERV::GraphState & aState ) {
1853 bool RetVal = false ;
1854 char * aNodeName = NULL ;
1855 SUPERV::GraphEvent theEvent = SUPERV::UndefinedEvent ;
1856 SUPERV::GraphState theState = SUPERV::UndefinedState ;
1857 if ( pthread_mutex_lock( &_MutexExecutorWait ) ) {
1858 perror("pthread_mutex_lock _MutexExecutorWait") ;
1861 if ( DataFlowExecutor() && !IsMacro() &&
1862 ( DataFlowExecutor()->GetListSize() || !DataFlowEditor()->IsEditing() ) ) {
1863 RetVal = DataFlowExecutor()->Event( & aNodeName , theEvent , theState , false ) ;
1864 // endService( "Graph_Impl::Event" );
1865 if ( strlen( aNodeName ) ) {
1866 if ( strcmp( aNodeName , Name() ) ) {
1867 aNode = Node( aNodeName ) ;
1874 aNode = SUPERV::Graph::_duplicate( SUPERV::Graph::_nil() ) ;
1876 // cout << "Graph_Impl::EventNoW " << aNode->Name() << " QSize " << DataFlowExecutor()->GetListSize() << endl ;
1879 // cout << "Graph_Impl::EventNoW NO DataFlowExecutor() or QSize=0 " << endl ;
1881 if ( pthread_mutex_unlock( &_MutexExecutorWait ) ) {
1882 perror("pthread_mutex_unlock _MutexExecutorWait") ;
1885 anEvent = theEvent ;
1890 bool Graph_Impl::Event( SUPERV::CNode_out aNode ,
1891 SUPERV::GraphEvent & anEvent ,
1892 SUPERV::GraphState & aState ) {
1893 // beginService( "Graph_Impl::Event" );
1894 bool RetVal = false ;
1895 char * aNodeName = NULL ;
1896 SUPERV::GraphEvent theEvent = SUPERV::UndefinedEvent ;
1897 SUPERV::GraphState theState = SUPERV::UndefinedState ;
1898 if ( pthread_mutex_lock( &_MutexExecutorWait ) ) {
1899 perror("pthread_mutex_lock _MutexExecutorWait") ;
1902 if ( DataFlowExecutor() && !IsMacro() &&
1903 ( DataFlowExecutor()->GetListSize() || !DataFlowEditor()->IsEditing() ) ){
1904 RetVal = DataFlowExecutor()->Event( & aNodeName , theEvent , theState ) ;
1905 // endService( "Graph_Impl::Event" );
1906 if ( strlen( aNodeName ) ) {
1907 if ( strcmp( aNodeName , Name() ) ) {
1908 aNode = Node( aNodeName ) ;
1915 aNode = SUPERV::Graph::_duplicate( SUPERV::Graph::_nil() ) ;
1917 // cout << "Graph_Impl::Event " << aNode->Name() << " QSize " << DataFlowExecutor()->GetListSize() << endl ;
1920 // cout << "Graph_Impl::Event NO DataFlowExecutor() or QSize=0 " << endl ;
1922 if ( pthread_mutex_unlock( &_MutexExecutorWait ) ) {
1923 perror("pthread_mutex_unlock _MutexExecutorWait") ;
1926 anEvent = theEvent ;
1932 bool Graph_Impl::EventW( SUPERV::CNode_out aNode ,
1933 SUPERV::GraphEvent & anEvent ,
1934 SUPERV::GraphState & aState ) {
1935 // beginService( "Graph_Impl::EventW" );
1936 bool RetVal = false ;
1937 char * aNodeName = NULL ;
1938 SUPERV::GraphEvent theEvent = SUPERV::UndefinedEvent ;
1939 SUPERV::GraphState theState = SUPERV::UndefinedState ;
1940 if ( pthread_mutex_lock( &_MutexExecutorWait ) ) {
1941 perror("pthread_mutex_lock _MutexExecutorWait") ;
1944 if ( DataFlowExecutor() && !IsMacro() &&
1945 ( DataFlowExecutor()->GetListSize() || !DataFlowEditor()->IsEditing() ) ) {
1946 RetVal = DataFlowExecutor()->EventW( & aNodeName , theEvent , theState ) ;
1947 if ( RetVal && strcmp( aNodeName , Name() ) ) {
1948 aNode = Node( aNodeName ) ;
1954 if ( pthread_mutex_unlock( &_MutexExecutorWait ) ) {
1955 perror("pthread_mutex_unlock _MutexExecutorWait") ;
1958 anEvent = theEvent ;
1960 // endService( "Graph_Impl::EventW" );
1964 long Graph_Impl::EventQSize() {
1965 // beginService( "Graph_Impl::EventQSize" );
1967 if ( pthread_mutex_lock( &_MutexExecutorWait ) ) {
1968 perror("pthread_mutex_lock _MutexExecutorWait") ;
1971 if ( DataFlowExecutor() && !IsMacro() ) {
1972 QSize = DataFlowExecutor()->EventQSize() ;
1974 if ( pthread_mutex_unlock( &_MutexExecutorWait ) ) {
1975 perror("pthread_mutex_unlock _MutexExecutorWait") ;
1978 // endService( "Graph_Impl::EventQSize" );
1982 long Graph_Impl::LastLevelDone() {
1983 // beginService( "Graph_Impl::LastLevelDone" );
1984 if ( pthread_mutex_lock( &_MutexExecutorWait ) ) {
1985 perror("pthread_mutex_lock _MutexExecutorWait") ;
1989 if ( DataFlowExecutor() && !IsMacro() ) {
1990 RetVal = DataFlowExecutor()->LastLevelDone() ;
1992 if ( pthread_mutex_unlock( &_MutexExecutorWait ) ) {
1993 perror("pthread_mutex_unlock _MutexExecutorWait") ;
1996 // endService( "Graph_Impl::LastLevelDone" );
2000 long Graph_Impl::SubGraphsNumber() {
2001 // beginService( "Graph_Impl::SubGraphsNumber" );
2003 if ( DataFlowEditor()->IsExecutable() && !IsMacro() ) {
2004 RetVal = DataFlowEditor()->SubGraphsNumber() ;
2006 // endService( "Graph_Impl::SubGraphsNumber" );
2010 SUPERV::ListOfNodes * Graph_Impl::SubGraphsNodes( const long aSubGraphNumber ) {
2011 beginService( "Graph_Impl::SubGraphsNodes" );
2012 SUPERV::ListOfNodes_var RetVal = new SUPERV::ListOfNodes ;
2013 if ( DataFlowEditor()->IsEditing() && !IsMacro() ) {
2014 SUPERV::ListOfNodes * aGraphNodes = Nodes() ;
2017 for ( i = 0 ; i < (int ) aGraphNodes->CNodes.length() ; i++ ) {
2018 SUPERV::CNode_var aNode = (aGraphNodes->CNodes)[ i ] ;
2019 if ( aNode->SubGraph() == aSubGraphNumber ) {
2020 RetVal = SetNode( RetVal , DataFlowEditor()->Graph()->GetChangeGraphNode( aNode->Name() ) ) ;
2024 for ( i = 0 ; i < (int ) aGraphNodes->FNodes.length() ; i++ ) {
2025 SUPERV::FNode_var aNode = (aGraphNodes->FNodes)[ i ] ;
2026 if ( aNode->SubGraph() == aSubGraphNumber ) {
2027 RetVal = SetNode( RetVal , DataFlowEditor()->Graph()->GetChangeGraphNode( aNode->Name() ) ) ;
2031 for ( i = 0 ; i < (int ) aGraphNodes->INodes.length() ; i++ ) {
2032 SUPERV::INode_var aNode = (aGraphNodes->INodes)[ i ] ;
2033 if ( aNode->SubGraph() == aSubGraphNumber ) {
2034 RetVal = SetNode( RetVal , DataFlowEditor()->Graph()->GetChangeGraphNode( aNode->Name() ) ) ;
2038 for ( i = 0 ; i < (int ) aGraphNodes->GNodes.length() ; i++ ) {
2039 SUPERV::GNode_var aNode = (aGraphNodes->GNodes)[ i ] ;
2040 if ( aNode->SubGraph() == aSubGraphNumber ) {
2041 RetVal = SetNode( RetVal , DataFlowEditor()->Graph()->GetChangeGraphNode( aNode->Name() ) ) ;
2045 for ( i = 0 ; i < (int ) aGraphNodes->LNodes.length() ; i++ ) {
2046 SUPERV::LNode_var aNode = (aGraphNodes->LNodes)[ i ] ;
2047 if ( aNode->SubGraph() == aSubGraphNumber ) {
2048 RetVal = SetNode( RetVal , DataFlowEditor()->Graph()->GetChangeGraphNode( aNode->Name() ) ) ;
2052 for ( i = 0 ; i < (int ) aGraphNodes->ELNodes.length() ; i++ ) {
2053 SUPERV::ELNode_var aNode = (aGraphNodes->ELNodes)[ i ] ;
2054 if ( aNode->SubGraph() == aSubGraphNumber ) {
2055 RetVal = SetNode( RetVal , DataFlowEditor()->Graph()->GetChangeGraphNode( aNode->Name() ) ) ;
2059 for ( i = 0 ; i < (int ) aGraphNodes->SNodes.length() ; i++ ) {
2060 SUPERV::SNode_var aNode = (aGraphNodes->SNodes)[ i ] ;
2061 if ( aNode->SubGraph() == aSubGraphNumber ) {
2062 RetVal = SetNode( RetVal , DataFlowEditor()->Graph()->GetChangeGraphNode( aNode->Name() ) ) ;
2066 for ( i = 0 ; i < (int ) aGraphNodes->ESNodes.length() ; i++ ) {
2067 SUPERV::ESNode_var aNode = (aGraphNodes->ESNodes)[ i ] ;
2068 if ( aNode->SubGraph() == aSubGraphNumber ) {
2069 RetVal = SetNode( RetVal , DataFlowEditor()->Graph()->GetChangeGraphNode( aNode->Name() ) ) ;
2073 endService( "Graph_Impl::SubGraphsNodes" );
2074 return ( RetVal._retn() ) ;
2077 bool Graph_Impl::Merge(const SUPERV::Graph_ptr aGraph ) {
2078 // beginService( "Graph_Impl::Merge" );
2079 bool RetVal = true ;
2081 map< string , int > aMapOfNodes ;
2082 RetVal = Merge( aGraph , aMapOfNodes ) ;
2084 // endService( "Graph_Impl::Merge" );
2088 bool Graph_Impl::Merge(const SUPERV::Graph_ptr aGraph , map< string , int > & aMapOfNodes ) {
2089 beginService( "Graph_Impl::Merge" );
2090 bool RetVal = true ;
2091 if ( DataFlowEditor()->IsEditing() && !IsMacro() ) {
2092 SUPERV::ListOfNodes * aGraphNodes = aGraph->Nodes() ;
2094 SUPERV::Port_ptr aPort ;
2095 // SUPERV::StreamPort_ptr aStreamPort ;
2097 for ( i = 0 ; i < (int ) aGraphNodes->CNodes.length() ; i++ ) {
2098 SUPERV::CNode_var aNode = (aGraphNodes->CNodes)[ i ] ;
2099 SUPERV::CNode_ptr myNode = CNode( *(aNode->Service()) ) ;
2100 if ( !CORBA::is_nil( myNode ) ) {
2101 myNode->SetName( aNode->Name() ) ;
2102 myNode->SetAuthor( aNode->Author() ) ;
2103 myNode->SetComment( aNode->Comment() ) ;
2104 myNode->Coords( aNode->X() , aNode->Y() ) ;
2105 string * aNodetheName = new string( aNode->Name() ) ;
2106 aMapOfNodes[ *aNodetheName ] = DataFlowEditor()->Graph()->GetGraphNodeIndex( myNode->Name() ) ;
2107 delete aNodetheName ;
2114 // The following informations are now in the service from SALOME_ModuleCatalog
2115 // SUPERV::ListOfStreamPorts myStreamPorts = *(aNode->StreamPorts()) ;
2117 // for ( j = 0 ; j < (int ) myStreamPorts.length() ; j++ ) {
2118 // if ( myStreamPorts[ j ]->IsInput() && myStreamPorts[ j ]->IsDataStream() ) {
2119 // aStreamPort = myNode->InStreamPort( myStreamPorts[ j ]->Name() , myStreamPorts[ j ]->Type() ) ;
2121 // else if ( myStreamPorts[ j ]->IsDataStream() ) {
2122 // aStreamPort = myNode->OutStreamPort( myStreamPorts[ j ]->Name() , myStreamPorts[ j ]->Type() ) ;
2128 for ( i = 0 ; i < (int ) aGraphNodes->FNodes.length() ; i++ ) {
2129 SUPERV::FNode_var aNode = (aGraphNodes->FNodes)[ i ] ;
2130 SUPERV::FNode_ptr myNode = FNode( aNode->GetComponentName() ,
2131 aNode->GetInterfaceName() ,
2132 *(aNode->Service()) ) ;
2133 if ( !CORBA::is_nil( myNode ) ) {
2134 myNode->SetName( aNode->Name() ) ;
2135 myNode->SetAuthor( aNode->Author() ) ;
2136 myNode->SetComment( aNode->Comment() ) ;
2137 myNode->Coords( aNode->X() , aNode->Y() ) ;
2138 string * aNodetheName = new string( aNode->Name() ) ;
2139 aMapOfNodes[ *aNodetheName ] = DataFlowEditor()->Graph()->GetGraphNodeIndex( myNode->Name() ) ;
2140 delete aNodetheName ;
2147 // The following informations are now in the service from SALOME_ModuleCatalog
2148 // SUPERV::ListOfStreamPorts myStreamPorts = *(aNode->StreamPorts()) ;
2150 // for ( j = 0 ; j < (int ) myStreamPorts.length() ; j++ ) {
2151 // if ( myStreamPorts[ j ]->IsInput() && myStreamPorts[ j ]->IsDataStream() ) {
2152 // aStreamPort = myNode->InStreamPort( myStreamPorts[ j ]->Name() , myStreamPorts[ j ]->Type() ) ;
2154 // else if ( myStreamPorts[ j ]->IsDataStream() ) {
2155 // aStreamPort = myNode->OutStreamPort( myStreamPorts[ j ]->Name() , myStreamPorts[ j ]->Type() ) ;
2162 for ( i = 0 ; i < (int ) aGraphNodes->INodes.length() ; i++ ) {
2163 SUPERV::INode_var aNode = (aGraphNodes->INodes)[ i ] ;
2164 SUPERV::INode_ptr myNode = INode( aNode->PyFuncName() , *(aNode->PyFunction()) ) ;
2165 if ( !CORBA::is_nil( myNode ) ) {
2166 myNode->SetName( aNode->Name() ) ;
2167 myNode->SetAuthor( aNode->Author() ) ;
2168 myNode->SetComment( aNode->Comment() ) ;
2169 myNode->Coords( aNode->X() , aNode->Y() ) ;
2170 string * aNodetheName = new string( aNode->Name() ) ;
2171 aMapOfNodes[ *aNodetheName ] = DataFlowEditor()->Graph()->GetGraphNodeIndex( myNode->Name() ) ;
2172 delete aNodetheName ;
2173 SUPERV::ListOfPorts myPorts = *(aNode->Ports()) ;
2175 for ( j = 0 ; j < (int ) myPorts.length() ; j++ ) {
2176 if ( myPorts[ j ]->IsInput() ) {
2177 aPort = myNode->InPort( myPorts[ j ]->Name() , myPorts[ j ]->Type() ) ;
2180 aPort = myNode->OutPort( myPorts[ j ]->Name() , myPorts[ j ]->Type() ) ;
2183 if ( DataFlowEditor()->Graph()->IsDataStreamNode() ) {
2184 SUPERV::ListOfStreamPorts myStreamPorts = *(aNode->StreamPorts()) ;
2185 for ( j = 0 ; j < (int ) myStreamPorts.length() ; j++ ) {
2186 if ( myStreamPorts[ j ]->IsInput() ) {
2187 aPort = myNode->InStreamPort( myStreamPorts[ j ]->Name() , StringToDataStreamType( myStreamPorts[ j ]->Type() ) , myStreamPorts[ j ]->Dependency() ) ;
2190 aPort = myNode->OutStreamPort( myStreamPorts[ j ]->Name() , StringToDataStreamType( myStreamPorts[ j ]->Type() ) , myStreamPorts[ j ]->Dependency() ) ;
2204 for ( i = 0 ; i < (int ) aGraphNodes->GNodes.length() ; i++ ) {
2205 SUPERV::GNode_var aNode = (aGraphNodes->GNodes)[ i ] ;
2206 SUPERV::GNode_ptr myNode = GNode( aNode->PyFuncName() , *(aNode->PyFunction()) , aNode->Coupled()->Name() ) ;
2207 if ( !CORBA::is_nil( myNode ) ) {
2208 myNode->SetName( aNode->Name() ) ;
2209 myNode->SetAuthor( aNode->Author() ) ;
2210 myNode->SetComment( aNode->Comment() ) ;
2211 myNode->Coords( aNode->X() , aNode->Y() ) ;
2212 string * aNodetheName = new string( aNode->Name() ) ;
2213 aMapOfNodes[ *aNodetheName ] = DataFlowEditor()->Graph()->GetGraphNodeIndex( myNode->Name() ) ;
2214 delete aNodetheName ;
2215 SUPERV::ListOfPorts myPorts = *(aNode->Ports()) ;
2217 for ( j = 0 ; j < (int ) myPorts.length() ; j++ ) {
2218 if ( myPorts[ j ]->IsInput() ) {
2219 aPort = myNode->InPort( myPorts[ j ]->Name() , myPorts[ j ]->Type() ) ;
2222 aPort = myNode->OutPort( myPorts[ j ]->Name() , myPorts[ j ]->Type() ) ;
2225 if ( DataFlowEditor()->Graph()->IsDataStreamNode() ) {
2226 SUPERV::ListOfStreamPorts myStreamPorts = *(aNode->StreamPorts()) ;
2227 for ( j = 0 ; j < (int ) myStreamPorts.length() ; j++ ) {
2228 if ( myStreamPorts[ j ]->IsInput() ) {
2229 aPort = myNode->InStreamPort( myStreamPorts[ j ]->Name() , StringToDataStreamType( myStreamPorts[ j ]->Type() ) , myStreamPorts[ j ]->Dependency() ) ;
2232 aPort = myNode->OutStreamPort( myStreamPorts[ j ]->Name() , StringToDataStreamType( myStreamPorts[ j ]->Type() ) , myStreamPorts[ j ]->Dependency() ) ;
2246 for ( i = 0 ; i < (int ) aGraphNodes->LNodes.length() ; i++ ) {
2247 SUPERV::LNode_var aNode = (aGraphNodes->LNodes)[ i ] ;
2248 SUPERV::INode_ptr anEndOfLoop ;
2249 SUPERV::LNode_ptr myNode = LNode( aNode->PyInitName() ,
2250 *(aNode->PyInit()) ,
2251 aNode->PyMoreName() ,
2252 *(aNode->PyMore()) ,
2253 aNode->PyNextName() ,
2254 *(aNode->PyNext()) ,
2256 if ( !CORBA::is_nil( myNode ) ) {
2257 myNode->SetName( aNode->Name() ) ;
2258 myNode->SetAuthor( aNode->Author() ) ;
2259 myNode->SetComment( aNode->Comment() ) ;
2260 myNode->Coords( aNode->X() , aNode->Y() ) ;
2261 string * aNodetheName = new string( aNode->Name() ) ;
2262 aMapOfNodes[ *aNodetheName ] = DataFlowEditor()->Graph()->GetGraphNodeIndex( myNode->Name() ) ;
2263 delete aNodetheName ;
2264 SUPERV::ListOfPorts myPorts = *(aNode->Ports()) ;
2266 for ( j = 0 ; j < (int ) myPorts.length() ; j++ ) {
2267 if ( myPorts[ j ]->IsInput() ) {
2268 aPort = myNode->InPort( myPorts[ j ]->Name() , myPorts[ j ]->Type() ) ;
2271 aPort = myNode->OutPort( myPorts[ j ]->Name() , myPorts[ j ]->Type() ) ;
2274 if ( DataFlowEditor()->Graph()->IsDataStreamNode() ) {
2275 SUPERV::ListOfStreamPorts myStreamPorts = *(aNode->StreamPorts()) ;
2276 for ( j = 0 ; j < (int ) myStreamPorts.length() ; j++ ) {
2277 if ( myStreamPorts[ j ]->IsInput() ) {
2278 aPort = myNode->InStreamPort( myStreamPorts[ j ]->Name() , StringToDataStreamType( myStreamPorts[ j ]->Type() ) , myStreamPorts[ j ]->Dependency() ) ;
2281 aPort = myNode->OutStreamPort( myStreamPorts[ j ]->Name() , StringToDataStreamType( myStreamPorts[ j ]->Type() ) , myStreamPorts[ j ]->Dependency() ) ;
2285 SUPERV::INode_ptr myEndOfLoop = aNode->Coupled() ;
2286 anEndOfLoop->SetName( myEndOfLoop->Name() ) ;
2287 anEndOfLoop->SetAuthor( myEndOfLoop->Author() ) ;
2288 anEndOfLoop->SetComment( myEndOfLoop->Comment() ) ;
2289 anEndOfLoop->Coords( myEndOfLoop->X() , myEndOfLoop->Y() ) ;
2290 anEndOfLoop->SetPyFunction( myEndOfLoop->PyFuncName() , *(myEndOfLoop->PyFunction()) ) ;
2291 aNodetheName = new string( myEndOfLoop->Name() ) ;
2292 aMapOfNodes[ *aNodetheName ] = DataFlowEditor()->Graph()->GetGraphNodeIndex( anEndOfLoop->Name() ) ;
2293 if ( DataFlowEditor()->Graph()->IsDataStreamNode() ) {
2294 SUPERV::ListOfStreamPorts myStreamLoopPorts = *(myEndOfLoop->StreamPorts()) ;
2295 for ( j = 0 ; j < (int ) myStreamLoopPorts.length() ; j++ ) {
2296 if ( myStreamLoopPorts[ j ]->IsInput() ) {
2297 aPort = myNode->InStreamPort( myStreamLoopPorts[ j ]->Name() , StringToDataStreamType( myStreamLoopPorts[ j ]->Type() ) , myStreamLoopPorts[ j ]->Dependency() ) ;
2300 aPort = myNode->OutStreamPort( myStreamLoopPorts[ j ]->Name() , StringToDataStreamType( myStreamLoopPorts[ j ]->Type() ) , myStreamLoopPorts[ j ]->Dependency() ) ;
2304 delete aNodetheName ;
2315 for ( i = 0 ; i < (int ) aGraphNodes->SNodes.length() ; i++ ) {
2316 SUPERV::SNode_var aNode = (aGraphNodes->SNodes)[ i ] ;
2317 SUPERV::INode_ptr anEndOfSwitch ;
2318 SUPERV::SNode_ptr myNode = SNode( aNode->PyFuncName() , *(aNode->PyFunction()) , anEndOfSwitch ) ;
2319 if ( !CORBA::is_nil( myNode ) ) {
2320 myNode->SetName( aNode->Name() ) ;
2321 myNode->SetAuthor( aNode->Author() ) ;
2322 myNode->SetComment( aNode->Comment() ) ;
2323 myNode->Coords( aNode->X() , aNode->Y() ) ;
2324 string * aNodetheName = new string( aNode->Name() ) ;
2325 aMapOfNodes[ *aNodetheName ] = DataFlowEditor()->Graph()->GetGraphNodeIndex( myNode->Name() ) ;
2326 delete aNodetheName ;
2327 SUPERV::ListOfPorts myPorts = *(aNode->Ports()) ;
2329 for ( j = 0 ; j < (int ) myPorts.length() ; j++ ) {
2330 if ( myPorts[ j ]->IsInput() ) {
2331 aPort = myNode->InPort( myPorts[ j ]->Name() , myPorts[ j ]->Type() ) ;
2334 aPort = myNode->OutPort( myPorts[ j ]->Name() , myPorts[ j ]->Type() ) ;
2337 if ( DataFlowEditor()->Graph()->IsDataStreamNode() ) {
2338 SUPERV::ListOfStreamPorts myStreamPorts = *(aNode->StreamPorts()) ;
2339 for ( j = 0 ; j < (int ) myStreamPorts.length() ; j++ ) {
2340 if ( myStreamPorts[ j ]->IsInput() ) {
2341 aPort = myNode->InStreamPort( myStreamPorts[ j ]->Name() , StringToDataStreamType( myStreamPorts[ j ]->Type() ) , myStreamPorts[ j ]->Dependency() ) ;
2344 aPort = myNode->OutStreamPort( myStreamPorts[ j ]->Name() , StringToDataStreamType( myStreamPorts[ j ]->Type() ) , myStreamPorts[ j ]->Dependency() ) ;
2348 SUPERV::INode_ptr myEndOfSwitch = aNode->Coupled() ;
2349 anEndOfSwitch->SetName( myEndOfSwitch->Name() ) ;
2350 anEndOfSwitch->SetAuthor( myEndOfSwitch->Author() ) ;
2351 anEndOfSwitch->SetComment( myEndOfSwitch->Comment() ) ;
2352 anEndOfSwitch->Coords( myEndOfSwitch->X() , myEndOfSwitch->Y() ) ;
2353 anEndOfSwitch->SetPyFunction( myEndOfSwitch->PyFuncName() , *(myEndOfSwitch->PyFunction()) ) ;
2354 aNodetheName = new string( myEndOfSwitch->Name() ) ;
2355 aMapOfNodes[ *aNodetheName ] = DataFlowEditor()->Graph()->GetGraphNodeIndex( anEndOfSwitch->Name() ) ;
2356 delete aNodetheName ;
2357 myPorts = *(myEndOfSwitch->Ports()) ;
2358 for ( j = 0 ; j < (int ) myPorts.length() ; j++ ) {
2359 if ( myPorts[ j ]->IsInput() ) {
2360 aPort = myNode->InPort( myPorts[ j ]->Name() , myPorts[ j ]->Type() ) ;
2363 aPort = myNode->OutPort( myPorts[ j ]->Name() , myPorts[ j ]->Type() ) ;
2366 if ( DataFlowEditor()->Graph()->IsDataStreamNode() ) {
2367 SUPERV::ListOfStreamPorts myStreamSwitchPorts = *(myEndOfSwitch->StreamPorts()) ;
2368 for ( j = 0 ; j < (int ) myStreamSwitchPorts.length() ; j++ ) {
2369 if ( myStreamSwitchPorts[ j ]->IsInput() ) {
2370 aPort = myNode->InStreamPort( myStreamSwitchPorts[ j ]->Name() , StringToDataStreamType( myStreamSwitchPorts[ j ]->Type() ) , myStreamSwitchPorts[ j ]->Dependency() ) ;
2373 aPort = myNode->OutStreamPort( myStreamSwitchPorts[ j ]->Name() , StringToDataStreamType( myStreamSwitchPorts[ j ]->Type() ) , myStreamSwitchPorts[ j ]->Dependency() ) ;
2386 SUPERV::ListOfLinks * aGraphLinks = aGraph->GLinks() ;
2387 SUPERV::ListOfPorts * aGraphPorts = aGraph->Ports() ;
2388 // cout << "Graph_Impl::Merge " << aGraphLinks->length() << " links " << aGraphPorts->length() << " GraphPorts"
2390 for ( i = 0 ; i < (int ) aGraphLinks->length() ; i++ ) {
2391 SUPERV::Link_var aLink = (*aGraphLinks)[ i ] ;
2392 SUPERV::Port_var OutPort = aLink->OutPort() ;
2393 SUPERV::Port_var InPort = aLink->InPort() ;
2394 string * aLinkFromNodeName = new string( OutPort->Node()->Name() ) ;
2395 string * aLinkToNodeName = new string( InPort->Node()->Name() ) ;
2396 RetVal = DataFlowEditor()->AddLink( DataFlowEditor()->Graph()->GetGraphNode( aMapOfNodes[ aLinkFromNodeName->c_str() ] )->Name() ,
2398 DataFlowEditor()->Graph()->GetGraphNode( aMapOfNodes[ aLinkToNodeName->c_str() ] )->Name() ,
2402 for ( j = 1 ; j <= aLink->CoordsSize() ; j++ ) {
2404 RetVal = aLink->Coords( j , X , Y ) ;
2407 RetVal = DataFlowEditor()->AddLinkCoord( DataFlowEditor()->Graph()->GetGraphNode( aMapOfNodes[ aLinkFromNodeName->c_str() ] )->Name() ,
2409 DataFlowEditor()->Graph()->GetGraphNode( aMapOfNodes[ aLinkToNodeName->c_str() ] )->Name() ,
2417 delete aLinkFromNodeName ;
2418 delete aLinkToNodeName ;
2424 for ( i = 0 ; i < (int ) aGraphPorts->length() ; i++ ) {
2425 SUPERV::Port_var aPort = (*aGraphPorts)[ i ] ;
2426 if ( !aPort->IsGate() ) {
2427 MESSAGE( "Graph_Impl::Merge " << i << ". " << aPort->Node()->Name() << " " << aPort->Name() ) ;
2428 char * aPortName = aPort->Name() ;
2429 char * aNodeName = new char[ strlen( aPortName ) + 1 ] ;
2430 strcpy( aNodeName , aPortName ) ;
2431 // char * thePortName = strchr( aNodeName , '\\' ) ;
2432 char * thePortName = aNodeName ;
2433 while ( ( thePortName = strchr( thePortName , '_' ) ) ) {
2434 if ( thePortName[1] == '_' ) {
2435 thePortName[ 0 ] = '\0' ;
2439 thePortName = &thePortName[2] ;
2442 bool hasinput = aGraph->Node( aNodeName )->Port( thePortName + 2 )->HasInput() ;
2443 // cout << "Graph_Impl::Merge " << " aNodeName " << aNodeName << " aPort " << thePortName + 1
2444 // << " HasInput " << hasinput << endl ;
2446 RetVal = DataFlowEditor()->AddInputData( DataFlowEditor()->Graph()->GetGraphNode( aMapOfNodes[ aNodeName ] )->Name() ,
2448 *(aPort->ToAny()) ) ;
2450 delete [] aNodeName ;
2459 MESSAGE( "Graph_Impl::Merge returns " << RetVal ) ;
2460 endService( "Graph_Impl::Merge" );
2464 SUPERV::StreamGraph_ptr Graph_Impl::ToStreamGraph() {
2465 SUPERV::StreamGraph_var iobject = SUPERV::StreamGraph::_nil() ;
2466 beginService( "Graph_Impl::ToStreamGraph" );
2467 if ( IsStreamGraph() && !IsMacro() ) {
2468 // StreamGraph_Impl * myStreamGraph = new StreamGraph_Impl( _Orb , _Poa , _ContId ,
2469 // instanceName() , interfaceName() ) ;
2470 // PortableServer::ObjectId * id = myStreamGraph->getId() ;
2471 // CORBA::Object_var obj = _poa->id_to_reference(*id);
2472 iobject = SUPERV::StreamGraph::_narrow( ObjRef() ) ;
2473 if ( CORBA::is_nil( iobject ) ) {
2474 MESSAGE( "ToStreamGraph of " << Name() << " (IsStreamGraph) --> nil reference" ) ;
2478 MESSAGE( "ToStreamGraph of " << Name() << " (IsNOTStreamGraph) --> nil reference" ) ;
2480 endService( "Graph_Impl::ToStreamGraph" );
2481 return SUPERV::StreamGraph::_duplicate( iobject ) ;
2485 * Destroy Executor and use only Editor and its data model
2487 void Graph_Impl::Editing() {
2488 if ( DataFlowEditor() && DataFlowExecutor() ) {
2489 delete DataFlowExecutor() ;
2490 DataFlowEditor()->Executor( NULL );