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 char * Graph_Impl::SavePY( bool importSuperV ) {
372 beginService( "Graph_Impl::SavePY" );
373 ostringstream fstring ;
375 RetVal = DataFlowEditor()->SavePY( fstring , importSuperV ) ;
377 endService( "Graph_Impl::SavePY" );
378 return CORBA::string_dup( fstring.str().c_str() );
380 SUPERV::CNode_ptr Graph_Impl::CNode( const SALOME_ModuleCatalog::Service &NodeService ) {
381 beginService( "Graph_Impl::CNode" );
382 SUPERV::CNode_var iobject = SUPERV::CNode::_nil() ;
383 if ( DataFlowEditor()->IsEditing() && !DataFlowEditor()->IsReadOnly() && !IsMacro() ) {
384 CNode_Impl * myNode = new CNode_Impl( _Orb , _Poa , _ContId ,
385 instanceName() , interfaceName() ,
387 NodeService , NULLSTRING ,
388 SUPERV::ComputingNode , NULLSTRING ) ;
389 if ( myNode->DataFlowNode() ) {
390 PortableServer::ObjectId * id = myNode->getId() ;
391 CORBA::Object_var obj = _poa->id_to_reference(*id);
392 iobject = SUPERV::CNode::_narrow(obj) ;
393 myNode->SetObjRef( SUPERV::CNode::_duplicate( iobject ) ) ;
396 DataFlowEditor()->UnValid() ;
397 endService( "Graph_Impl::CNode" );
398 return SUPERV::CNode::_duplicate( iobject ) ;
401 SUPERV::FNode_ptr Graph_Impl::FNode( const char * NodeComponentName ,
402 const char * NodeInterfaceName ,
403 const SALOME_ModuleCatalog::Service &NodeService ) {
404 beginService( "Graph_Impl::FNode" );
405 SUPERV::FNode_var iobject = SUPERV::FNode::_nil() ;
406 if ( DataFlowEditor()->IsEditing() && !DataFlowEditor()->IsReadOnly() && !IsMacro() ) {
407 FNode_Impl * myNode = new FNode_Impl( _Orb , _Poa , _ContId ,
408 instanceName() , interfaceName() ,
412 NodeInterfaceName ) ;
413 if ( myNode->DataFlowNode() ) {
414 PortableServer::ObjectId * id = myNode->getId() ;
415 CORBA::Object_var obj = _poa->id_to_reference(*id);
416 iobject = SUPERV::FNode::_narrow(obj) ;
417 myNode->SetObjRef( SUPERV::FNode::_duplicate( iobject ) ) ;
420 DataFlowEditor()->UnValid() ;
421 endService( "Graph_Impl::FNode" );
422 return SUPERV::FNode::_duplicate( iobject ) ;
425 SUPERV::INode_ptr Graph_Impl::INode( const char * FuncName ,
426 const SUPERV::ListOfStrings & PythonFuntion ) {
427 beginService( "Graph_Impl::INode" );
428 SUPERV::INode_var iobject = SUPERV::INode::_nil() ;
429 if ( DataFlowEditor()->IsEditing() && !DataFlowEditor()->IsReadOnly() && !IsMacro() ) {
430 INode_Impl * myNode = new INode_Impl( _Orb , _Poa , _ContId ,
431 instanceName() , interfaceName() ,
433 FuncName , PythonFuntion ,
434 SUPERV::InLineNode ) ;
435 if ( myNode->DataFlowNode() ) {
436 PortableServer::ObjectId * id = myNode->getId() ;
437 CORBA::Object_var obj = _poa->id_to_reference(*id);
438 iobject = SUPERV::INode::_narrow(obj) ;
439 myNode->SetObjRef( SUPERV::INode::_duplicate( iobject ) ) ;
442 endService( "Graph_Impl::INode" );
443 return SUPERV::INode::_duplicate( iobject ) ;
447 SUPERV::GNode_ptr Graph_Impl::GNode( const char * FuncName ,
448 const SUPERV::ListOfStrings & PythonFuntion ,
449 const char * anInLineNode ) {
450 beginService( "Graph_Impl::GNode" );
451 SUPERV::GNode_var iobject = SUPERV::GNode::_nil() ;
452 if ( DataFlowEditor()->IsEditing() && !DataFlowEditor()->IsReadOnly() && !IsMacro() ) {
453 GNode_Impl * myNode = new GNode_Impl( _Orb , _Poa , _ContId ,
454 instanceName() , interfaceName() ,
456 FuncName , PythonFuntion ,
458 if ( myNode->DataFlowNode() ) {
459 PortableServer::ObjectId * id = myNode->getId() ;
460 CORBA::Object_var obj = _poa->id_to_reference(*id);
461 iobject = SUPERV::GNode::_narrow(obj) ;
462 myNode->SetObjRef( SUPERV::GNode::_duplicate( iobject ) ) ;
463 if ( strlen( anInLineNode ) ) {
464 GraphBase::InLineNode * CoupledINode = (GraphBase::InLineNode * ) DataFlowEditor()->Graph()->GetGraphNode( anInLineNode ) ;
465 if ( anInLineNode ) {
466 myNode->SetCoupled( anInLineNode ) ;
467 Link( myNode->Port( "OutGate" ) , CoupledINode->ObjRef()->Port( "InGate" ) ) ;
472 DataFlowEditor()->UnValid() ;
473 endService( "Graph_Impl::GNode" );
474 return SUPERV::GNode::_duplicate( iobject ) ;
477 SUPERV::LNode_ptr Graph_Impl::LNode( const char * InitName ,
478 const SUPERV::ListOfStrings & InitFunction ,
479 const char * MoreName ,
480 const SUPERV::ListOfStrings & MoreFunction ,
481 const char * NextName ,
482 const SUPERV::ListOfStrings & NextFunction ,
483 SUPERV::INode_out anEndOfLoop ) {
484 beginService( "Graph_Impl::LNode" );
485 SUPERV::LNode_var iobject = SUPERV::LNode::_nil() ;
486 SUPERV::ELNode_var iendobject = SUPERV::ELNode::_nil() ;
487 if ( DataFlowEditor()->IsEditing() && !DataFlowEditor()->IsReadOnly() && !IsMacro() ) {
488 GraphBase::ListOfFuncName FuncNameList ;
489 FuncNameList.resize(3) ;
490 FuncNameList[0] = InitName ;
491 FuncNameList[1] = MoreName ;
492 FuncNameList[2] = NextName ;
493 GraphBase::ListOfPythonFunctions PythonFunctionList ;
494 PythonFunctionList.resize(3) ;
495 PythonFunctionList[0] = &InitFunction ;
496 PythonFunctionList[1] = &MoreFunction ;
497 PythonFunctionList[2] = &NextFunction ;
498 LNode_Impl * myNode = new LNode_Impl( _Orb , _Poa , _ContId ,
499 instanceName() , interfaceName() ,
501 FuncNameList , PythonFunctionList ,
502 // InitName , InitFunction ,
503 // MoreName , MoreFunction ,
504 // NextName , NextFunction ,
506 if ( myNode->DataFlowNode() ) {
507 PortableServer::ObjectId * id = myNode->getId() ;
508 CORBA::Object_var obj = _poa->id_to_reference(*id);
509 iobject = SUPERV::LNode::_narrow(obj) ;
510 myNode->SetObjRef( SUPERV::LNode::_duplicate( iobject ) ) ;
512 SALOME_ModuleCatalog::Service aVoidService = SALOME_ModuleCatalog::Service() ;
514 if ( strlen( InitName ) ) {
515 anEndName = new char( 3 + strlen( InitName ) + 1 ) ;
516 strcpy( anEndName , "End" ) ;
517 strcat( anEndName , InitName ) ;
520 anEndName = new char( 3 + strlen( "Loop" ) + 1 ) ;
521 strcpy( anEndName , "EndLoop" ) ;
523 ELNode_Impl * myEndNode = new ELNode_Impl( _Orb , _Poa , _ContId ,
524 instanceName() , interfaceName() ,
527 SUPERV::EndLoopNode ) ;
528 PortableServer::ObjectId * endid = myEndNode->getId() ;
529 CORBA::Object_var endobj = _poa->id_to_reference(*endid);
530 iendobject = SUPERV::ELNode::_narrow(endobj) ;
531 myEndNode->SetObjRef( SUPERV::ELNode::_duplicate( iendobject ) ) ;
532 myNode->SetCoupled( myEndNode->BaseNode()->Name() ) ;
533 myEndNode->SetCoupled( myNode->BaseNode()->Name() ) ;
534 //JR 25.01.2005 That links are already done in SetCoupled above ...
535 // Link( myNode->Port( "DoLoop" ) , myEndNode->Port( "DoLoop" ) ) ;
536 // Link( myEndNode->Port( "DoLoop" ) , myNode->Port( "InitLoop" ) ) ;
537 // Link( myEndNode->Port( "DoLoop" ) , myNode->Port( "DoLoop" ) ) ;
540 anEndOfLoop = SUPERV::ELNode::_duplicate( iendobject ) ;
541 DataFlowEditor()->UnValid() ;
542 endService( "Graph_Impl::LNode" );
543 return SUPERV::LNode::_duplicate( iobject ) ;
546 SUPERV::SNode_ptr Graph_Impl::SNode( const char * FuncName ,
547 const SUPERV::ListOfStrings & PythonFunction ,
548 SUPERV::INode_out anEndOfSwitch ) {
549 beginService( "Graph_Impl::SNode" );
550 SUPERV::SNode_var iobject = SUPERV::SNode::_nil() ;
551 SUPERV::ESNode_var iendobject = SUPERV::ESNode::_nil() ;
552 if ( DataFlowEditor()->IsEditing() && !DataFlowEditor()->IsReadOnly() && !IsMacro() ) {
553 SNode_Impl * myNode = new SNode_Impl( _Orb , _Poa , _ContId ,
554 instanceName() , interfaceName() ,
556 FuncName , PythonFunction ,
557 SUPERV::SwitchNode ) ;
558 if ( myNode->DataFlowNode() ) {
559 PortableServer::ObjectId * id = myNode->getId() ;
560 CORBA::Object_var obj = _poa->id_to_reference(*id);
561 iobject = SUPERV::SNode::_narrow(obj) ;
562 myNode->SetObjRef( SUPERV::SNode::_duplicate( iobject ) ) ;
564 string anEndName = "End" ;
565 if ( strlen( FuncName ) ) {
566 anEndName += FuncName ;
569 anEndName += "Switch" ;
571 // cout << "Graph_Impl::SNode anEndName " << (void *) FuncName << " " << FuncName
572 // << " " << strlen(FuncName) << " " << (void *) anEndName.c_str() << " "
573 // << anEndName.c_str() << endl ;
574 ESNode_Impl * myEndNode = new ESNode_Impl( _Orb , _Poa , _ContId ,
575 instanceName() , interfaceName() ,
578 SUPERV::EndSwitchNode ) ;
579 // cout << "Graph_Impl::SNode returned anEndName " << (void *) FuncName << " "
580 // << FuncName << " " << strlen(FuncName) << " " << (void *) anEndName.c_str()
581 // << " " << anEndName.c_str() << endl ;
582 PortableServer::ObjectId * endid = myEndNode->getId() ;
583 CORBA::Object_var endobj = _poa->id_to_reference(*endid);
584 iendobject = SUPERV::ESNode::_narrow(endobj) ;
585 myEndNode->SetObjRef( SUPERV::ESNode::_duplicate( iendobject ) ) ;
586 myNode->SetCoupled( myEndNode->BaseNode()->Name() ) ;
587 myEndNode->SetCoupled( myNode->BaseNode()->Name() ) ;
588 if ( !Link( myNode->Port( "Default" ) , myEndNode->Port( "Default" ) ) ) {
589 iobject = SUPERV::SNode::_nil() ;
590 iendobject = SUPERV::ESNode::_nil() ;
594 anEndOfSwitch = SUPERV::ESNode::_duplicate( iendobject ) ;
595 DataFlowEditor()->UnValid() ;
596 endService( "Graph_Impl::SNode" );
597 return SUPERV::SNode::_duplicate( iobject ) ;
600 // WARNING : THIS IS COMPLICATED :
601 SUPERV::Graph_var Graph_Impl::LoadDataFlows( GraphEditor::DataFlow * aDataFlowEditor ,
602 GraphBase::ListOfSGraphs * aListOfDataFlows ,
604 beginService( "Graph_Impl::EditorLoadDataFlows" ) ;
605 MESSAGE("Graph_Impl::LoadDataFlows index " << index << " " << (*aListOfDataFlows)[index].Info.theName.c_str() ) ;
607 SUPERV::Graph_var iobject = SUPERV::Graph::_nil() ;
608 // That method is recursive :
609 // At first we load the supergraph with index = 0 :
610 // (After we load the graph corresponding to each MacroNode :)
611 if ( !aDataFlowEditor->LoadDataFlow( &(*aListOfDataFlows)[ index ] ) ) {
612 MESSAGE("Graph_Impl::LoadDataFlows failed " << (*aListOfDataFlows)[index].Info.theName.c_str() ) ;
613 return SUPERV::Graph::_duplicate( iobject ) ;
615 // That graph is not a StreamGraph :
616 else if ( !aDataFlowEditor->Graph()->HasDataStream() ) {
617 aDataFlowEditor->Graph()->Kind( SUPERV::DataFlowGraph ) ;
618 // aDataFlowEditor->Graph()->SetGraphEditor( aDataFlowEditor ) ;
619 Graph_Impl * myGraph ;
620 // We create a Graph ObjRef for that graph
621 myGraph = new Graph_Impl( _Orb , _Poa, _ContId,
622 instanceName() , interfaceName() ,
623 aDataFlowEditor , NULL ) ;
624 PortableServer::ObjectId * id = myGraph->getId() ;
625 CORBA::Object_var obj = _poa->id_to_reference(*id) ;
626 iobject = SUPERV::Graph::_narrow( obj ) ;
627 myGraph->SetObjRef( SUPERV::Graph::_duplicate( iobject ) ) ;
628 myGraph->SetObjImpl( (CNode_Impl * ) myGraph ) ;
629 GraphBase::Graph * aGraph = myGraph->DataFlowEditor()->Graph() ;
632 // asv: set Editor for the graph itself and for all its macro nodes
633 aGraph->GraphEditor( aDataFlowEditor );
635 // For the supergraph or each graph of MacroNodes we search MacroNodes recursively :
636 for ( i = 0 ; i < aGraph->GraphNodesSize() ; i++ ) {
637 if ( aGraph->GraphNodes( i )->IsMacroNode() ) {
638 GraphBase::GOTONode * aMacroNode = (GraphBase::GOTONode * ) aGraph->GraphNodes( i ) ;
640 // asv : 05.11.04 : fix of bug - "insert file" into existing graph with MacroNodes worked incorrectly!
641 // aMacroNode is an "old" node, and here we must analize only "new" nodes, that
642 // came from aListOfDataFlows and were loaded by aDataFlowEditor->LoadDataFlow( &(*aListOfDataFlows)[ index ] )
643 // so here we check if the node is "new" or "old"
644 if ( aMacroNode->GraphEditor() && aMacroNode->CoupledNode() )
647 // asv: set Editor for the graph itself and for all its macro nodes
648 aMacroNode->GraphEditor( aDataFlowEditor );
650 // Creation of a GraphMacroNode ObjRef in the current editor
651 SUPERV::Graph_var macroiobject = SUPERV::Graph::_nil() ;
652 Graph_Impl * myMacroNode ;
653 myMacroNode = new Graph_Impl( _Orb , _Poa, _ContId,
654 instanceName() , interfaceName() ,
655 aMacroNode->Name() , SUPERV::MacroNode ) ;
656 id = myMacroNode->getId() ;
657 obj = _poa->id_to_reference(*id);
658 macroiobject = SUPERV::Graph::_narrow( obj ) ;
659 myMacroNode->DataFlowEditor( aDataFlowEditor ) ;
660 GraphEditor::InNode * aDataFlowNode = (GraphEditor::InNode * ) aMacroNode->GetInNode() ;
661 myMacroNode->DataFlowNode( aDataFlowNode ) ;
662 aDataFlowNode->SetObjRef( SUPERV::CNode::_duplicate( SUPERV::CNode::_narrow( obj ) ) ) ;
663 aDataFlowNode->SetObjImpl( myMacroNode ) ;
665 char * aCoupledNodeName = aMacroNode->CoupledNodeName() ;
666 MESSAGE( "LoadDataFlows MacroNode " << aMacroNode->Name() << " --> " << aCoupledNodeName
667 << " to be searched among " << (*aListOfDataFlows).size() << " Graphs" ) ;
670 for ( index = 0 ; index < (int ) (*aListOfDataFlows).size() ; index++ ) {
671 MESSAGE( "LoadDataFlows Graph" << index << " " << (*aListOfDataFlows)[index].Info.theName.c_str() ) ;
672 if ( !strcmp( aCoupledNodeName , (*aListOfDataFlows)[index].Info.theName.c_str() ) ) {
675 // At first create the editor and a StreamGraph
676 GraphEditor::DataFlow * aMacroGraphDataFlowEditor ;
677 CreateEditor( _Orb , instanceName() , aCoupledNodeName , SUPERV::DataStreamGraph ,
678 dbgfile , &aMacroGraphDataFlowEditor ) ;
680 if ( _DebugFileName ) {
681 delete [] _DebugFileName ;
683 _DebugFileName = new char[ strlen( dbgfile.c_str() )+1 ] ;
684 strcpy( _DebugFileName , dbgfile.c_str() ) ;
686 MESSAGE( "RECURSIVE IMPORT OF GRAPHS OF MACRONODES :" << aCoupledNodeName ) ;
687 if ( CORBA::is_nil( LoadDataFlows( aMacroGraphDataFlowEditor , aListOfDataFlows , index ) ) ) {
688 MESSAGE("Graph_Impl::LoadDataFlows failed" ) ;
689 return SUPERV::Graph::_duplicate( iobject ) ;
692 // That graph is not a StreamGraph :
693 else if ( !aMacroGraphDataFlowEditor->Graph()->HasDataStream() ) {
694 Graph_Impl * myMacroGraph ;
695 // The Graph ObjRef for that graph was already created
696 myMacroGraph = (Graph_Impl * ) aMacroGraphDataFlowEditor->Graph()->ObjImpl() ;
698 GraphBase::Graph * aMacroGraph = myMacroGraph->DataFlowEditor()->Graph() ;
700 aMacroGraph->GraphMacroLevel( aGraph->GraphMacroLevel() + 1 ) ;
701 aMacroGraph->CoupledNode( aMacroNode ) ;
702 aMacroGraph->MacroObject( SUPERV::Graph::_duplicate( macroiobject ) ) ;
704 // Set the GraphMacroNode ObjRef in the MacroNode
705 aMacroNode->GraphMacroLevel( aGraph->GraphMacroLevel() + 1 ) ;
706 aMacroNode->CoupledNode( aMacroGraph ) ;
707 aMacroNode->MacroObject( SUPERV::Graph::_narrow( aMacroGraphDataFlowEditor->Graph()->ObjRef() ) ) ;
708 MESSAGE( "LoadDataFlows aMacroGraph " << aMacroGraph << " " << aMacroGraph->Name()
709 << " coupled to " << aMacroGraph->CoupledNode() << " "
710 << aMacroGraph->CoupledNode()->Name() << " Editor " << aMacroGraph->GraphEditor() ) ;
711 MESSAGE( "LoadDataFlows aMacroNode " << aMacroNode << " " << aMacroNode->Name()
712 << " coupled to " << aMacroNode->CoupledNode() << " "
713 << aMacroNode->CoupledNode()->Name() << " Editor " << aMacroNode->GraphEditor() ) ;
714 MESSAGE( "LoadDataFlows current Graph " << aGraph << " " << aGraph->Name()
715 << " coupled to " << aGraph->CoupledNode()
716 << " Editor " << aGraph->GraphEditor() << " " << aGraph->Name() ) ;
722 return SUPERV::Graph::_duplicate( SUPERV::Graph::_nil() ) ;
727 else if ( (*aListOfDataFlows).size() == 1 ) {
728 StreamGraph_Impl * myStreamGraph ;
729 // We create a Graph ObjRef for that graph
730 myStreamGraph = new StreamGraph_Impl( _Orb , _Poa, _ContId,
731 instanceName() , interfaceName() ,
732 aDataFlowEditor , NULL ) ;
733 PortableServer::ObjectId * id = myStreamGraph->getId() ;
734 CORBA::Object_var obj = _poa->id_to_reference(*id) ;
735 SUPERV::StreamGraph_var Streamiobject = SUPERV::StreamGraph::_nil() ;
736 Streamiobject = SUPERV::StreamGraph::_narrow( obj ) ;
737 myStreamGraph->SetObjRef( SUPERV::StreamGraph::_duplicate( Streamiobject ) ) ;
738 myStreamGraph->SetObjImpl( (CNode_Impl * ) myStreamGraph ) ;
739 // iobject = SUPERV::Graph::_narrow( obj ) ;
740 iobject = SUPERV::Graph::_narrow( Streamiobject ) ;
743 MESSAGE( "Graph_Impl::LoadDataFlows StreamGraph with MacroNodes not yet implemented" ) ;
746 endService( "Graph_Impl::EditorLoadDataFlows" );
747 return SUPERV::Graph::_duplicate( iobject ) ;
750 SUPERV::Graph_var Graph_Impl::LoadDataFlows( GraphExecutor::DataFlow * aDataFlowExecutor ,
751 GraphBase::ListOfSGraphs * aListOfDataFlows ,
753 beginService( "Graph_Impl::ExecutorLoadDataFlows" ) ;
754 MESSAGE("Graph_Impl::LoadDataFlows(Executor) index " << index << " " << (*aListOfDataFlows)[index].Info.theName.c_str() << " aDataFlowExecutor " << aDataFlowExecutor ) ;
756 // That method is recursive :
757 // At first we load the supergraph with index = 0 :
758 // (After we load the graph corresponding to each MacroNode :)
759 if ( !aDataFlowExecutor->LoadDataFlow( &(*aListOfDataFlows)[ index ] ) ) {
760 MESSAGE("Graph_Impl::LoadDataFlows(Executor) failed, could not LoadDataFlow(supergraph)" ) ;
761 return SUPERV::Graph::_duplicate( SUPERV::Graph::_nil() ) ;
764 // That graph is not a StreamGraph :
766 aDataFlowExecutor->Graph()->Kind( SUPERV::DataFlowGraph ) ;
767 GraphEditor::DataFlow * aDataFlowEditor ;
768 aDataFlowEditor = DataFlowEditor() ;
769 GraphBase::Graph * anEditorGraph = aDataFlowEditor->Graph() ;
770 GraphBase::Graph * anExecutorGraph = aDataFlowExecutor->Graph() ;
771 if ( aDataFlowEditor->Executor() ) {
772 delete aDataFlowEditor->Executor() ;
773 aDataFlowEditor->Executor( NULL ) ;
774 aDataFlowEditor->Editing() ;
776 aDataFlowEditor->Executor( aDataFlowExecutor ) ;
777 anExecutorGraph->GraphEditor( aDataFlowEditor ) ;
779 if ( !aDataFlowExecutor->Graph()->HasDataStream() ) {
780 // For the supergraph or each graph of MacroNodes we search MacroNodes recursively :
782 for ( i = 0 ; i < anExecutorGraph->GraphNodesSize() ; i++ ) {
783 if ( anExecutorGraph->GraphNodes( i )->IsMacroNode() ) {
784 GraphBase::GOTONode * aMacroNode = (GraphBase::GOTONode * ) anExecutorGraph->GraphNodes( i ) ;
785 aMacroNode->GraphEditor( aDataFlowEditor ) ;
787 // get the macro node's editor object
788 char * aMacroGraphName = aMacroNode->CoupledNodeName() ;
789 GraphBase::Graph* aMacroGraph = (GraphBase::Graph*)((GraphBase::GOTONode *)anEditorGraph->GetGraphNode( aMacroNode->Name() ))->CoupledNode() ;
790 GraphEditor::DataFlow* aMacroGraphEditor = aMacroGraph->GraphEditor();
792 MESSAGE( "LoadDataFlows(Executor) MacroNode " << aMacroNode->Name() << " Coupled to " << aMacroGraphName
793 << " to be searched among " << (*aListOfDataFlows).size() << " Graphs" << endl ) ;
796 for ( index = 0 ; index < (int ) (*aListOfDataFlows).size() && !found; index++ ) {
797 if ( !strcmp( aMacroGraphName , (*aListOfDataFlows)[index].Info.theName.c_str() ) )
801 MESSAGE("Graph_Impl::LoadDataFlows(Executor) failed, Macro node's coupled graph \"" << aMacroGraphName << "\" was not found" ) ;
802 return SUPERV::Graph::_duplicate( SUPERV::Graph::_nil() ) ;
804 index--; // it was incremented in "for ..." before last check ( !found ).
806 // At first create the editor and a StreamGraph
808 GraphExecutor::DataFlow * aMacroGraphExecutor ;
809 CreateExecutor( _Orb , instanceName() , aMacroGraphName , SUPERV::DataStreamGraph ,
810 dbgfile , &aMacroGraphExecutor );
812 // set GraphMacroLevel for Executor's graph
813 GraphBase::Graph* aMacroGraphExe = aMacroGraphExecutor->Graph();
814 aMacroGraphExe->GraphMacroLevel( anExecutorGraph->GraphMacroLevel() + 1 );
816 // load data flows in MacroGraph's executor
817 Graph_Impl* aMacroGraphImpl = (Graph_Impl*) aMacroGraphEditor->Graph()->ObjImpl();
818 MESSAGE( "RECURSIVE IMPORT OF GRAPHS OF MACRONODES : " << aMacroGraphName ) ;
819 if ( CORBA::is_nil( aMacroGraphImpl->LoadDataFlows( aMacroGraphExecutor, aListOfDataFlows , index ) ) ) {
820 MESSAGE("Graph_Impl::LoadDataFlows(Executor) failed, could not LoadDataFlow( MacroNodeGraph \"" <<aMacroGraphName << "\" )" ) ;
821 return SUPERV::Graph::_duplicate( SUPERV::Graph::_nil() ) ;
824 // set coupled pair MacroNode <--> MacroGraph
825 aMacroGraphExe->CoupledNode( aMacroNode ) ;
826 aMacroNode->CoupledNode( aMacroGraphExe ) ;
828 // initialize MacroNode's InPorts with corresponding "external" values
830 for ( q = 0 ; q < aMacroNode->GetNodeInPortsSize() ; q++ ) {
831 const GraphBase::InPort * anInPort = aMacroNode->GetNodeInPort( q ) ;
832 if ( anInPort->IsDataConnected() ) {
833 const char* aMacroGraphInPortName = aMacroGraph->GetNodeInPort( q )->PortName();
834 //JR 30.03.2005 if ( !aMacroGraphExecutor->InputOfAny( aMacroGraphInPortName, *anInPort->GetOutPort()->Value(),false ) ) {
835 if ( !aMacroGraphExecutor->InputOfAny( aMacroGraphInPortName, anInPort->GetOutPort()->Value(),false ) ) {
836 return SUPERV::Graph::_duplicate( SUPERV::Graph::_nil() ) ;
839 MESSAGE( "LoadDataFlows(Executor) " << aMacroGraph->Name() << "->InputOfAny( "
840 << aMacroGraphInPortName << " , Value )" ) ;
843 } // end of init MacroNode's InPorts
845 aMacroGraphImpl->Run() ;
848 } // end of for( get nodes of the graph...)
850 } // end of setting initial graph's structure..
852 endService( "Graph_Impl::ExecutorLoadDataFlows" );
854 PortableServer::ObjectId * id = getId();
855 CORBA::Object_var obj = _poa->id_to_reference( *id );
856 SUPERV::Graph_var iobject = SUPERV::Graph::_narrow( obj ) ;
857 return SUPERV::Graph::_duplicate( iobject ) ;
860 SUPERV::Graph_ptr Graph_Impl::MNode( const char * aXmlFileName ) {
861 beginService( "Graph_Impl::MNode" );
862 SUPERV::Graph_var iobject = SUPERV::Graph::_nil() ;
863 MESSAGE( "Graph_Impl::MNode( " << aXmlFileName << " )" ) ;
865 GraphBase::ListOfSGraphs aListOfDataFlows ;
867 // At first create the editor and a StreamGraph with the xml file
868 GraphEditor::DataFlow * aDataFlowEditor ;
869 CreateEditor( _Orb , instanceName() , aXmlFileName , SUPERV::DataStreamGraph ,
870 dbgfile , &aDataFlowEditor ) ;
872 if ( _DebugFileName ) {
873 delete [] _DebugFileName ;
875 _DebugFileName = new char[ strlen( dbgfile.c_str() )+1 ] ;
876 strcpy( _DebugFileName , dbgfile.c_str() ) ;
878 int lenname = strlen( aXmlFileName ) ;
879 bool loaded = false ;
880 // Import of the xml file
881 if ( lenname > 4 && !strcmp( &aXmlFileName[ lenname - 4 ] , ".xml" ) ) {
882 loaded = aDataFlowEditor->LoadXml( aXmlFileName , aListOfDataFlows ) ;
884 iobject = MNode( aDataFlowEditor , &aListOfDataFlows ) ;
891 // WARNING : THIS IS COMPLICATED :
892 // I should have to remove duplicated code ...
893 SUPERV::Graph_ptr Graph_Impl::MNode( GraphEditor::DataFlow * aMacroGraphDataFlowEditor ,
894 GraphBase::ListOfSGraphs * aListOfDataFlows ) {
895 beginService( "Graph_Impl::MNode" ) ;
896 SUPERV::Graph_var iobject = SUPERV::Graph::_nil() ;
897 SUPERV::Graph_var macroiobject = SUPERV::Graph::_nil() ;
900 MESSAGE( "Graph_Impl::MNode DataFlowEditor->LoadDataFlow" ) ;
901 // if ( !aMacroGraphDataFlowEditor->LoadDataFlow( &aListOfDataFlows[ 0 ] ) ) {
902 iobject = LoadDataFlows( aMacroGraphDataFlowEditor , aListOfDataFlows , 0 ) ;
903 if ( CORBA::is_nil( iobject ) ) {
904 MESSAGE("Graph_Impl::MNode LoadDataFlow failed" ) ;
908 // That graph is not a StreamGraph :
909 else if ( !aMacroGraphDataFlowEditor->Graph()->HasDataStream() ) {
910 aMacroGraphDataFlowEditor->Graph()->Kind( SUPERV::DataFlowGraph ) ;
911 aMacroGraphDataFlowEditor->Graph()->GraphEditor( aMacroGraphDataFlowEditor ) ;
913 Graph_Impl * myMacroGraph = (Graph_Impl * ) aMacroGraphDataFlowEditor->Graph()->ObjImpl() ;
914 // Creation of a GraphMacroNode in the current editor
915 string aMacroNodeName = string( "Macro_" ) + string( myMacroGraph->Name() ) ;
916 Graph_Impl * myMacroNode ;
917 myMacroNode = new Graph_Impl( _Orb , _Poa, _ContId,
918 instanceName() , interfaceName() ,
919 aMacroNodeName.c_str() , SUPERV::MacroNode ) ;
920 PortableServer::ObjectId * id = myMacroNode->getId() ;
921 CORBA::Object_var obj = _poa->id_to_reference(*id);
922 macroiobject = SUPERV::Graph::_narrow( obj ) ;
923 myMacroNode->DataFlowEditor( DataFlowEditor() ) ;
925 // Creation of the MacroNode itself in the current Graph
926 GraphBase::ListOfFuncName aFuncName ;
927 aFuncName.resize( 1 ) ;
929 SUPERV::ListOfStrings aListOfStrings ;
930 aListOfStrings.length( 1 ) ;
931 aListOfStrings[0] = "" ;
932 GraphBase::ListOfPythonFunctions aPythonFunction ;
933 aPythonFunction.resize( 1 ) ;
934 aPythonFunction[0] = &aListOfStrings ;
935 SALOME_ModuleCatalog::Service * aMacroNodeService = myMacroGraph->Service() ;
936 GraphEditor::InNode * aDataFlowNode = DataFlowEditor()->AddNode( *aMacroNodeService , "" , "" ,
937 aMacroNodeName.c_str() , SUPERV::MacroNode ,
938 aFuncName , aPythonFunction ) ;
939 aDataFlowNode->SetPythonFunction( "" , aListOfStrings ) ;
940 myMacroNode->DataFlowNode( aDataFlowNode ) ;
941 aDataFlowNode->ComputingNode()->SetService( *aMacroNodeService ) ;
942 aDataFlowNode->SetObjRef( SUPERV::CNode::_duplicate( SUPERV::CNode::_narrow( obj ) ) ) ;
943 aDataFlowNode->SetObjImpl( this ) ;
945 GraphBase::Graph * aGraph = myMacroGraph->DataFlowEditor()->Graph() ;
946 GraphBase::Graph * aGraphOfMacroGraph = myMacroNode->DataFlowEditor()->Graph() ;
947 GraphBase::Graph * aMacroGraph = myMacroNode->DataFlowNode()->GraphMacroNode() ;
948 aMacroGraph->Kind( SUPERV::MacroNode ) ;
949 aMacroGraph->GraphEditor( DataFlowEditor() ) ;
950 // Creation of the Ports of the MacroNode from the ports of the GraphMacroNode
951 aMacroGraph->SetMacroPorts( aGraph ) ;
952 // Valid ==> creation of Service and the ports of the current Graph
953 DataFlowEditor()->IsValid() ;
954 // Set the Input Datas from the GraphMacroNode to the current Graph
955 aMacroGraph->SetMacroDatas( aGraph , aGraphOfMacroGraph ) ;
956 aMacroGraphDataFlowEditor->UnValid() ;
957 // Set the MacroNode ObjRef in the GraphMacroNode
958 aGraph->CoupledNode( aMacroGraph ) ;
959 aGraph->MacroObject( SUPERV::Graph::_duplicate( macroiobject ) ) ;
960 // Set the GraphMacroNode ObjRef in the MacroNode
961 aDataFlowNode->GraphMacroNode()->GraphMacroLevel( aGraphOfMacroGraph->GraphMacroLevel() + 1 ) ;
962 aMacroGraph->CoupledNode( aGraph ) ;
963 // aGraphOfMacroGraph->CoupledNode( aGraph ) ;
964 aMacroGraph->MacroObject( SUPERV::Graph::_duplicate( iobject ) ) ;
965 // aGraphOfMacroGraph->MacroObject( SUPERV::Graph::_duplicate( iobject ) ) ;
966 // aDataFlowNode->CoupledNode( aGraph ) ;
967 // aDataFlowNode->ComputingNode()->MacroObject( SUPERV::Graph::_duplicate( iobject ) ) ;
968 // Set the MacroLevel of that graph
969 aGraph->GraphMacroLevel( aGraphOfMacroGraph->GraphMacroLevel() + 1 ) ;
970 aMacroGraph->Coordinates( 0 , 0 ) ;
971 MESSAGE( "DataFlowNode Graph " << this << " DataFlowEditor " << DataFlowEditor() << " aDataFlowNode "
972 << aDataFlowNode << " " << aDataFlowNode->Name() << " created" ) ;
973 MESSAGE( "MNode aGraph " << aGraph << " " << aGraph->Name()
974 << " coupled to " << aGraph->CoupledNode() << " "
975 << aGraph->CoupledNode()->Name() ) ;
976 MESSAGE( "MNode aMacroGraph " << aMacroGraph << " " << aMacroGraph->Name()
977 << " coupled to " << aMacroGraph->CoupledNode() << " "
978 << aMacroGraph->CoupledNode()->Name() ) ;
979 MESSAGE( "MNode aMacroGraph " << myMacroNode->DataFlowEditor()->Graph() << " "
980 << myMacroNode->DataFlowEditor()->Graph()->Name()
981 << " coupled to " << myMacroNode->DataFlowEditor()->Graph()->CoupledNode() ) ;
984 delete aMacroGraphDataFlowEditor ;
987 endService( "Graph_Impl::MNode" );
988 return SUPERV::Graph::_duplicate( macroiobject ) ;
991 // For python supergraph
992 SUPERV::Graph_ptr Graph_Impl::GraphMNode( SUPERV::Graph_ptr myMacroGraph ) {
993 SUPERV::Graph_var iobject = myMacroGraph ;
994 beginService( "Graph_Impl::GraphMNode" ) ;
996 // GraphBase::Graph * myMacroGraph = aGraph;
997 SUPERV::Graph_var macroiobject = SUPERV::StreamGraph::_nil() ;
998 // Creation of a GraphMacroNode in the current editor
1000 string aMacroNodeName = string( "Macro_" ) + string( myMacroGraph->Name() ) ;
1001 //string aMacroNodeName = string( myMacroGraph->CoupledName() ) ;
1002 MESSAGE( "GraphMNode( " << myMacroGraph->Name() << " )" ) ;
1003 Graph_Impl * myMacroNode ;
1004 myMacroNode = new Graph_Impl( _Orb , _Poa, _ContId,
1005 instanceName() , interfaceName() ,
1006 aMacroNodeName.c_str() , SUPERV::MacroNode ) ;
1007 PortableServer::ObjectId * id = myMacroNode->getId() ;
1008 CORBA::Object_var obj = _poa->id_to_reference(*id);
1009 macroiobject = SUPERV::Graph::_narrow( obj ) ;
1010 myMacroNode->DataFlowEditor( DataFlowEditor() ) ;
1012 // Creation of the MacroNode itself in the current Graph
1013 GraphBase::ListOfFuncName aFuncName ;
1014 aFuncName.resize( 1 ) ;
1016 SUPERV::ListOfStrings aListOfStrings ;
1017 aListOfStrings.length( 1 ) ;
1018 aListOfStrings[0] = "" ;
1019 GraphBase::ListOfPythonFunctions aPythonFunction ;
1020 aPythonFunction.resize( 1 ) ;
1021 aPythonFunction[0] = &aListOfStrings ;
1022 SALOME_ModuleCatalog::Service * aMacroNodeService = myMacroGraph->Service() ;
1023 GraphEditor::InNode * aDataFlowNode ;
1024 aDataFlowNode = DataFlowEditor()->AddNode( *aMacroNodeService , "" , "" ,
1025 aMacroNodeName.c_str() , SUPERV::MacroNode ,
1026 aFuncName , aPythonFunction ) ;
1027 aDataFlowNode->SetPythonFunction( "" , aListOfStrings ) ;
1028 myMacroNode->DataFlowNode( aDataFlowNode ) ;
1029 aDataFlowNode->ComputingNode()->SetService( *aMacroNodeService ) ;
1030 aDataFlowNode->SetObjRef( SUPERV::CNode::_duplicate( SUPERV::CNode::_narrow( obj ) ) ) ;
1031 aDataFlowNode->SetObjImpl( this ) ;
1033 // GraphBase::Graph * aGraph = DataFlowEditor()->Automaton()->MapGraph( myMacroGraph->Name() ) ;
1034 GraphBase::Graph * aGraph ;
1035 //DataFlowEditor()->Automaton()->GraphBase( &aGraph ) ;
1036 myMacroGraph->Coupled() ;
1037 GraphBase::Graph * aGraphOfMacroGraph = myMacroNode->DataFlowEditor()->Graph() ;
1038 GraphBase::Graph * aMacroGraph = myMacroNode->DataFlowNode()->GraphMacroNode() ;
1039 aMacroGraph->Kind( SUPERV::MacroNode ) ;
1040 aMacroGraph->GraphEditor( DataFlowEditor() ) ;
1041 // Creation of the Ports of the MacroNode from the ports of the GraphMacroNode
1042 aMacroGraph->SetMacroPorts( aGraph ) ;
1043 // Valid ==> creation of Service and the ports of the current Graph
1044 DataFlowEditor()->IsValid() ;
1045 // Set the Input Datas from the GraphMacroNode to the current Graph
1046 aMacroGraph->SetMacroDatas( aGraph , aGraphOfMacroGraph ) ;
1047 // aMacroGraphDataFlowEditor->UnValid() ;
1048 aGraph->GraphEditor()->UnValid() ;
1049 // Set the MacroNode ObjRef in the GraphMacroNode
1050 aGraph->CoupledNode( aMacroGraph ) ;
1051 aGraph->MacroObject( SUPERV::Graph::_duplicate( macroiobject ) ) ;
1052 // Set the GraphMacroNode ObjRef in the MacroNode
1053 aDataFlowNode->GraphMacroNode()->GraphMacroLevel( aGraphOfMacroGraph->GraphMacroLevel() + 1 ) ;
1054 aMacroGraph->CoupledNode( aGraph ) ;
1055 aMacroGraph->MacroObject( SUPERV::Graph::_duplicate( iobject ) ) ;
1056 // aDataFlowNode->CoupledNode( aGraph ) ;
1057 // aDataFlowNode->ComputingNode()->MacroObject( SUPERV::Graph::_duplicate( iobject ) ) ;
1058 // Set the MacroLevel of that graph
1059 aGraph->GraphMacroLevel( aGraphOfMacroGraph->GraphMacroLevel() + 1 ) ;
1060 aMacroGraph->Coordinates( 0 , 0 ) ;
1061 MESSAGE( aGraph->Name() << "->CoupledNode()->GraphEditor() : " << aGraph->CoupledNode()->GraphEditor() ) ;
1062 MESSAGE( aMacroGraph->Name() << "->CoupledNode()->GraphEditor() : "
1063 << aMacroGraph->CoupledNode()->GraphEditor() ) ;
1064 MESSAGE( "DataFlowNode Graph " << this << " DataFlowEditor " << DataFlowEditor() << " aDataFlowNode "
1065 << aDataFlowNode << " " << aDataFlowNode->Name() << " created" ) ;
1067 endService( "Graph_Impl::GraphMNode" ) ;
1068 return SUPERV::Graph::_duplicate( macroiobject ) ;
1071 SUPERV::Graph_ptr Graph_Impl::FlowObjRef() {
1072 beginService( "Graph_Impl::FlowObjRef" );
1073 SUPERV::Graph_var iobject = SUPERV::Graph::_nil() ;
1075 iobject = SUPERV::Graph::_narrow( DataFlowNode()->GraphMacroNode()->MacroObject() ) ;
1077 else if ( IsGraph() ) {
1078 iobject = SUPERV::Graph::_narrow( DataFlowEditor()->Graph()->MacroObject() ) ;
1080 if ( CORBA::is_nil( iobject ) ) {
1081 MESSAGE( "Graph_Impl::FlowObjRef() returns a NIL Object" ) ;
1083 endService( "Graph_Impl::FlowObjRef" );
1084 return SUPERV::Graph::_duplicate( iobject ) ;
1087 SUPERV::StreamGraph_ptr Graph_Impl::StreamObjRef() {
1088 beginService( "Graph_Impl::StreamObjRef" );
1089 SUPERV::StreamGraph_var iobject = SUPERV::StreamGraph::_nil() ;
1091 iobject = SUPERV::StreamGraph::_narrow( DataFlowNode()->GraphMacroNode()->MacroObject() ) ;
1093 else if ( IsGraph() || IsStreamGraph() ) {
1094 iobject = SUPERV::StreamGraph::_narrow( DataFlowEditor()->Graph()->MacroObject() ) ;
1096 if ( CORBA::is_nil( iobject ) ) {
1097 MESSAGE( "Graph_Impl::StreamObjRef() returns a NIL Object" ) ;
1099 endService( "Graph_Impl::StreamObjRef" );
1100 return SUPERV::StreamGraph::_duplicate( iobject ) ;
1103 SUPERV::CNode_ptr Graph_Impl::Node(char const * aNodeName ) {
1104 // beginService( "Graph_Impl::Node" );
1105 SUPERV::CNode_var iobject = SUPERV::CNode::_nil() ;
1107 if ( CORBA::is_nil( DataFlowEditor()->GetNode( aNodeName )->ObjRef() ) ) {
1108 CNode_Impl * myNode = new CNode_Impl( _Orb , _Poa , _ContId ,
1109 instanceName() , interfaceName() ,
1111 DataFlowEditor()->GetNode( aNodeName ) ) ;
1112 PortableServer::ObjectId * id = myNode->getId() ;
1113 CORBA::Object_var obj = _poa->id_to_reference(*id);
1114 iobject = SUPERV::CNode::_narrow(obj) ;
1115 myNode->SetObjRef( SUPERV::CNode::_duplicate( iobject ) ) ;
1118 iobject = DataFlowEditor()->GetNode( aNodeName )->ObjRef() ;
1121 GraphEditor::InNode * anInNode = DataFlowEditor()->GetNode( aNodeName ) ;
1123 if ( CORBA::is_nil( anInNode->ObjRef() ) ) {
1124 SetNodeObjRef( anInNode ) ;
1126 iobject = anInNode->ObjRef() ;
1129 // endService( "Graph_Impl::Node" );
1130 return SUPERV::CNode::_duplicate( iobject ) ;
1133 SUPERV::Link_ptr Graph_Impl::Link( SUPERV::Port_ptr OutPort ,
1134 SUPERV::Port_ptr InPort ) {
1135 // beginService( "Graph_Impl::Link" );
1136 SUPERV::Link_var iobject = SUPERV::Link::_nil() ;
1137 if ( DataFlowEditor()->IsEditing() && !DataFlowEditor()->IsReadOnly() &&
1138 !OutPort->IsDataStream() && !InPort->IsDataStream() && !IsMacro() ) {
1139 MESSAGE( "Graph_Impl::Link( " << OutPort->Node()->Name() << "( " << OutPort->Name() << " ) --> "
1140 << InPort->Node()->Name() << "( " << InPort->Name() << " )" ) ;
1141 GraphEditor::InNode * anInNode = DataFlowEditor()->GetNode( InPort->Node()->Name() ) ;
1142 GraphEditor::InNode * anOutNode = DataFlowEditor()->GetNode( OutPort->Node()->Name() ) ;
1143 if ( anInNode == NULL || anOutNode== NULL ) {
1144 MESSAGE( "Graph_Impl::Link( " << OutPort->Node()->Name() << " " << anOutNode << " , "
1145 << InPort->Node()->Name() << " " << anInNode << " ) Node(s) not found in " << Name() ) ;
1148 GraphBase::InPort * anInPort = anInNode->ComputingNode()->GetChangeInPort( InPort->Name() ) ;
1149 GraphBase::OutPort * anOutPort = anOutNode->ComputingNode()->GetChangeOutPort( OutPort->Name() ) ;
1150 if ( anInPort == NULL || anOutPort== NULL ) {
1151 MESSAGE( "Graph_Impl::Link( " << OutPort->Name() << " " << anOutPort << " , "
1152 << InPort->Name() << " " << anInPort << " ) Port(s) not found" ) ;
1154 else if ( CORBA::is_nil( anOutPort->InPortObjRef( anInPort ) ) ) {
1155 const char * DataFlowOutNodeName = OutPort->Node()->Name() ;
1156 GraphEditor::InNode * DataFlowOutNode = DataFlowEditor()->GetNode( DataFlowOutNodeName ) ;
1157 const char * DataFlowInNodeName = InPort->Node()->Name() ;
1158 GraphEditor::InNode * DataFlowInNode = DataFlowEditor()->GetNode( DataFlowInNodeName ) ;
1159 if ( DataFlowOutNode && DataFlowInNode ) {
1161 Link_Impl * myLink = new Link_Impl( _Orb , _Poa , _ContId ,
1162 instanceName() , interfaceName() ,
1168 true , false , Success ) ;
1170 PortableServer::ObjectId * id = myLink->getId() ;
1171 CORBA::Object_var obj = _poa->id_to_reference(*id);
1172 iobject = SUPERV::Link::_narrow(obj) ;
1173 anOutPort->AddInPortObjRef( anInPort , SUPERV::Link::_duplicate( iobject ) ) ;
1178 iobject = anOutPort->InPortObjRef( anInPort ) ;
1182 DataFlowEditor()->UnValid() ;
1183 // endService( "Graph_Impl::Link" );
1184 return SUPERV::Link::_duplicate( iobject ) ;
1187 // Only to see MacroNodes with actual GUI ... :
1188 #define GOTOMacroNode 0
1190 void Graph_Impl::SetNodeObjRef( GraphEditor::InNode * anInNode ) {
1191 MESSAGE("Graph_Impl::SetNodeObjRef " << anInNode->Name() << " " << anInNode->Kind() ) ;
1192 CORBA::Object_var obj ;
1193 if ( anInNode->IsComputingNode() ) {
1194 CNode_Impl * myNode = new CNode_Impl( _Orb , _Poa , _ContId ,
1195 instanceName() , interfaceName() ,
1198 PortableServer::ObjectId * id = myNode->getId() ;
1199 obj = _poa->id_to_reference(*id);
1200 SUPERV::CNode_var iobject = SUPERV::CNode::_narrow(obj) ;
1201 myNode->SetObjRef( SUPERV::CNode::_duplicate( iobject ) ) ;
1203 else if ( anInNode->IsFactoryNode() ) {
1204 FNode_Impl * myNode = new FNode_Impl( _Orb , _Poa , _ContId ,
1205 instanceName() , interfaceName() ,
1208 PortableServer::ObjectId * id = myNode->getId() ;
1209 obj = _poa->id_to_reference(*id);
1210 SUPERV::FNode_var iobject = SUPERV::FNode::_narrow(obj) ;
1211 myNode->SetObjRef( SUPERV::FNode::_duplicate( iobject ) ) ;
1213 else if ( anInNode->IsInLineNode() ) {
1214 INode_Impl * myNode = new INode_Impl( _Orb , _Poa , _ContId ,
1215 instanceName() , interfaceName() ,
1218 PortableServer::ObjectId * id = myNode->getId() ;
1219 obj = _poa->id_to_reference(*id);
1220 SUPERV::INode_var iobject = SUPERV::INode::_narrow(obj) ;
1221 myNode->SetObjRef( SUPERV::INode::_duplicate( iobject ) ) ;
1224 else if ( anInNode->IsGOTONode() || anInNode->IsMacroNode() ) {
1225 if ( anInNode->IsMacroNode() ) {
1226 anInNode->ComputingNode()->Kind( SUPERV::GOTONode ) ;
1229 else if ( anInNode->IsGOTONode() ) {
1231 GNode_Impl * myNode = new GNode_Impl( _Orb , _Poa , _ContId ,
1232 instanceName() , interfaceName() ,
1235 PortableServer::ObjectId * id = myNode->getId() ;
1236 obj = _poa->id_to_reference(*id);
1237 SUPERV::GNode_var iobject = SUPERV::GNode::_narrow(obj) ;
1238 myNode->SetObjRef( SUPERV::GNode::_duplicate( iobject ) ) ;
1240 else if ( anInNode->IsMacroNode() ) {
1241 Graph_Impl * myNode = new Graph_Impl( _Orb , _Poa , _ContId ,
1242 instanceName() , interfaceName() ,
1245 PortableServer::ObjectId * id = myNode->getId() ;
1246 obj = _poa->id_to_reference(*id);
1247 SUPERV::Graph_var iobject = SUPERV::Graph::_narrow(obj) ;
1248 myNode->SetObjRef( SUPERV::Graph::_duplicate( iobject ) ) ;
1250 else if ( anInNode->IsLoopNode() ) {
1251 LNode_Impl * myNode = new LNode_Impl( _Orb , _Poa , _ContId ,
1252 instanceName() , interfaceName() ,
1255 PortableServer::ObjectId * id = myNode->getId() ;
1256 obj = _poa->id_to_reference(*id);
1257 SUPERV::LNode_var iobject = SUPERV::LNode::_narrow(obj) ;
1258 myNode->SetObjRef( SUPERV::LNode::_duplicate( iobject ) ) ;
1260 else if ( anInNode->IsEndLoopNode() ) {
1261 ELNode_Impl * myNode = new ELNode_Impl( _Orb , _Poa , _ContId ,
1262 instanceName() , interfaceName() ,
1265 PortableServer::ObjectId * id = myNode->getId() ;
1266 obj = _poa->id_to_reference(*id);
1267 SUPERV::ELNode_var iobject = SUPERV::ELNode::_narrow(obj) ;
1268 myNode->SetObjRef( SUPERV::ELNode::_duplicate( iobject ) ) ;
1270 else if ( anInNode->IsSwitchNode() ) {
1271 SNode_Impl * myNode = new SNode_Impl( _Orb , _Poa , _ContId ,
1272 instanceName() , interfaceName() ,
1275 PortableServer::ObjectId * id = myNode->getId() ;
1276 obj = _poa->id_to_reference(*id);
1277 SUPERV::SNode_var iobject = SUPERV::SNode::_narrow(obj) ;
1278 myNode->SetObjRef( SUPERV::SNode::_duplicate( iobject ) ) ;
1280 else if ( anInNode->IsEndSwitchNode() ) {
1281 ESNode_Impl * myNode = new ESNode_Impl( _Orb , _Poa , _ContId ,
1282 instanceName() , interfaceName() ,
1285 PortableServer::ObjectId * id = myNode->getId() ;
1286 obj = _poa->id_to_reference(*id);
1287 SUPERV::ESNode_var iobject = SUPERV::ESNode::_narrow(obj) ;
1288 myNode->SetObjRef( SUPERV::ESNode::_duplicate( iobject ) ) ;
1292 SUPERV::ListOfNodes_var Graph_Impl::SetNode( SUPERV::ListOfNodes_var RetVal ,
1293 GraphBase::ComputingNode * aNode ) {
1295 // if ( _DataFlowExecutor ) {
1296 if ( DataFlowExecutor() ) {
1297 MESSAGE("Graph_Impl::SetNode " << aNode->Name() << " " << aNode->Kind() << " "
1298 << DataFlowExecutor()->StateName( DataFlowExecutor()->AutomatonState( aNode->Name() ) ) ) ;
1301 MESSAGE("Graph_Impl::SetNode " << aNode->Name() << " " << aNode->Kind() ) ;
1303 if ( aNode->IsComputingNode() ) {
1304 index = RetVal->CNodes.length() ;
1305 RetVal->CNodes.length( index+1 );
1307 else if ( aNode->IsFactoryNode() ) {
1308 index = RetVal->FNodes.length() ;
1309 RetVal->FNodes.length( index+1 );
1311 else if ( aNode->IsInLineNode() ) {
1312 index = RetVal->INodes.length() ;
1313 RetVal->INodes.length( index+1 );
1316 else if ( aNode->IsGOTONode() || aNode->IsMacroNode() ) {
1318 else if ( aNode->IsGOTONode() ) {
1320 index = RetVal->GNodes.length() ;
1321 RetVal->GNodes.length( index+1 );
1323 else if ( aNode->IsMacroNode() ) {
1324 index = RetVal->Graphs.length() ;
1325 RetVal->Graphs.length( index+1 );
1327 else if ( aNode->IsLoopNode() ) {
1328 index = RetVal->LNodes.length() ;
1329 RetVal->LNodes.length( index+1 );
1331 else if ( aNode->IsEndLoopNode() ) {
1332 index = RetVal->ELNodes.length() ;
1333 RetVal->ELNodes.length( index+1 );
1335 else if ( aNode->IsSwitchNode() ) {
1336 index = RetVal->SNodes.length() ;
1337 RetVal->SNodes.length( index+1 );
1339 else if ( aNode->IsEndSwitchNode() ) {
1340 index = RetVal->ESNodes.length() ;
1341 RetVal->ESNodes.length( index+1 );
1343 if ( CORBA::is_nil( aNode->ObjRef() ) ) {
1344 SetNodeObjRef( (GraphEditor::InNode * ) aNode->GetInNode() ) ;
1346 SUPERV::CNode_var aNodeObjRef = aNode->ObjRef() ;
1347 if ( aNode->IsComputingNode() ) {
1348 RetVal->CNodes[index] = SUPERV::CNode::_duplicate( aNodeObjRef ) ;
1350 else if ( aNode->IsFactoryNode() ) {
1351 RetVal->FNodes[index] = SUPERV::FNode::_duplicate( SUPERV::FNode::_narrow( aNodeObjRef ) ) ;
1353 else if ( aNode->IsInLineNode() ) {
1354 RetVal->INodes[index] = SUPERV::INode::_duplicate( SUPERV::INode::_narrow( aNodeObjRef ) ) ;
1357 else if ( aNode->IsGOTONode() || aNode->IsMacroNode() ) {
1359 else if ( aNode->IsGOTONode() ) {
1361 RetVal->GNodes[index] = SUPERV::GNode::_duplicate( SUPERV::GNode::_narrow( aNodeObjRef ) ) ;
1363 else if ( aNode->IsMacroNode() ) {
1364 RetVal->Graphs[index] = SUPERV::Graph::_duplicate( SUPERV::Graph::_narrow( aNodeObjRef ) ) ;
1366 else if ( aNode->IsLoopNode() ) {
1367 RetVal->LNodes[index] = SUPERV::LNode::_duplicate( SUPERV::LNode::_narrow( aNodeObjRef ) ) ;
1369 else if ( aNode->IsEndLoopNode() ) {
1370 RetVal->ELNodes[index] = SUPERV::ELNode::_duplicate( SUPERV::ELNode::_narrow( aNodeObjRef ) ) ;
1372 else if ( aNode->IsSwitchNode() ) {
1373 RetVal->SNodes[index] = SUPERV::SNode::_duplicate( SUPERV::SNode::_narrow( aNodeObjRef ) ) ;
1375 else if ( aNode->IsEndSwitchNode() ) {
1376 RetVal->ESNodes[index] = SUPERV::ESNode::_duplicate( SUPERV::ESNode::_narrow( aNodeObjRef ) ) ;
1378 return ( RetVal._retn() ) ;
1381 SUPERV::ListOfNodes * Graph_Impl::Nodes() {
1382 SUPERV::ListOfNodes_var RetVal = new SUPERV::ListOfNodes;
1383 beginService( "Graph_Impl::Nodes" );
1384 RetVal->CNodes.length(0) ;
1385 RetVal->FNodes.length(0) ;
1386 RetVal->INodes.length(0) ;
1387 RetVal->LNodes.length(0) ;
1388 RetVal->SNodes.length(0) ;
1389 RetVal->GNodes.length(0) ;
1390 RetVal->Graphs.length(0) ;
1393 cout << DataFlowEditor()->Graph()->GetGraphNodeSize() << " Nodes in the Map and "
1394 << DataFlowEditor()->Graph()->GraphNodesSize() << " Nodes int the Vector" << endl ;
1395 for ( i = 0 ; i < DataFlowEditor()->Graph()->GraphNodesSize() ; i++ ) {
1396 GraphBase::ComputingNode * aNode = DataFlowEditor()->Graph()->GraphNodes( i ) ;
1398 cout << i << ". Vector : " << aNode->Name() << " Map : "
1399 << DataFlowEditor()->Graph()->GetGraphNode( aNode->Name() )->Name()
1402 RetVal = SetNode( RetVal , aNode ) ;
1405 char * aStateG = "" ;
1406 if ( DataFlowExecutor() ) {
1407 aStateG = (char *) DataFlowExecutor()->StateName( DataFlowExecutor()->AutomatonState() ) ;
1409 MESSAGE("Graph_Impl::Nodes GraphState " << aStateG << " CNodes " << RetVal->CNodes.length() ) ;
1410 for ( i = 0 ; i < RetVal->CNodes.length() ; i++ ) {
1411 MESSAGE(" " << RetVal->CNodes[ i ] ->Name() ) ;
1413 MESSAGE("FNodes " << RetVal->FNodes.length() ) ;
1414 for ( i = 0 ; i < RetVal->FNodes.length() ; i++ ) {
1415 MESSAGE(" " << RetVal->FNodes[ i ] ->Name() ) ;
1417 MESSAGE("INodes " << RetVal->INodes.length() ) ;
1418 for ( i = 0 ; i < RetVal->INodes.length() ; i++ ) {
1419 MESSAGE(" " << RetVal->INodes[ i ] ->Name() ) ;
1421 MESSAGE("GNodes " << RetVal->GNodes.length() ) ;
1422 for ( i = 0 ; i < RetVal->GNodes.length() ; i++ ) {
1423 MESSAGE(" " << RetVal->GNodes[ i ] ->Name() ) ;
1425 MESSAGE("LNodes " << RetVal->LNodes.length() ) ;
1426 for ( i = 0 ; i < RetVal->LNodes.length() ; i++ ) {
1427 MESSAGE(" " << RetVal->LNodes[ i ] ->Name() ) ;
1429 MESSAGE("ELNodes " << RetVal->ELNodes.length() ) ;
1430 for ( i = 0 ; i < RetVal->ELNodes.length() ; i++ ) {
1431 MESSAGE(" " << RetVal->ELNodes[ i ] ->Name() ) ;
1433 MESSAGE("SNodes " << RetVal->SNodes.length() ) ;
1434 for ( i = 0 ; i < RetVal->SNodes.length() ; i++ ) {
1435 MESSAGE(" " << RetVal->SNodes[ i ] ->Name() ) ;
1437 MESSAGE("ESNodes " << RetVal->ESNodes.length() ) ;
1438 for ( i = 0 ; i < RetVal->ESNodes.length() ; i++ ) {
1439 MESSAGE(" " << RetVal->ESNodes[ i ] ->Name() ) ;
1441 MESSAGE("Graphs " << RetVal->Graphs.length() ) ;
1442 for ( i = 0 ; i < RetVal->Graphs.length() ; i++ ) {
1443 MESSAGE(" " << RetVal->Graphs[ i ] ->Name() ) ;
1445 if ( DataFlowExecutor() ) {
1446 DataFlowExecutor()->EventList() ;
1450 endService( "Graph_Impl::Nodes" );
1451 return ( RetVal._retn() ) ;
1454 SUPERV::ListOfLinks * Graph_Impl::GLinks() {
1455 return Links( NULL , NULL ) ;
1458 SUPERV::ListOfLinks * Graph_Impl::Links( GraphBase::ComputingNode * theNode ,
1459 const char * anInputParam ) {
1461 SUPERV::ListOfLinks_var RetVal = new SUPERV::ListOfLinks ;
1462 RetVal->length( 0 ) ;
1464 int i , j , countlink ;
1466 for ( i = 0 ; i < DataFlowEditor()->Graph()->GraphNodesSize() ; i++ ) {
1467 GraphEditor::InNode * aNode = NULL ;
1468 aNode = (GraphEditor::InNode * ) DataFlowEditor()->Graph()->GraphNodes( i )->GetInNode() ;
1469 bool ToProcess = false ;
1470 if ( theNode == NULL ) {
1474 if ( !strcmp( theNode->Name() , aNode->Name() ) ) {
1475 if ( !theNode->IsEndSwitchNode() ) {
1479 else if ( theNode->IsEndSwitchNode() ) {
1484 for ( j = 0 ; j < aNode->GetNodeInPortsSize() ; j++ ) {
1485 GraphBase::InPort * anInPort = NULL ;
1486 anInPort = aNode->GetChangeNodeInPort( j ) ;
1487 if ( anInputParam == NULL ||
1488 !strcmp( anInPort->PortName() , anInputParam ) ) {
1489 GraphBase::OutPort * anOutPort = NULL ;
1490 anOutPort = anInPort->GetOutPort() ;
1491 if ( anOutPort && !anOutPort->IsDataStream() ) {
1492 if ( strcmp( anOutPort->NodeName() , Name() ) ) {
1493 // MESSAGE("Graph_Impl::Links " << anOutPort->NodeName() << "("
1494 // << anOutPort->PortName() << ") --> " << aNode->Name() << "("
1495 // << anInPort->PortName() << ")" ) ;
1496 if ( theNode == NULL ||
1498 //JR 14.02.2005 : Debug : we must see also that links !
1499 // ( theNode != NULL && !theNode->IsEndSwitchNode() &&
1500 !strcmp( theNode->Name() , aNode->Name() ) ) {
1501 if ( anInPort->IsLoop() || anOutPort->IsLoop() ||
1502 ( aNode->IsEndLoopNode() && !strcmp( aNode->CoupledNode()->Name() ,
1503 anOutPort->NodeName() ) ) ) {
1504 // MESSAGE( "Link " << anOutPort->NodeName() << "("
1505 // << anOutPort->PortName() << ") --> " << aNode->Name() << "("
1506 // << anInPort->PortName() << ")" << " ignored" ) ;
1508 else if ( CORBA::is_nil( anOutPort->InPortObjRef( anInPort ) ) ) {
1510 beginService( "Graph_Impl::Links" );
1513 GraphEditor::InNode * anOutNode = NULL ;
1514 anOutNode = (GraphEditor::InNode * ) DataFlowEditor()->Graph()->GetChangeGraphNode( anOutPort->NodeName() )->GetInNode() ;
1517 Link_Impl * myLink = new Link_Impl( _Orb , _Poa , _ContId ,
1518 instanceName() , interfaceName() ,
1521 anInPort->PortName() ,
1523 anOutPort->PortName() ,
1524 false , true , Success ) ;
1526 PortableServer::ObjectId * id = myLink->getId() ;
1527 CORBA::Object_var obj = _poa->id_to_reference(*id);
1528 SUPERV::Link_var iobject ;
1529 iobject = SUPERV::Link::_narrow(obj) ;
1530 RetVal->length( countlink + 1 ) ;
1531 RetVal[ countlink++ ] = SUPERV::Link::_duplicate( iobject ) ;
1532 anOutPort->AddInPortObjRef( anInPort , SUPERV::Link::_duplicate( iobject ) ) ;
1537 RetVal->length( countlink + 1 ) ;
1538 RetVal[ countlink++ ] = SUPERV::Link::_duplicate( anOutPort->InPortObjRef( anInPort ) ) ;
1540 // MESSAGE( "Link " << anOutPort->NodeName() << "("
1541 // << anOutPort->PortName() << ") --> " << aNode->Name() << "("
1542 // << anInPort->PortName() << ")" << " selected" ) ;
1545 // MESSAGE( "Link " << anOutPort->NodeName() << "("
1546 // << anOutPort->PortName() << ") --> " << aNode->Name() << "("
1547 // << anInPort->PortName() << ")" << " skipped" ) ;
1554 for ( j = 0 ; j < aNode->GetNodeOutPortsSize() ; j++ ) {
1555 GraphBase::OutPort * anOutPort = aNode->GetChangeNodeOutPort( j ) ;
1556 // MESSAGE( "Graph_Impl::Links " << aNode->Name() << " Out" << j << " " << anOutPort->PortName() << " "
1557 // << anOutPort->PortStatus() << " PortConnected to " << anOutPort->InPortsSize() << " InPorts" ) ;
1559 for ( k = 0 ; k < anOutPort->InPortsSize() ; k++ ) {
1560 GraphBase::InPort * anInPort = anOutPort->ChangeInPorts( k ) ;
1561 // MESSAGE( " --> In" << k << " " << anInPort->NodeName() << " " << anInPort->PortName()
1562 // << " " << anInPort->PortStatus() ) ;
1563 if ( anInPort->IsPortConnected() ) {
1564 GraphBase::ComputingNode * aComputingNode = DataFlowEditor()->Graph()->GetChangeGraphNode( anInPort->NodeName() ) ;
1565 GraphEditor::InNode * toNode = (GraphEditor::InNode * ) aComputingNode->GetInNode() ;
1566 if ( theNode == NULL ||
1567 !strcmp( theNode->Name() , aNode->Name() ) ) {
1568 if ( !anInPort->IsDataStream() ) {
1570 //JR 14.02.2005 : Debug : we must see also that links !
1571 // if ( theNode || ( toNode->IsEndSwitchNode() && !aNode->IsSwitchNode() ) ) {
1572 if ( anInputParam == NULL ||
1573 !strcmp( anInPort->PortName() , anInputParam ) ) {
1574 if ( anInPort->IsLoop() || anOutPort->IsLoop() ||
1575 ( toNode->IsEndLoopNode() && !strcmp( toNode->CoupledNode()->Name() ,
1576 anOutPort->NodeName() ) ) ) {
1577 // MESSAGE( "Link " << anOutPort->NodeName() << "("
1578 // << anOutPort->PortName() << ") --> " << toNode->Name() << "("
1579 // << anInPort->PortName() << ")" << " ignored" ) ;
1581 else if ( CORBA::is_nil( anOutPort->InPortObjRef( anInPort ) ) ) {
1583 beginService( "Graph_Impl::Links" );
1587 Link_Impl * myLink = new Link_Impl( _Orb , _Poa , _ContId ,
1588 instanceName() , interfaceName() ,
1591 anInPort->PortName() ,
1593 anOutPort->PortName() ,
1594 false , true , Success ) ;
1596 PortableServer::ObjectId * id = myLink->getId() ;
1597 CORBA::Object_var obj = _poa->id_to_reference(*id);
1598 SUPERV::Link_var iobject ;
1599 iobject = SUPERV::Link::_narrow(obj) ;
1600 RetVal->length( countlink + 1 ) ;
1601 RetVal[ countlink++ ] = SUPERV::Link::_duplicate( iobject ) ;
1602 anOutPort->AddInPortObjRef( anInPort , SUPERV::Link::_duplicate( iobject ) ) ;
1606 RetVal->length( countlink + 1 ) ;
1607 RetVal[ countlink++ ] = SUPERV::Link::_duplicate( SUPERV::Link::_narrow( anOutPort->InPortObjRef( anInPort ) ) ) ;
1609 // MESSAGE( "Link " << anOutPort->NodeName() << "("
1610 // << anOutPort->PortName() << ") --> " << toNode->Name() << "("
1611 // << anInPort->PortName() << ")" << " selected" ) ;
1614 // MESSAGE( "Link " << anOutPort->NodeName() << "("
1615 // << anOutPort->PortName() << ") --> " << toNode->Name() << "("
1616 // << anInPort->PortName() << ")" << " skipped" ) ;
1627 const char * NodeName = "" ;
1628 const char * InputParamName = "" ;
1630 NodeName = theNode->Name() ;
1632 if ( anInputParam ) {
1633 InputParamName = anInputParam ;
1635 MESSAGE( RetVal->length() << " Links of Node " << NodeName << " and of InPort " << InputParamName ) ;
1636 for ( i = 0 ; i < (int ) RetVal->length() ; i++ ) {
1637 MESSAGE( "Link " << RetVal[i]->OutPort()->Node()->Name() << "("
1638 << RetVal[i]->OutPort()->Name() << ") --> "
1639 << RetVal[i]->InPort()->Node()->Name() << "("
1640 << RetVal[i]->InPort()->Name() << ")" ) ;
1644 endService( "Graph_Impl::Links" );
1647 return ( RetVal._retn() ) ;
1650 Engines::Component_ptr Graph_Impl::ComponentRef( const char * aComputerContainer ,
1651 const char * aComponentName ) {
1652 Engines::Component_var objComponent = Engines::Component::_nil() ;
1654 Engines::Container_var myContainer ;
1655 DataFlowEditor()->Graph()->StartComponent( 0 , aComputerContainer , aComponentName ,
1656 myContainer , objComponent ) ;
1658 return Engines::Component::_duplicate( objComponent ) ;
1661 bool Graph_Impl::IsValid() {
1662 // beginService( "Graph_Impl::IsValid" );
1663 bool RetVal = false ;
1665 RetVal = DataFlowEditor()->IsValid() ;
1667 // endService( "Graph_Impl::IsValid" );
1670 bool Graph_Impl::IsExecutable() {
1671 // beginService( "Graph_Impl::IsExecutable" );
1672 bool RetVal = false ;
1674 // asv : 15.11.04 : added "&& GraphMacroLevel() == 0" ->
1675 // subgraphs are not executable by themselves, RetVal = false..
1676 if ( !IsMacro() && DataFlowEditor()->Graph()->GraphMacroLevel() == 0 ) {
1677 RetVal = DataFlowEditor()->IsExecutable() ;
1679 // endService( "Graph_Impl::IsExecutable" );
1683 bool Graph_Impl::IsEditing() {
1685 bool RetVal = false ;
1687 RetVal = DataFlowEditor()->IsEditing() ;
1693 return !IsExecuting();
1696 bool Graph_Impl::IsExecuting() {
1698 bool RetVal = false ;
1700 RetVal = !DataFlowEditor()->IsEditing() ;
1704 return CNode_Impl::IsExecuting();
1707 bool Graph_Impl::IsReadOnly() {
1708 // beginService( "Graph_Impl::IsExecuting" );
1709 bool RetVal = false ;
1711 RetVal = DataFlowEditor()->IsReadOnly() ;
1713 // endService( "Graph_Impl::IsExecuting" );
1717 long Graph_Impl::LevelMax() {
1718 // beginService( "Graph_Impl::LevelMax" );
1721 RetVal = DataFlowEditor()->LevelMax() ;
1723 // endService( "Graph_Impl::LevelMax" );
1726 SUPERV::ListOfNodes * Graph_Impl::LevelNodes(long aLevel ) {
1727 // beginService( "Graph_Impl::LevelNodes" );
1728 SUPERV::ListOfNodes_var RetVal = new SUPERV::ListOfNodes;
1731 SUPERV::ListOfStrings_var Nodes = DataFlowEditor()->LevelNodes( aLevel ) ;
1732 // RetVal->length( Nodes->length() );
1733 for ( i = 0 ; i < (int ) Nodes->length() ; i++ ) {
1734 // char * aNode = Nodes[ i ] ;
1735 GraphBase::ComputingNode * aNode = DataFlowEditor()->Graph()->GetChangeGraphNode( Nodes[ i ] ) ;
1736 RetVal = SetNode( RetVal , aNode ) ;
1737 // cout << "Graph_Impl::LevelNodes( " << aLevel << " ) " << aNode->Name() << endl ;
1738 // CNode_Impl * myNode = new CNode_Impl( _Orb , _Poa , _ContId ,
1739 // instanceName() , interfaceName() ,
1740 // DataFlowEditor() ,
1741 // (GraphEditor::InNode * ) DataFlowEditor()->GetChangeGraphNode( aNode )->GetInNode() ) ;
1742 // PortableServer::ObjectId * id = myNode->getId() ;
1743 // CORBA::Object_var obj = _poa->id_to_reference(*id);
1744 // SUPERV::CNode_var iobject ;
1745 // iobject = SUPERV::CNode::_narrow(obj) ;
1746 // RetVal[i] = SUPERV::CNode::_duplicate( iobject ) ;
1749 // endService( "Graph_Impl::LevelNodes" );
1750 return ( RetVal._retn() ) ;
1752 long Graph_Impl::ThreadsMax() {
1753 // beginService( "Graph_Impl::ThreadsMax" );
1756 RetVal = DataFlowEditor()->ThreadsMax() ;
1758 // endService( "Graph_Impl::ThreadsMax" );
1761 long Graph_Impl::Threads() {
1762 // beginService( "Node_Impl::Threads" );
1763 long RetVal = false ;
1765 RetVal = DataFlowExecutor()->Threads() ;
1767 // endService( "Node_Impl::Threads" );
1770 long Graph_Impl::SuspendedThreads() {
1771 // beginService( "Node_Impl::SuspendedThreads" );
1772 long RetVal = false ;
1774 RetVal = DataFlowExecutor()->SuspendedThreads() ;
1776 // endService( "Node_Impl::SuspendedThreads" );
1780 bool Graph_Impl::Begin() {
1781 bool RetVal = false ;
1782 if ( DataFlowEditor()->IsEditing() ) {
1783 if ( pthread_mutex_lock( &_MutexExecutorWait ) ) {
1784 perror("pthread_mutex_lock _MutexExecutorWait") ;
1787 if ( DataFlowExecutor() ) {
1788 MESSAGE( "Graph_Impl::Begin " << DataFlowExecutor()->Threads() << " threads" )
1789 Editing(); // just in case it was not called before by GUI..
1791 if ( DataFlowEditor()->IsExecutable() ) {
1792 DataFlowEditor()->EditedAfterExecution( false ) ;
1793 GraphBase::ListOfSGraphs * myListOfGraphs = DataFlowEditor()->GetDataFlows() ;
1795 GraphExecutor::DataFlow * aDataFlowExecutor ;
1797 CreateExecutor( _Orb , instanceName() , (*myListOfGraphs)[ 0 ].Info.theName.c_str() , Kind() ,
1798 dbgfile , &aDataFlowExecutor ) ;
1800 MESSAGE( "Graph_Impl::Begin : DataFlowExecutor created" );
1801 if ( !CORBA::is_nil( LoadDataFlows( aDataFlowExecutor, myListOfGraphs , 0 ) ) )
1805 DataFlowExecutor()->Graph()->SetObjImpl( DataFlowEditor()->Graph()->ObjImpl() ) ;
1808 if ( pthread_mutex_unlock( &_MutexExecutorWait ) ) {
1809 perror("pthread_mutex_unlock _MutexExecutorWait") ;
1817 * run() : was created in order to reduce code dublication, Run() and Start() do the same thing
1818 * except for final call to Executor->Run( bool ) - Run() calls with AndSuspend=false
1819 * and Start() calls with AndSuspend=true flag. The rest of the actions are the same:
1820 * 1. if a MacroNode's coupled graph (MacroLevel>0) -> simply Run() it.
1821 * 2. if a Supergraph -> create executor, load dataflow in it (done in Begin()), then - Run() it.
1823 bool Graph_Impl::run( const bool andSuspend ) {
1824 bool RetVal = false ;
1826 // if Editing or Finished state, and, naturally, 'this' is not a MacroNode.
1827 if ( ( DataFlowEditor()->IsEditing() || IsDone() ) && !IsMacro() ) {
1829 if ( DataFlowEditor()->Graph()->GraphMacroLevel() ) {
1830 // MacroGraph's Executor was created in recursive function LoadDataflows(Executor), called from
1831 // Begin() of Supergraph. See Begin() and LoadDataflows(Executor) for details.
1835 // Create Executor instance and its datamodel
1839 // Set Executing flag to avoid edition operations during execution, EditedAfterExecution=false
1840 DataFlowEditor()->Executing() ;
1841 DataFlowEditor()->EditedAfterExecution( false );
1843 // THE MAIN RUN METHOD
1844 RetVal = DataFlowExecutor()->Run( andSuspend );
1852 * Run() - called on "Execute" command
1854 bool Graph_Impl::Run() {
1855 beginService( "Graph_Impl::Run" );
1856 bool RetVal = run( /*andSuspend=*/false ) ;
1857 MESSAGE( "Graph_Impl::Run " << DataFlowEditor()->Graph()->Name() << " RetVal " << RetVal ) ;
1858 endService( "Graph_Impl::Run" );
1863 * Run() - called on "Execute step-by-step" command
1865 bool Graph_Impl::Start() {
1866 beginService( "Graph_Impl::Start" );
1867 bool RetVal = run( /*andSuspend=*/true ) ;
1868 MESSAGE( "Graph_Impl::Start " << DataFlowEditor()->Graph()->Name() << " RetVal " << RetVal ) ;
1869 endService( "Graph_Impl::Start" );
1873 bool Graph_Impl::EventNoW( SUPERV::CNode_out aNode ,
1874 SUPERV::GraphEvent & anEvent ,
1875 SUPERV::GraphState & aState ) {
1876 bool RetVal = false ;
1877 char * aNodeName = NULL ;
1878 SUPERV::GraphEvent theEvent = SUPERV::UndefinedEvent ;
1879 SUPERV::GraphState theState = SUPERV::UndefinedState ;
1880 if ( pthread_mutex_lock( &_MutexExecutorWait ) ) {
1881 perror("pthread_mutex_lock _MutexExecutorWait") ;
1884 if ( DataFlowExecutor() && !IsMacro() &&
1885 ( DataFlowExecutor()->GetListSize() || !DataFlowEditor()->IsEditing() ) ) {
1886 RetVal = DataFlowExecutor()->Event( & aNodeName , theEvent , theState , false ) ;
1887 // endService( "Graph_Impl::Event" );
1888 if ( strlen( aNodeName ) ) {
1889 if ( strcmp( aNodeName , Name() ) ) {
1890 aNode = Node( aNodeName ) ;
1897 aNode = SUPERV::Graph::_duplicate( SUPERV::Graph::_nil() ) ;
1899 // cout << "Graph_Impl::EventNoW " << aNode->Name() << " QSize " << DataFlowExecutor()->GetListSize() << endl ;
1902 // cout << "Graph_Impl::EventNoW NO DataFlowExecutor() or QSize=0 " << endl ;
1904 if ( pthread_mutex_unlock( &_MutexExecutorWait ) ) {
1905 perror("pthread_mutex_unlock _MutexExecutorWait") ;
1908 anEvent = theEvent ;
1913 bool Graph_Impl::Event( SUPERV::CNode_out aNode ,
1914 SUPERV::GraphEvent & anEvent ,
1915 SUPERV::GraphState & aState ) {
1916 // beginService( "Graph_Impl::Event" );
1917 bool RetVal = false ;
1918 char * aNodeName = NULL ;
1919 SUPERV::GraphEvent theEvent = SUPERV::UndefinedEvent ;
1920 SUPERV::GraphState theState = SUPERV::UndefinedState ;
1921 if ( pthread_mutex_lock( &_MutexExecutorWait ) ) {
1922 perror("pthread_mutex_lock _MutexExecutorWait") ;
1925 if ( DataFlowExecutor() && !IsMacro() &&
1926 ( DataFlowExecutor()->GetListSize() || !DataFlowEditor()->IsEditing() ) ){
1927 RetVal = DataFlowExecutor()->Event( & aNodeName , theEvent , theState ) ;
1928 // endService( "Graph_Impl::Event" );
1929 if ( strlen( aNodeName ) ) {
1930 if ( strcmp( aNodeName , Name() ) ) {
1931 aNode = Node( aNodeName ) ;
1938 aNode = SUPERV::Graph::_duplicate( SUPERV::Graph::_nil() ) ;
1940 // cout << "Graph_Impl::Event " << aNode->Name() << " QSize " << DataFlowExecutor()->GetListSize() << endl ;
1943 // cout << "Graph_Impl::Event NO DataFlowExecutor() or QSize=0 " << endl ;
1945 if ( pthread_mutex_unlock( &_MutexExecutorWait ) ) {
1946 perror("pthread_mutex_unlock _MutexExecutorWait") ;
1949 anEvent = theEvent ;
1955 bool Graph_Impl::EventW( SUPERV::CNode_out aNode ,
1956 SUPERV::GraphEvent & anEvent ,
1957 SUPERV::GraphState & aState ) {
1958 // beginService( "Graph_Impl::EventW" );
1959 bool RetVal = false ;
1960 char * aNodeName = NULL ;
1961 SUPERV::GraphEvent theEvent = SUPERV::UndefinedEvent ;
1962 SUPERV::GraphState theState = SUPERV::UndefinedState ;
1963 if ( pthread_mutex_lock( &_MutexExecutorWait ) ) {
1964 perror("pthread_mutex_lock _MutexExecutorWait") ;
1967 if ( DataFlowExecutor() && !IsMacro() &&
1968 ( DataFlowExecutor()->GetListSize() || !DataFlowEditor()->IsEditing() ) ) {
1969 RetVal = DataFlowExecutor()->EventW( & aNodeName , theEvent , theState ) ;
1970 if ( RetVal && strcmp( aNodeName , Name() ) ) {
1971 aNode = Node( aNodeName ) ;
1977 if ( pthread_mutex_unlock( &_MutexExecutorWait ) ) {
1978 perror("pthread_mutex_unlock _MutexExecutorWait") ;
1981 anEvent = theEvent ;
1983 // endService( "Graph_Impl::EventW" );
1987 long Graph_Impl::EventQSize() {
1988 // beginService( "Graph_Impl::EventQSize" );
1990 if ( pthread_mutex_lock( &_MutexExecutorWait ) ) {
1991 perror("pthread_mutex_lock _MutexExecutorWait") ;
1994 if ( DataFlowExecutor() && !IsMacro() ) {
1995 QSize = DataFlowExecutor()->EventQSize() ;
1997 if ( pthread_mutex_unlock( &_MutexExecutorWait ) ) {
1998 perror("pthread_mutex_unlock _MutexExecutorWait") ;
2001 // endService( "Graph_Impl::EventQSize" );
2005 long Graph_Impl::LastLevelDone() {
2006 // beginService( "Graph_Impl::LastLevelDone" );
2007 if ( pthread_mutex_lock( &_MutexExecutorWait ) ) {
2008 perror("pthread_mutex_lock _MutexExecutorWait") ;
2012 if ( DataFlowExecutor() && !IsMacro() ) {
2013 RetVal = DataFlowExecutor()->LastLevelDone() ;
2015 if ( pthread_mutex_unlock( &_MutexExecutorWait ) ) {
2016 perror("pthread_mutex_unlock _MutexExecutorWait") ;
2019 // endService( "Graph_Impl::LastLevelDone" );
2023 long Graph_Impl::SubGraphsNumber() {
2024 // beginService( "Graph_Impl::SubGraphsNumber" );
2026 if ( DataFlowEditor()->IsExecutable() && !IsMacro() ) {
2027 RetVal = DataFlowEditor()->SubGraphsNumber() ;
2029 // endService( "Graph_Impl::SubGraphsNumber" );
2033 SUPERV::ListOfNodes * Graph_Impl::SubGraphsNodes( const long aSubGraphNumber ) {
2034 beginService( "Graph_Impl::SubGraphsNodes" );
2035 SUPERV::ListOfNodes_var RetVal = new SUPERV::ListOfNodes ;
2036 if ( DataFlowEditor()->IsEditing() && !IsMacro() ) {
2037 SUPERV::ListOfNodes * aGraphNodes = Nodes() ;
2040 for ( i = 0 ; i < (int ) aGraphNodes->CNodes.length() ; i++ ) {
2041 SUPERV::CNode_var aNode = (aGraphNodes->CNodes)[ i ] ;
2042 if ( aNode->SubGraph() == aSubGraphNumber ) {
2043 RetVal = SetNode( RetVal , DataFlowEditor()->Graph()->GetChangeGraphNode( aNode->Name() ) ) ;
2047 for ( i = 0 ; i < (int ) aGraphNodes->FNodes.length() ; i++ ) {
2048 SUPERV::FNode_var aNode = (aGraphNodes->FNodes)[ i ] ;
2049 if ( aNode->SubGraph() == aSubGraphNumber ) {
2050 RetVal = SetNode( RetVal , DataFlowEditor()->Graph()->GetChangeGraphNode( aNode->Name() ) ) ;
2054 for ( i = 0 ; i < (int ) aGraphNodes->INodes.length() ; i++ ) {
2055 SUPERV::INode_var aNode = (aGraphNodes->INodes)[ i ] ;
2056 if ( aNode->SubGraph() == aSubGraphNumber ) {
2057 RetVal = SetNode( RetVal , DataFlowEditor()->Graph()->GetChangeGraphNode( aNode->Name() ) ) ;
2061 for ( i = 0 ; i < (int ) aGraphNodes->GNodes.length() ; i++ ) {
2062 SUPERV::GNode_var aNode = (aGraphNodes->GNodes)[ i ] ;
2063 if ( aNode->SubGraph() == aSubGraphNumber ) {
2064 RetVal = SetNode( RetVal , DataFlowEditor()->Graph()->GetChangeGraphNode( aNode->Name() ) ) ;
2068 for ( i = 0 ; i < (int ) aGraphNodes->LNodes.length() ; i++ ) {
2069 SUPERV::LNode_var aNode = (aGraphNodes->LNodes)[ i ] ;
2070 if ( aNode->SubGraph() == aSubGraphNumber ) {
2071 RetVal = SetNode( RetVal , DataFlowEditor()->Graph()->GetChangeGraphNode( aNode->Name() ) ) ;
2075 for ( i = 0 ; i < (int ) aGraphNodes->ELNodes.length() ; i++ ) {
2076 SUPERV::ELNode_var aNode = (aGraphNodes->ELNodes)[ i ] ;
2077 if ( aNode->SubGraph() == aSubGraphNumber ) {
2078 RetVal = SetNode( RetVal , DataFlowEditor()->Graph()->GetChangeGraphNode( aNode->Name() ) ) ;
2082 for ( i = 0 ; i < (int ) aGraphNodes->SNodes.length() ; i++ ) {
2083 SUPERV::SNode_var aNode = (aGraphNodes->SNodes)[ i ] ;
2084 if ( aNode->SubGraph() == aSubGraphNumber ) {
2085 RetVal = SetNode( RetVal , DataFlowEditor()->Graph()->GetChangeGraphNode( aNode->Name() ) ) ;
2089 for ( i = 0 ; i < (int ) aGraphNodes->ESNodes.length() ; i++ ) {
2090 SUPERV::ESNode_var aNode = (aGraphNodes->ESNodes)[ i ] ;
2091 if ( aNode->SubGraph() == aSubGraphNumber ) {
2092 RetVal = SetNode( RetVal , DataFlowEditor()->Graph()->GetChangeGraphNode( aNode->Name() ) ) ;
2096 endService( "Graph_Impl::SubGraphsNodes" );
2097 return ( RetVal._retn() ) ;
2100 bool Graph_Impl::Merge(const SUPERV::Graph_ptr aGraph ) {
2101 // beginService( "Graph_Impl::Merge" );
2102 bool RetVal = true ;
2104 map< string , int > aMapOfNodes ;
2105 RetVal = Merge( aGraph , aMapOfNodes ) ;
2107 // endService( "Graph_Impl::Merge" );
2111 bool Graph_Impl::Merge(const SUPERV::Graph_ptr aGraph , map< string , int > & aMapOfNodes ) {
2112 beginService( "Graph_Impl::Merge" );
2113 bool RetVal = true ;
2114 if ( DataFlowEditor()->IsEditing() && !IsMacro() ) {
2115 SUPERV::ListOfNodes * aGraphNodes = aGraph->Nodes() ;
2117 SUPERV::Port_ptr aPort ;
2118 // SUPERV::StreamPort_ptr aStreamPort ;
2120 for ( i = 0 ; i < (int ) aGraphNodes->CNodes.length() ; i++ ) {
2121 SUPERV::CNode_var aNode = (aGraphNodes->CNodes)[ i ] ;
2122 SUPERV::CNode_ptr myNode = CNode( *(aNode->Service()) ) ;
2123 if ( !CORBA::is_nil( myNode ) ) {
2124 myNode->SetName( aNode->Name() ) ;
2125 myNode->SetAuthor( aNode->Author() ) ;
2126 myNode->SetComment( aNode->Comment() ) ;
2127 myNode->Coords( aNode->X() , aNode->Y() ) ;
2128 string * aNodetheName = new string( aNode->Name() ) ;
2129 aMapOfNodes[ *aNodetheName ] = DataFlowEditor()->Graph()->GetGraphNodeIndex( myNode->Name() ) ;
2130 delete aNodetheName ;
2137 // The following informations are now in the service from SALOME_ModuleCatalog
2138 // SUPERV::ListOfStreamPorts myStreamPorts = *(aNode->StreamPorts()) ;
2140 // for ( j = 0 ; j < (int ) myStreamPorts.length() ; j++ ) {
2141 // if ( myStreamPorts[ j ]->IsInput() && myStreamPorts[ j ]->IsDataStream() ) {
2142 // aStreamPort = myNode->InStreamPort( myStreamPorts[ j ]->Name() , myStreamPorts[ j ]->Type() ) ;
2144 // else if ( myStreamPorts[ j ]->IsDataStream() ) {
2145 // aStreamPort = myNode->OutStreamPort( myStreamPorts[ j ]->Name() , myStreamPorts[ j ]->Type() ) ;
2151 for ( i = 0 ; i < (int ) aGraphNodes->FNodes.length() ; i++ ) {
2152 SUPERV::FNode_var aNode = (aGraphNodes->FNodes)[ i ] ;
2153 SUPERV::FNode_ptr myNode = FNode( aNode->GetComponentName() ,
2154 aNode->GetInterfaceName() ,
2155 *(aNode->Service()) ) ;
2156 if ( !CORBA::is_nil( myNode ) ) {
2157 myNode->SetName( aNode->Name() ) ;
2158 myNode->SetAuthor( aNode->Author() ) ;
2159 myNode->SetComment( aNode->Comment() ) ;
2160 myNode->Coords( aNode->X() , aNode->Y() ) ;
2161 string * aNodetheName = new string( aNode->Name() ) ;
2162 aMapOfNodes[ *aNodetheName ] = DataFlowEditor()->Graph()->GetGraphNodeIndex( myNode->Name() ) ;
2163 delete aNodetheName ;
2170 // The following informations are now in the service from SALOME_ModuleCatalog
2171 // SUPERV::ListOfStreamPorts myStreamPorts = *(aNode->StreamPorts()) ;
2173 // for ( j = 0 ; j < (int ) myStreamPorts.length() ; j++ ) {
2174 // if ( myStreamPorts[ j ]->IsInput() && myStreamPorts[ j ]->IsDataStream() ) {
2175 // aStreamPort = myNode->InStreamPort( myStreamPorts[ j ]->Name() , myStreamPorts[ j ]->Type() ) ;
2177 // else if ( myStreamPorts[ j ]->IsDataStream() ) {
2178 // aStreamPort = myNode->OutStreamPort( myStreamPorts[ j ]->Name() , myStreamPorts[ j ]->Type() ) ;
2185 for ( i = 0 ; i < (int ) aGraphNodes->INodes.length() ; i++ ) {
2186 SUPERV::INode_var aNode = (aGraphNodes->INodes)[ i ] ;
2187 SUPERV::INode_ptr myNode = INode( aNode->PyFuncName() , *(aNode->PyFunction()) ) ;
2188 if ( !CORBA::is_nil( myNode ) ) {
2189 myNode->SetName( aNode->Name() ) ;
2190 myNode->SetAuthor( aNode->Author() ) ;
2191 myNode->SetComment( aNode->Comment() ) ;
2192 myNode->Coords( aNode->X() , aNode->Y() ) ;
2193 string * aNodetheName = new string( aNode->Name() ) ;
2194 aMapOfNodes[ *aNodetheName ] = DataFlowEditor()->Graph()->GetGraphNodeIndex( myNode->Name() ) ;
2195 delete aNodetheName ;
2196 SUPERV::ListOfPorts myPorts = *(aNode->Ports()) ;
2198 for ( j = 0 ; j < (int ) myPorts.length() ; j++ ) {
2199 if ( myPorts[ j ]->IsInput() ) {
2200 aPort = myNode->InPort( myPorts[ j ]->Name() , myPorts[ j ]->Type() ) ;
2203 aPort = myNode->OutPort( myPorts[ j ]->Name() , myPorts[ j ]->Type() ) ;
2206 if ( DataFlowEditor()->Graph()->IsDataStreamNode() ) {
2207 SUPERV::ListOfStreamPorts myStreamPorts = *(aNode->StreamPorts()) ;
2208 for ( j = 0 ; j < (int ) myStreamPorts.length() ; j++ ) {
2209 if ( myStreamPorts[ j ]->IsInput() ) {
2210 aPort = myNode->InStreamPort( myStreamPorts[ j ]->Name() , StringToDataStreamType( myStreamPorts[ j ]->Type() ) , myStreamPorts[ j ]->Dependency() ) ;
2213 aPort = myNode->OutStreamPort( myStreamPorts[ j ]->Name() , StringToDataStreamType( myStreamPorts[ j ]->Type() ) , myStreamPorts[ j ]->Dependency() ) ;
2227 for ( i = 0 ; i < (int ) aGraphNodes->GNodes.length() ; i++ ) {
2228 SUPERV::GNode_var aNode = (aGraphNodes->GNodes)[ i ] ;
2229 SUPERV::GNode_ptr myNode = GNode( aNode->PyFuncName() , *(aNode->PyFunction()) , aNode->Coupled()->Name() ) ;
2230 if ( !CORBA::is_nil( myNode ) ) {
2231 myNode->SetName( aNode->Name() ) ;
2232 myNode->SetAuthor( aNode->Author() ) ;
2233 myNode->SetComment( aNode->Comment() ) ;
2234 myNode->Coords( aNode->X() , aNode->Y() ) ;
2235 string * aNodetheName = new string( aNode->Name() ) ;
2236 aMapOfNodes[ *aNodetheName ] = DataFlowEditor()->Graph()->GetGraphNodeIndex( myNode->Name() ) ;
2237 delete aNodetheName ;
2238 SUPERV::ListOfPorts myPorts = *(aNode->Ports()) ;
2240 for ( j = 0 ; j < (int ) myPorts.length() ; j++ ) {
2241 if ( myPorts[ j ]->IsInput() ) {
2242 aPort = myNode->InPort( myPorts[ j ]->Name() , myPorts[ j ]->Type() ) ;
2245 aPort = myNode->OutPort( myPorts[ j ]->Name() , myPorts[ j ]->Type() ) ;
2248 if ( DataFlowEditor()->Graph()->IsDataStreamNode() ) {
2249 SUPERV::ListOfStreamPorts myStreamPorts = *(aNode->StreamPorts()) ;
2250 for ( j = 0 ; j < (int ) myStreamPorts.length() ; j++ ) {
2251 if ( myStreamPorts[ j ]->IsInput() ) {
2252 aPort = myNode->InStreamPort( myStreamPorts[ j ]->Name() , StringToDataStreamType( myStreamPorts[ j ]->Type() ) , myStreamPorts[ j ]->Dependency() ) ;
2255 aPort = myNode->OutStreamPort( myStreamPorts[ j ]->Name() , StringToDataStreamType( myStreamPorts[ j ]->Type() ) , myStreamPorts[ j ]->Dependency() ) ;
2269 for ( i = 0 ; i < (int ) aGraphNodes->LNodes.length() ; i++ ) {
2270 SUPERV::LNode_var aNode = (aGraphNodes->LNodes)[ i ] ;
2271 SUPERV::INode_ptr anEndOfLoop ;
2272 SUPERV::LNode_ptr myNode = LNode( aNode->PyInitName() ,
2273 *(aNode->PyInit()) ,
2274 aNode->PyMoreName() ,
2275 *(aNode->PyMore()) ,
2276 aNode->PyNextName() ,
2277 *(aNode->PyNext()) ,
2279 if ( !CORBA::is_nil( myNode ) ) {
2280 myNode->SetName( aNode->Name() ) ;
2281 myNode->SetAuthor( aNode->Author() ) ;
2282 myNode->SetComment( aNode->Comment() ) ;
2283 myNode->Coords( aNode->X() , aNode->Y() ) ;
2284 string * aNodetheName = new string( aNode->Name() ) ;
2285 aMapOfNodes[ *aNodetheName ] = DataFlowEditor()->Graph()->GetGraphNodeIndex( myNode->Name() ) ;
2286 delete aNodetheName ;
2287 SUPERV::ListOfPorts myPorts = *(aNode->Ports()) ;
2289 for ( j = 0 ; j < (int ) myPorts.length() ; j++ ) {
2290 if ( myPorts[ j ]->IsInput() ) {
2291 aPort = myNode->InPort( myPorts[ j ]->Name() , myPorts[ j ]->Type() ) ;
2294 aPort = myNode->OutPort( myPorts[ j ]->Name() , myPorts[ j ]->Type() ) ;
2297 if ( DataFlowEditor()->Graph()->IsDataStreamNode() ) {
2298 SUPERV::ListOfStreamPorts myStreamPorts = *(aNode->StreamPorts()) ;
2299 for ( j = 0 ; j < (int ) myStreamPorts.length() ; j++ ) {
2300 if ( myStreamPorts[ j ]->IsInput() ) {
2301 aPort = myNode->InStreamPort( myStreamPorts[ j ]->Name() , StringToDataStreamType( myStreamPorts[ j ]->Type() ) , myStreamPorts[ j ]->Dependency() ) ;
2304 aPort = myNode->OutStreamPort( myStreamPorts[ j ]->Name() , StringToDataStreamType( myStreamPorts[ j ]->Type() ) , myStreamPorts[ j ]->Dependency() ) ;
2308 SUPERV::INode_ptr myEndOfLoop = aNode->Coupled() ;
2309 anEndOfLoop->SetName( myEndOfLoop->Name() ) ;
2310 anEndOfLoop->SetAuthor( myEndOfLoop->Author() ) ;
2311 anEndOfLoop->SetComment( myEndOfLoop->Comment() ) ;
2312 anEndOfLoop->Coords( myEndOfLoop->X() , myEndOfLoop->Y() ) ;
2313 anEndOfLoop->SetPyFunction( myEndOfLoop->PyFuncName() , *(myEndOfLoop->PyFunction()) ) ;
2314 aNodetheName = new string( myEndOfLoop->Name() ) ;
2315 aMapOfNodes[ *aNodetheName ] = DataFlowEditor()->Graph()->GetGraphNodeIndex( anEndOfLoop->Name() ) ;
2316 if ( DataFlowEditor()->Graph()->IsDataStreamNode() ) {
2317 SUPERV::ListOfStreamPorts myStreamLoopPorts = *(myEndOfLoop->StreamPorts()) ;
2318 for ( j = 0 ; j < (int ) myStreamLoopPorts.length() ; j++ ) {
2319 if ( myStreamLoopPorts[ j ]->IsInput() ) {
2320 aPort = myNode->InStreamPort( myStreamLoopPorts[ j ]->Name() , StringToDataStreamType( myStreamLoopPorts[ j ]->Type() ) , myStreamLoopPorts[ j ]->Dependency() ) ;
2323 aPort = myNode->OutStreamPort( myStreamLoopPorts[ j ]->Name() , StringToDataStreamType( myStreamLoopPorts[ j ]->Type() ) , myStreamLoopPorts[ j ]->Dependency() ) ;
2327 delete aNodetheName ;
2338 for ( i = 0 ; i < (int ) aGraphNodes->SNodes.length() ; i++ ) {
2339 SUPERV::SNode_var aNode = (aGraphNodes->SNodes)[ i ] ;
2340 SUPERV::INode_ptr anEndOfSwitch ;
2341 SUPERV::SNode_ptr myNode = SNode( aNode->PyFuncName() , *(aNode->PyFunction()) , anEndOfSwitch ) ;
2342 if ( !CORBA::is_nil( myNode ) ) {
2343 myNode->SetName( aNode->Name() ) ;
2344 myNode->SetAuthor( aNode->Author() ) ;
2345 myNode->SetComment( aNode->Comment() ) ;
2346 myNode->Coords( aNode->X() , aNode->Y() ) ;
2347 string * aNodetheName = new string( aNode->Name() ) ;
2348 aMapOfNodes[ *aNodetheName ] = DataFlowEditor()->Graph()->GetGraphNodeIndex( myNode->Name() ) ;
2349 delete aNodetheName ;
2350 SUPERV::ListOfPorts myPorts = *(aNode->Ports()) ;
2352 for ( j = 0 ; j < (int ) myPorts.length() ; j++ ) {
2353 if ( myPorts[ j ]->IsInput() ) {
2354 aPort = myNode->InPort( myPorts[ j ]->Name() , myPorts[ j ]->Type() ) ;
2357 aPort = myNode->OutPort( myPorts[ j ]->Name() , myPorts[ j ]->Type() ) ;
2360 if ( DataFlowEditor()->Graph()->IsDataStreamNode() ) {
2361 SUPERV::ListOfStreamPorts myStreamPorts = *(aNode->StreamPorts()) ;
2362 for ( j = 0 ; j < (int ) myStreamPorts.length() ; j++ ) {
2363 if ( myStreamPorts[ j ]->IsInput() ) {
2364 aPort = myNode->InStreamPort( myStreamPorts[ j ]->Name() , StringToDataStreamType( myStreamPorts[ j ]->Type() ) , myStreamPorts[ j ]->Dependency() ) ;
2367 aPort = myNode->OutStreamPort( myStreamPorts[ j ]->Name() , StringToDataStreamType( myStreamPorts[ j ]->Type() ) , myStreamPorts[ j ]->Dependency() ) ;
2371 SUPERV::INode_ptr myEndOfSwitch = aNode->Coupled() ;
2372 anEndOfSwitch->SetName( myEndOfSwitch->Name() ) ;
2373 anEndOfSwitch->SetAuthor( myEndOfSwitch->Author() ) ;
2374 anEndOfSwitch->SetComment( myEndOfSwitch->Comment() ) ;
2375 anEndOfSwitch->Coords( myEndOfSwitch->X() , myEndOfSwitch->Y() ) ;
2376 anEndOfSwitch->SetPyFunction( myEndOfSwitch->PyFuncName() , *(myEndOfSwitch->PyFunction()) ) ;
2377 aNodetheName = new string( myEndOfSwitch->Name() ) ;
2378 aMapOfNodes[ *aNodetheName ] = DataFlowEditor()->Graph()->GetGraphNodeIndex( anEndOfSwitch->Name() ) ;
2379 delete aNodetheName ;
2380 myPorts = *(myEndOfSwitch->Ports()) ;
2381 for ( j = 0 ; j < (int ) myPorts.length() ; j++ ) {
2382 if ( myPorts[ j ]->IsInput() ) {
2383 aPort = myNode->InPort( myPorts[ j ]->Name() , myPorts[ j ]->Type() ) ;
2386 aPort = myNode->OutPort( myPorts[ j ]->Name() , myPorts[ j ]->Type() ) ;
2389 if ( DataFlowEditor()->Graph()->IsDataStreamNode() ) {
2390 SUPERV::ListOfStreamPorts myStreamSwitchPorts = *(myEndOfSwitch->StreamPorts()) ;
2391 for ( j = 0 ; j < (int ) myStreamSwitchPorts.length() ; j++ ) {
2392 if ( myStreamSwitchPorts[ j ]->IsInput() ) {
2393 aPort = myNode->InStreamPort( myStreamSwitchPorts[ j ]->Name() , StringToDataStreamType( myStreamSwitchPorts[ j ]->Type() ) , myStreamSwitchPorts[ j ]->Dependency() ) ;
2396 aPort = myNode->OutStreamPort( myStreamSwitchPorts[ j ]->Name() , StringToDataStreamType( myStreamSwitchPorts[ j ]->Type() ) , myStreamSwitchPorts[ j ]->Dependency() ) ;
2409 SUPERV::ListOfLinks * aGraphLinks = aGraph->GLinks() ;
2410 SUPERV::ListOfPorts * aGraphPorts = aGraph->Ports() ;
2411 // cout << "Graph_Impl::Merge " << aGraphLinks->length() << " links " << aGraphPorts->length() << " GraphPorts"
2413 for ( i = 0 ; i < (int ) aGraphLinks->length() ; i++ ) {
2414 SUPERV::Link_var aLink = (*aGraphLinks)[ i ] ;
2415 SUPERV::Port_var OutPort = aLink->OutPort() ;
2416 SUPERV::Port_var InPort = aLink->InPort() ;
2417 string * aLinkFromNodeName = new string( OutPort->Node()->Name() ) ;
2418 string * aLinkToNodeName = new string( InPort->Node()->Name() ) ;
2419 RetVal = DataFlowEditor()->AddLink( DataFlowEditor()->Graph()->GetGraphNode( aMapOfNodes[ aLinkFromNodeName->c_str() ] )->Name() ,
2421 DataFlowEditor()->Graph()->GetGraphNode( aMapOfNodes[ aLinkToNodeName->c_str() ] )->Name() ,
2425 for ( j = 1 ; j <= aLink->CoordsSize() ; j++ ) {
2427 RetVal = aLink->Coords( j , X , Y ) ;
2430 RetVal = DataFlowEditor()->AddLinkCoord( DataFlowEditor()->Graph()->GetGraphNode( aMapOfNodes[ aLinkFromNodeName->c_str() ] )->Name() ,
2432 DataFlowEditor()->Graph()->GetGraphNode( aMapOfNodes[ aLinkToNodeName->c_str() ] )->Name() ,
2440 delete aLinkFromNodeName ;
2441 delete aLinkToNodeName ;
2447 for ( i = 0 ; i < (int ) aGraphPorts->length() ; i++ ) {
2448 SUPERV::Port_var aPort = (*aGraphPorts)[ i ] ;
2449 if ( !aPort->IsGate() ) {
2450 MESSAGE( "Graph_Impl::Merge " << i << ". " << aPort->Node()->Name() << " " << aPort->Name() ) ;
2451 char * aPortName = aPort->Name() ;
2452 char * aNodeName = new char[ strlen( aPortName ) + 1 ] ;
2453 strcpy( aNodeName , aPortName ) ;
2454 // char * thePortName = strchr( aNodeName , '\\' ) ;
2455 char * thePortName = aNodeName ;
2456 while ( ( thePortName = strchr( thePortName , '_' ) ) ) {
2457 if ( thePortName[1] == '_' ) {
2458 thePortName[ 0 ] = '\0' ;
2462 thePortName = &thePortName[2] ;
2465 bool hasinput = aGraph->Node( aNodeName )->Port( thePortName + 2 )->HasInput() ;
2466 // cout << "Graph_Impl::Merge " << " aNodeName " << aNodeName << " aPort " << thePortName + 1
2467 // << " HasInput " << hasinput << endl ;
2469 RetVal = DataFlowEditor()->AddInputData( DataFlowEditor()->Graph()->GetGraphNode( aMapOfNodes[ aNodeName ] )->Name() ,
2471 *(aPort->ToAny()) ) ;
2473 delete [] aNodeName ;
2482 MESSAGE( "Graph_Impl::Merge returns " << RetVal ) ;
2483 endService( "Graph_Impl::Merge" );
2487 SUPERV::StreamGraph_ptr Graph_Impl::ToStreamGraph() {
2488 SUPERV::StreamGraph_var iobject = SUPERV::StreamGraph::_nil() ;
2489 beginService( "Graph_Impl::ToStreamGraph" );
2490 if ( IsStreamGraph() && !IsMacro() ) {
2491 // StreamGraph_Impl * myStreamGraph = new StreamGraph_Impl( _Orb , _Poa , _ContId ,
2492 // instanceName() , interfaceName() ) ;
2493 // PortableServer::ObjectId * id = myStreamGraph->getId() ;
2494 // CORBA::Object_var obj = _poa->id_to_reference(*id);
2495 iobject = SUPERV::StreamGraph::_narrow( ObjRef() ) ;
2496 if ( CORBA::is_nil( iobject ) ) {
2497 MESSAGE( "ToStreamGraph of " << Name() << " (IsStreamGraph) --> nil reference" ) ;
2501 MESSAGE( "ToStreamGraph of " << Name() << " (IsNOTStreamGraph) --> nil reference" ) ;
2503 endService( "Graph_Impl::ToStreamGraph" );
2504 return SUPERV::StreamGraph::_duplicate( iobject ) ;
2508 * Destroy Executor and use only Editor and its data model
2510 void Graph_Impl::Editing() {
2511 if ( DataFlowEditor() && DataFlowExecutor() ) {
2512 delete DataFlowExecutor() ;
2513 DataFlowEditor()->Executor( NULL );