1 // SUPERV Supervision : contains the implementation of interfaces of SuperVision described in SUPERV.idl
3 // Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 // See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
24 // File : Graph_Impl.cxx
25 // Author : Jean Rahuel
35 //#include "utilities.h"
37 #include "SALOME_Container_i.hxx"
39 #include "StreamGraph_Impl.hxx"
41 #include "DataFlowEditor_DataFlow.hxx"
43 extern GraphExecutor::FiniteStateMachine * theAutomaton ;
45 static void CreateEditor( CORBA::ORB_ptr orb ,
46 const char *instanceName ,
47 const char *aDataFlowName ,
48 const SUPERV::KindOfNode aKindOfNode ,
50 GraphEditor::DataFlow ** aDataFlowEditor ) {
51 bool aXmlFile = false ;
52 int lenname = strlen( aDataFlowName ) ;
53 char * theDataFlowName = new char [ lenname+1 ] ;
54 strcpy( theDataFlowName , aDataFlowName ) ;
55 if ( aDataFlowName ) {
56 if ( lenname > 4 && !strcmp( &aDataFlowName[ lenname - 4 ] , ".xml" ) ) {
57 strncpy( theDataFlowName , &aDataFlowName[ 0 ] , lenname-4 ) ;
58 theDataFlowName[ lenname-4 ] = '\0' ;
61 for ( i = lenname - 5 ; i >= 0 ; i-- ) {
62 if ( aDataFlowName[ i ] == '/' ) {
63 strncpy( theDataFlowName , &aDataFlowName[ i + 1 ] , lenname-5-i ) ;
64 theDataFlowName[ lenname-5-i ] = '\0' ;
70 strcpy( theDataFlowName , &aDataFlowName[ 0 ] ) ;
74 string theDataFlowInstanceName = theDataFlowName ;
76 // asv : 16.11.04 : creation of log file in /tmp/logs/$USER dir.
77 // "/tmp/logs/$USER" was created by runSalome.py -> orbmodule.py.
78 dbgfile = "/tmp/logs/" ;
79 dbgfile += getenv( "USER" ) ;
81 dbgfile += instanceName ;
83 dbgfile += theDataFlowInstanceName ;
84 dbgfile = dbgfile + "_" + theAutomaton->DbgFileNumber() + ".log" ;
85 FILE* f = fopen ( dbgfile.c_str(), "a" );
86 if ( f ) { // check if file can be opened for writing
89 else { // if file can't be opened - use a guaranteed temp file name
90 char* aTempNam = tempnam( NULL, NULL );
95 SALOME_NamingService * NamingService = new SALOME_NamingService( orb ) ;
96 *aDataFlowEditor = new GraphEditor::DataFlow( orb , NamingService ,
97 theDataFlowInstanceName.c_str() , dbgfile.c_str() ,
99 MESSAGE( "CreateEditor " << theDataFlowName << " uniquely named " << theDataFlowInstanceName << " created with "
100 << dbgfile.c_str() ) ;
102 delete [] theDataFlowName ;
105 static void CreateExecutor( CORBA::ORB_ptr orb ,
106 const char *instanceName ,
107 const char *aDataFlowName ,
108 const SUPERV::KindOfNode aKindOfNode ,
110 GraphExecutor::DataFlow ** aDataFlowExecutor ) {
111 int lenname = strlen( aDataFlowName ) ;
112 char * theDataFlowName = new char [ lenname+1 ] ;
113 strcpy( theDataFlowName , aDataFlowName ) ;
114 if ( aDataFlowName ) {
115 strcpy( theDataFlowName , &aDataFlowName[ 0 ] ) ;
118 string theDataFlowInstanceName = theDataFlowName ;
120 // asv : 16.11.04 : creation of log file in /tmp/logs/$USER dir.
121 // "/tmp/logs/$USER" was created by runSalome.py -> orbmodule.py.
122 dbgfile = "/tmp/logs/" ;
123 dbgfile += getenv( "USER" ) ;
125 dbgfile += instanceName ;
127 dbgfile += theDataFlowInstanceName ;
128 dbgfile = dbgfile + "_" + theAutomaton->DbgFileNumber() ;
130 astr << theAutomaton->ExecNumber() ;
131 dbgfile += astr.str() ;
132 dbgfile += string( "_Exec.log" ) ;
133 FILE* f = fopen ( dbgfile.c_str(), "a" );
134 if ( f ) { // check if file can be opened for writing
137 else { // if file can't be opened - use a guaranteed temp file name
138 char* aTempNam = tempnam( NULL, NULL );
143 SALOME_NamingService * NamingService = new SALOME_NamingService( orb ) ;
144 *aDataFlowExecutor = new GraphExecutor::DataFlow( orb , NamingService ,
145 theDataFlowInstanceName.c_str() , dbgfile.c_str() ,
148 MESSAGE( "CreateExecutor " << theDataFlowName << " " << theDataFlowInstanceName << " created with "
149 << dbgfile.c_str() ) ;
151 delete [] theDataFlowName ;
154 Graph_Impl::Graph_Impl( CORBA::ORB_ptr orb ,
155 PortableServer::POA_ptr poa ,
156 PortableServer::ObjectId * contId ,
157 const char *instanceName ,
158 const char *interfaceName ,
159 const char *aDataFlowName ,
160 const SUPERV::KindOfNode aKindOfNode ) :
161 GNode_Impl( orb , poa , contId , instanceName , interfaceName , aDataFlowName , aKindOfNode ) {
162 // MESSAGE("Graph_Impl::Graph_Impl activate object instanceName("
163 // << instanceName << ") interfaceName(" << interfaceName << ") --> "
164 // << hex << (void *) this << dec )
165 // beginService( "Graph_Impl::Graph_Impl" );
166 _Orb = CORBA::ORB::_duplicate(orb);
169 _DebugFileName = NULL ;
170 if ( aKindOfNode == SUPERV::DataFlowGraph || aKindOfNode == SUPERV::MacroNode ) {
171 // MESSAGE( "Graph_Impl::Graph_Impl _poa->activate_object" );
173 _id = _poa->activate_object(_thisObj);
176 // MESSAGE( "Graph_Impl::Graph_Impl NO _poa->activate_object " );
179 if ( aKindOfNode == SUPERV::DataFlowGraph || aKindOfNode == SUPERV::DataStreamGraph ) {
181 GraphEditor::DataFlow * aDataFlowEditor ;
182 CreateEditor( orb , instanceName , aDataFlowName , aKindOfNode ,
183 dbgfile , &aDataFlowEditor ) ;
185 if ( _DebugFileName ) {
186 delete [] _DebugFileName ;
188 _DebugFileName = new char[ strlen( dbgfile.c_str() )+1 ] ;
189 strcpy( _DebugFileName , dbgfile.c_str() ) ;
191 _NamingService = new SALOME_NamingService( orb ) ;
192 DataFlowEditor( aDataFlowEditor ) ;
193 DataFlowEditor()->Graph()->GraphEditor( aDataFlowEditor ) ;
194 DataFlowEditor()->Graph()->SetObjImpl( this ) ;
196 pthread_mutex_init( &_MutexExecutorWait , NULL ) ;
197 // DataFlowExecutor( NULL ) ;
198 // endService( "Graph_Impl::Graph_Impl" );
201 Graph_Impl::Graph_Impl( CORBA::ORB_ptr orb ,
202 PortableServer::POA_ptr poa ,
203 PortableServer::ObjectId * contId ,
204 const char *instanceName ,
205 const char *interfaceName ,
206 GraphEditor::DataFlow * aDataFlowEditor ,
207 GraphEditor::InNode * aDataFlowNode ) :
208 GNode_Impl( orb , poa , contId , instanceName , interfaceName , aDataFlowEditor , aDataFlowNode ) {
209 // beginService( "Graph_Impl::Graph_Impl" );
210 // MESSAGE( aDataFlowEditor->Graph()->Name() << " " );
211 if ( aDataFlowEditor->Graph()->IsDataFlowNode() ||
212 ( aDataFlowNode && aDataFlowNode->IsMacroNode() ) ) {
213 // MESSAGE( "Graph_Impl::Graph_Impl _poa->activate_object" );
215 _id = _poa->activate_object(_thisObj);
218 // MESSAGE( "Graph_Impl::Graph_Impl NO _poa->activate_object " );
220 _Orb = CORBA::ORB::_duplicate(orb);
223 _DebugFileName = NULL ;
224 DataFlowEditor( aDataFlowEditor ) ;
225 DataFlowEditor()->Graph()->GraphEditor( aDataFlowEditor ) ;
226 DataFlowEditor()->Graph()->SetObjImpl( this ) ;
227 pthread_mutex_init( &_MutexExecutorWait , NULL ) ;
228 // DataFlowExecutor( NULL ) ;
229 // endService( "Graph_Impl::Graph_Impl" );
232 Graph_Impl::Graph_Impl() {
235 Graph_Impl::~Graph_Impl() {
236 beginService( "Graph_Impl::~Graph_Impl" );
237 endService( "Graph_Impl::~Graph_Impl" );
240 void Graph_Impl::destroy() {
241 beginService( "Graph_Impl::destroy" );
242 if ( DataFlowNode() && DataFlowNode()->ComputingNode()->IsMacroNode() ) {
243 SUPERV::Graph_var aGraph = DataFlowNode()->GOTONode()->MacroObject() ;
244 GNode_Impl::Delete() ;
245 if ( !CORBA::is_nil( aGraph ) ) {
250 SUPERV::Graph_var aGraph = DataFlowEditor()->Graph()->MacroObject() ;
251 GNode_Impl::Delete() ;
252 if ( !CORBA::is_nil( aGraph ) ) {
256 _poa->deactivate_object(*_id) ;
257 CORBA::release(_poa) ;
259 _thisObj->_remove_ref();
260 endService( "Graph_Impl::destroy" );
264 char* Graph_Impl::getIOR() {
266 return CORBA::string_dup( NULLSTRING ) ;
268 else if ( CORBA::is_nil( myServant ) ) {
269 PortableServer::ObjectId* id = getId();
270 CORBA::Object_var obj;
271 obj = _poa->id_to_reference(*id);
272 myServant = SUPERV::Graph::_narrow(obj);
274 return(CORBA::string_dup(_Orb->object_to_string(myServant)));
277 SUPERV::Graph_ptr Graph_Impl::Copy() {
278 beginService( "Graph_Impl::Copy" );
279 SUPERV::Graph_var iobject = SUPERV::Graph::_nil() ;
281 Graph_Impl * myGraph ;
282 myGraph = new Graph_Impl( _Orb , _Poa, _ContId,
283 instanceName() , interfaceName() ,
284 DataFlowEditor()->Graph()->Name() , SUPERV::DataFlowGraph ) ;
285 PortableServer::ObjectId * id = myGraph->getId() ;
286 CORBA::Object_var obj = _poa->id_to_reference(*id);
287 iobject = SUPERV::Graph::_narrow(obj) ;
288 GraphBase::ListOfSGraphs * aListOfSGraphs = GetGraphs() ;
289 myGraph->LoadGraphs( aListOfSGraphs ) ;
291 endService( "Graph_Impl::Copy" );
292 return SUPERV::Graph::_duplicate(iobject) ;
295 void Graph_Impl::ReadOnly() {
296 DataFlowEditor()->ReadOnly() ;
299 SUPERV::INode_ptr Graph_Impl::Node() {
300 // beginService( "Graph_Impl::Node" );
301 PortableServer::ObjectId * id = getId() ;
302 CORBA::Object_var obj = _poa->id_to_reference(*id);
303 SUPERV::Graph_var iobject ;
304 iobject = SUPERV::Graph::_narrow(obj) ;
305 // endService( "Graph_Impl::Node" );
306 return SUPERV::Graph::_duplicate(iobject) ;
309 GraphBase::ListOfSGraphs * Graph_Impl::GetGraphs() {
310 return DataFlowEditor()->GetDataFlows() ;
313 bool Graph_Impl::LoadGraphs( GraphBase::ListOfSGraphs * aListOfDataFlows ) {
314 beginService( "Graph_Impl::LoadGraphs" );
315 bool RetVal = false ;
316 if ( DataFlowEditor()->IsEditing() ) {
317 // RetVal = DataFlowEditor()->LoadDataFlows( aListOfDataFlows ) ;
318 if ( CORBA::is_nil( LoadDataFlows( DataFlowEditor() , aListOfDataFlows , 0 ) ) ) {
322 endService( "Graph_Impl::LoadGraphs" );
326 bool Graph_Impl::Import(const char * aXmlFile ) {
327 beginService( "Graph_Impl::Import" );
328 bool RetVal = false ;
329 if ( DataFlowEditor()->IsEditing() && !IsMacro() ) {
330 GraphBase::ListOfSGraphs aListOfDataFlows ;
331 RetVal = DataFlowEditor()->LoadXml( aXmlFile , aListOfDataFlows ) ;
332 if ( RetVal && aXmlFile != NULL ) {
333 // RetVal = DataFlowEditor()->LoadDataFlows( &aListOfDataFlows ) ;
334 if ( CORBA::is_nil( LoadDataFlows( DataFlowEditor() , &aListOfDataFlows , 0 ) ) ) {
339 endService( "Graph_Impl::Import" );
343 bool Graph_Impl::Export(const char * anXmlFile ) {
344 beginService( "Graph_Impl::Export" );
345 bool RetVal = false ;
347 char * aFile = new char [ strlen( anXmlFile ) + 5 ] ;
348 strcpy( aFile , anXmlFile ) ;
349 int len = strlen( aFile ) ;
350 if ( !strcmp( &aFile[ len - 4 ] , ".xml" ) ) {
352 else if ( !strcmp( &aFile[ len - 3 ] , ".py" ) ) {
353 strcpy( &aFile[ len - 3 ] , ".xml" ) ;
354 len = strlen( aFile ) ;
357 strcat( aFile , ".xml" ) ;
358 len = strlen( aFile ) ;
360 RetVal = DataFlowEditor()->SaveXml( aFile ) ;
362 strcpy( &aFile[ len - 4 ] , ".py" ) ;
363 RetVal = DataFlowEditor()->SavePy( aFile ) ;
367 endService( "Graph_Impl::Export" );
371 SUPERV::CNode_ptr Graph_Impl::CNode( const SALOME_ModuleCatalog::Service &NodeService ) {
372 beginService( "Graph_Impl::CNode" );
373 SUPERV::CNode_var iobject = SUPERV::CNode::_nil() ;
374 if ( DataFlowEditor()->IsEditing() && !DataFlowEditor()->IsReadOnly() && !IsMacro() ) {
375 CNode_Impl * myNode = new CNode_Impl( _Orb , _Poa , _ContId ,
376 instanceName() , interfaceName() ,
378 NodeService , NULLSTRING ,
379 SUPERV::ComputingNode , NULLSTRING ) ;
380 if ( myNode->DataFlowNode() ) {
381 PortableServer::ObjectId * id = myNode->getId() ;
382 CORBA::Object_var obj = _poa->id_to_reference(*id);
383 iobject = SUPERV::CNode::_narrow(obj) ;
384 myNode->SetObjRef( SUPERV::CNode::_duplicate( iobject ) ) ;
387 DataFlowEditor()->UnValid() ;
388 endService( "Graph_Impl::CNode" );
389 return SUPERV::CNode::_duplicate( iobject ) ;
392 SUPERV::FNode_ptr Graph_Impl::FNode( const char * NodeComponentName ,
393 const char * NodeInterfaceName ,
394 const SALOME_ModuleCatalog::Service &NodeService ) {
395 beginService( "Graph_Impl::FNode" );
396 SUPERV::FNode_var iobject = SUPERV::FNode::_nil() ;
397 if ( DataFlowEditor()->IsEditing() && !DataFlowEditor()->IsReadOnly() && !IsMacro() ) {
398 FNode_Impl * myNode = new FNode_Impl( _Orb , _Poa , _ContId ,
399 instanceName() , interfaceName() ,
403 NodeInterfaceName ) ;
404 if ( myNode->DataFlowNode() ) {
405 PortableServer::ObjectId * id = myNode->getId() ;
406 CORBA::Object_var obj = _poa->id_to_reference(*id);
407 iobject = SUPERV::FNode::_narrow(obj) ;
408 myNode->SetObjRef( SUPERV::FNode::_duplicate( iobject ) ) ;
411 DataFlowEditor()->UnValid() ;
412 endService( "Graph_Impl::FNode" );
413 return SUPERV::FNode::_duplicate( iobject ) ;
416 SUPERV::INode_ptr Graph_Impl::INode( const char * FuncName ,
417 const SUPERV::ListOfStrings & PythonFuntion ) {
418 beginService( "Graph_Impl::INode" );
419 SUPERV::INode_var iobject = SUPERV::INode::_nil() ;
420 if ( DataFlowEditor()->IsEditing() && !DataFlowEditor()->IsReadOnly() && !IsMacro() ) {
421 INode_Impl * myNode = new INode_Impl( _Orb , _Poa , _ContId ,
422 instanceName() , interfaceName() ,
424 FuncName , PythonFuntion ,
425 SUPERV::InLineNode ) ;
426 if ( myNode->DataFlowNode() ) {
427 PortableServer::ObjectId * id = myNode->getId() ;
428 CORBA::Object_var obj = _poa->id_to_reference(*id);
429 iobject = SUPERV::INode::_narrow(obj) ;
430 myNode->SetObjRef( SUPERV::INode::_duplicate( iobject ) ) ;
433 endService( "Graph_Impl::INode" );
434 return SUPERV::INode::_duplicate( iobject ) ;
438 SUPERV::GNode_ptr Graph_Impl::GNode( const char * FuncName ,
439 const SUPERV::ListOfStrings & PythonFuntion ,
440 const char * anInLineNode ) {
441 beginService( "Graph_Impl::GNode" );
442 SUPERV::GNode_var iobject = SUPERV::GNode::_nil() ;
443 if ( DataFlowEditor()->IsEditing() && !DataFlowEditor()->IsReadOnly() && !IsMacro() ) {
444 GNode_Impl * myNode = new GNode_Impl( _Orb , _Poa , _ContId ,
445 instanceName() , interfaceName() ,
447 FuncName , PythonFuntion ,
449 if ( myNode->DataFlowNode() ) {
450 PortableServer::ObjectId * id = myNode->getId() ;
451 CORBA::Object_var obj = _poa->id_to_reference(*id);
452 iobject = SUPERV::GNode::_narrow(obj) ;
453 myNode->SetObjRef( SUPERV::GNode::_duplicate( iobject ) ) ;
454 if ( strlen( anInLineNode ) ) {
455 GraphBase::InLineNode * CoupledINode = (GraphBase::InLineNode * ) DataFlowEditor()->Graph()->GetGraphNode( anInLineNode ) ;
456 if ( anInLineNode ) {
457 myNode->SetCoupled( anInLineNode ) ;
458 Link( myNode->Port( "OutGate" ) , CoupledINode->ObjRef()->Port( "InGate" ) ) ;
463 DataFlowEditor()->UnValid() ;
464 endService( "Graph_Impl::GNode" );
465 return SUPERV::GNode::_duplicate( iobject ) ;
468 SUPERV::LNode_ptr Graph_Impl::LNode( const char * InitName ,
469 const SUPERV::ListOfStrings & InitFunction ,
470 const char * MoreName ,
471 const SUPERV::ListOfStrings & MoreFunction ,
472 const char * NextName ,
473 const SUPERV::ListOfStrings & NextFunction ,
474 SUPERV::INode_out anEndOfLoop ) {
475 beginService( "Graph_Impl::LNode" );
476 SUPERV::LNode_var iobject = SUPERV::LNode::_nil() ;
477 SUPERV::ELNode_var iendobject = SUPERV::ELNode::_nil() ;
478 if ( DataFlowEditor()->IsEditing() && !DataFlowEditor()->IsReadOnly() && !IsMacro() ) {
479 GraphBase::ListOfFuncName FuncNameList ;
480 FuncNameList.resize(3) ;
481 FuncNameList[0] = InitName ;
482 FuncNameList[1] = MoreName ;
483 FuncNameList[2] = NextName ;
484 GraphBase::ListOfPythonFunctions PythonFunctionList ;
485 PythonFunctionList.resize(3) ;
486 PythonFunctionList[0] = &InitFunction ;
487 PythonFunctionList[1] = &MoreFunction ;
488 PythonFunctionList[2] = &NextFunction ;
489 LNode_Impl * myNode = new LNode_Impl( _Orb , _Poa , _ContId ,
490 instanceName() , interfaceName() ,
492 FuncNameList , PythonFunctionList ,
493 // InitName , InitFunction ,
494 // MoreName , MoreFunction ,
495 // NextName , NextFunction ,
497 if ( myNode->DataFlowNode() ) {
498 PortableServer::ObjectId * id = myNode->getId() ;
499 CORBA::Object_var obj = _poa->id_to_reference(*id);
500 iobject = SUPERV::LNode::_narrow(obj) ;
501 myNode->SetObjRef( SUPERV::LNode::_duplicate( iobject ) ) ;
503 SALOME_ModuleCatalog::Service aVoidService = SALOME_ModuleCatalog::Service() ;
505 if ( strlen( InitName ) ) {
506 anEndName = new char( 3 + strlen( InitName ) + 1 ) ;
507 strcpy( anEndName , "End" ) ;
508 strcat( anEndName , InitName ) ;
511 anEndName = new char( 3 + strlen( "Loop" ) + 1 ) ;
512 strcpy( anEndName , "EndLoop" ) ;
514 ELNode_Impl * myEndNode = new ELNode_Impl( _Orb , _Poa , _ContId ,
515 instanceName() , interfaceName() ,
518 SUPERV::EndLoopNode ) ;
519 PortableServer::ObjectId * endid = myEndNode->getId() ;
520 CORBA::Object_var endobj = _poa->id_to_reference(*endid);
521 iendobject = SUPERV::ELNode::_narrow(endobj) ;
522 myEndNode->SetObjRef( SUPERV::ELNode::_duplicate( iendobject ) ) ;
523 myNode->SetCoupled( myEndNode->BaseNode()->Name() ) ;
524 myEndNode->SetCoupled( myNode->BaseNode()->Name() ) ;
525 //JR 25.01.2005 That links are already done in SetCoupled above ...
526 // Link( myNode->Port( "DoLoop" ) , myEndNode->Port( "DoLoop" ) ) ;
527 // Link( myEndNode->Port( "DoLoop" ) , myNode->Port( "InitLoop" ) ) ;
528 // Link( myEndNode->Port( "DoLoop" ) , myNode->Port( "DoLoop" ) ) ;
531 anEndOfLoop = SUPERV::ELNode::_duplicate( iendobject ) ;
532 DataFlowEditor()->UnValid() ;
533 endService( "Graph_Impl::LNode" );
534 return SUPERV::LNode::_duplicate( iobject ) ;
537 SUPERV::SNode_ptr Graph_Impl::SNode( const char * FuncName ,
538 const SUPERV::ListOfStrings & PythonFunction ,
539 SUPERV::INode_out anEndOfSwitch ) {
540 beginService( "Graph_Impl::SNode" );
541 SUPERV::SNode_var iobject = SUPERV::SNode::_nil() ;
542 SUPERV::ESNode_var iendobject = SUPERV::ESNode::_nil() ;
543 if ( DataFlowEditor()->IsEditing() && !DataFlowEditor()->IsReadOnly() && !IsMacro() ) {
544 SNode_Impl * myNode = new SNode_Impl( _Orb , _Poa , _ContId ,
545 instanceName() , interfaceName() ,
547 FuncName , PythonFunction ,
548 SUPERV::SwitchNode ) ;
549 if ( myNode->DataFlowNode() ) {
550 PortableServer::ObjectId * id = myNode->getId() ;
551 CORBA::Object_var obj = _poa->id_to_reference(*id);
552 iobject = SUPERV::SNode::_narrow(obj) ;
553 myNode->SetObjRef( SUPERV::SNode::_duplicate( iobject ) ) ;
555 string anEndName = "End" ;
556 if ( strlen( FuncName ) ) {
557 anEndName += FuncName ;
560 anEndName += "Switch" ;
562 // cout << "Graph_Impl::SNode anEndName " << (void *) FuncName << " " << FuncName
563 // << " " << strlen(FuncName) << " " << (void *) anEndName.c_str() << " "
564 // << anEndName.c_str() << endl ;
565 ESNode_Impl * myEndNode = new ESNode_Impl( _Orb , _Poa , _ContId ,
566 instanceName() , interfaceName() ,
569 SUPERV::EndSwitchNode ) ;
570 // cout << "Graph_Impl::SNode returned anEndName " << (void *) FuncName << " "
571 // << FuncName << " " << strlen(FuncName) << " " << (void *) anEndName.c_str()
572 // << " " << anEndName.c_str() << endl ;
573 PortableServer::ObjectId * endid = myEndNode->getId() ;
574 CORBA::Object_var endobj = _poa->id_to_reference(*endid);
575 iendobject = SUPERV::ESNode::_narrow(endobj) ;
576 myEndNode->SetObjRef( SUPERV::ESNode::_duplicate( iendobject ) ) ;
577 myNode->SetCoupled( myEndNode->BaseNode()->Name() ) ;
578 myEndNode->SetCoupled( myNode->BaseNode()->Name() ) ;
579 if ( !Link( myNode->Port( "Default" ) , myEndNode->Port( "Default" ) ) ) {
580 iobject = SUPERV::SNode::_nil() ;
581 iendobject = SUPERV::ESNode::_nil() ;
585 anEndOfSwitch = SUPERV::ESNode::_duplicate( iendobject ) ;
586 DataFlowEditor()->UnValid() ;
587 endService( "Graph_Impl::SNode" );
588 return SUPERV::SNode::_duplicate( iobject ) ;
591 // WARNING : THIS IS COMPLICATED :
592 SUPERV::Graph_var Graph_Impl::LoadDataFlows( GraphEditor::DataFlow * aDataFlowEditor ,
593 GraphBase::ListOfSGraphs * aListOfDataFlows ,
595 beginService( "Graph_Impl::EditorLoadDataFlows" ) ;
596 MESSAGE("Graph_Impl::LoadDataFlows index " << index << " " << (*aListOfDataFlows)[index].Info.theName.c_str() ) ;
598 SUPERV::Graph_var iobject = SUPERV::Graph::_nil() ;
599 // That method is recursive :
600 // At first we load the supergraph with index = 0 :
601 // (After we load the graph corresponding to each MacroNode :)
602 if ( !aDataFlowEditor->LoadDataFlow( &(*aListOfDataFlows)[ index ] ) ) {
603 MESSAGE("Graph_Impl::LoadDataFlows failed " << (*aListOfDataFlows)[index].Info.theName.c_str() ) ;
604 return SUPERV::Graph::_duplicate( iobject ) ;
606 // That graph is not a StreamGraph :
607 else if ( !aDataFlowEditor->Graph()->HasDataStream() ) {
608 aDataFlowEditor->Graph()->Kind( SUPERV::DataFlowGraph ) ;
609 // aDataFlowEditor->Graph()->SetGraphEditor( aDataFlowEditor ) ;
610 Graph_Impl * myGraph ;
611 // We create a Graph ObjRef for that graph
612 myGraph = new Graph_Impl( _Orb , _Poa, _ContId,
613 instanceName() , interfaceName() ,
614 aDataFlowEditor , NULL ) ;
615 PortableServer::ObjectId * id = myGraph->getId() ;
616 CORBA::Object_var obj = _poa->id_to_reference(*id) ;
617 iobject = SUPERV::Graph::_narrow( obj ) ;
618 myGraph->SetObjRef( SUPERV::Graph::_duplicate( iobject ) ) ;
619 myGraph->SetObjImpl( (CNode_Impl * ) myGraph ) ;
620 GraphBase::Graph * aGraph = myGraph->DataFlowEditor()->Graph() ;
623 // asv: set Editor for the graph itself and for all its macro nodes
624 aGraph->GraphEditor( aDataFlowEditor );
626 // For the supergraph or each graph of MacroNodes we search MacroNodes recursively :
627 for ( i = 0 ; i < aGraph->GraphNodesSize() ; i++ ) {
628 if ( aGraph->GraphNodes( i )->IsMacroNode() ) {
629 GraphBase::GOTONode * aMacroNode = (GraphBase::GOTONode * ) aGraph->GraphNodes( i ) ;
631 // asv : 05.11.04 : fix of bug - "insert file" into existing graph with MacroNodes worked incorrectly!
632 // aMacroNode is an "old" node, and here we must analize only "new" nodes, that
633 // came from aListOfDataFlows and were loaded by aDataFlowEditor->LoadDataFlow( &(*aListOfDataFlows)[ index ] )
634 // so here we check if the node is "new" or "old"
635 if ( aMacroNode->GraphEditor() && aMacroNode->CoupledNode() )
638 // asv: set Editor for the graph itself and for all its macro nodes
639 aMacroNode->GraphEditor( aDataFlowEditor );
641 // Creation of a GraphMacroNode ObjRef in the current editor
642 SUPERV::Graph_var macroiobject = SUPERV::Graph::_nil() ;
643 Graph_Impl * myMacroNode ;
644 myMacroNode = new Graph_Impl( _Orb , _Poa, _ContId,
645 instanceName() , interfaceName() ,
646 aMacroNode->Name() , SUPERV::MacroNode ) ;
647 id = myMacroNode->getId() ;
648 obj = _poa->id_to_reference(*id);
649 macroiobject = SUPERV::Graph::_narrow( obj ) ;
650 myMacroNode->DataFlowEditor( aDataFlowEditor ) ;
651 GraphEditor::InNode * aDataFlowNode = (GraphEditor::InNode * ) aMacroNode->GetInNode() ;
652 myMacroNode->DataFlowNode( aDataFlowNode ) ;
653 aDataFlowNode->SetObjRef( SUPERV::CNode::_duplicate( SUPERV::CNode::_narrow( obj ) ) ) ;
654 aDataFlowNode->SetObjImpl( myMacroNode ) ;
656 char * aCoupledNodeName = aMacroNode->CoupledNodeName() ;
657 MESSAGE( "LoadDataFlows MacroNode " << aMacroNode->Name() << " --> " << aCoupledNodeName
658 << " to be searched among " << (*aListOfDataFlows).size() << " Graphs" ) ;
661 for ( index = 0 ; index < (int ) (*aListOfDataFlows).size() ; index++ ) {
662 MESSAGE( "LoadDataFlows Graph" << index << " " << (*aListOfDataFlows)[index].Info.theName.c_str() ) ;
663 if ( !strcmp( aCoupledNodeName , (*aListOfDataFlows)[index].Info.theName.c_str() ) ) {
666 // At first create the editor and a StreamGraph
667 GraphEditor::DataFlow * aMacroGraphDataFlowEditor ;
668 CreateEditor( _Orb , instanceName() , aCoupledNodeName , SUPERV::DataStreamGraph ,
669 dbgfile , &aMacroGraphDataFlowEditor ) ;
671 if ( _DebugFileName ) {
672 delete [] _DebugFileName ;
674 _DebugFileName = new char[ strlen( dbgfile.c_str() )+1 ] ;
675 strcpy( _DebugFileName , dbgfile.c_str() ) ;
677 MESSAGE( "RECURSIVE IMPORT OF GRAPHS OF MACRONODES :" << aCoupledNodeName ) ;
678 if ( CORBA::is_nil( LoadDataFlows( aMacroGraphDataFlowEditor , aListOfDataFlows , index ) ) ) {
679 MESSAGE("Graph_Impl::LoadDataFlows failed" ) ;
680 return SUPERV::Graph::_duplicate( iobject ) ;
683 // That graph is not a StreamGraph :
684 else if ( !aMacroGraphDataFlowEditor->Graph()->HasDataStream() ) {
685 Graph_Impl * myMacroGraph ;
686 // The Graph ObjRef for that graph was already created
687 myMacroGraph = (Graph_Impl * ) aMacroGraphDataFlowEditor->Graph()->ObjImpl() ;
689 GraphBase::Graph * aMacroGraph = myMacroGraph->DataFlowEditor()->Graph() ;
691 aMacroGraph->GraphMacroLevel( aGraph->GraphMacroLevel() + 1 ) ;
692 aMacroGraph->CoupledNode( aMacroNode ) ;
693 aMacroGraph->MacroObject( SUPERV::Graph::_duplicate( macroiobject ) ) ;
695 // Set the GraphMacroNode ObjRef in the MacroNode
696 aMacroNode->GraphMacroLevel( aGraph->GraphMacroLevel() + 1 ) ;
697 aMacroNode->CoupledNode( aMacroGraph ) ;
698 aMacroNode->MacroObject( SUPERV::Graph::_narrow( aMacroGraphDataFlowEditor->Graph()->ObjRef() ) ) ;
699 MESSAGE( "LoadDataFlows aMacroGraph " << aMacroGraph << " " << aMacroGraph->Name()
700 << " coupled to " << aMacroGraph->CoupledNode() << " "
701 << aMacroGraph->CoupledNode()->Name() << " Editor " << aMacroGraph->GraphEditor() ) ;
702 MESSAGE( "LoadDataFlows aMacroNode " << aMacroNode << " " << aMacroNode->Name()
703 << " coupled to " << aMacroNode->CoupledNode() << " "
704 << aMacroNode->CoupledNode()->Name() << " Editor " << aMacroNode->GraphEditor() ) ;
705 MESSAGE( "LoadDataFlows current Graph " << aGraph << " " << aGraph->Name()
706 << " coupled to " << aGraph->CoupledNode()
707 << " Editor " << aGraph->GraphEditor() << " " << aGraph->Name() ) ;
713 return SUPERV::Graph::_duplicate( SUPERV::Graph::_nil() ) ;
718 else if ( (*aListOfDataFlows).size() == 1 ) {
719 StreamGraph_Impl * myStreamGraph ;
720 // We create a Graph ObjRef for that graph
721 myStreamGraph = new StreamGraph_Impl( _Orb , _Poa, _ContId,
722 instanceName() , interfaceName() ,
723 aDataFlowEditor , NULL ) ;
724 PortableServer::ObjectId * id = myStreamGraph->getId() ;
725 CORBA::Object_var obj = _poa->id_to_reference(*id) ;
726 SUPERV::StreamGraph_var Streamiobject = SUPERV::StreamGraph::_nil() ;
727 Streamiobject = SUPERV::StreamGraph::_narrow( obj ) ;
728 myStreamGraph->SetObjRef( SUPERV::StreamGraph::_duplicate( Streamiobject ) ) ;
729 myStreamGraph->SetObjImpl( (CNode_Impl * ) myStreamGraph ) ;
730 // iobject = SUPERV::Graph::_narrow( obj ) ;
731 iobject = SUPERV::Graph::_narrow( Streamiobject ) ;
734 MESSAGE( "Graph_Impl::LoadDataFlows StreamGraph with MacroNodes not yet implemented" ) ;
737 endService( "Graph_Impl::EditorLoadDataFlows" );
738 return SUPERV::Graph::_duplicate( iobject ) ;
741 SUPERV::Graph_var Graph_Impl::LoadDataFlows( GraphExecutor::DataFlow * aDataFlowExecutor ,
742 GraphBase::ListOfSGraphs * aListOfDataFlows ,
744 beginService( "Graph_Impl::ExecutorLoadDataFlows" ) ;
745 MESSAGE("Graph_Impl::LoadDataFlows(Executor) index " << index << " " << (*aListOfDataFlows)[index].Info.theName.c_str() << " aDataFlowExecutor " << aDataFlowExecutor ) ;
747 // That method is recursive :
748 // At first we load the supergraph with index = 0 :
749 // (After we load the graph corresponding to each MacroNode :)
750 if ( !aDataFlowExecutor->LoadDataFlow( &(*aListOfDataFlows)[ index ] ) ) {
751 MESSAGE("Graph_Impl::LoadDataFlows(Executor) failed, could not LoadDataFlow(supergraph)" ) ;
752 return SUPERV::Graph::_duplicate( SUPERV::Graph::_nil() ) ;
755 // That graph is not a StreamGraph :
757 aDataFlowExecutor->Graph()->Kind( SUPERV::DataFlowGraph ) ;
758 GraphEditor::DataFlow * aDataFlowEditor ;
759 aDataFlowEditor = DataFlowEditor() ;
760 GraphBase::Graph * anEditorGraph = aDataFlowEditor->Graph() ;
761 GraphBase::Graph * anExecutorGraph = aDataFlowExecutor->Graph() ;
762 if ( aDataFlowEditor->Executor() ) {
763 delete aDataFlowEditor->Executor() ;
764 aDataFlowEditor->Executor( NULL ) ;
765 aDataFlowEditor->Editing() ;
767 aDataFlowEditor->Executor( aDataFlowExecutor ) ;
768 anExecutorGraph->GraphEditor( aDataFlowEditor ) ;
770 if ( !aDataFlowExecutor->Graph()->HasDataStream() ) {
771 // For the supergraph or each graph of MacroNodes we search MacroNodes recursively :
773 for ( i = 0 ; i < anExecutorGraph->GraphNodesSize() ; i++ ) {
774 if ( anExecutorGraph->GraphNodes( i )->IsMacroNode() ) {
775 GraphBase::GOTONode * aMacroNode = (GraphBase::GOTONode * ) anExecutorGraph->GraphNodes( i ) ;
776 aMacroNode->GraphEditor( aDataFlowEditor ) ;
778 // get the macro node's editor object
779 char * aMacroGraphName = aMacroNode->CoupledNodeName() ;
780 GraphBase::Graph* aMacroGraph = (GraphBase::Graph*)((GraphBase::GOTONode *)anEditorGraph->GetGraphNode( aMacroNode->Name() ))->CoupledNode() ;
781 GraphEditor::DataFlow* aMacroGraphEditor = aMacroGraph->GraphEditor();
783 MESSAGE( "LoadDataFlows(Executor) MacroNode " << aMacroNode->Name() << " Coupled to " << aMacroGraphName
784 << " to be searched among " << (*aListOfDataFlows).size() << " Graphs" << endl ) ;
787 for ( index = 0 ; index < (int ) (*aListOfDataFlows).size() && !found; index++ ) {
788 if ( !strcmp( aMacroGraphName , (*aListOfDataFlows)[index].Info.theName.c_str() ) )
792 MESSAGE("Graph_Impl::LoadDataFlows(Executor) failed, Macro node's coupled graph \"" << aMacroGraphName << "\" was not found" ) ;
793 return SUPERV::Graph::_duplicate( SUPERV::Graph::_nil() ) ;
795 index--; // it was incremented in "for ..." before last check ( !found ).
797 // At first create the editor and a StreamGraph
799 GraphExecutor::DataFlow * aMacroGraphExecutor ;
800 CreateExecutor( _Orb , instanceName() , aMacroGraphName , SUPERV::DataStreamGraph ,
801 dbgfile , &aMacroGraphExecutor );
803 // set GraphMacroLevel for Executor's graph
804 GraphBase::Graph* aMacroGraphExe = aMacroGraphExecutor->Graph();
805 aMacroGraphExe->GraphMacroLevel( anExecutorGraph->GraphMacroLevel() + 1 );
807 // load data flows in MacroGraph's executor
808 Graph_Impl* aMacroGraphImpl = (Graph_Impl*) aMacroGraphEditor->Graph()->ObjImpl();
809 MESSAGE( "RECURSIVE IMPORT OF GRAPHS OF MACRONODES : " << aMacroGraphName ) ;
810 if ( CORBA::is_nil( aMacroGraphImpl->LoadDataFlows( aMacroGraphExecutor, aListOfDataFlows , index ) ) ) {
811 MESSAGE("Graph_Impl::LoadDataFlows(Executor) failed, could not LoadDataFlow( MacroNodeGraph \"" <<aMacroGraphName << "\" )" ) ;
812 return SUPERV::Graph::_duplicate( SUPERV::Graph::_nil() ) ;
815 // set coupled pair MacroNode <--> MacroGraph
816 aMacroGraphExe->CoupledNode( aMacroNode ) ;
817 aMacroNode->CoupledNode( aMacroGraphExe ) ;
819 //JR 04.05.2005 Debug : InPorts values of MacroNodes are like for other nodes
820 // InPorts values of MacroGraphs of MacroNodes are done in the Executor
821 // It was probably to try to debug anything but it was a wrong debug and I do not know what bug
822 // ===> folowing code is commented
824 // initialize MacroNode's InPorts with corresponding "external" values
826 for ( q = 0 ; q < aMacroNode->GetNodeInPortsSize() ; q++ ) {
827 const GraphBase::InPort * anInPort = aMacroNode->GetNodeInPort( q ) ;
828 if ( anInPort->IsDataConnected() ) {
829 const char* aMacroGraphInPortName = aMacroGraph->GetNodeInPort( q )->PortName();
830 //JR 30.03.2005 if ( !aMacroGraphExecutor->InputOfAny( aMacroGraphInPortName, *anInPort->GetOutPort()->Value(),false ) ) {
831 if ( !aMacroGraphExecutor->InputOfAny( aMacroGraphInPortName, anInPort->GetOutPort()->Value(),false ) ) {
832 return SUPERV::Graph::_duplicate( SUPERV::Graph::_nil() ) ;
835 MESSAGE( "LoadDataFlows(Executor) " << aMacroGraph->Name() << "->InputOfAny( "
836 << aMacroGraphInPortName << " , Value )" ) ;
839 } // end of init MacroNode's InPorts
841 aMacroGraphImpl->Run() ;
844 } // end of for( get nodes of the graph...)
846 } // end of setting initial graph's structure..
848 endService( "Graph_Impl::ExecutorLoadDataFlows" );
850 PortableServer::ObjectId * id = getId();
851 CORBA::Object_var obj = _poa->id_to_reference( *id );
852 SUPERV::Graph_var iobject = SUPERV::Graph::_narrow( obj ) ;
853 return SUPERV::Graph::_duplicate( iobject ) ;
856 SUPERV::Graph_ptr Graph_Impl::MNode( const char * aXmlFileName ) {
857 beginService( "Graph_Impl::MNode" );
858 SUPERV::Graph_var iobject = SUPERV::Graph::_nil() ;
859 MESSAGE( "Graph_Impl::MNode( " << aXmlFileName << " )" ) ;
861 GraphBase::ListOfSGraphs aListOfDataFlows ;
863 // At first create the editor and a StreamGraph with the xml file
864 GraphEditor::DataFlow * aDataFlowEditor ;
865 CreateEditor( _Orb , instanceName() , aXmlFileName , SUPERV::DataStreamGraph ,
866 dbgfile , &aDataFlowEditor ) ;
868 if ( _DebugFileName ) {
869 delete [] _DebugFileName ;
871 _DebugFileName = new char[ strlen( dbgfile.c_str() )+1 ] ;
872 strcpy( _DebugFileName , dbgfile.c_str() ) ;
874 int lenname = strlen( aXmlFileName ) ;
875 bool loaded = false ;
876 // Import of the xml file
877 if ( lenname > 4 && !strcmp( &aXmlFileName[ lenname - 4 ] , ".xml" ) ) {
878 loaded = aDataFlowEditor->LoadXml( aXmlFileName , aListOfDataFlows ) ;
880 iobject = MNode( aDataFlowEditor , &aListOfDataFlows ) ;
887 // WARNING : THIS IS COMPLICATED :
888 // I should have to remove duplicated code ...
889 SUPERV::Graph_ptr Graph_Impl::MNode( GraphEditor::DataFlow * aMacroGraphDataFlowEditor ,
890 GraphBase::ListOfSGraphs * aListOfDataFlows ) {
891 beginService( "Graph_Impl::MNode" ) ;
892 SUPERV::Graph_var iobject = SUPERV::Graph::_nil() ;
893 SUPERV::Graph_var macroiobject = SUPERV::Graph::_nil() ;
896 MESSAGE( "Graph_Impl::MNode DataFlowEditor->LoadDataFlow" ) ;
897 // if ( !aMacroGraphDataFlowEditor->LoadDataFlow( &aListOfDataFlows[ 0 ] ) ) {
898 iobject = LoadDataFlows( aMacroGraphDataFlowEditor , aListOfDataFlows , 0 ) ;
899 if ( CORBA::is_nil( iobject ) ) {
900 MESSAGE("Graph_Impl::MNode LoadDataFlow failed" ) ;
904 // That graph is not a StreamGraph :
905 else if ( !aMacroGraphDataFlowEditor->Graph()->HasDataStream() ) {
906 aMacroGraphDataFlowEditor->Graph()->Kind( SUPERV::DataFlowGraph ) ;
907 aMacroGraphDataFlowEditor->Graph()->GraphEditor( aMacroGraphDataFlowEditor ) ;
909 Graph_Impl * myMacroGraph = (Graph_Impl * ) aMacroGraphDataFlowEditor->Graph()->ObjImpl() ;
910 // Creation of a GraphMacroNode in the current editor
911 string aMacroNodeName = string( "Macro_" ) + string( myMacroGraph->Name() ) ;
912 Graph_Impl * myMacroNode ;
913 myMacroNode = new Graph_Impl( _Orb , _Poa, _ContId,
914 instanceName() , interfaceName() ,
915 aMacroNodeName.c_str() , SUPERV::MacroNode ) ;
916 PortableServer::ObjectId * id = myMacroNode->getId() ;
917 CORBA::Object_var obj = _poa->id_to_reference(*id);
918 macroiobject = SUPERV::Graph::_narrow( obj ) ;
919 myMacroNode->DataFlowEditor( DataFlowEditor() ) ;
921 // Creation of the MacroNode itself in the current Graph
922 GraphBase::ListOfFuncName aFuncName ;
923 aFuncName.resize( 1 ) ;
925 SUPERV::ListOfStrings aListOfStrings ;
926 aListOfStrings.length( 1 ) ;
927 aListOfStrings[0] = "" ;
928 GraphBase::ListOfPythonFunctions aPythonFunction ;
929 aPythonFunction.resize( 1 ) ;
930 aPythonFunction[0] = &aListOfStrings ;
931 SALOME_ModuleCatalog::Service * aMacroNodeService = myMacroGraph->Service() ;
932 GraphEditor::InNode * aDataFlowNode = DataFlowEditor()->AddNode( *aMacroNodeService , "" , "" ,
933 aMacroNodeName.c_str() , SUPERV::MacroNode ,
934 aFuncName , aPythonFunction ) ;
935 aDataFlowNode->SetPythonFunction( "" , aListOfStrings ) ;
936 myMacroNode->DataFlowNode( aDataFlowNode ) ;
937 aDataFlowNode->ComputingNode()->SetService( *aMacroNodeService ) ;
938 aDataFlowNode->SetObjRef( SUPERV::CNode::_duplicate( SUPERV::CNode::_narrow( obj ) ) ) ;
939 aDataFlowNode->SetObjImpl( this ) ;
941 GraphBase::Graph * aGraph = myMacroGraph->DataFlowEditor()->Graph() ;
942 GraphBase::Graph * aGraphOfMacroGraph = myMacroNode->DataFlowEditor()->Graph() ;
943 GraphBase::Graph * aMacroGraph = myMacroNode->DataFlowNode()->GraphMacroNode() ;
944 aMacroGraph->Kind( SUPERV::MacroNode ) ;
945 aMacroGraph->GraphEditor( DataFlowEditor() ) ;
946 // Creation of the Ports of the MacroNode from the ports of the GraphMacroNode
947 aMacroGraph->SetMacroPorts( aGraph ) ;
948 // Valid ==> creation of Service and the ports of the current Graph
949 DataFlowEditor()->IsValid() ;
950 // Set the Input Datas from the GraphMacroNode to the current Graph
951 aMacroGraph->SetMacroDatas( aGraph , aGraphOfMacroGraph ) ;
952 aMacroGraphDataFlowEditor->UnValid() ;
953 // Set the MacroNode ObjRef in the GraphMacroNode
954 aGraph->CoupledNode( aMacroGraph ) ;
955 aGraph->MacroObject( SUPERV::Graph::_duplicate( macroiobject ) ) ;
956 // Set the GraphMacroNode ObjRef in the MacroNode
957 aDataFlowNode->GraphMacroNode()->GraphMacroLevel( aGraphOfMacroGraph->GraphMacroLevel() + 1 ) ;
958 aMacroGraph->CoupledNode( aGraph ) ;
959 // aGraphOfMacroGraph->CoupledNode( aGraph ) ;
960 aMacroGraph->MacroObject( SUPERV::Graph::_duplicate( iobject ) ) ;
961 // aGraphOfMacroGraph->MacroObject( SUPERV::Graph::_duplicate( iobject ) ) ;
962 // aDataFlowNode->CoupledNode( aGraph ) ;
963 // aDataFlowNode->ComputingNode()->MacroObject( SUPERV::Graph::_duplicate( iobject ) ) ;
964 // Set the MacroLevel of that graph
965 aGraph->GraphMacroLevel( aGraphOfMacroGraph->GraphMacroLevel() + 1 ) ;
966 aMacroGraph->Coordinates( 0 , 0 ) ;
967 MESSAGE( "DataFlowNode Graph " << this << " DataFlowEditor " << DataFlowEditor() << " aDataFlowNode "
968 << aDataFlowNode << " " << aDataFlowNode->Name() << " created" ) ;
969 MESSAGE( "MNode aGraph " << aGraph << " " << aGraph->Name()
970 << " coupled to " << aGraph->CoupledNode() << " "
971 << aGraph->CoupledNode()->Name() ) ;
972 MESSAGE( "MNode aMacroGraph " << aMacroGraph << " " << aMacroGraph->Name()
973 << " coupled to " << aMacroGraph->CoupledNode() << " "
974 << aMacroGraph->CoupledNode()->Name() ) ;
975 MESSAGE( "MNode aMacroGraph " << myMacroNode->DataFlowEditor()->Graph() << " "
976 << myMacroNode->DataFlowEditor()->Graph()->Name()
977 << " coupled to " << myMacroNode->DataFlowEditor()->Graph()->CoupledNode() ) ;
980 delete aMacroGraphDataFlowEditor ;
983 endService( "Graph_Impl::MNode" );
984 return SUPERV::Graph::_duplicate( macroiobject ) ;
987 // For python supergraph
988 SUPERV::Graph_ptr Graph_Impl::GraphMNode( SUPERV::Graph_ptr myMacroGraph ) {
989 SUPERV::Graph_var iobject = myMacroGraph ;
990 beginService( "Graph_Impl::GraphMNode" ) ;
992 // GraphBase::Graph * myMacroGraph = aGraph;
993 SUPERV::Graph_var macroiobject = SUPERV::StreamGraph::_nil() ;
994 // Creation of a GraphMacroNode in the current editor
996 string aMacroNodeName = string( "Macro_" ) + string( myMacroGraph->Name() ) ;
997 //string aMacroNodeName = string( myMacroGraph->CoupledName() ) ;
998 MESSAGE( "GraphMNode( " << myMacroGraph->Name() << " )" ) ;
999 Graph_Impl * myMacroNode ;
1000 myMacroNode = new Graph_Impl( _Orb , _Poa, _ContId,
1001 instanceName() , interfaceName() ,
1002 aMacroNodeName.c_str() , SUPERV::MacroNode ) ;
1003 PortableServer::ObjectId * id = myMacroNode->getId() ;
1004 CORBA::Object_var obj = _poa->id_to_reference(*id);
1005 macroiobject = SUPERV::Graph::_narrow( obj ) ;
1006 myMacroNode->DataFlowEditor( DataFlowEditor() ) ;
1008 // Creation of the MacroNode itself in the current Graph
1009 GraphBase::ListOfFuncName aFuncName ;
1010 aFuncName.resize( 1 ) ;
1012 SUPERV::ListOfStrings aListOfStrings ;
1013 aListOfStrings.length( 1 ) ;
1014 aListOfStrings[0] = "" ;
1015 GraphBase::ListOfPythonFunctions aPythonFunction ;
1016 aPythonFunction.resize( 1 ) ;
1017 aPythonFunction[0] = &aListOfStrings ;
1018 SALOME_ModuleCatalog::Service * aMacroNodeService = myMacroGraph->Service() ;
1019 GraphEditor::InNode * aDataFlowNode ;
1020 aDataFlowNode = DataFlowEditor()->AddNode( *aMacroNodeService , "" , "" ,
1021 aMacroNodeName.c_str() , SUPERV::MacroNode ,
1022 aFuncName , aPythonFunction ) ;
1023 aDataFlowNode->SetPythonFunction( "" , aListOfStrings ) ;
1024 myMacroNode->DataFlowNode( aDataFlowNode ) ;
1025 aDataFlowNode->ComputingNode()->SetService( *aMacroNodeService ) ;
1026 aDataFlowNode->SetObjRef( SUPERV::CNode::_duplicate( SUPERV::CNode::_narrow( obj ) ) ) ;
1027 aDataFlowNode->SetObjImpl( this ) ;
1029 // GraphBase::Graph * aGraph = DataFlowEditor()->Automaton()->MapGraph( myMacroGraph->Name() ) ;
1030 GraphBase::Graph * aGraph ;
1031 //DataFlowEditor()->Automaton()->GraphBase( &aGraph ) ;
1032 myMacroGraph->Coupled() ;
1033 GraphBase::Graph * aGraphOfMacroGraph = myMacroNode->DataFlowEditor()->Graph() ;
1034 GraphBase::Graph * aMacroGraph = myMacroNode->DataFlowNode()->GraphMacroNode() ;
1035 aMacroGraph->Kind( SUPERV::MacroNode ) ;
1036 aMacroGraph->GraphEditor( DataFlowEditor() ) ;
1037 // Creation of the Ports of the MacroNode from the ports of the GraphMacroNode
1038 aMacroGraph->SetMacroPorts( aGraph ) ;
1039 // Valid ==> creation of Service and the ports of the current Graph
1040 DataFlowEditor()->IsValid() ;
1041 // Set the Input Datas from the GraphMacroNode to the current Graph
1042 aMacroGraph->SetMacroDatas( aGraph , aGraphOfMacroGraph ) ;
1043 // aMacroGraphDataFlowEditor->UnValid() ;
1044 aGraph->GraphEditor()->UnValid() ;
1045 // Set the MacroNode ObjRef in the GraphMacroNode
1046 aGraph->CoupledNode( aMacroGraph ) ;
1047 aGraph->MacroObject( SUPERV::Graph::_duplicate( macroiobject ) ) ;
1048 // Set the GraphMacroNode ObjRef in the MacroNode
1049 aDataFlowNode->GraphMacroNode()->GraphMacroLevel( aGraphOfMacroGraph->GraphMacroLevel() + 1 ) ;
1050 aMacroGraph->CoupledNode( aGraph ) ;
1051 aMacroGraph->MacroObject( SUPERV::Graph::_duplicate( iobject ) ) ;
1052 // aDataFlowNode->CoupledNode( aGraph ) ;
1053 // aDataFlowNode->ComputingNode()->MacroObject( SUPERV::Graph::_duplicate( iobject ) ) ;
1054 // Set the MacroLevel of that graph
1055 aGraph->GraphMacroLevel( aGraphOfMacroGraph->GraphMacroLevel() + 1 ) ;
1056 aMacroGraph->Coordinates( 0 , 0 ) ;
1057 MESSAGE( aGraph->Name() << "->CoupledNode()->GraphEditor() : " << aGraph->CoupledNode()->GraphEditor() ) ;
1058 MESSAGE( aMacroGraph->Name() << "->CoupledNode()->GraphEditor() : "
1059 << aMacroGraph->CoupledNode()->GraphEditor() ) ;
1060 MESSAGE( "DataFlowNode Graph " << this << " DataFlowEditor " << DataFlowEditor() << " aDataFlowNode "
1061 << aDataFlowNode << " " << aDataFlowNode->Name() << " created" ) ;
1063 endService( "Graph_Impl::GraphMNode" ) ;
1064 return SUPERV::Graph::_duplicate( macroiobject ) ;
1067 SUPERV::Graph_ptr Graph_Impl::FlowObjRef() {
1068 beginService( "Graph_Impl::FlowObjRef" );
1069 SUPERV::Graph_var iobject = SUPERV::Graph::_nil() ;
1071 iobject = SUPERV::Graph::_narrow( DataFlowNode()->GraphMacroNode()->MacroObject() ) ;
1073 else if ( IsGraph() ) {
1074 iobject = SUPERV::Graph::_narrow( DataFlowEditor()->Graph()->MacroObject() ) ;
1076 if ( CORBA::is_nil( iobject ) ) {
1077 MESSAGE( "Graph_Impl::FlowObjRef() returns a NIL Object" ) ;
1079 endService( "Graph_Impl::FlowObjRef" );
1080 return SUPERV::Graph::_duplicate( iobject ) ;
1083 SUPERV::StreamGraph_ptr Graph_Impl::StreamObjRef() {
1084 beginService( "Graph_Impl::StreamObjRef" );
1085 SUPERV::StreamGraph_var iobject = SUPERV::StreamGraph::_nil() ;
1087 iobject = SUPERV::StreamGraph::_narrow( DataFlowNode()->GraphMacroNode()->MacroObject() ) ;
1089 else if ( IsGraph() || IsStreamGraph() ) {
1090 iobject = SUPERV::StreamGraph::_narrow( DataFlowEditor()->Graph()->MacroObject() ) ;
1092 if ( CORBA::is_nil( iobject ) ) {
1093 MESSAGE( "Graph_Impl::StreamObjRef() returns a NIL Object" ) ;
1095 endService( "Graph_Impl::StreamObjRef" );
1096 return SUPERV::StreamGraph::_duplicate( iobject ) ;
1099 SUPERV::CNode_ptr Graph_Impl::Node(char const * aNodeName ) {
1100 // beginService( "Graph_Impl::Node" );
1101 SUPERV::CNode_var iobject = SUPERV::CNode::_nil() ;
1103 if ( CORBA::is_nil( DataFlowEditor()->GetNode( aNodeName )->ObjRef() ) ) {
1104 CNode_Impl * myNode = new CNode_Impl( _Orb , _Poa , _ContId ,
1105 instanceName() , interfaceName() ,
1107 DataFlowEditor()->GetNode( aNodeName ) ) ;
1108 PortableServer::ObjectId * id = myNode->getId() ;
1109 CORBA::Object_var obj = _poa->id_to_reference(*id);
1110 iobject = SUPERV::CNode::_narrow(obj) ;
1111 myNode->SetObjRef( SUPERV::CNode::_duplicate( iobject ) ) ;
1114 iobject = DataFlowEditor()->GetNode( aNodeName )->ObjRef() ;
1117 GraphEditor::InNode * anInNode = DataFlowEditor()->GetNode( aNodeName ) ;
1119 if ( CORBA::is_nil( anInNode->ObjRef() ) ) {
1120 SetNodeObjRef( anInNode ) ;
1122 iobject = anInNode->ObjRef() ;
1125 // endService( "Graph_Impl::Node" );
1126 return SUPERV::CNode::_duplicate( iobject ) ;
1129 SUPERV::Link_ptr Graph_Impl::Link( SUPERV::Port_ptr OutPort ,
1130 SUPERV::Port_ptr InPort ) {
1131 beginService( "Graph_Impl::Link" );
1132 SUPERV::Link_var iobject = SUPERV::Link::_nil() ;
1133 if ( DataFlowEditor()->IsEditing() && !DataFlowEditor()->IsReadOnly() &&
1134 !OutPort->IsDataStream() && !InPort->IsDataStream() && !IsMacro() ) {
1135 MESSAGE( "Graph_Impl::Link( " << OutPort->Node()->Name() << "( " << OutPort->Name() << " ) --> "
1136 << InPort->Node()->Name() << "( " << InPort->Name() << " )" ) ;
1137 GraphEditor::InNode * anInNode = DataFlowEditor()->GetNode( InPort->Node()->Name() ) ;
1138 GraphEditor::InNode * anOutNode = DataFlowEditor()->GetNode( OutPort->Node()->Name() ) ;
1139 if ( anInNode == NULL || anOutNode== NULL ) {
1140 MESSAGE( "Graph_Impl::Link( " << OutPort->Node()->Name() << " " << anOutNode << " , "
1141 << InPort->Node()->Name() << " " << anInNode << " ) Node(s) not found in " << Name() ) ;
1144 GraphBase::InPort * anInPort = anInNode->ComputingNode()->GetChangeInPort( InPort->Name() ) ;
1145 GraphBase::OutPort * anOutPort = anOutNode->ComputingNode()->GetChangeOutPort( OutPort->Name() ) ;
1146 if ( anInPort == NULL || anOutPort== NULL ) {
1147 MESSAGE( "Graph_Impl::Link( " << OutPort->Name() << " " << anOutPort << " , "
1148 << InPort->Name() << " " << anInPort << " ) Port(s) not found" ) ;
1150 else if ( CORBA::is_nil( anOutPort->InPortObjRef( anInPort ) ) ) {
1151 const char * DataFlowOutNodeName = OutPort->Node()->Name() ;
1152 GraphEditor::InNode * DataFlowOutNode = DataFlowEditor()->GetNode( DataFlowOutNodeName ) ;
1153 const char * DataFlowInNodeName = InPort->Node()->Name() ;
1154 GraphEditor::InNode * DataFlowInNode = DataFlowEditor()->GetNode( DataFlowInNodeName ) ;
1155 if ( DataFlowOutNode && DataFlowInNode ) {
1157 Link_Impl * myLink = new Link_Impl( _Orb , _Poa , _ContId ,
1158 instanceName() , interfaceName() ,
1164 true , false , Success ) ;
1166 PortableServer::ObjectId * id = myLink->getId() ;
1167 CORBA::Object_var obj = _poa->id_to_reference(*id);
1168 iobject = SUPERV::Link::_narrow(obj) ;
1169 anOutPort->AddInPortObjRef( anInPort , SUPERV::Link::_duplicate( iobject ) ) ;
1174 MESSAGE( "Graph_Impl::Link( " << OutPort->Name() << " " << anOutPort << " , "
1175 << InPort->Name() << " " << anInPort << " ) ObjRef already exists" ) ;
1176 iobject = anOutPort->InPortObjRef( anInPort ) ;
1180 DataFlowEditor()->UnValid() ;
1181 endService( "Graph_Impl::Link" );
1182 return SUPERV::Link::_duplicate( iobject ) ;
1185 // Only to see MacroNodes with actual GUI ... :
1186 #define GOTOMacroNode 0
1188 void Graph_Impl::SetNodeObjRef( GraphEditor::InNode * anInNode ) {
1189 MESSAGE("Graph_Impl::SetNodeObjRef " << anInNode->Name() << " " << anInNode->Kind() ) ;
1190 CORBA::Object_var obj ;
1191 if ( anInNode->IsComputingNode() ) {
1192 CNode_Impl * myNode = new CNode_Impl( _Orb , _Poa , _ContId ,
1193 instanceName() , interfaceName() ,
1196 PortableServer::ObjectId * id = myNode->getId() ;
1197 obj = _poa->id_to_reference(*id);
1198 SUPERV::CNode_var iobject = SUPERV::CNode::_narrow(obj) ;
1199 myNode->SetObjRef( SUPERV::CNode::_duplicate( iobject ) ) ;
1201 else if ( anInNode->IsFactoryNode() ) {
1202 FNode_Impl * myNode = new FNode_Impl( _Orb , _Poa , _ContId ,
1203 instanceName() , interfaceName() ,
1206 PortableServer::ObjectId * id = myNode->getId() ;
1207 obj = _poa->id_to_reference(*id);
1208 SUPERV::FNode_var iobject = SUPERV::FNode::_narrow(obj) ;
1209 myNode->SetObjRef( SUPERV::FNode::_duplicate( iobject ) ) ;
1211 else if ( anInNode->IsInLineNode() ) {
1212 INode_Impl * myNode = new INode_Impl( _Orb , _Poa , _ContId ,
1213 instanceName() , interfaceName() ,
1216 PortableServer::ObjectId * id = myNode->getId() ;
1217 obj = _poa->id_to_reference(*id);
1218 SUPERV::INode_var iobject = SUPERV::INode::_narrow(obj) ;
1219 myNode->SetObjRef( SUPERV::INode::_duplicate( iobject ) ) ;
1222 else if ( anInNode->IsGOTONode() || anInNode->IsMacroNode() ) {
1223 if ( anInNode->IsMacroNode() ) {
1224 anInNode->ComputingNode()->Kind( SUPERV::GOTONode ) ;
1227 else if ( anInNode->IsGOTONode() ) {
1229 GNode_Impl * myNode = new GNode_Impl( _Orb , _Poa , _ContId ,
1230 instanceName() , interfaceName() ,
1233 PortableServer::ObjectId * id = myNode->getId() ;
1234 obj = _poa->id_to_reference(*id);
1235 SUPERV::GNode_var iobject = SUPERV::GNode::_narrow(obj) ;
1236 myNode->SetObjRef( SUPERV::GNode::_duplicate( iobject ) ) ;
1238 else if ( anInNode->IsMacroNode() ) {
1239 Graph_Impl * myNode = new Graph_Impl( _Orb , _Poa , _ContId ,
1240 instanceName() , interfaceName() ,
1243 PortableServer::ObjectId * id = myNode->getId() ;
1244 obj = _poa->id_to_reference(*id);
1245 SUPERV::Graph_var iobject = SUPERV::Graph::_narrow(obj) ;
1246 myNode->SetObjRef( SUPERV::Graph::_duplicate( iobject ) ) ;
1248 else if ( anInNode->IsLoopNode() ) {
1249 LNode_Impl * myNode = new LNode_Impl( _Orb , _Poa , _ContId ,
1250 instanceName() , interfaceName() ,
1253 PortableServer::ObjectId * id = myNode->getId() ;
1254 obj = _poa->id_to_reference(*id);
1255 SUPERV::LNode_var iobject = SUPERV::LNode::_narrow(obj) ;
1256 myNode->SetObjRef( SUPERV::LNode::_duplicate( iobject ) ) ;
1258 else if ( anInNode->IsEndLoopNode() ) {
1259 ELNode_Impl * myNode = new ELNode_Impl( _Orb , _Poa , _ContId ,
1260 instanceName() , interfaceName() ,
1263 PortableServer::ObjectId * id = myNode->getId() ;
1264 obj = _poa->id_to_reference(*id);
1265 SUPERV::ELNode_var iobject = SUPERV::ELNode::_narrow(obj) ;
1266 myNode->SetObjRef( SUPERV::ELNode::_duplicate( iobject ) ) ;
1268 else if ( anInNode->IsSwitchNode() ) {
1269 SNode_Impl * myNode = new SNode_Impl( _Orb , _Poa , _ContId ,
1270 instanceName() , interfaceName() ,
1273 PortableServer::ObjectId * id = myNode->getId() ;
1274 obj = _poa->id_to_reference(*id);
1275 SUPERV::SNode_var iobject = SUPERV::SNode::_narrow(obj) ;
1276 myNode->SetObjRef( SUPERV::SNode::_duplicate( iobject ) ) ;
1278 else if ( anInNode->IsEndSwitchNode() ) {
1279 ESNode_Impl * myNode = new ESNode_Impl( _Orb , _Poa , _ContId ,
1280 instanceName() , interfaceName() ,
1283 PortableServer::ObjectId * id = myNode->getId() ;
1284 obj = _poa->id_to_reference(*id);
1285 SUPERV::ESNode_var iobject = SUPERV::ESNode::_narrow(obj) ;
1286 myNode->SetObjRef( SUPERV::ESNode::_duplicate( iobject ) ) ;
1290 SUPERV::ListOfNodes_var Graph_Impl::SetNode( SUPERV::ListOfNodes_var RetVal ,
1291 GraphBase::ComputingNode * aNode ) {
1293 // if ( _DataFlowExecutor ) {
1294 if ( DataFlowExecutor() ) {
1295 MESSAGE("Graph_Impl::SetNode " << aNode->Name() << " " << aNode->Kind() << " "
1296 << DataFlowExecutor()->StateName( DataFlowExecutor()->AutomatonState( aNode->Name() ) ) ) ;
1299 MESSAGE("Graph_Impl::SetNode " << aNode->Name() << " " << aNode->Kind() ) ;
1301 if ( aNode->IsComputingNode() ) {
1302 index = RetVal->CNodes.length() ;
1303 RetVal->CNodes.length( index+1 );
1305 else if ( aNode->IsFactoryNode() ) {
1306 index = RetVal->FNodes.length() ;
1307 RetVal->FNodes.length( index+1 );
1309 else if ( aNode->IsInLineNode() ) {
1310 index = RetVal->INodes.length() ;
1311 RetVal->INodes.length( index+1 );
1314 else if ( aNode->IsGOTONode() || aNode->IsMacroNode() ) {
1316 else if ( aNode->IsGOTONode() ) {
1318 index = RetVal->GNodes.length() ;
1319 RetVal->GNodes.length( index+1 );
1321 else if ( aNode->IsMacroNode() ) {
1322 index = RetVal->Graphs.length() ;
1323 RetVal->Graphs.length( index+1 );
1325 else if ( aNode->IsLoopNode() ) {
1326 index = RetVal->LNodes.length() ;
1327 RetVal->LNodes.length( index+1 );
1329 else if ( aNode->IsEndLoopNode() ) {
1330 index = RetVal->ELNodes.length() ;
1331 RetVal->ELNodes.length( index+1 );
1333 else if ( aNode->IsSwitchNode() ) {
1334 index = RetVal->SNodes.length() ;
1335 RetVal->SNodes.length( index+1 );
1337 else if ( aNode->IsEndSwitchNode() ) {
1338 index = RetVal->ESNodes.length() ;
1339 RetVal->ESNodes.length( index+1 );
1341 if ( CORBA::is_nil( aNode->ObjRef() ) ) {
1342 SetNodeObjRef( (GraphEditor::InNode * ) aNode->GetInNode() ) ;
1344 SUPERV::CNode_var aNodeObjRef = aNode->ObjRef() ;
1345 if ( aNode->IsComputingNode() ) {
1346 RetVal->CNodes[index] = SUPERV::CNode::_duplicate( aNodeObjRef ) ;
1348 else if ( aNode->IsFactoryNode() ) {
1349 RetVal->FNodes[index] = SUPERV::FNode::_duplicate( SUPERV::FNode::_narrow( aNodeObjRef ) ) ;
1351 else if ( aNode->IsInLineNode() ) {
1352 RetVal->INodes[index] = SUPERV::INode::_duplicate( SUPERV::INode::_narrow( aNodeObjRef ) ) ;
1355 else if ( aNode->IsGOTONode() || aNode->IsMacroNode() ) {
1357 else if ( aNode->IsGOTONode() ) {
1359 RetVal->GNodes[index] = SUPERV::GNode::_duplicate( SUPERV::GNode::_narrow( aNodeObjRef ) ) ;
1361 else if ( aNode->IsMacroNode() ) {
1362 RetVal->Graphs[index] = SUPERV::Graph::_duplicate( SUPERV::Graph::_narrow( aNodeObjRef ) ) ;
1364 else if ( aNode->IsLoopNode() ) {
1365 RetVal->LNodes[index] = SUPERV::LNode::_duplicate( SUPERV::LNode::_narrow( aNodeObjRef ) ) ;
1367 else if ( aNode->IsEndLoopNode() ) {
1368 RetVal->ELNodes[index] = SUPERV::ELNode::_duplicate( SUPERV::ELNode::_narrow( aNodeObjRef ) ) ;
1370 else if ( aNode->IsSwitchNode() ) {
1371 RetVal->SNodes[index] = SUPERV::SNode::_duplicate( SUPERV::SNode::_narrow( aNodeObjRef ) ) ;
1373 else if ( aNode->IsEndSwitchNode() ) {
1374 RetVal->ESNodes[index] = SUPERV::ESNode::_duplicate( SUPERV::ESNode::_narrow( aNodeObjRef ) ) ;
1376 return ( RetVal._retn() ) ;
1379 SUPERV::ListOfNodes * Graph_Impl::Nodes() {
1380 SUPERV::ListOfNodes_var RetVal = new SUPERV::ListOfNodes;
1381 beginService( "Graph_Impl::Nodes" );
1382 RetVal->CNodes.length(0) ;
1383 RetVal->FNodes.length(0) ;
1384 RetVal->INodes.length(0) ;
1385 RetVal->LNodes.length(0) ;
1386 RetVal->SNodes.length(0) ;
1387 RetVal->GNodes.length(0) ;
1388 RetVal->Graphs.length(0) ;
1391 MESSAGE( DataFlowEditor()->Graph()->GetGraphNodeSize() << " Nodes in the Map and "
1392 << DataFlowEditor()->Graph()->GraphNodesSize() << " Nodes int the Vector" ) ;
1393 for ( i = 0 ; i < DataFlowEditor()->Graph()->GraphNodesSize() ; i++ ) {
1394 GraphBase::ComputingNode * aNode = DataFlowEditor()->Graph()->GraphNodes( i ) ;
1396 MESSAGE( i << ". Vector : " << aNode->Name() << " Map : "
1397 << DataFlowEditor()->Graph()->GetGraphNode( aNode->Name() )->Name() ) ;
1399 RetVal = SetNode( RetVal , aNode ) ;
1402 char * aStateG = "" ;
1403 if ( DataFlowExecutor() ) {
1404 aStateG = (char *) DataFlowExecutor()->StateName( DataFlowExecutor()->AutomatonState() ) ;
1406 MESSAGE("Graph_Impl::Nodes GraphState " << aStateG << " CNodes " << RetVal->CNodes.length() ) ;
1407 for ( i = 0 ; i < RetVal->CNodes.length() ; i++ ) {
1408 MESSAGE(" " << RetVal->CNodes[ i ] ->Name() ) ;
1410 MESSAGE("FNodes " << RetVal->FNodes.length() ) ;
1411 for ( i = 0 ; i < RetVal->FNodes.length() ; i++ ) {
1412 MESSAGE(" " << RetVal->FNodes[ i ] ->Name() ) ;
1414 MESSAGE("INodes " << RetVal->INodes.length() ) ;
1415 for ( i = 0 ; i < RetVal->INodes.length() ; i++ ) {
1416 MESSAGE(" " << RetVal->INodes[ i ] ->Name() ) ;
1418 MESSAGE("GNodes " << RetVal->GNodes.length() ) ;
1419 for ( i = 0 ; i < RetVal->GNodes.length() ; i++ ) {
1420 MESSAGE(" " << RetVal->GNodes[ i ] ->Name() ) ;
1422 MESSAGE("LNodes " << RetVal->LNodes.length() ) ;
1423 for ( i = 0 ; i < RetVal->LNodes.length() ; i++ ) {
1424 MESSAGE(" " << RetVal->LNodes[ i ] ->Name() ) ;
1426 MESSAGE("ELNodes " << RetVal->ELNodes.length() ) ;
1427 for ( i = 0 ; i < RetVal->ELNodes.length() ; i++ ) {
1428 MESSAGE(" " << RetVal->ELNodes[ i ] ->Name() ) ;
1430 MESSAGE("SNodes " << RetVal->SNodes.length() ) ;
1431 for ( i = 0 ; i < RetVal->SNodes.length() ; i++ ) {
1432 MESSAGE(" " << RetVal->SNodes[ i ] ->Name() ) ;
1434 MESSAGE("ESNodes " << RetVal->ESNodes.length() ) ;
1435 for ( i = 0 ; i < RetVal->ESNodes.length() ; i++ ) {
1436 MESSAGE(" " << RetVal->ESNodes[ i ] ->Name() ) ;
1438 MESSAGE("Graphs " << RetVal->Graphs.length() ) ;
1439 for ( i = 0 ; i < RetVal->Graphs.length() ; i++ ) {
1440 MESSAGE(" " << RetVal->Graphs[ i ] ->Name() ) ;
1442 if ( DataFlowExecutor() ) {
1443 DataFlowExecutor()->EventList() ;
1447 endService( "Graph_Impl::Nodes" );
1448 return ( RetVal._retn() ) ;
1451 SUPERV::ListOfLinks * Graph_Impl::GLinks() {
1452 return Links( NULL , NULL ) ;
1455 SUPERV::ListOfLinks * Graph_Impl::Links( GraphBase::ComputingNode * theNode ,
1456 const char * anInputParam ) {
1458 SUPERV::ListOfLinks_var RetVal = new SUPERV::ListOfLinks ;
1459 RetVal->length( 0 ) ;
1461 int i , j , countlink ;
1463 for ( i = 0 ; i < DataFlowEditor()->Graph()->GraphNodesSize() ; i++ ) {
1464 GraphEditor::InNode * aNode = NULL ;
1465 aNode = (GraphEditor::InNode * ) DataFlowEditor()->Graph()->GraphNodes( i )->GetInNode() ;
1466 bool ToProcess = false ;
1467 if ( theNode == NULL ) {
1471 if ( !strcmp( theNode->Name() , aNode->Name() ) ) {
1472 if ( !theNode->IsEndSwitchNode() ) {
1476 else if ( theNode->IsEndSwitchNode() ) {
1481 for ( j = 0 ; j < aNode->GetNodeInPortsSize() ; j++ ) {
1482 GraphBase::InPort * anInPort = NULL ;
1483 anInPort = aNode->GetChangeNodeInPort( j ) ;
1484 if ( anInputParam == NULL ||
1485 !strcmp( anInPort->PortName() , anInputParam ) ) {
1486 GraphBase::OutPort * anOutPort = NULL ;
1487 anOutPort = anInPort->GetOutPort() ;
1488 if ( anOutPort && !anOutPort->IsDataStream() ) {
1489 if ( strcmp( anOutPort->NodeName() , Name() ) ) {
1490 // MESSAGE("Graph_Impl::Links " << anOutPort->NodeName() << "("
1491 // << anOutPort->PortName() << ") --> " << aNode->Name() << "("
1492 // << anInPort->PortName() << ")" ) ;
1493 if ( theNode == NULL ||
1495 //JR 14.02.2005 : Debug : we must see also that links !
1496 // ( theNode != NULL && !theNode->IsEndSwitchNode() &&
1497 !strcmp( theNode->Name() , aNode->Name() ) ) {
1498 if ( anInPort->IsLoop() || anOutPort->IsLoop() ||
1499 ( aNode->IsEndLoopNode() && !strcmp( aNode->CoupledNode()->Name() ,
1500 anOutPort->NodeName() ) ) ) {
1501 // MESSAGE( "Link " << anOutPort->NodeName() << "("
1502 // << anOutPort->PortName() << ") --> " << aNode->Name() << "("
1503 // << anInPort->PortName() << ")" << " ignored" ) ;
1505 else if ( CORBA::is_nil( anOutPort->InPortObjRef( anInPort ) ) ) {
1507 beginService( "Graph_Impl::Links" );
1510 GraphEditor::InNode * anOutNode = NULL ;
1511 anOutNode = (GraphEditor::InNode * ) DataFlowEditor()->Graph()->GetChangeGraphNode( anOutPort->NodeName() )->GetInNode() ;
1514 Link_Impl * myLink = new Link_Impl( _Orb , _Poa , _ContId ,
1515 instanceName() , interfaceName() ,
1518 anInPort->PortName() ,
1520 anOutPort->PortName() ,
1521 false , true , Success ) ;
1523 PortableServer::ObjectId * id = myLink->getId() ;
1524 CORBA::Object_var obj = _poa->id_to_reference(*id);
1525 SUPERV::Link_var iobject ;
1526 iobject = SUPERV::Link::_narrow(obj) ;
1527 RetVal->length( countlink + 1 ) ;
1528 RetVal[ countlink++ ] = SUPERV::Link::_duplicate( iobject ) ;
1529 anOutPort->AddInPortObjRef( anInPort , SUPERV::Link::_duplicate( iobject ) ) ;
1534 RetVal->length( countlink + 1 ) ;
1535 RetVal[ countlink++ ] = SUPERV::Link::_duplicate( anOutPort->InPortObjRef( anInPort ) ) ;
1537 // MESSAGE( "Link " << anOutPort->NodeName() << "("
1538 // << anOutPort->PortName() << ") --> " << aNode->Name() << "("
1539 // << anInPort->PortName() << ")" << " selected" ) ;
1542 // MESSAGE( "Link " << anOutPort->NodeName() << "("
1543 // << anOutPort->PortName() << ") --> " << aNode->Name() << "("
1544 // << anInPort->PortName() << ")" << " skipped" ) ;
1551 for ( j = 0 ; j < aNode->GetNodeOutPortsSize() ; j++ ) {
1552 GraphBase::OutPort * anOutPort = aNode->GetChangeNodeOutPort( j ) ;
1553 // MESSAGE( "Graph_Impl::Links " << aNode->Name() << " Out" << j << " " << anOutPort->PortName() << " "
1554 // << anOutPort->PortStatus() << " PortConnected to " << anOutPort->InPortsSize() << " InPorts" ) ;
1556 for ( k = 0 ; k < anOutPort->InPortsSize() ; k++ ) {
1557 GraphBase::InPort * anInPort = anOutPort->ChangeInPorts( k ) ;
1558 // MESSAGE( " --> In" << k << " " << anInPort->NodeName() << " " << anInPort->PortName()
1559 // << " " << anInPort->PortStatus() ) ;
1560 if ( anInPort->IsPortConnected() ) {
1561 GraphBase::ComputingNode * aComputingNode = DataFlowEditor()->Graph()->GetChangeGraphNode( anInPort->NodeName() ) ;
1562 GraphEditor::InNode * toNode = (GraphEditor::InNode * ) aComputingNode->GetInNode() ;
1563 if ( theNode == NULL ||
1564 !strcmp( theNode->Name() , aNode->Name() ) ) {
1565 if ( !anInPort->IsDataStream() ) {
1567 //JR 14.02.2005 : Debug : we must see also that links !
1568 // if ( theNode || ( toNode->IsEndSwitchNode() && !aNode->IsSwitchNode() ) ) {
1569 if ( anInputParam == NULL ||
1570 !strcmp( anInPort->PortName() , anInputParam ) ) {
1571 if ( anInPort->IsLoop() || anOutPort->IsLoop() ||
1572 ( toNode->IsEndLoopNode() && !strcmp( toNode->CoupledNode()->Name() ,
1573 anOutPort->NodeName() ) ) ) {
1574 // MESSAGE( "Link " << anOutPort->NodeName() << "("
1575 // << anOutPort->PortName() << ") --> " << toNode->Name() << "("
1576 // << anInPort->PortName() << ")" << " ignored" ) ;
1578 else if ( CORBA::is_nil( anOutPort->InPortObjRef( anInPort ) ) ) {
1580 beginService( "Graph_Impl::Links" );
1584 Link_Impl * myLink = new Link_Impl( _Orb , _Poa , _ContId ,
1585 instanceName() , interfaceName() ,
1588 anInPort->PortName() ,
1590 anOutPort->PortName() ,
1591 false , true , Success ) ;
1593 PortableServer::ObjectId * id = myLink->getId() ;
1594 CORBA::Object_var obj = _poa->id_to_reference(*id);
1595 SUPERV::Link_var iobject ;
1596 iobject = SUPERV::Link::_narrow(obj) ;
1597 RetVal->length( countlink + 1 ) ;
1598 RetVal[ countlink++ ] = SUPERV::Link::_duplicate( iobject ) ;
1599 anOutPort->AddInPortObjRef( anInPort , SUPERV::Link::_duplicate( iobject ) ) ;
1603 RetVal->length( countlink + 1 ) ;
1604 RetVal[ countlink++ ] = SUPERV::Link::_duplicate( SUPERV::Link::_narrow( anOutPort->InPortObjRef( anInPort ) ) ) ;
1606 // MESSAGE( "Link " << anOutPort->NodeName() << "("
1607 // << anOutPort->PortName() << ") --> " << toNode->Name() << "("
1608 // << anInPort->PortName() << ")" << " selected" ) ;
1611 // MESSAGE( "Link " << anOutPort->NodeName() << "("
1612 // << anOutPort->PortName() << ") --> " << toNode->Name() << "("
1613 // << anInPort->PortName() << ")" << " skipped" ) ;
1624 const char * NodeName = "" ;
1625 const char * InputParamName = "" ;
1627 NodeName = theNode->Name() ;
1629 if ( anInputParam ) {
1630 InputParamName = anInputParam ;
1632 MESSAGE( RetVal->length() << " Links of Node " << NodeName << " and of InPort " << InputParamName ) ;
1633 for ( i = 0 ; i < (int ) RetVal->length() ; i++ ) {
1634 MESSAGE( "Link " << RetVal[i]->OutPort()->Node()->Name() << "("
1635 << RetVal[i]->OutPort()->Name() << ") --> "
1636 << RetVal[i]->InPort()->Node()->Name() << "("
1637 << RetVal[i]->InPort()->Name() << ")" ) ;
1641 endService( "Graph_Impl::Links" );
1644 return ( RetVal._retn() ) ;
1647 Engines::Component_ptr Graph_Impl::ComponentRef( const char * aComputerContainer ,
1648 const char * aComponentName ) {
1649 Engines::Component_var objComponent = Engines::Component::_nil() ;
1651 Engines::Container_var myContainer ;
1652 DataFlowEditor()->Graph()->StartComponent( 0 , aComputerContainer , aComponentName ,
1653 myContainer , objComponent ) ;
1655 return Engines::Component::_duplicate( objComponent ) ;
1658 char * Graph_Impl::Messages() {
1659 beginService( "Graph_Impl::Messages" );
1661 MESSAGE( "Graph_Impl::Messages IsEditing " << DataFlowEditor()->IsEditing() ) ;
1662 Messages = DataFlowEditor()->Graph()->Messages() ;
1663 DataFlowEditor()->Graph()->ReSetMessages() ;
1664 if ( DataFlowExecutor() ) {
1665 Messages += DataFlowExecutor()->Graph()->Messages() ;
1666 DataFlowExecutor()->Graph()->ReSetMessages() ;
1668 endService( "Graph_Impl::Messages" );
1669 return ( CORBA::string_dup( Messages.c_str() ) ) ;
1672 bool Graph_Impl::IsValid() {
1673 // beginService( "Graph_Impl::IsValid" );
1674 bool RetVal = false ;
1676 RetVal = DataFlowEditor()->IsValid() ;
1678 // endService( "Graph_Impl::IsValid" );
1681 bool Graph_Impl::IsExecutable() {
1682 // beginService( "Graph_Impl::IsExecutable" );
1683 bool RetVal = false ;
1685 // asv : 15.11.04 : added "&& GraphMacroLevel() == 0" ->
1686 // subgraphs are not executable by themselves, RetVal = false..
1687 if ( !IsMacro() && DataFlowEditor()->Graph()->GraphMacroLevel() == 0 ) {
1688 RetVal = DataFlowEditor()->IsExecutable() ;
1690 // endService( "Graph_Impl::IsExecutable" );
1694 bool Graph_Impl::IsEditing() {
1696 bool RetVal = false ;
1698 RetVal = DataFlowEditor()->IsEditing() ;
1704 return !IsExecuting();
1707 bool Graph_Impl::IsExecuting() {
1709 bool RetVal = false ;
1711 RetVal = !DataFlowEditor()->IsEditing() ;
1715 return CNode_Impl::IsExecuting();
1718 bool Graph_Impl::IsReadOnly() {
1719 // beginService( "Graph_Impl::IsExecuting" );
1720 bool RetVal = false ;
1722 RetVal = DataFlowEditor()->IsReadOnly() ;
1724 // endService( "Graph_Impl::IsExecuting" );
1728 long Graph_Impl::LevelMax() {
1729 // beginService( "Graph_Impl::LevelMax" );
1732 RetVal = DataFlowEditor()->LevelMax() ;
1734 // endService( "Graph_Impl::LevelMax" );
1737 SUPERV::ListOfNodes * Graph_Impl::LevelNodes(long aLevel ) {
1738 // beginService( "Graph_Impl::LevelNodes" );
1739 SUPERV::ListOfNodes_var RetVal = new SUPERV::ListOfNodes;
1742 SUPERV::ListOfStrings_var Nodes = DataFlowEditor()->LevelNodes( aLevel ) ;
1743 // RetVal->length( Nodes->length() );
1744 for ( i = 0 ; i < (int ) Nodes->length() ; i++ ) {
1745 // char * aNode = Nodes[ i ] ;
1746 GraphBase::ComputingNode * aNode = DataFlowEditor()->Graph()->GetChangeGraphNode( Nodes[ i ] ) ;
1747 RetVal = SetNode( RetVal , aNode ) ;
1748 // cout << "Graph_Impl::LevelNodes( " << aLevel << " ) " << aNode->Name() << endl ;
1749 // CNode_Impl * myNode = new CNode_Impl( _Orb , _Poa , _ContId ,
1750 // instanceName() , interfaceName() ,
1751 // DataFlowEditor() ,
1752 // (GraphEditor::InNode * ) DataFlowEditor()->GetChangeGraphNode( aNode )->GetInNode() ) ;
1753 // PortableServer::ObjectId * id = myNode->getId() ;
1754 // CORBA::Object_var obj = _poa->id_to_reference(*id);
1755 // SUPERV::CNode_var iobject ;
1756 // iobject = SUPERV::CNode::_narrow(obj) ;
1757 // RetVal[i] = SUPERV::CNode::_duplicate( iobject ) ;
1760 // endService( "Graph_Impl::LevelNodes" );
1761 return ( RetVal._retn() ) ;
1763 long Graph_Impl::ThreadsMax() {
1764 // beginService( "Graph_Impl::ThreadsMax" );
1767 RetVal = DataFlowEditor()->ThreadsMax() ;
1769 // endService( "Graph_Impl::ThreadsMax" );
1772 long Graph_Impl::Threads() {
1773 // beginService( "Node_Impl::Threads" );
1774 long RetVal = false ;
1776 RetVal = DataFlowExecutor()->Threads() ;
1778 // endService( "Node_Impl::Threads" );
1781 long Graph_Impl::SuspendedThreads() {
1782 // beginService( "Node_Impl::SuspendedThreads" );
1783 long RetVal = false ;
1785 RetVal = DataFlowExecutor()->SuspendedThreads() ;
1787 // endService( "Node_Impl::SuspendedThreads" );
1791 bool Graph_Impl::Begin() {
1792 bool RetVal = false ;
1793 if ( DataFlowEditor()->IsEditing() ) {
1794 if ( pthread_mutex_lock( &_MutexExecutorWait ) ) {
1795 perror("pthread_mutex_lock _MutexExecutorWait") ;
1798 DataFlowEditor()->Graph()->ReSetMessages() ; // ==> Only one set of errors messages ...
1799 if ( DataFlowExecutor() ) {
1800 MESSAGE( "Graph_Impl::Begin " << DataFlowExecutor()->Threads() << " threads" )
1801 Editing(); // just in case it was not called before by GUI..
1803 if ( DataFlowEditor()->IsExecutable() ) {
1804 DataFlowEditor()->EditedAfterExecution( false ) ;
1805 GraphBase::ListOfSGraphs * myListOfGraphs = DataFlowEditor()->GetDataFlows() ;
1807 GraphExecutor::DataFlow * aDataFlowExecutor ;
1809 CreateExecutor( _Orb , instanceName() , (*myListOfGraphs)[ 0 ].Info.theName.c_str() , Kind() ,
1810 dbgfile , &aDataFlowExecutor ) ;
1812 MESSAGE( "Graph_Impl::Begin : DataFlowExecutor created" );
1813 if ( !CORBA::is_nil( LoadDataFlows( aDataFlowExecutor, myListOfGraphs , 0 ) ) )
1817 DataFlowExecutor()->Graph()->SetObjImpl( DataFlowEditor()->Graph()->ObjImpl() ) ;
1820 if ( pthread_mutex_unlock( &_MutexExecutorWait ) ) {
1821 perror("pthread_mutex_unlock _MutexExecutorWait") ;
1829 * run() : was created in order to reduce code dublication, Run() and Start() do the same thing
1830 * except for final call to Executor->Run( bool ) - Run() calls with AndSuspend=false
1831 * and Start() calls with AndSuspend=true flag. The rest of the actions are the same:
1832 * 1. if a MacroNode's coupled graph (MacroLevel>0) -> simply Run() it.
1833 * 2. if a Supergraph -> create executor, load dataflow in it (done in Begin()), then - Run() it.
1835 bool Graph_Impl::run( const bool andSuspend ) {
1836 bool RetVal = false ;
1838 // if Editing or Finished state, and, naturally, 'this' is not a MacroNode.
1839 if ( ( DataFlowEditor()->IsEditing() || IsDone() ) && !IsMacro() ) {
1841 if ( DataFlowEditor()->Graph()->GraphMacroLevel() ) {
1842 // MacroGraph's Executor was created in recursive function LoadDataflows(Executor), called from
1843 // Begin() of Supergraph. See Begin() and LoadDataflows(Executor) for details.
1847 // Create Executor instance and its datamodel
1851 // Set Executing flag to avoid edition operations during execution, EditedAfterExecution=false
1852 DataFlowEditor()->Executing() ;
1853 DataFlowEditor()->EditedAfterExecution( false );
1855 // THE MAIN RUN METHOD
1856 RetVal = DataFlowExecutor()->Run( andSuspend );
1864 * Run() - called on "Execute" command
1866 bool Graph_Impl::Run() {
1867 beginService( "Graph_Impl::Run" );
1868 bool RetVal = run( /*andSuspend=*/false ) ;
1869 MESSAGE( "Graph_Impl::Run " << DataFlowEditor()->Graph()->Name() << " RetVal " << RetVal ) ;
1870 endService( "Graph_Impl::Run" );
1875 * Run() - called on "Execute step-by-step" command
1877 bool Graph_Impl::Start() {
1878 beginService( "Graph_Impl::Start" );
1879 bool RetVal = run( /*andSuspend=*/true ) ;
1880 MESSAGE( "Graph_Impl::Start " << DataFlowEditor()->Graph()->Name() << " RetVal " << RetVal ) ;
1881 endService( "Graph_Impl::Start" );
1885 bool Graph_Impl::EventNoW( SUPERV::CNode_out aNode ,
1886 SUPERV::GraphEvent & anEvent ,
1887 SUPERV::GraphState & aState ) {
1888 bool RetVal = false ;
1889 char * aNodeName = NULL ;
1890 SUPERV::GraphEvent theEvent = SUPERV::UndefinedEvent ;
1891 SUPERV::GraphState theState = SUPERV::UndefinedState ;
1892 if ( pthread_mutex_lock( &_MutexExecutorWait ) ) {
1893 perror("pthread_mutex_lock _MutexExecutorWait") ;
1896 if ( DataFlowExecutor() && !IsMacro() &&
1897 ( DataFlowExecutor()->GetListSize() || !DataFlowEditor()->IsEditing() ) ) {
1898 RetVal = DataFlowExecutor()->Event( & aNodeName , theEvent , theState , false ) ;
1899 // endService( "Graph_Impl::Event" );
1900 if ( strlen( aNodeName ) ) {
1901 if ( strcmp( aNodeName , Name() ) ) {
1902 aNode = Node( aNodeName ) ;
1909 aNode = SUPERV::Graph::_duplicate( SUPERV::Graph::_nil() ) ;
1911 // cout << "Graph_Impl::EventNoW " << aNode->Name() << " QSize " << DataFlowExecutor()->GetListSize() << endl ;
1914 // cout << "Graph_Impl::EventNoW NO DataFlowExecutor() or QSize=0 " << endl ;
1916 if ( pthread_mutex_unlock( &_MutexExecutorWait ) ) {
1917 perror("pthread_mutex_unlock _MutexExecutorWait") ;
1920 anEvent = theEvent ;
1925 bool Graph_Impl::Event( SUPERV::CNode_out aNode ,
1926 SUPERV::GraphEvent & anEvent ,
1927 SUPERV::GraphState & aState ) {
1928 // beginService( "Graph_Impl::Event" );
1929 bool RetVal = false ;
1930 char * aNodeName = NULL ;
1931 SUPERV::GraphEvent theEvent = SUPERV::UndefinedEvent ;
1932 SUPERV::GraphState theState = SUPERV::UndefinedState ;
1933 if ( pthread_mutex_lock( &_MutexExecutorWait ) ) {
1934 perror("pthread_mutex_lock _MutexExecutorWait") ;
1937 if ( DataFlowExecutor() && !IsMacro() &&
1938 ( DataFlowExecutor()->GetListSize() || !DataFlowEditor()->IsEditing() ) ){
1939 RetVal = DataFlowExecutor()->Event( & aNodeName , theEvent , theState ) ;
1940 // endService( "Graph_Impl::Event" );
1941 if ( strlen( aNodeName ) ) {
1942 if ( strcmp( aNodeName , Name() ) ) {
1943 aNode = Node( aNodeName ) ;
1950 aNode = SUPERV::Graph::_duplicate( SUPERV::Graph::_nil() ) ;
1952 // cout << "Graph_Impl::Event " << aNode->Name() << " QSize " << DataFlowExecutor()->GetListSize() << endl ;
1955 // cout << "Graph_Impl::Event NO DataFlowExecutor() or QSize=0 " << endl ;
1957 if ( pthread_mutex_unlock( &_MutexExecutorWait ) ) {
1958 perror("pthread_mutex_unlock _MutexExecutorWait") ;
1961 anEvent = theEvent ;
1967 bool Graph_Impl::EventW( SUPERV::CNode_out aNode ,
1968 SUPERV::GraphEvent & anEvent ,
1969 SUPERV::GraphState & aState ) {
1970 // beginService( "Graph_Impl::EventW" );
1971 bool RetVal = false ;
1972 char * aNodeName = NULL ;
1973 SUPERV::GraphEvent theEvent = SUPERV::UndefinedEvent ;
1974 SUPERV::GraphState theState = SUPERV::UndefinedState ;
1975 if ( pthread_mutex_lock( &_MutexExecutorWait ) ) {
1976 perror("pthread_mutex_lock _MutexExecutorWait") ;
1979 if ( DataFlowExecutor() && !IsMacro() &&
1980 ( DataFlowExecutor()->GetListSize() || !DataFlowEditor()->IsEditing() ) ) {
1981 RetVal = DataFlowExecutor()->EventW( & aNodeName , theEvent , theState ) ;
1982 if ( RetVal && strcmp( aNodeName , Name() ) ) {
1983 aNode = Node( aNodeName ) ;
1989 if ( pthread_mutex_unlock( &_MutexExecutorWait ) ) {
1990 perror("pthread_mutex_unlock _MutexExecutorWait") ;
1993 anEvent = theEvent ;
1995 // endService( "Graph_Impl::EventW" );
1999 long Graph_Impl::EventQSize() {
2000 // beginService( "Graph_Impl::EventQSize" );
2002 if ( pthread_mutex_lock( &_MutexExecutorWait ) ) {
2003 perror("pthread_mutex_lock _MutexExecutorWait") ;
2006 if ( DataFlowExecutor() && !IsMacro() ) {
2007 QSize = DataFlowExecutor()->EventQSize() ;
2009 if ( pthread_mutex_unlock( &_MutexExecutorWait ) ) {
2010 perror("pthread_mutex_unlock _MutexExecutorWait") ;
2013 // endService( "Graph_Impl::EventQSize" );
2017 long Graph_Impl::LastLevelDone() {
2018 // beginService( "Graph_Impl::LastLevelDone" );
2019 if ( pthread_mutex_lock( &_MutexExecutorWait ) ) {
2020 perror("pthread_mutex_lock _MutexExecutorWait") ;
2024 if ( DataFlowExecutor() && !IsMacro() ) {
2025 RetVal = DataFlowExecutor()->LastLevelDone() ;
2027 if ( pthread_mutex_unlock( &_MutexExecutorWait ) ) {
2028 perror("pthread_mutex_unlock _MutexExecutorWait") ;
2031 // endService( "Graph_Impl::LastLevelDone" );
2035 long Graph_Impl::SubGraphsNumber() {
2036 // beginService( "Graph_Impl::SubGraphsNumber" );
2038 if ( DataFlowEditor()->IsExecutable() && !IsMacro() ) {
2039 RetVal = DataFlowEditor()->SubGraphsNumber() ;
2041 // endService( "Graph_Impl::SubGraphsNumber" );
2045 SUPERV::ListOfNodes * Graph_Impl::SubGraphsNodes( const long aSubGraphNumber ) {
2046 beginService( "Graph_Impl::SubGraphsNodes" );
2047 SUPERV::ListOfNodes_var RetVal = new SUPERV::ListOfNodes ;
2048 if ( DataFlowEditor()->IsEditing() && !IsMacro() ) {
2049 SUPERV::ListOfNodes * aGraphNodes = Nodes() ;
2052 for ( i = 0 ; i < (int ) aGraphNodes->CNodes.length() ; i++ ) {
2053 SUPERV::CNode_var aNode = (aGraphNodes->CNodes)[ i ] ;
2054 if ( aNode->SubGraph() == aSubGraphNumber ) {
2055 RetVal = SetNode( RetVal , DataFlowEditor()->Graph()->GetChangeGraphNode( aNode->Name() ) ) ;
2059 for ( i = 0 ; i < (int ) aGraphNodes->FNodes.length() ; i++ ) {
2060 SUPERV::FNode_var aNode = (aGraphNodes->FNodes)[ i ] ;
2061 if ( aNode->SubGraph() == aSubGraphNumber ) {
2062 RetVal = SetNode( RetVal , DataFlowEditor()->Graph()->GetChangeGraphNode( aNode->Name() ) ) ;
2066 for ( i = 0 ; i < (int ) aGraphNodes->INodes.length() ; i++ ) {
2067 SUPERV::INode_var aNode = (aGraphNodes->INodes)[ i ] ;
2068 if ( aNode->SubGraph() == aSubGraphNumber ) {
2069 RetVal = SetNode( RetVal , DataFlowEditor()->Graph()->GetChangeGraphNode( aNode->Name() ) ) ;
2073 for ( i = 0 ; i < (int ) aGraphNodes->GNodes.length() ; i++ ) {
2074 SUPERV::GNode_var aNode = (aGraphNodes->GNodes)[ i ] ;
2075 if ( aNode->SubGraph() == aSubGraphNumber ) {
2076 RetVal = SetNode( RetVal , DataFlowEditor()->Graph()->GetChangeGraphNode( aNode->Name() ) ) ;
2080 for ( i = 0 ; i < (int ) aGraphNodes->LNodes.length() ; i++ ) {
2081 SUPERV::LNode_var aNode = (aGraphNodes->LNodes)[ i ] ;
2082 if ( aNode->SubGraph() == aSubGraphNumber ) {
2083 RetVal = SetNode( RetVal , DataFlowEditor()->Graph()->GetChangeGraphNode( aNode->Name() ) ) ;
2087 for ( i = 0 ; i < (int ) aGraphNodes->ELNodes.length() ; i++ ) {
2088 SUPERV::ELNode_var aNode = (aGraphNodes->ELNodes)[ i ] ;
2089 if ( aNode->SubGraph() == aSubGraphNumber ) {
2090 RetVal = SetNode( RetVal , DataFlowEditor()->Graph()->GetChangeGraphNode( aNode->Name() ) ) ;
2094 for ( i = 0 ; i < (int ) aGraphNodes->SNodes.length() ; i++ ) {
2095 SUPERV::SNode_var aNode = (aGraphNodes->SNodes)[ i ] ;
2096 if ( aNode->SubGraph() == aSubGraphNumber ) {
2097 RetVal = SetNode( RetVal , DataFlowEditor()->Graph()->GetChangeGraphNode( aNode->Name() ) ) ;
2101 for ( i = 0 ; i < (int ) aGraphNodes->ESNodes.length() ; i++ ) {
2102 SUPERV::ESNode_var aNode = (aGraphNodes->ESNodes)[ i ] ;
2103 if ( aNode->SubGraph() == aSubGraphNumber ) {
2104 RetVal = SetNode( RetVal , DataFlowEditor()->Graph()->GetChangeGraphNode( aNode->Name() ) ) ;
2108 endService( "Graph_Impl::SubGraphsNodes" );
2109 return ( RetVal._retn() ) ;
2112 bool Graph_Impl::Merge(const SUPERV::Graph_ptr aGraph ) {
2113 // beginService( "Graph_Impl::Merge" );
2114 bool RetVal = true ;
2116 map< string , int > aMapOfNodes ;
2117 RetVal = Merge( aGraph , aMapOfNodes ) ;
2119 // endService( "Graph_Impl::Merge" );
2123 bool Graph_Impl::Merge(const SUPERV::Graph_ptr aGraph , map< string , int > & aMapOfNodes ) {
2124 beginService( "Graph_Impl::Merge" );
2125 bool RetVal = true ;
2126 if ( DataFlowEditor()->IsEditing() && !IsMacro() ) {
2127 SUPERV::ListOfNodes * aGraphNodes = aGraph->Nodes() ;
2129 SUPERV::Port_ptr aPort ;
2130 // SUPERV::StreamPort_ptr aStreamPort ;
2132 for ( i = 0 ; i < (int ) aGraphNodes->CNodes.length() ; i++ ) {
2133 SUPERV::CNode_var aNode = (aGraphNodes->CNodes)[ i ] ;
2134 SUPERV::CNode_ptr myNode = CNode( *(aNode->Service()) ) ;
2135 if ( !CORBA::is_nil( myNode ) ) {
2136 myNode->SetName( aNode->Name() ) ;
2137 myNode->SetAuthor( aNode->Author() ) ;
2138 myNode->SetComment( aNode->Comment() ) ;
2139 myNode->Coords( aNode->X() , aNode->Y() ) ;
2140 string * aNodetheName = new string( aNode->Name() ) ;
2141 aMapOfNodes[ *aNodetheName ] = DataFlowEditor()->Graph()->GetGraphNodeIndex( myNode->Name() ) ;
2142 delete aNodetheName ;
2149 // The following informations are now in the service from SALOME_ModuleCatalog
2150 // SUPERV::ListOfStreamPorts myStreamPorts = *(aNode->StreamPorts()) ;
2152 // for ( j = 0 ; j < (int ) myStreamPorts.length() ; j++ ) {
2153 // if ( myStreamPorts[ j ]->IsInput() && myStreamPorts[ j ]->IsDataStream() ) {
2154 // aStreamPort = myNode->InStreamPort( myStreamPorts[ j ]->Name() , myStreamPorts[ j ]->Type() ) ;
2156 // else if ( myStreamPorts[ j ]->IsDataStream() ) {
2157 // aStreamPort = myNode->OutStreamPort( myStreamPorts[ j ]->Name() , myStreamPorts[ j ]->Type() ) ;
2163 for ( i = 0 ; i < (int ) aGraphNodes->FNodes.length() ; i++ ) {
2164 SUPERV::FNode_var aNode = (aGraphNodes->FNodes)[ i ] ;
2165 SUPERV::FNode_ptr myNode = FNode( aNode->GetComponentName() ,
2166 aNode->GetInterfaceName() ,
2167 *(aNode->Service()) ) ;
2168 if ( !CORBA::is_nil( myNode ) ) {
2169 myNode->SetName( aNode->Name() ) ;
2170 myNode->SetAuthor( aNode->Author() ) ;
2171 myNode->SetComment( aNode->Comment() ) ;
2172 myNode->Coords( aNode->X() , aNode->Y() ) ;
2173 string * aNodetheName = new string( aNode->Name() ) ;
2174 aMapOfNodes[ *aNodetheName ] = DataFlowEditor()->Graph()->GetGraphNodeIndex( myNode->Name() ) ;
2175 delete aNodetheName ;
2182 // The following informations are now in the service from SALOME_ModuleCatalog
2183 // SUPERV::ListOfStreamPorts myStreamPorts = *(aNode->StreamPorts()) ;
2185 // for ( j = 0 ; j < (int ) myStreamPorts.length() ; j++ ) {
2186 // if ( myStreamPorts[ j ]->IsInput() && myStreamPorts[ j ]->IsDataStream() ) {
2187 // aStreamPort = myNode->InStreamPort( myStreamPorts[ j ]->Name() , myStreamPorts[ j ]->Type() ) ;
2189 // else if ( myStreamPorts[ j ]->IsDataStream() ) {
2190 // aStreamPort = myNode->OutStreamPort( myStreamPorts[ j ]->Name() , myStreamPorts[ j ]->Type() ) ;
2197 for ( i = 0 ; i < (int ) aGraphNodes->INodes.length() ; i++ ) {
2198 SUPERV::INode_var aNode = (aGraphNodes->INodes)[ i ] ;
2199 SUPERV::INode_ptr myNode = INode( aNode->PyFuncName() , *(aNode->PyFunction()) ) ;
2200 if ( !CORBA::is_nil( myNode ) ) {
2201 myNode->SetName( aNode->Name() ) ;
2202 myNode->SetAuthor( aNode->Author() ) ;
2203 myNode->SetComment( aNode->Comment() ) ;
2204 myNode->Coords( aNode->X() , aNode->Y() ) ;
2205 string * aNodetheName = new string( aNode->Name() ) ;
2206 aMapOfNodes[ *aNodetheName ] = DataFlowEditor()->Graph()->GetGraphNodeIndex( myNode->Name() ) ;
2207 delete aNodetheName ;
2208 SUPERV::ListOfPorts myPorts = *(aNode->Ports()) ;
2210 for ( j = 0 ; j < (int ) myPorts.length() ; j++ ) {
2211 if ( myPorts[ j ]->IsInput() ) {
2212 aPort = myNode->InPort( myPorts[ j ]->Name() , myPorts[ j ]->Type() ) ;
2215 aPort = myNode->OutPort( myPorts[ j ]->Name() , myPorts[ j ]->Type() ) ;
2218 if ( DataFlowEditor()->Graph()->IsDataStreamNode() ) {
2219 SUPERV::ListOfStreamPorts myStreamPorts = *(aNode->StreamPorts()) ;
2220 for ( j = 0 ; j < (int ) myStreamPorts.length() ; j++ ) {
2221 if ( myStreamPorts[ j ]->IsInput() ) {
2222 aPort = myNode->InStreamPort( myStreamPorts[ j ]->Name() , StringToDataStreamType( myStreamPorts[ j ]->Type() ) , myStreamPorts[ j ]->Dependency() ) ;
2225 aPort = myNode->OutStreamPort( myStreamPorts[ j ]->Name() , StringToDataStreamType( myStreamPorts[ j ]->Type() ) , myStreamPorts[ j ]->Dependency() ) ;
2239 for ( i = 0 ; i < (int ) aGraphNodes->GNodes.length() ; i++ ) {
2240 SUPERV::GNode_var aNode = (aGraphNodes->GNodes)[ i ] ;
2241 SUPERV::GNode_ptr myNode = GNode( aNode->PyFuncName() , *(aNode->PyFunction()) , aNode->Coupled()->Name() ) ;
2242 if ( !CORBA::is_nil( myNode ) ) {
2243 myNode->SetName( aNode->Name() ) ;
2244 myNode->SetAuthor( aNode->Author() ) ;
2245 myNode->SetComment( aNode->Comment() ) ;
2246 myNode->Coords( aNode->X() , aNode->Y() ) ;
2247 string * aNodetheName = new string( aNode->Name() ) ;
2248 aMapOfNodes[ *aNodetheName ] = DataFlowEditor()->Graph()->GetGraphNodeIndex( myNode->Name() ) ;
2249 delete aNodetheName ;
2250 SUPERV::ListOfPorts myPorts = *(aNode->Ports()) ;
2252 for ( j = 0 ; j < (int ) myPorts.length() ; j++ ) {
2253 if ( myPorts[ j ]->IsInput() ) {
2254 aPort = myNode->InPort( myPorts[ j ]->Name() , myPorts[ j ]->Type() ) ;
2257 aPort = myNode->OutPort( myPorts[ j ]->Name() , myPorts[ j ]->Type() ) ;
2260 if ( DataFlowEditor()->Graph()->IsDataStreamNode() ) {
2261 SUPERV::ListOfStreamPorts myStreamPorts = *(aNode->StreamPorts()) ;
2262 for ( j = 0 ; j < (int ) myStreamPorts.length() ; j++ ) {
2263 if ( myStreamPorts[ j ]->IsInput() ) {
2264 aPort = myNode->InStreamPort( myStreamPorts[ j ]->Name() , StringToDataStreamType( myStreamPorts[ j ]->Type() ) , myStreamPorts[ j ]->Dependency() ) ;
2267 aPort = myNode->OutStreamPort( myStreamPorts[ j ]->Name() , StringToDataStreamType( myStreamPorts[ j ]->Type() ) , myStreamPorts[ j ]->Dependency() ) ;
2281 for ( i = 0 ; i < (int ) aGraphNodes->LNodes.length() ; i++ ) {
2282 SUPERV::LNode_var aNode = (aGraphNodes->LNodes)[ i ] ;
2283 SUPERV::INode_ptr anEndOfLoop ;
2284 SUPERV::LNode_ptr myNode = LNode( aNode->PyInitName() ,
2285 *(aNode->PyInit()) ,
2286 aNode->PyMoreName() ,
2287 *(aNode->PyMore()) ,
2288 aNode->PyNextName() ,
2289 *(aNode->PyNext()) ,
2291 if ( !CORBA::is_nil( myNode ) ) {
2292 myNode->SetName( aNode->Name() ) ;
2293 myNode->SetAuthor( aNode->Author() ) ;
2294 myNode->SetComment( aNode->Comment() ) ;
2295 myNode->Coords( aNode->X() , aNode->Y() ) ;
2296 string * aNodetheName = new string( aNode->Name() ) ;
2297 aMapOfNodes[ *aNodetheName ] = DataFlowEditor()->Graph()->GetGraphNodeIndex( myNode->Name() ) ;
2298 delete aNodetheName ;
2299 SUPERV::ListOfPorts myPorts = *(aNode->Ports()) ;
2301 for ( j = 0 ; j < (int ) myPorts.length() ; j++ ) {
2302 if ( myPorts[ j ]->IsInput() ) {
2303 aPort = myNode->InPort( myPorts[ j ]->Name() , myPorts[ j ]->Type() ) ;
2306 aPort = myNode->OutPort( myPorts[ j ]->Name() , myPorts[ j ]->Type() ) ;
2309 if ( DataFlowEditor()->Graph()->IsDataStreamNode() ) {
2310 SUPERV::ListOfStreamPorts myStreamPorts = *(aNode->StreamPorts()) ;
2311 for ( j = 0 ; j < (int ) myStreamPorts.length() ; j++ ) {
2312 if ( myStreamPorts[ j ]->IsInput() ) {
2313 aPort = myNode->InStreamPort( myStreamPorts[ j ]->Name() , StringToDataStreamType( myStreamPorts[ j ]->Type() ) , myStreamPorts[ j ]->Dependency() ) ;
2316 aPort = myNode->OutStreamPort( myStreamPorts[ j ]->Name() , StringToDataStreamType( myStreamPorts[ j ]->Type() ) , myStreamPorts[ j ]->Dependency() ) ;
2320 SUPERV::INode_ptr myEndOfLoop = aNode->Coupled() ;
2321 anEndOfLoop->SetName( myEndOfLoop->Name() ) ;
2322 anEndOfLoop->SetAuthor( myEndOfLoop->Author() ) ;
2323 anEndOfLoop->SetComment( myEndOfLoop->Comment() ) ;
2324 anEndOfLoop->Coords( myEndOfLoop->X() , myEndOfLoop->Y() ) ;
2325 anEndOfLoop->SetPyFunction( myEndOfLoop->PyFuncName() , *(myEndOfLoop->PyFunction()) ) ;
2326 aNodetheName = new string( myEndOfLoop->Name() ) ;
2327 aMapOfNodes[ *aNodetheName ] = DataFlowEditor()->Graph()->GetGraphNodeIndex( anEndOfLoop->Name() ) ;
2328 if ( DataFlowEditor()->Graph()->IsDataStreamNode() ) {
2329 SUPERV::ListOfStreamPorts myStreamLoopPorts = *(myEndOfLoop->StreamPorts()) ;
2330 for ( j = 0 ; j < (int ) myStreamLoopPorts.length() ; j++ ) {
2331 if ( myStreamLoopPorts[ j ]->IsInput() ) {
2332 aPort = myNode->InStreamPort( myStreamLoopPorts[ j ]->Name() , StringToDataStreamType( myStreamLoopPorts[ j ]->Type() ) , myStreamLoopPorts[ j ]->Dependency() ) ;
2335 aPort = myNode->OutStreamPort( myStreamLoopPorts[ j ]->Name() , StringToDataStreamType( myStreamLoopPorts[ j ]->Type() ) , myStreamLoopPorts[ j ]->Dependency() ) ;
2339 delete aNodetheName ;
2350 for ( i = 0 ; i < (int ) aGraphNodes->SNodes.length() ; i++ ) {
2351 SUPERV::SNode_var aNode = (aGraphNodes->SNodes)[ i ] ;
2352 SUPERV::INode_ptr anEndOfSwitch ;
2353 SUPERV::SNode_ptr myNode = SNode( aNode->PyFuncName() , *(aNode->PyFunction()) , anEndOfSwitch ) ;
2354 if ( !CORBA::is_nil( myNode ) ) {
2355 myNode->SetName( aNode->Name() ) ;
2356 myNode->SetAuthor( aNode->Author() ) ;
2357 myNode->SetComment( aNode->Comment() ) ;
2358 myNode->Coords( aNode->X() , aNode->Y() ) ;
2359 string * aNodetheName = new string( aNode->Name() ) ;
2360 aMapOfNodes[ *aNodetheName ] = DataFlowEditor()->Graph()->GetGraphNodeIndex( myNode->Name() ) ;
2361 delete aNodetheName ;
2362 SUPERV::ListOfPorts myPorts = *(aNode->Ports()) ;
2364 for ( j = 0 ; j < (int ) myPorts.length() ; j++ ) {
2365 if ( myPorts[ j ]->IsInput() ) {
2366 aPort = myNode->InPort( myPorts[ j ]->Name() , myPorts[ j ]->Type() ) ;
2369 aPort = myNode->OutPort( myPorts[ j ]->Name() , myPorts[ j ]->Type() ) ;
2372 if ( DataFlowEditor()->Graph()->IsDataStreamNode() ) {
2373 SUPERV::ListOfStreamPorts myStreamPorts = *(aNode->StreamPorts()) ;
2374 for ( j = 0 ; j < (int ) myStreamPorts.length() ; j++ ) {
2375 if ( myStreamPorts[ j ]->IsInput() ) {
2376 aPort = myNode->InStreamPort( myStreamPorts[ j ]->Name() , StringToDataStreamType( myStreamPorts[ j ]->Type() ) , myStreamPorts[ j ]->Dependency() ) ;
2379 aPort = myNode->OutStreamPort( myStreamPorts[ j ]->Name() , StringToDataStreamType( myStreamPorts[ j ]->Type() ) , myStreamPorts[ j ]->Dependency() ) ;
2383 SUPERV::INode_ptr myEndOfSwitch = aNode->Coupled() ;
2384 anEndOfSwitch->SetName( myEndOfSwitch->Name() ) ;
2385 anEndOfSwitch->SetAuthor( myEndOfSwitch->Author() ) ;
2386 anEndOfSwitch->SetComment( myEndOfSwitch->Comment() ) ;
2387 anEndOfSwitch->Coords( myEndOfSwitch->X() , myEndOfSwitch->Y() ) ;
2388 anEndOfSwitch->SetPyFunction( myEndOfSwitch->PyFuncName() , *(myEndOfSwitch->PyFunction()) ) ;
2389 aNodetheName = new string( myEndOfSwitch->Name() ) ;
2390 aMapOfNodes[ *aNodetheName ] = DataFlowEditor()->Graph()->GetGraphNodeIndex( anEndOfSwitch->Name() ) ;
2391 delete aNodetheName ;
2392 myPorts = *(myEndOfSwitch->Ports()) ;
2393 for ( j = 0 ; j < (int ) myPorts.length() ; j++ ) {
2394 if ( myPorts[ j ]->IsInput() ) {
2395 aPort = myNode->InPort( myPorts[ j ]->Name() , myPorts[ j ]->Type() ) ;
2398 aPort = myNode->OutPort( myPorts[ j ]->Name() , myPorts[ j ]->Type() ) ;
2401 if ( DataFlowEditor()->Graph()->IsDataStreamNode() ) {
2402 SUPERV::ListOfStreamPorts myStreamSwitchPorts = *(myEndOfSwitch->StreamPorts()) ;
2403 for ( j = 0 ; j < (int ) myStreamSwitchPorts.length() ; j++ ) {
2404 if ( myStreamSwitchPorts[ j ]->IsInput() ) {
2405 aPort = myNode->InStreamPort( myStreamSwitchPorts[ j ]->Name() , StringToDataStreamType( myStreamSwitchPorts[ j ]->Type() ) , myStreamSwitchPorts[ j ]->Dependency() ) ;
2408 aPort = myNode->OutStreamPort( myStreamSwitchPorts[ j ]->Name() , StringToDataStreamType( myStreamSwitchPorts[ j ]->Type() ) , myStreamSwitchPorts[ j ]->Dependency() ) ;
2421 SUPERV::ListOfLinks * aGraphLinks = aGraph->GLinks() ;
2422 SUPERV::ListOfPorts * aGraphPorts = aGraph->Ports() ;
2423 // cout << "Graph_Impl::Merge " << aGraphLinks->length() << " links " << aGraphPorts->length() << " GraphPorts"
2425 for ( i = 0 ; i < (int ) aGraphLinks->length() ; i++ ) {
2426 SUPERV::Link_var aLink = (*aGraphLinks)[ i ] ;
2427 SUPERV::Port_var OutPort = aLink->OutPort() ;
2428 SUPERV::Port_var InPort = aLink->InPort() ;
2429 string * aLinkFromNodeName = new string( OutPort->Node()->Name() ) ;
2430 string * aLinkToNodeName = new string( InPort->Node()->Name() ) ;
2431 RetVal = DataFlowEditor()->AddLink( DataFlowEditor()->Graph()->GetGraphNode( aMapOfNodes[ aLinkFromNodeName->c_str() ] )->Name() ,
2433 DataFlowEditor()->Graph()->GetGraphNode( aMapOfNodes[ aLinkToNodeName->c_str() ] )->Name() ,
2437 for ( j = 1 ; j <= aLink->CoordsSize() ; j++ ) {
2439 RetVal = aLink->Coords( j , X , Y ) ;
2442 RetVal = DataFlowEditor()->AddLinkCoord( DataFlowEditor()->Graph()->GetGraphNode( aMapOfNodes[ aLinkFromNodeName->c_str() ] )->Name() ,
2444 DataFlowEditor()->Graph()->GetGraphNode( aMapOfNodes[ aLinkToNodeName->c_str() ] )->Name() ,
2452 delete aLinkFromNodeName ;
2453 delete aLinkToNodeName ;
2459 for ( i = 0 ; i < (int ) aGraphPorts->length() ; i++ ) {
2460 SUPERV::Port_var aPort = (*aGraphPorts)[ i ] ;
2461 if ( !aPort->IsGate() ) {
2462 MESSAGE( "Graph_Impl::Merge " << i << ". " << aPort->Node()->Name() << " " << aPort->Name() ) ;
2463 char * aPortName = aPort->Name() ;
2464 char * aNodeName = new char[ strlen( aPortName ) + 1 ] ;
2465 strcpy( aNodeName , aPortName ) ;
2466 // char * thePortName = strchr( aNodeName , '\\' ) ;
2467 char * thePortName = aNodeName ;
2468 while ( ( thePortName = strchr( thePortName , '_' ) ) ) {
2469 if ( thePortName[1] == '_' ) {
2470 thePortName[ 0 ] = '\0' ;
2474 thePortName = &thePortName[2] ;
2477 bool hasinput = aGraph->Node( aNodeName )->Port( thePortName + 2 )->HasInput() ;
2478 // cout << "Graph_Impl::Merge " << " aNodeName " << aNodeName << " aPort " << thePortName + 1
2479 // << " HasInput " << hasinput << endl ;
2481 RetVal = DataFlowEditor()->AddInputData( DataFlowEditor()->Graph()->GetGraphNode( aMapOfNodes[ aNodeName ] )->Name() ,
2483 *(aPort->ToAny()) ) ;
2485 delete [] aNodeName ;
2494 MESSAGE( "Graph_Impl::Merge returns " << RetVal ) ;
2495 endService( "Graph_Impl::Merge" );
2499 SUPERV::StreamGraph_ptr Graph_Impl::ToStreamGraph() {
2500 SUPERV::StreamGraph_var iobject = SUPERV::StreamGraph::_nil() ;
2501 beginService( "Graph_Impl::ToStreamGraph" );
2502 if ( IsStreamGraph() && !IsMacro() ) {
2503 // StreamGraph_Impl * myStreamGraph = new StreamGraph_Impl( _Orb , _Poa , _ContId ,
2504 // instanceName() , interfaceName() ) ;
2505 // PortableServer::ObjectId * id = myStreamGraph->getId() ;
2506 // CORBA::Object_var obj = _poa->id_to_reference(*id);
2507 iobject = SUPERV::StreamGraph::_narrow( ObjRef() ) ;
2508 if ( CORBA::is_nil( iobject ) ) {
2509 MESSAGE( "ToStreamGraph of " << Name() << " (IsStreamGraph) --> nil reference" ) ;
2513 MESSAGE( "ToStreamGraph of " << Name() << " (IsNOTStreamGraph) --> nil reference" ) ;
2515 endService( "Graph_Impl::ToStreamGraph" );
2516 return SUPERV::StreamGraph::_duplicate( iobject ) ;
2520 * Destroy Executor and use only Editor and its data model
2522 void Graph_Impl::Editing() {
2523 if ( DataFlowEditor() && DataFlowExecutor() ) {
2524 delete DataFlowExecutor() ;
2525 DataFlowEditor()->Executor( NULL );