1 // SUPERV Supervision : contains the implementation of interfaces of SuperVision described in SUPERV.idl
3 // Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 // See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
24 // File : Graph_Impl.cxx
25 // Author : Jean Rahuel
35 //#include "utilities.h"
37 #include "SALOME_Container_i.hxx"
39 #include "StreamGraph_Impl.hxx"
41 #include "DataFlowEditor_DataFlow.hxx"
43 extern GraphExecutor::FiniteStateMachine * theAutomaton ;
45 static void CreateEditor( CORBA::ORB_ptr orb ,
46 const char *instanceName ,
47 const char *aDataFlowName ,
48 const SUPERV::KindOfNode aKindOfNode ,
50 GraphEditor::DataFlow ** aDataFlowEditor ) {
51 bool aXmlFile = false ;
52 int lenname = strlen( aDataFlowName ) ;
53 char * theDataFlowName = new char [ lenname+1 ] ;
54 strcpy( theDataFlowName , aDataFlowName ) ;
55 if ( aDataFlowName ) {
56 if ( lenname > 4 && !strcmp( &aDataFlowName[ lenname - 4 ] , ".xml" ) ) {
57 strncpy( theDataFlowName , &aDataFlowName[ 0 ] , lenname-4 ) ;
58 theDataFlowName[ lenname-4 ] = '\0' ;
61 for ( i = lenname - 5 ; i >= 0 ; i-- ) {
62 if ( aDataFlowName[ i ] == '/' ) {
63 strncpy( theDataFlowName , &aDataFlowName[ i + 1 ] , lenname-5-i ) ;
64 theDataFlowName[ lenname-5-i ] = '\0' ;
70 strcpy( theDataFlowName , &aDataFlowName[ 0 ] ) ;
74 string theDataFlowInstanceName = theDataFlowName ;
76 // asv : 16.11.04 : creation of log file in /tmp/logs/$USER dir.
77 // "/tmp/logs/$USER" was created by runSalome.py -> orbmodule.py.
78 dbgfile = "/tmp/logs/" ;
79 dbgfile += getenv( "USER" ) ;
81 dbgfile += instanceName ;
83 dbgfile += theDataFlowInstanceName ;
84 dbgfile = dbgfile + "_" + theAutomaton->DbgFileNumber() + ".log" ;
85 FILE* f = fopen ( dbgfile.c_str(), "a" );
86 if ( f ) { // check if file can be opened for writing
89 else { // if file can't be opened - use a guaranteed temp file name
90 char* aTempNam = tempnam( NULL, NULL );
95 SALOME_NamingService * NamingService = new SALOME_NamingService( orb ) ;
96 *aDataFlowEditor = new GraphEditor::DataFlow( orb , NamingService ,
97 theDataFlowInstanceName.c_str() , dbgfile.c_str() ,
99 MESSAGE( "CreateEditor " << theDataFlowName << " uniquely named " << theDataFlowInstanceName << " created with "
100 << dbgfile.c_str() ) ;
102 delete [] theDataFlowName ;
105 static void CreateExecutor( CORBA::ORB_ptr orb ,
106 const char *instanceName ,
107 const char *aDataFlowName ,
108 const SUPERV::KindOfNode aKindOfNode ,
110 GraphExecutor::DataFlow ** aDataFlowExecutor ) {
111 int lenname = strlen( aDataFlowName ) ;
112 char * theDataFlowName = new char [ lenname+1 ] ;
113 strcpy( theDataFlowName , aDataFlowName ) ;
114 if ( aDataFlowName ) {
115 strcpy( theDataFlowName , &aDataFlowName[ 0 ] ) ;
118 string theDataFlowInstanceName = theDataFlowName ;
120 // asv : 16.11.04 : creation of log file in /tmp/logs/$USER dir.
121 // "/tmp/logs/$USER" was created by runSalome.py -> orbmodule.py.
122 dbgfile = "/tmp/logs/" ;
123 dbgfile += getenv( "USER" ) ;
125 dbgfile += instanceName ;
127 dbgfile += theDataFlowInstanceName ;
128 dbgfile = dbgfile + "_" + theAutomaton->DbgFileNumber() ;
130 astr << theAutomaton->ExecNumber() ;
131 dbgfile += astr.str() ;
132 dbgfile += string( "_Exec.log" ) ;
133 FILE* f = fopen ( dbgfile.c_str(), "a" );
134 if ( f ) { // check if file can be opened for writing
137 else { // if file can't be opened - use a guaranteed temp file name
138 char* aTempNam = tempnam( NULL, NULL );
143 SALOME_NamingService * NamingService = new SALOME_NamingService( orb ) ;
144 *aDataFlowExecutor = new GraphExecutor::DataFlow( orb , NamingService ,
145 theDataFlowInstanceName.c_str() , dbgfile.c_str() ,
148 MESSAGE( "CreateExecutor " << theDataFlowName << " " << theDataFlowInstanceName << " created with "
149 << dbgfile.c_str() ) ;
151 delete [] theDataFlowName ;
154 Graph_Impl::Graph_Impl( CORBA::ORB_ptr orb ,
155 PortableServer::POA_ptr poa ,
156 PortableServer::ObjectId * contId ,
157 const char *instanceName ,
158 const char *interfaceName ,
159 const char *aDataFlowName ,
160 const SUPERV::KindOfNode aKindOfNode ) :
161 GNode_Impl( orb , poa , contId , instanceName , interfaceName , aDataFlowName , aKindOfNode ) {
162 // MESSAGE("Graph_Impl::Graph_Impl activate object instanceName("
163 // << instanceName << ") interfaceName(" << interfaceName << ") --> "
164 // << hex << (void *) this << dec )
165 // beginService( "Graph_Impl::Graph_Impl" );
166 _Orb = CORBA::ORB::_duplicate(orb);
169 _DebugFileName = NULL ;
170 if ( aKindOfNode == SUPERV::DataFlowGraph || aKindOfNode == SUPERV::MacroNode ) {
171 // MESSAGE( "Graph_Impl::Graph_Impl _poa->activate_object" );
173 _id = _poa->activate_object(_thisObj);
176 // MESSAGE( "Graph_Impl::Graph_Impl NO _poa->activate_object " );
179 if ( aKindOfNode == SUPERV::DataFlowGraph || aKindOfNode == SUPERV::DataStreamGraph ) {
181 GraphEditor::DataFlow * aDataFlowEditor ;
182 CreateEditor( orb , instanceName , aDataFlowName , aKindOfNode ,
183 dbgfile , &aDataFlowEditor ) ;
185 if ( _DebugFileName ) {
186 delete [] _DebugFileName ;
188 _DebugFileName = new char[ strlen( dbgfile.c_str() )+1 ] ;
189 strcpy( _DebugFileName , dbgfile.c_str() ) ;
191 _NamingService = new SALOME_NamingService( orb ) ;
192 DataFlowEditor( aDataFlowEditor ) ;
193 DataFlowEditor()->Graph()->GraphEditor( aDataFlowEditor ) ;
194 DataFlowEditor()->Graph()->SetObjImpl( this ) ;
196 pthread_mutex_init( &_MutexExecutorWait , NULL ) ;
197 // DataFlowExecutor( NULL ) ;
198 // endService( "Graph_Impl::Graph_Impl" );
201 Graph_Impl::Graph_Impl( CORBA::ORB_ptr orb ,
202 PortableServer::POA_ptr poa ,
203 PortableServer::ObjectId * contId ,
204 const char *instanceName ,
205 const char *interfaceName ,
206 GraphEditor::DataFlow * aDataFlowEditor ,
207 GraphEditor::InNode * aDataFlowNode ) :
208 GNode_Impl( orb , poa , contId , instanceName , interfaceName , aDataFlowEditor , aDataFlowNode ) {
209 // beginService( "Graph_Impl::Graph_Impl" );
210 // MESSAGE( aDataFlowEditor->Graph()->Name() << " " );
211 if ( aDataFlowEditor->Graph()->IsDataFlowNode() ||
212 ( aDataFlowNode && aDataFlowNode->IsMacroNode() ) ) {
213 // MESSAGE( "Graph_Impl::Graph_Impl _poa->activate_object" );
215 _id = _poa->activate_object(_thisObj);
218 // MESSAGE( "Graph_Impl::Graph_Impl NO _poa->activate_object " );
220 _Orb = CORBA::ORB::_duplicate(orb);
223 _DebugFileName = NULL ;
224 DataFlowEditor( aDataFlowEditor ) ;
225 DataFlowEditor()->Graph()->GraphEditor( aDataFlowEditor ) ;
226 DataFlowEditor()->Graph()->SetObjImpl( this ) ;
227 pthread_mutex_init( &_MutexExecutorWait , NULL ) ;
228 // DataFlowExecutor( NULL ) ;
229 // endService( "Graph_Impl::Graph_Impl" );
232 Graph_Impl::Graph_Impl() {
235 Graph_Impl::~Graph_Impl() {
236 beginService( "Graph_Impl::~Graph_Impl" );
237 endService( "Graph_Impl::~Graph_Impl" );
240 void Graph_Impl::destroy() {
241 beginService( "Graph_Impl::destroy" );
242 if ( DataFlowNode() && DataFlowNode()->ComputingNode()->IsMacroNode() ) {
243 SUPERV::Graph_var aGraph = DataFlowNode()->GOTONode()->MacroObject() ;
244 GNode_Impl::Delete() ;
245 if ( !CORBA::is_nil( aGraph ) ) {
250 SUPERV::Graph_var aGraph = DataFlowEditor()->Graph()->MacroObject() ;
251 GNode_Impl::Delete() ;
252 if ( !CORBA::is_nil( aGraph ) ) {
256 _poa->deactivate_object(*_id) ;
257 // CORBA::release(_poa) ;
259 // _thisObj->_remove_ref();
260 endService( "Graph_Impl::destroy" );
264 char* Graph_Impl::getIOR() {
266 return CORBA::string_dup( NULLSTRING ) ;
268 else if ( CORBA::is_nil( myServant ) ) {
269 PortableServer::ObjectId* id = getId();
270 CORBA::Object_var obj;
271 obj = _poa->id_to_reference(*id);
272 myServant = SUPERV::Graph::_narrow(obj);
274 return(CORBA::string_dup(_Orb->object_to_string(myServant)));
277 SUPERV::Graph_ptr Graph_Impl::Copy() {
278 beginService( "Graph_Impl::Copy" );
279 SUPERV::Graph_var iobject = SUPERV::Graph::_nil() ;
281 Graph_Impl * myGraph ;
282 myGraph = new Graph_Impl( _Orb , _Poa, _ContId,
283 instanceName() , interfaceName() ,
284 DataFlowEditor()->Graph()->Name() , SUPERV::DataFlowGraph ) ;
285 PortableServer::ObjectId * id = myGraph->getId() ;
286 CORBA::Object_var obj = _poa->id_to_reference(*id);
287 iobject = SUPERV::Graph::_narrow(obj) ;
288 GraphBase::ListOfSGraphs * aListOfSGraphs = GetGraphs() ;
289 myGraph->LoadGraphs( aListOfSGraphs ) ;
291 endService( "Graph_Impl::Copy" );
292 return SUPERV::Graph::_duplicate(iobject) ;
295 void Graph_Impl::ReadOnly() {
296 DataFlowEditor()->ReadOnly() ;
299 SUPERV::INode_ptr Graph_Impl::Node() {
300 // beginService( "Graph_Impl::Node" );
301 PortableServer::ObjectId * id = getId() ;
302 CORBA::Object_var obj = _poa->id_to_reference(*id);
303 SUPERV::Graph_var iobject ;
304 iobject = SUPERV::Graph::_narrow(obj) ;
305 // endService( "Graph_Impl::Node" );
306 return SUPERV::Graph::_duplicate(iobject) ;
309 GraphBase::ListOfSGraphs * Graph_Impl::GetGraphs() {
310 return DataFlowEditor()->GetDataFlows() ;
313 bool Graph_Impl::LoadGraphs( GraphBase::ListOfSGraphs * aListOfDataFlows ) {
314 beginService( "Graph_Impl::LoadGraphs" );
315 bool RetVal = false ;
316 if ( DataFlowEditor()->IsEditing() ) {
317 // RetVal = DataFlowEditor()->LoadDataFlows( aListOfDataFlows ) ;
318 if ( CORBA::is_nil( LoadDataFlows( DataFlowEditor() , aListOfDataFlows , 0 ) ) ) {
322 endService( "Graph_Impl::LoadGraphs" );
326 bool Graph_Impl::Import(const char * aXmlFile ) {
327 beginService( "Graph_Impl::Import" );
328 bool RetVal = false ;
329 if ( DataFlowEditor()->IsEditing() && !IsMacro() ) {
330 GraphBase::ListOfSGraphs aListOfDataFlows ;
331 RetVal = DataFlowEditor()->LoadXml( aXmlFile , aListOfDataFlows ) ;
332 if ( RetVal && aXmlFile != NULL ) {
333 // RetVal = DataFlowEditor()->LoadDataFlows( &aListOfDataFlows ) ;
334 if ( CORBA::is_nil( LoadDataFlows( DataFlowEditor() , &aListOfDataFlows , 0 ) ) ) {
339 endService( "Graph_Impl::Import" );
343 bool Graph_Impl::Export(const char * anXmlFile ) {
344 beginService( "Graph_Impl::Export" );
345 bool RetVal = false ;
347 char * aFile = new char [ strlen( anXmlFile ) + 5 ] ;
348 strcpy( aFile , anXmlFile ) ;
349 int len = strlen( aFile ) ;
350 if ( !strcmp( &aFile[ len - 4 ] , ".xml" ) ) {
352 else if ( !strcmp( &aFile[ len - 3 ] , ".py" ) ) {
353 strcpy( &aFile[ len - 3 ] , ".xml" ) ;
354 len = strlen( aFile ) ;
357 strcat( aFile , ".xml" ) ;
358 len = strlen( aFile ) ;
360 RetVal = DataFlowEditor()->SaveXml( aFile ) ;
362 strcpy( &aFile[ len - 4 ] , ".py" ) ;
363 RetVal = DataFlowEditor()->SavePy( aFile ) ;
367 endService( "Graph_Impl::Export" );
371 char * Graph_Impl::SavePY( bool importSuperV ) {
372 beginService( "Graph_Impl::SavePY" );
373 ostringstream fstring ;
375 RetVal = DataFlowEditor()->SavePY( fstring , importSuperV ) ;
377 endService( "Graph_Impl::SavePY" );
378 return CORBA::string_dup( fstring.str().c_str() );
380 SUPERV::CNode_ptr Graph_Impl::CNode( const SALOME_ModuleCatalog::Service &NodeService ) {
381 beginService( "Graph_Impl::CNode" );
382 SUPERV::CNode_var iobject = SUPERV::CNode::_nil() ;
383 if ( DataFlowEditor()->IsEditing() && !DataFlowEditor()->IsReadOnly() && !IsMacro() ) {
384 CNode_Impl * myNode = new CNode_Impl( _Orb , _Poa , _ContId ,
385 instanceName() , interfaceName() ,
387 NodeService , NULLSTRING ,
388 SUPERV::ComputingNode , NULLSTRING ) ;
389 if ( myNode->DataFlowNode() ) {
390 PortableServer::ObjectId * id = myNode->getId() ;
391 CORBA::Object_var obj = _poa->id_to_reference(*id);
392 iobject = SUPERV::CNode::_narrow(obj) ;
393 myNode->SetObjRef( SUPERV::CNode::_duplicate( iobject ) ) ;
396 DataFlowEditor()->UnValid() ;
397 endService( "Graph_Impl::CNode" );
398 return SUPERV::CNode::_duplicate( iobject ) ;
401 SUPERV::FNode_ptr Graph_Impl::FNode( const char * NodeComponentName ,
402 const char * NodeInterfaceName ,
403 const SALOME_ModuleCatalog::Service &NodeService ) {
404 beginService( "Graph_Impl::FNode" );
405 SUPERV::FNode_var iobject = SUPERV::FNode::_nil() ;
406 if ( DataFlowEditor()->IsEditing() && !DataFlowEditor()->IsReadOnly() && !IsMacro() ) {
407 FNode_Impl * myNode = new FNode_Impl( _Orb , _Poa , _ContId ,
408 instanceName() , interfaceName() ,
412 NodeInterfaceName ) ;
413 if ( myNode->DataFlowNode() ) {
414 PortableServer::ObjectId * id = myNode->getId() ;
415 CORBA::Object_var obj = _poa->id_to_reference(*id);
416 iobject = SUPERV::FNode::_narrow(obj) ;
417 myNode->SetObjRef( SUPERV::FNode::_duplicate( iobject ) ) ;
420 DataFlowEditor()->UnValid() ;
421 endService( "Graph_Impl::FNode" );
422 return SUPERV::FNode::_duplicate( iobject ) ;
425 SUPERV::INode_ptr Graph_Impl::INode( const char * FuncName ,
426 const SUPERV::ListOfStrings & PythonFuntion ) {
427 beginService( "Graph_Impl::INode" );
428 SUPERV::INode_var iobject = SUPERV::INode::_nil() ;
429 if ( DataFlowEditor()->IsEditing() && !DataFlowEditor()->IsReadOnly() && !IsMacro() ) {
430 INode_Impl * myNode = new INode_Impl( _Orb , _Poa , _ContId ,
431 instanceName() , interfaceName() ,
433 FuncName , PythonFuntion ,
434 SUPERV::InLineNode ) ;
435 if ( myNode->DataFlowNode() ) {
436 PortableServer::ObjectId * id = myNode->getId() ;
437 CORBA::Object_var obj = _poa->id_to_reference(*id);
438 iobject = SUPERV::INode::_narrow(obj) ;
439 myNode->SetObjRef( SUPERV::INode::_duplicate( iobject ) ) ;
442 endService( "Graph_Impl::INode" );
443 return SUPERV::INode::_duplicate( iobject ) ;
447 SUPERV::GNode_ptr Graph_Impl::GNode( const char * FuncName ,
448 const SUPERV::ListOfStrings & PythonFuntion ,
449 const char * anInLineNode ) {
450 beginService( "Graph_Impl::GNode" );
451 SUPERV::GNode_var iobject = SUPERV::GNode::_nil() ;
452 if ( DataFlowEditor()->IsEditing() && !DataFlowEditor()->IsReadOnly() && !IsMacro() ) {
453 GNode_Impl * myNode = new GNode_Impl( _Orb , _Poa , _ContId ,
454 instanceName() , interfaceName() ,
456 FuncName , PythonFuntion ,
458 if ( myNode->DataFlowNode() ) {
459 PortableServer::ObjectId * id = myNode->getId() ;
460 CORBA::Object_var obj = _poa->id_to_reference(*id);
461 iobject = SUPERV::GNode::_narrow(obj) ;
462 myNode->SetObjRef( SUPERV::GNode::_duplicate( iobject ) ) ;
463 if ( strlen( anInLineNode ) ) {
464 GraphBase::InLineNode * CoupledINode = (GraphBase::InLineNode * ) DataFlowEditor()->Graph()->GetGraphNode( anInLineNode ) ;
465 if ( anInLineNode ) {
466 myNode->SetCoupled( anInLineNode ) ;
467 Link( myNode->Port( "OutGate" ) , CoupledINode->ObjRef()->Port( "InGate" ) ) ;
472 DataFlowEditor()->UnValid() ;
473 endService( "Graph_Impl::GNode" );
474 return SUPERV::GNode::_duplicate( iobject ) ;
477 SUPERV::LNode_ptr Graph_Impl::LNode( const char * InitName ,
478 const SUPERV::ListOfStrings & InitFunction ,
479 const char * MoreName ,
480 const SUPERV::ListOfStrings & MoreFunction ,
481 const char * NextName ,
482 const SUPERV::ListOfStrings & NextFunction ,
483 SUPERV::INode_out anEndOfLoop ) {
484 beginService( "Graph_Impl::LNode" );
485 SUPERV::LNode_var iobject = SUPERV::LNode::_nil() ;
486 SUPERV::ELNode_var iendobject = SUPERV::ELNode::_nil() ;
487 if ( DataFlowEditor()->IsEditing() && !DataFlowEditor()->IsReadOnly() && !IsMacro() ) {
488 GraphBase::ListOfFuncName FuncNameList ;
489 FuncNameList.resize(3) ;
490 FuncNameList[0] = InitName ;
491 FuncNameList[1] = MoreName ;
492 FuncNameList[2] = NextName ;
493 GraphBase::ListOfPythonFunctions PythonFunctionList ;
494 PythonFunctionList.resize(3) ;
495 PythonFunctionList[0] = &InitFunction ;
496 PythonFunctionList[1] = &MoreFunction ;
497 PythonFunctionList[2] = &NextFunction ;
498 LNode_Impl * myNode = new LNode_Impl( _Orb , _Poa , _ContId ,
499 instanceName() , interfaceName() ,
501 FuncNameList , PythonFunctionList ,
502 // InitName , InitFunction ,
503 // MoreName , MoreFunction ,
504 // NextName , NextFunction ,
506 if ( myNode->DataFlowNode() ) {
507 PortableServer::ObjectId * id = myNode->getId() ;
508 CORBA::Object_var obj = _poa->id_to_reference(*id);
509 iobject = SUPERV::LNode::_narrow(obj) ;
510 myNode->SetObjRef( SUPERV::LNode::_duplicate( iobject ) ) ;
512 SALOME_ModuleCatalog::Service aVoidService = SALOME_ModuleCatalog::Service() ;
514 if ( strlen( InitName ) ) {
515 anEndName = new char( 3 + strlen( InitName ) + 1 ) ;
516 strcpy( anEndName , "End" ) ;
517 strcat( anEndName , InitName ) ;
520 anEndName = new char( 3 + strlen( "Loop" ) + 1 ) ;
521 strcpy( anEndName , "EndLoop" ) ;
523 ELNode_Impl * myEndNode = new ELNode_Impl( _Orb , _Poa , _ContId ,
524 instanceName() , interfaceName() ,
527 SUPERV::EndLoopNode ) ;
528 PortableServer::ObjectId * endid = myEndNode->getId() ;
529 CORBA::Object_var endobj = _poa->id_to_reference(*endid);
530 iendobject = SUPERV::ELNode::_narrow(endobj) ;
531 myEndNode->SetObjRef( SUPERV::ELNode::_duplicate( iendobject ) ) ;
532 myNode->SetCoupled( myEndNode->BaseNode()->Name() ) ;
533 myEndNode->SetCoupled( myNode->BaseNode()->Name() ) ;
534 //JR 25.01.2005 That links are already done in SetCoupled above ...
535 // Link( myNode->Port( "DoLoop" ) , myEndNode->Port( "DoLoop" ) ) ;
536 // Link( myEndNode->Port( "DoLoop" ) , myNode->Port( "InitLoop" ) ) ;
537 // Link( myEndNode->Port( "DoLoop" ) , myNode->Port( "DoLoop" ) ) ;
540 anEndOfLoop = SUPERV::ELNode::_duplicate( iendobject ) ;
541 DataFlowEditor()->UnValid() ;
542 endService( "Graph_Impl::LNode" );
543 return SUPERV::LNode::_duplicate( iobject ) ;
546 SUPERV::SNode_ptr Graph_Impl::SNode( const char * FuncName ,
547 const SUPERV::ListOfStrings & PythonFunction ,
548 SUPERV::INode_out anEndOfSwitch ) {
549 beginService( "Graph_Impl::SNode" );
550 SUPERV::SNode_var iobject = SUPERV::SNode::_nil() ;
551 SUPERV::ESNode_var iendobject = SUPERV::ESNode::_nil() ;
552 if ( DataFlowEditor()->IsEditing() && !DataFlowEditor()->IsReadOnly() && !IsMacro() ) {
553 SNode_Impl * myNode = new SNode_Impl( _Orb , _Poa , _ContId ,
554 instanceName() , interfaceName() ,
556 FuncName , PythonFunction ,
557 SUPERV::SwitchNode ) ;
558 if ( myNode->DataFlowNode() ) {
559 PortableServer::ObjectId * id = myNode->getId() ;
560 CORBA::Object_var obj = _poa->id_to_reference(*id);
561 iobject = SUPERV::SNode::_narrow(obj) ;
562 myNode->SetObjRef( SUPERV::SNode::_duplicate( iobject ) ) ;
564 string anEndName = "End" ;
565 if ( strlen( FuncName ) ) {
566 anEndName += FuncName ;
569 anEndName += "Switch" ;
571 // cout << "Graph_Impl::SNode anEndName " << (void *) FuncName << " " << FuncName
572 // << " " << strlen(FuncName) << " " << (void *) anEndName.c_str() << " "
573 // << anEndName.c_str() << endl ;
574 ESNode_Impl * myEndNode = new ESNode_Impl( _Orb , _Poa , _ContId ,
575 instanceName() , interfaceName() ,
578 SUPERV::EndSwitchNode ) ;
579 // cout << "Graph_Impl::SNode returned anEndName " << (void *) FuncName << " "
580 // << FuncName << " " << strlen(FuncName) << " " << (void *) anEndName.c_str()
581 // << " " << anEndName.c_str() << endl ;
582 PortableServer::ObjectId * endid = myEndNode->getId() ;
583 CORBA::Object_var endobj = _poa->id_to_reference(*endid);
584 iendobject = SUPERV::ESNode::_narrow(endobj) ;
585 myEndNode->SetObjRef( SUPERV::ESNode::_duplicate( iendobject ) ) ;
586 myNode->SetCoupled( myEndNode->BaseNode()->Name() ) ;
587 myEndNode->SetCoupled( myNode->BaseNode()->Name() ) ;
588 if ( !Link( myNode->Port( "Default" ) , myEndNode->Port( "Default" ) ) ) {
589 iobject = SUPERV::SNode::_nil() ;
590 iendobject = SUPERV::ESNode::_nil() ;
594 anEndOfSwitch = SUPERV::ESNode::_duplicate( iendobject ) ;
595 DataFlowEditor()->UnValid() ;
596 endService( "Graph_Impl::SNode" );
597 return SUPERV::SNode::_duplicate( iobject ) ;
600 // WARNING : THIS IS COMPLICATED :
601 SUPERV::Graph_var Graph_Impl::LoadDataFlows( GraphEditor::DataFlow * aDataFlowEditor ,
602 GraphBase::ListOfSGraphs * aListOfDataFlows ,
604 beginService( "Graph_Impl::EditorLoadDataFlows" ) ;
605 MESSAGE("Graph_Impl::LoadDataFlows index " << index << " " << (*aListOfDataFlows)[index].Info.theName.c_str() ) ;
607 SUPERV::Graph_var iobject = SUPERV::Graph::_nil() ;
608 // That method is recursive :
609 // At first we load the supergraph with index = 0 :
610 // (After we load the graph corresponding to each MacroNode :)
611 if ( !aDataFlowEditor->LoadDataFlow( &(*aListOfDataFlows)[ index ] ) ) {
612 MESSAGE("Graph_Impl::LoadDataFlows failed " << (*aListOfDataFlows)[index].Info.theName.c_str() ) ;
613 return SUPERV::Graph::_duplicate( iobject ) ;
615 // That graph is not a StreamGraph :
616 else if ( !aDataFlowEditor->Graph()->HasDataStream() ) {
617 aDataFlowEditor->Graph()->Kind( SUPERV::DataFlowGraph ) ;
618 // aDataFlowEditor->Graph()->SetGraphEditor( aDataFlowEditor ) ;
619 Graph_Impl * myGraph ;
620 // We create a Graph ObjRef for that graph
621 myGraph = new Graph_Impl( _Orb , _Poa, _ContId,
622 instanceName() , interfaceName() ,
623 aDataFlowEditor , NULL ) ;
624 PortableServer::ObjectId * id = myGraph->getId() ;
625 CORBA::Object_var obj = _poa->id_to_reference(*id) ;
626 iobject = SUPERV::Graph::_narrow( obj ) ;
627 myGraph->SetObjRef( SUPERV::Graph::_duplicate( iobject ) ) ;
628 myGraph->SetObjImpl( (CNode_Impl * ) myGraph ) ;
629 GraphBase::Graph * aGraph = myGraph->DataFlowEditor()->Graph() ;
632 // asv: set Editor for the graph itself and for all its macro nodes
633 aGraph->GraphEditor( aDataFlowEditor );
635 // For the supergraph or each graph of MacroNodes we search MacroNodes recursively :
636 for ( i = 0 ; i < aGraph->GraphNodesSize() ; i++ ) {
637 if ( aGraph->GraphNodes( i )->IsMacroNode() ) {
638 GraphBase::GOTONode * aMacroNode = (GraphBase::GOTONode * ) aGraph->GraphNodes( i ) ;
640 // asv : 05.11.04 : fix of bug - "insert file" into existing graph with MacroNodes worked incorrectly!
641 // aMacroNode is an "old" node, and here we must analize only "new" nodes, that
642 // came from aListOfDataFlows and were loaded by aDataFlowEditor->LoadDataFlow( &(*aListOfDataFlows)[ index ] )
643 // so here we check if the node is "new" or "old"
644 if ( aMacroNode->GraphEditor() && aMacroNode->CoupledNode() )
647 // asv: set Editor for the graph itself and for all its macro nodes
648 aMacroNode->GraphEditor( aDataFlowEditor );
650 // Creation of a GraphMacroNode ObjRef in the current editor
651 SUPERV::Graph_var macroiobject = SUPERV::Graph::_nil() ;
652 Graph_Impl * myMacroNode ;
653 myMacroNode = new Graph_Impl( _Orb , _Poa, _ContId,
654 instanceName() , interfaceName() ,
655 aMacroNode->Name() , SUPERV::MacroNode ) ;
656 id = myMacroNode->getId() ;
657 obj = _poa->id_to_reference(*id);
658 macroiobject = SUPERV::Graph::_narrow( obj ) ;
659 myMacroNode->DataFlowEditor( aDataFlowEditor ) ;
660 GraphEditor::InNode * aDataFlowNode = (GraphEditor::InNode * ) aMacroNode->GetInNode() ;
661 myMacroNode->DataFlowNode( aDataFlowNode ) ;
662 aDataFlowNode->SetObjRef( SUPERV::CNode::_duplicate( SUPERV::CNode::_narrow( obj ) ) ) ;
663 aDataFlowNode->SetObjImpl( myMacroNode ) ;
665 char * aCoupledNodeName = aMacroNode->CoupledNodeName() ;
666 MESSAGE( "LoadDataFlows MacroNode " << aMacroNode->Name() << " --> " << aCoupledNodeName
667 << " to be searched among " << (*aListOfDataFlows).size() << " Graphs" ) ;
670 for ( index = 0 ; index < (int ) (*aListOfDataFlows).size() ; index++ ) {
671 MESSAGE( "LoadDataFlows Graph" << index << " " << (*aListOfDataFlows)[index].Info.theName.c_str() ) ;
672 if ( !strcmp( aCoupledNodeName , (*aListOfDataFlows)[index].Info.theName.c_str() ) ) {
675 // At first create the editor and a StreamGraph
676 GraphEditor::DataFlow * aMacroGraphDataFlowEditor ;
677 CreateEditor( _Orb , instanceName() , aCoupledNodeName , SUPERV::DataStreamGraph ,
678 dbgfile , &aMacroGraphDataFlowEditor ) ;
680 if ( _DebugFileName ) {
681 delete [] _DebugFileName ;
683 _DebugFileName = new char[ strlen( dbgfile.c_str() )+1 ] ;
684 strcpy( _DebugFileName , dbgfile.c_str() ) ;
686 MESSAGE( "RECURSIVE IMPORT OF GRAPHS OF MACRONODES :" << aCoupledNodeName ) ;
687 if ( CORBA::is_nil( LoadDataFlows( aMacroGraphDataFlowEditor , aListOfDataFlows , index ) ) ) {
688 MESSAGE("Graph_Impl::LoadDataFlows failed" ) ;
689 return SUPERV::Graph::_duplicate( iobject ) ;
692 // That graph is not a StreamGraph :
693 else if ( !aMacroGraphDataFlowEditor->Graph()->HasDataStream() ) {
694 Graph_Impl * myMacroGraph ;
695 // The Graph ObjRef for that graph was already created
696 myMacroGraph = (Graph_Impl * ) aMacroGraphDataFlowEditor->Graph()->ObjImpl() ;
698 GraphBase::Graph * aMacroGraph = myMacroGraph->DataFlowEditor()->Graph() ;
700 aMacroGraph->GraphMacroLevel( aGraph->GraphMacroLevel() + 1 ) ;
701 aMacroGraph->CoupledNode( aMacroNode ) ;
702 aMacroGraph->MacroObject( SUPERV::Graph::_duplicate( macroiobject ) ) ;
704 // Set the GraphMacroNode ObjRef in the MacroNode
705 aMacroNode->GraphMacroLevel( aGraph->GraphMacroLevel() + 1 ) ;
706 aMacroNode->CoupledNode( aMacroGraph ) ;
707 aMacroNode->MacroObject( SUPERV::Graph::_narrow( aMacroGraphDataFlowEditor->Graph()->ObjRef() ) ) ;
708 MESSAGE( "LoadDataFlows aMacroGraph " << aMacroGraph << " " << aMacroGraph->Name()
709 << " coupled to " << aMacroGraph->CoupledNode() << " "
710 << aMacroGraph->CoupledNode()->Name() << " Editor " << aMacroGraph->GraphEditor() ) ;
711 MESSAGE( "LoadDataFlows aMacroNode " << aMacroNode << " " << aMacroNode->Name()
712 << " coupled to " << aMacroNode->CoupledNode() << " "
713 << aMacroNode->CoupledNode()->Name() << " Editor " << aMacroNode->GraphEditor() ) ;
714 MESSAGE( "LoadDataFlows current Graph " << aGraph << " " << aGraph->Name()
715 << " coupled to " << aGraph->CoupledNode()
716 << " Editor " << aGraph->GraphEditor() << " " << aGraph->Name() ) ;
722 return SUPERV::Graph::_duplicate( SUPERV::Graph::_nil() ) ;
727 else if ( (*aListOfDataFlows).size() == 1 ) {
728 StreamGraph_Impl * myStreamGraph ;
729 // We create a Graph ObjRef for that graph
730 myStreamGraph = new StreamGraph_Impl( _Orb , _Poa, _ContId,
731 instanceName() , interfaceName() ,
732 aDataFlowEditor , NULL ) ;
733 PortableServer::ObjectId * id = myStreamGraph->getId() ;
734 CORBA::Object_var obj = _poa->id_to_reference(*id) ;
735 SUPERV::StreamGraph_var Streamiobject = SUPERV::StreamGraph::_nil() ;
736 Streamiobject = SUPERV::StreamGraph::_narrow( obj ) ;
737 myStreamGraph->SetObjRef( SUPERV::StreamGraph::_duplicate( Streamiobject ) ) ;
738 myStreamGraph->SetObjImpl( (CNode_Impl * ) myStreamGraph ) ;
739 // iobject = SUPERV::Graph::_narrow( obj ) ;
740 iobject = SUPERV::Graph::_narrow( Streamiobject ) ;
743 MESSAGE( "Graph_Impl::LoadDataFlows StreamGraph with MacroNodes not yet implemented" ) ;
746 endService( "Graph_Impl::EditorLoadDataFlows" );
747 return SUPERV::Graph::_duplicate( iobject ) ;
750 SUPERV::Graph_var Graph_Impl::LoadDataFlows( GraphExecutor::DataFlow * aDataFlowExecutor ,
751 GraphBase::ListOfSGraphs * aListOfDataFlows ,
753 beginService( "Graph_Impl::ExecutorLoadDataFlows" ) ;
754 MESSAGE("Graph_Impl::LoadDataFlows(Executor) index " << index << " " << (*aListOfDataFlows)[index].Info.theName.c_str() << " aDataFlowExecutor " << aDataFlowExecutor ) ;
756 // That method is recursive :
757 // At first we load the supergraph with index = 0 :
758 // (After we load the graph corresponding to each MacroNode :)
759 if ( !aDataFlowExecutor->LoadDataFlow( &(*aListOfDataFlows)[ index ] ) ) {
760 MESSAGE("Graph_Impl::LoadDataFlows(Executor) failed, could not LoadDataFlow(supergraph)" ) ;
761 return SUPERV::Graph::_duplicate( SUPERV::Graph::_nil() ) ;
764 // That graph is not a StreamGraph :
766 aDataFlowExecutor->Graph()->Kind( SUPERV::DataFlowGraph ) ;
767 GraphEditor::DataFlow * aDataFlowEditor ;
768 aDataFlowEditor = DataFlowEditor() ;
769 GraphBase::Graph * anEditorGraph = aDataFlowEditor->Graph() ;
770 GraphBase::Graph * anExecutorGraph = aDataFlowExecutor->Graph() ;
771 if ( aDataFlowEditor->Executor() ) {
772 delete aDataFlowEditor->Executor() ;
773 aDataFlowEditor->Executor( NULL ) ;
774 aDataFlowEditor->Editing() ;
776 aDataFlowEditor->Executor( aDataFlowExecutor ) ;
777 anExecutorGraph->GraphEditor( aDataFlowEditor ) ;
779 if ( !aDataFlowExecutor->Graph()->HasDataStream() ) {
780 // For the supergraph or each graph of MacroNodes we search MacroNodes recursively :
782 for ( i = 0 ; i < anExecutorGraph->GraphNodesSize() ; i++ ) {
783 if ( anExecutorGraph->GraphNodes( i )->IsMacroNode() ) {
784 GraphBase::GOTONode * aMacroNode = (GraphBase::GOTONode * ) anExecutorGraph->GraphNodes( i ) ;
785 aMacroNode->GraphEditor( aDataFlowEditor ) ;
787 // get the macro node's editor object
788 char * aMacroGraphName = aMacroNode->CoupledNodeName() ;
789 GraphBase::Graph* aMacroGraph = (GraphBase::Graph*)((GraphBase::GOTONode *)anEditorGraph->GetGraphNode( aMacroNode->Name() ))->CoupledNode() ;
790 GraphEditor::DataFlow* aMacroGraphEditor = aMacroGraph->GraphEditor();
792 MESSAGE( "LoadDataFlows(Executor) MacroNode " << aMacroNode->Name() << " Coupled to " << aMacroGraphName
793 << " to be searched among " << (*aListOfDataFlows).size() << " Graphs" << endl ) ;
796 for ( index = 0 ; index < (int ) (*aListOfDataFlows).size() && !found; index++ ) {
797 if ( !strcmp( aMacroGraphName , (*aListOfDataFlows)[index].Info.theName.c_str() ) )
801 MESSAGE("Graph_Impl::LoadDataFlows(Executor) failed, Macro node's coupled graph \"" << aMacroGraphName << "\" was not found" ) ;
802 return SUPERV::Graph::_duplicate( SUPERV::Graph::_nil() ) ;
804 index--; // it was incremented in "for ..." before last check ( !found ).
806 // At first create the editor and a StreamGraph
808 GraphExecutor::DataFlow * aMacroGraphExecutor ;
809 CreateExecutor( _Orb , instanceName() , aMacroGraphName , SUPERV::DataStreamGraph ,
810 dbgfile , &aMacroGraphExecutor );
812 // set GraphMacroLevel for Executor's graph
813 GraphBase::Graph* aMacroGraphExe = aMacroGraphExecutor->Graph();
814 aMacroGraphExe->GraphMacroLevel( anExecutorGraph->GraphMacroLevel() + 1 );
816 // load data flows in MacroGraph's executor
817 Graph_Impl* aMacroGraphImpl = (Graph_Impl*) aMacroGraphEditor->Graph()->ObjImpl();
818 MESSAGE( "RECURSIVE IMPORT OF GRAPHS OF MACRONODES : " << aMacroGraphName ) ;
819 if ( CORBA::is_nil( aMacroGraphImpl->LoadDataFlows( aMacroGraphExecutor, aListOfDataFlows , index ) ) ) {
820 MESSAGE("Graph_Impl::LoadDataFlows(Executor) failed, could not LoadDataFlow( MacroNodeGraph \"" <<aMacroGraphName << "\" )" ) ;
821 return SUPERV::Graph::_duplicate( SUPERV::Graph::_nil() ) ;
824 // set coupled pair MacroNode <--> MacroGraph
825 aMacroGraphExe->CoupledNode( aMacroNode ) ;
826 aMacroNode->CoupledNode( aMacroGraphExe ) ;
828 //JR 04.05.2005 Debug : InPorts values of MacroNodes are like for other nodes
829 // InPorts values of MacroGraphs of MacroNodes are done in the Executor
830 // It was probably to try to debug anything but it was a wrong debug and I do not know what bug
831 // ===> folowing code is commented
833 // initialize MacroNode's InPorts with corresponding "external" values
835 for ( q = 0 ; q < aMacroNode->GetNodeInPortsSize() ; q++ ) {
836 const GraphBase::InPort * anInPort = aMacroNode->GetNodeInPort( q ) ;
837 if ( anInPort->IsDataConnected() ) {
838 const char* aMacroGraphInPortName = aMacroGraph->GetNodeInPort( q )->PortName();
839 //JR 30.03.2005 if ( !aMacroGraphExecutor->InputOfAny( aMacroGraphInPortName, *anInPort->GetOutPort()->Value(),false ) ) {
840 if ( !aMacroGraphExecutor->InputOfAny( aMacroGraphInPortName, anInPort->GetOutPort()->Value(),false ) ) {
841 return SUPERV::Graph::_duplicate( SUPERV::Graph::_nil() ) ;
844 MESSAGE( "LoadDataFlows(Executor) " << aMacroGraph->Name() << "->InputOfAny( "
845 << aMacroGraphInPortName << " , Value )" ) ;
848 } // end of init MacroNode's InPorts
850 aMacroGraphImpl->Run() ;
853 } // end of for( get nodes of the graph...)
855 } // end of setting initial graph's structure..
857 endService( "Graph_Impl::ExecutorLoadDataFlows" );
859 PortableServer::ObjectId * id = getId();
860 CORBA::Object_var obj = _poa->id_to_reference( *id );
861 SUPERV::Graph_var iobject = SUPERV::Graph::_narrow( obj ) ;
862 return SUPERV::Graph::_duplicate( iobject ) ;
865 SUPERV::Graph_ptr Graph_Impl::MNode( const char * aXmlFileName ) {
866 beginService( "Graph_Impl::MNode" );
867 SUPERV::Graph_var iobject = SUPERV::Graph::_nil() ;
868 MESSAGE( "Graph_Impl::MNode( " << aXmlFileName << " )" ) ;
870 GraphBase::ListOfSGraphs aListOfDataFlows ;
872 // At first create the editor and a StreamGraph with the xml file
873 GraphEditor::DataFlow * aDataFlowEditor ;
874 CreateEditor( _Orb , instanceName() , aXmlFileName , SUPERV::DataStreamGraph ,
875 dbgfile , &aDataFlowEditor ) ;
877 if ( _DebugFileName ) {
878 delete [] _DebugFileName ;
880 _DebugFileName = new char[ strlen( dbgfile.c_str() )+1 ] ;
881 strcpy( _DebugFileName , dbgfile.c_str() ) ;
883 int lenname = strlen( aXmlFileName ) ;
884 bool loaded = false ;
885 // Import of the xml file
886 if ( lenname > 4 && !strcmp( &aXmlFileName[ lenname - 4 ] , ".xml" ) ) {
887 loaded = aDataFlowEditor->LoadXml( aXmlFileName , aListOfDataFlows ) ;
889 iobject = MNode( aDataFlowEditor , &aListOfDataFlows ) ;
896 // WARNING : THIS IS COMPLICATED :
897 // I should have to remove duplicated code ...
898 SUPERV::Graph_ptr Graph_Impl::MNode( GraphEditor::DataFlow * aMacroGraphDataFlowEditor ,
899 GraphBase::ListOfSGraphs * aListOfDataFlows ) {
900 beginService( "Graph_Impl::MNode" ) ;
901 SUPERV::Graph_var iobject = SUPERV::Graph::_nil() ;
902 SUPERV::Graph_var macroiobject = SUPERV::Graph::_nil() ;
905 MESSAGE( "Graph_Impl::MNode DataFlowEditor->LoadDataFlow" ) ;
906 // if ( !aMacroGraphDataFlowEditor->LoadDataFlow( &aListOfDataFlows[ 0 ] ) ) {
907 iobject = LoadDataFlows( aMacroGraphDataFlowEditor , aListOfDataFlows , 0 ) ;
908 if ( CORBA::is_nil( iobject ) ) {
909 MESSAGE("Graph_Impl::MNode LoadDataFlow failed" ) ;
913 // That graph is not a StreamGraph :
914 else if ( !aMacroGraphDataFlowEditor->Graph()->HasDataStream() ) {
915 aMacroGraphDataFlowEditor->Graph()->Kind( SUPERV::DataFlowGraph ) ;
916 aMacroGraphDataFlowEditor->Graph()->GraphEditor( aMacroGraphDataFlowEditor ) ;
918 Graph_Impl * myMacroGraph = (Graph_Impl * ) aMacroGraphDataFlowEditor->Graph()->ObjImpl() ;
919 // Creation of a GraphMacroNode in the current editor
920 string aMacroNodeName = string( "Macro_" ) + string( myMacroGraph->Name() ) ;
921 Graph_Impl * myMacroNode ;
922 myMacroNode = new Graph_Impl( _Orb , _Poa, _ContId,
923 instanceName() , interfaceName() ,
924 aMacroNodeName.c_str() , SUPERV::MacroNode ) ;
925 PortableServer::ObjectId * id = myMacroNode->getId() ;
926 CORBA::Object_var obj = _poa->id_to_reference(*id);
927 macroiobject = SUPERV::Graph::_narrow( obj ) ;
928 myMacroNode->DataFlowEditor( DataFlowEditor() ) ;
930 // Creation of the MacroNode itself in the current Graph
931 GraphBase::ListOfFuncName aFuncName ;
932 aFuncName.resize( 1 ) ;
934 SUPERV::ListOfStrings aListOfStrings ;
935 aListOfStrings.length( 1 ) ;
936 aListOfStrings[0] = "" ;
937 GraphBase::ListOfPythonFunctions aPythonFunction ;
938 aPythonFunction.resize( 1 ) ;
939 aPythonFunction[0] = &aListOfStrings ;
940 SALOME_ModuleCatalog::Service * aMacroNodeService = myMacroGraph->Service() ;
941 GraphEditor::InNode * aDataFlowNode = DataFlowEditor()->AddNode( *aMacroNodeService , "" , "" ,
942 aMacroNodeName.c_str() , SUPERV::MacroNode ,
943 aFuncName , aPythonFunction ) ;
944 aDataFlowNode->SetPythonFunction( "" , aListOfStrings ) ;
945 myMacroNode->DataFlowNode( aDataFlowNode ) ;
946 aDataFlowNode->ComputingNode()->SetService( *aMacroNodeService ) ;
947 aDataFlowNode->SetObjRef( SUPERV::CNode::_duplicate( SUPERV::CNode::_narrow( obj ) ) ) ;
948 aDataFlowNode->SetObjImpl( this ) ;
950 GraphBase::Graph * aGraph = myMacroGraph->DataFlowEditor()->Graph() ;
951 GraphBase::Graph * aGraphOfMacroGraph = myMacroNode->DataFlowEditor()->Graph() ;
952 GraphBase::Graph * aMacroGraph = myMacroNode->DataFlowNode()->GraphMacroNode() ;
953 aMacroGraph->Kind( SUPERV::MacroNode ) ;
954 aMacroGraph->GraphEditor( DataFlowEditor() ) ;
955 // Creation of the Ports of the MacroNode from the ports of the GraphMacroNode
956 aMacroGraph->SetMacroPorts( aGraph ) ;
957 // Valid ==> creation of Service and the ports of the current Graph
958 DataFlowEditor()->IsValid() ;
959 // Set the Input Datas from the GraphMacroNode to the current Graph
960 aMacroGraph->SetMacroDatas( aGraph , aGraphOfMacroGraph ) ;
961 aMacroGraphDataFlowEditor->UnValid() ;
962 // Set the MacroNode ObjRef in the GraphMacroNode
963 aGraph->CoupledNode( aMacroGraph ) ;
964 aGraph->MacroObject( SUPERV::Graph::_duplicate( macroiobject ) ) ;
965 // Set the GraphMacroNode ObjRef in the MacroNode
966 aDataFlowNode->GraphMacroNode()->GraphMacroLevel( aGraphOfMacroGraph->GraphMacroLevel() + 1 ) ;
967 aMacroGraph->CoupledNode( aGraph ) ;
968 // aGraphOfMacroGraph->CoupledNode( aGraph ) ;
969 aMacroGraph->MacroObject( SUPERV::Graph::_duplicate( iobject ) ) ;
970 // aGraphOfMacroGraph->MacroObject( SUPERV::Graph::_duplicate( iobject ) ) ;
971 // aDataFlowNode->CoupledNode( aGraph ) ;
972 // aDataFlowNode->ComputingNode()->MacroObject( SUPERV::Graph::_duplicate( iobject ) ) ;
973 // Set the MacroLevel of that graph
974 aGraph->GraphMacroLevel( aGraphOfMacroGraph->GraphMacroLevel() + 1 ) ;
975 aMacroGraph->Coordinates( 0 , 0 ) ;
976 MESSAGE( "DataFlowNode Graph " << this << " DataFlowEditor " << DataFlowEditor() << " aDataFlowNode "
977 << aDataFlowNode << " " << aDataFlowNode->Name() << " created" ) ;
978 MESSAGE( "MNode aGraph " << aGraph << " " << aGraph->Name()
979 << " coupled to " << aGraph->CoupledNode() << " "
980 << aGraph->CoupledNode()->Name() ) ;
981 MESSAGE( "MNode aMacroGraph " << aMacroGraph << " " << aMacroGraph->Name()
982 << " coupled to " << aMacroGraph->CoupledNode() << " "
983 << aMacroGraph->CoupledNode()->Name() ) ;
984 MESSAGE( "MNode aMacroGraph " << myMacroNode->DataFlowEditor()->Graph() << " "
985 << myMacroNode->DataFlowEditor()->Graph()->Name()
986 << " coupled to " << myMacroNode->DataFlowEditor()->Graph()->CoupledNode() ) ;
989 delete aMacroGraphDataFlowEditor ;
992 endService( "Graph_Impl::MNode" );
993 return SUPERV::Graph::_duplicate( macroiobject ) ;
996 // For python supergraph
997 SUPERV::Graph_ptr Graph_Impl::GraphMNode( SUPERV::Graph_ptr myMacroGraph ) {
998 SUPERV::Graph_var iobject = myMacroGraph ;
999 beginService( "Graph_Impl::GraphMNode" ) ;
1001 // GraphBase::Graph * myMacroGraph = aGraph;
1002 SUPERV::Graph_var macroiobject = SUPERV::StreamGraph::_nil() ;
1003 // Creation of a GraphMacroNode in the current editor
1005 string aMacroNodeName = string( "Macro_" ) + string( myMacroGraph->Name() ) ;
1006 //string aMacroNodeName = string( myMacroGraph->CoupledName() ) ;
1007 MESSAGE( "GraphMNode( " << myMacroGraph->Name() << " )" ) ;
1008 Graph_Impl * myMacroNode ;
1009 myMacroNode = new Graph_Impl( _Orb , _Poa, _ContId,
1010 instanceName() , interfaceName() ,
1011 aMacroNodeName.c_str() , SUPERV::MacroNode ) ;
1012 PortableServer::ObjectId * id = myMacroNode->getId() ;
1013 CORBA::Object_var obj = _poa->id_to_reference(*id);
1014 macroiobject = SUPERV::Graph::_narrow( obj ) ;
1015 myMacroNode->DataFlowEditor( DataFlowEditor() ) ;
1017 // Creation of the MacroNode itself in the current Graph
1018 GraphBase::ListOfFuncName aFuncName ;
1019 aFuncName.resize( 1 ) ;
1021 SUPERV::ListOfStrings aListOfStrings ;
1022 aListOfStrings.length( 1 ) ;
1023 aListOfStrings[0] = "" ;
1024 GraphBase::ListOfPythonFunctions aPythonFunction ;
1025 aPythonFunction.resize( 1 ) ;
1026 aPythonFunction[0] = &aListOfStrings ;
1027 SALOME_ModuleCatalog::Service * aMacroNodeService = myMacroGraph->Service() ;
1028 GraphEditor::InNode * aDataFlowNode ;
1029 aDataFlowNode = DataFlowEditor()->AddNode( *aMacroNodeService , "" , "" ,
1030 aMacroNodeName.c_str() , SUPERV::MacroNode ,
1031 aFuncName , aPythonFunction ) ;
1032 aDataFlowNode->SetPythonFunction( "" , aListOfStrings ) ;
1033 myMacroNode->DataFlowNode( aDataFlowNode ) ;
1034 aDataFlowNode->ComputingNode()->SetService( *aMacroNodeService ) ;
1035 aDataFlowNode->SetObjRef( SUPERV::CNode::_duplicate( SUPERV::CNode::_narrow( obj ) ) ) ;
1036 aDataFlowNode->SetObjImpl( this ) ;
1038 // GraphBase::Graph * aGraph = DataFlowEditor()->Automaton()->MapGraph( myMacroGraph->Name() ) ;
1039 GraphBase::Graph * aGraph ;
1040 //DataFlowEditor()->Automaton()->GraphBase( &aGraph ) ;
1041 myMacroGraph->Coupled() ;
1042 GraphBase::Graph * aGraphOfMacroGraph = myMacroNode->DataFlowEditor()->Graph() ;
1043 GraphBase::Graph * aMacroGraph = myMacroNode->DataFlowNode()->GraphMacroNode() ;
1044 aMacroGraph->Kind( SUPERV::MacroNode ) ;
1045 aMacroGraph->GraphEditor( DataFlowEditor() ) ;
1046 // Creation of the Ports of the MacroNode from the ports of the GraphMacroNode
1047 aMacroGraph->SetMacroPorts( aGraph ) ;
1048 // Valid ==> creation of Service and the ports of the current Graph
1049 DataFlowEditor()->IsValid() ;
1050 // Set the Input Datas from the GraphMacroNode to the current Graph
1051 aMacroGraph->SetMacroDatas( aGraph , aGraphOfMacroGraph ) ;
1052 // aMacroGraphDataFlowEditor->UnValid() ;
1053 aGraph->GraphEditor()->UnValid() ;
1054 // Set the MacroNode ObjRef in the GraphMacroNode
1055 aGraph->CoupledNode( aMacroGraph ) ;
1056 aGraph->MacroObject( SUPERV::Graph::_duplicate( macroiobject ) ) ;
1057 // Set the GraphMacroNode ObjRef in the MacroNode
1058 aDataFlowNode->GraphMacroNode()->GraphMacroLevel( aGraphOfMacroGraph->GraphMacroLevel() + 1 ) ;
1059 aMacroGraph->CoupledNode( aGraph ) ;
1060 aMacroGraph->MacroObject( SUPERV::Graph::_duplicate( iobject ) ) ;
1061 // aDataFlowNode->CoupledNode( aGraph ) ;
1062 // aDataFlowNode->ComputingNode()->MacroObject( SUPERV::Graph::_duplicate( iobject ) ) ;
1063 // Set the MacroLevel of that graph
1064 aGraph->GraphMacroLevel( aGraphOfMacroGraph->GraphMacroLevel() + 1 ) ;
1065 aMacroGraph->Coordinates( 0 , 0 ) ;
1066 MESSAGE( aGraph->Name() << "->CoupledNode()->GraphEditor() : " << aGraph->CoupledNode()->GraphEditor() ) ;
1067 MESSAGE( aMacroGraph->Name() << "->CoupledNode()->GraphEditor() : "
1068 << aMacroGraph->CoupledNode()->GraphEditor() ) ;
1069 MESSAGE( "DataFlowNode Graph " << this << " DataFlowEditor " << DataFlowEditor() << " aDataFlowNode "
1070 << aDataFlowNode << " " << aDataFlowNode->Name() << " created" ) ;
1072 endService( "Graph_Impl::GraphMNode" ) ;
1073 return SUPERV::Graph::_duplicate( macroiobject ) ;
1076 SUPERV::Graph_ptr Graph_Impl::FlowObjRef() {
1077 beginService( "Graph_Impl::FlowObjRef" );
1078 SUPERV::Graph_var iobject = SUPERV::Graph::_nil() ;
1080 iobject = SUPERV::Graph::_narrow( DataFlowNode()->GraphMacroNode()->MacroObject() ) ;
1082 else if ( IsGraph() ) {
1083 iobject = SUPERV::Graph::_narrow( DataFlowEditor()->Graph()->MacroObject() ) ;
1085 if ( CORBA::is_nil( iobject ) ) {
1086 MESSAGE( "Graph_Impl::FlowObjRef() returns a NIL Object" ) ;
1088 endService( "Graph_Impl::FlowObjRef" );
1089 return SUPERV::Graph::_duplicate( iobject ) ;
1092 SUPERV::StreamGraph_ptr Graph_Impl::StreamObjRef() {
1093 beginService( "Graph_Impl::StreamObjRef" );
1094 SUPERV::StreamGraph_var iobject = SUPERV::StreamGraph::_nil() ;
1096 iobject = SUPERV::StreamGraph::_narrow( DataFlowNode()->GraphMacroNode()->MacroObject() ) ;
1098 else if ( IsGraph() || IsStreamGraph() ) {
1099 iobject = SUPERV::StreamGraph::_narrow( DataFlowEditor()->Graph()->MacroObject() ) ;
1101 if ( CORBA::is_nil( iobject ) ) {
1102 MESSAGE( "Graph_Impl::StreamObjRef() returns a NIL Object" ) ;
1104 endService( "Graph_Impl::StreamObjRef" );
1105 return SUPERV::StreamGraph::_duplicate( iobject ) ;
1108 SUPERV::CNode_ptr Graph_Impl::Node(char const * aNodeName ) {
1109 // beginService( "Graph_Impl::Node" );
1110 SUPERV::CNode_var iobject = SUPERV::CNode::_nil() ;
1112 if ( CORBA::is_nil( DataFlowEditor()->GetNode( aNodeName )->ObjRef() ) ) {
1113 CNode_Impl * myNode = new CNode_Impl( _Orb , _Poa , _ContId ,
1114 instanceName() , interfaceName() ,
1116 DataFlowEditor()->GetNode( aNodeName ) ) ;
1117 PortableServer::ObjectId * id = myNode->getId() ;
1118 CORBA::Object_var obj = _poa->id_to_reference(*id);
1119 iobject = SUPERV::CNode::_narrow(obj) ;
1120 myNode->SetObjRef( SUPERV::CNode::_duplicate( iobject ) ) ;
1123 iobject = DataFlowEditor()->GetNode( aNodeName )->ObjRef() ;
1126 GraphEditor::InNode * anInNode = DataFlowEditor()->GetNode( aNodeName ) ;
1128 if ( CORBA::is_nil( anInNode->ObjRef() ) ) {
1129 SetNodeObjRef( anInNode ) ;
1131 iobject = anInNode->ObjRef() ;
1134 // endService( "Graph_Impl::Node" );
1135 return SUPERV::CNode::_duplicate( iobject ) ;
1138 SUPERV::Link_ptr Graph_Impl::Link( SUPERV::Port_ptr OutPort ,
1139 SUPERV::Port_ptr InPort ) {
1140 // beginService( "Graph_Impl::Link" );
1141 SUPERV::Link_var iobject = SUPERV::Link::_nil() ;
1142 if ( DataFlowEditor()->IsEditing() && !DataFlowEditor()->IsReadOnly() &&
1143 !OutPort->IsDataStream() && !InPort->IsDataStream() && !IsMacro() ) {
1144 MESSAGE( "Graph_Impl::Link( " << OutPort->Node()->Name() << "( " << OutPort->Name() << " ) --> "
1145 << InPort->Node()->Name() << "( " << InPort->Name() << " )" ) ;
1146 GraphEditor::InNode * anInNode = DataFlowEditor()->GetNode( InPort->Node()->Name() ) ;
1147 GraphEditor::InNode * anOutNode = DataFlowEditor()->GetNode( OutPort->Node()->Name() ) ;
1148 if ( anInNode == NULL || anOutNode== NULL ) {
1149 MESSAGE( "Graph_Impl::Link( " << OutPort->Node()->Name() << " " << anOutNode << " , "
1150 << InPort->Node()->Name() << " " << anInNode << " ) Node(s) not found in " << Name() ) ;
1153 GraphBase::InPort * anInPort = anInNode->ComputingNode()->GetChangeInPort( InPort->Name() ) ;
1154 GraphBase::OutPort * anOutPort = anOutNode->ComputingNode()->GetChangeOutPort( OutPort->Name() ) ;
1155 if ( anInPort == NULL || anOutPort== NULL ) {
1156 MESSAGE( "Graph_Impl::Link( " << OutPort->Name() << " " << anOutPort << " , "
1157 << InPort->Name() << " " << anInPort << " ) Port(s) not found" ) ;
1159 else if ( CORBA::is_nil( anOutPort->InPortObjRef( anInPort ) ) ) {
1160 const char * DataFlowOutNodeName = OutPort->Node()->Name() ;
1161 GraphEditor::InNode * DataFlowOutNode = DataFlowEditor()->GetNode( DataFlowOutNodeName ) ;
1162 const char * DataFlowInNodeName = InPort->Node()->Name() ;
1163 GraphEditor::InNode * DataFlowInNode = DataFlowEditor()->GetNode( DataFlowInNodeName ) ;
1164 if ( DataFlowOutNode && DataFlowInNode ) {
1166 Link_Impl * myLink = new Link_Impl( _Orb , _Poa , _ContId ,
1167 instanceName() , interfaceName() ,
1173 true , false , Success ) ;
1175 PortableServer::ObjectId * id = myLink->getId() ;
1176 CORBA::Object_var obj = _poa->id_to_reference(*id);
1177 iobject = SUPERV::Link::_narrow(obj) ;
1178 anOutPort->AddInPortObjRef( anInPort , SUPERV::Link::_duplicate( iobject ) ) ;
1183 MESSAGE( "Graph_Impl::Link( " << OutPort->Name() << " " << anOutPort << " , "
1184 << InPort->Name() << " " << anInPort << " ) ObjRef already exists" ) ;
1185 iobject = anOutPort->InPortObjRef( anInPort ) ;
1189 DataFlowEditor()->UnValid() ;
1190 // endService( "Graph_Impl::Link" );
1191 return SUPERV::Link::_duplicate( iobject ) ;
1194 // Only to see MacroNodes with actual GUI ... :
1195 #define GOTOMacroNode 0
1197 void Graph_Impl::SetNodeObjRef( GraphEditor::InNode * anInNode ) {
1198 MESSAGE("Graph_Impl::SetNodeObjRef " << anInNode->Name() << " " << anInNode->Kind() ) ;
1199 CORBA::Object_var obj ;
1200 if ( anInNode->IsComputingNode() ) {
1201 CNode_Impl * myNode = new CNode_Impl( _Orb , _Poa , _ContId ,
1202 instanceName() , interfaceName() ,
1205 PortableServer::ObjectId * id = myNode->getId() ;
1206 obj = _poa->id_to_reference(*id);
1207 SUPERV::CNode_var iobject = SUPERV::CNode::_narrow(obj) ;
1208 myNode->SetObjRef( SUPERV::CNode::_duplicate( iobject ) ) ;
1210 else if ( anInNode->IsFactoryNode() ) {
1211 FNode_Impl * myNode = new FNode_Impl( _Orb , _Poa , _ContId ,
1212 instanceName() , interfaceName() ,
1215 PortableServer::ObjectId * id = myNode->getId() ;
1216 obj = _poa->id_to_reference(*id);
1217 SUPERV::FNode_var iobject = SUPERV::FNode::_narrow(obj) ;
1218 myNode->SetObjRef( SUPERV::FNode::_duplicate( iobject ) ) ;
1220 else if ( anInNode->IsInLineNode() ) {
1221 INode_Impl * myNode = new INode_Impl( _Orb , _Poa , _ContId ,
1222 instanceName() , interfaceName() ,
1225 PortableServer::ObjectId * id = myNode->getId() ;
1226 obj = _poa->id_to_reference(*id);
1227 SUPERV::INode_var iobject = SUPERV::INode::_narrow(obj) ;
1228 myNode->SetObjRef( SUPERV::INode::_duplicate( iobject ) ) ;
1231 else if ( anInNode->IsGOTONode() || anInNode->IsMacroNode() ) {
1232 if ( anInNode->IsMacroNode() ) {
1233 anInNode->ComputingNode()->Kind( SUPERV::GOTONode ) ;
1236 else if ( anInNode->IsGOTONode() ) {
1238 GNode_Impl * myNode = new GNode_Impl( _Orb , _Poa , _ContId ,
1239 instanceName() , interfaceName() ,
1242 PortableServer::ObjectId * id = myNode->getId() ;
1243 obj = _poa->id_to_reference(*id);
1244 SUPERV::GNode_var iobject = SUPERV::GNode::_narrow(obj) ;
1245 myNode->SetObjRef( SUPERV::GNode::_duplicate( iobject ) ) ;
1247 else if ( anInNode->IsMacroNode() ) {
1248 Graph_Impl * myNode = new Graph_Impl( _Orb , _Poa , _ContId ,
1249 instanceName() , interfaceName() ,
1252 PortableServer::ObjectId * id = myNode->getId() ;
1253 obj = _poa->id_to_reference(*id);
1254 SUPERV::Graph_var iobject = SUPERV::Graph::_narrow(obj) ;
1255 myNode->SetObjRef( SUPERV::Graph::_duplicate( iobject ) ) ;
1257 else if ( anInNode->IsLoopNode() ) {
1258 LNode_Impl * myNode = new LNode_Impl( _Orb , _Poa , _ContId ,
1259 instanceName() , interfaceName() ,
1262 PortableServer::ObjectId * id = myNode->getId() ;
1263 obj = _poa->id_to_reference(*id);
1264 SUPERV::LNode_var iobject = SUPERV::LNode::_narrow(obj) ;
1265 myNode->SetObjRef( SUPERV::LNode::_duplicate( iobject ) ) ;
1267 else if ( anInNode->IsEndLoopNode() ) {
1268 ELNode_Impl * myNode = new ELNode_Impl( _Orb , _Poa , _ContId ,
1269 instanceName() , interfaceName() ,
1272 PortableServer::ObjectId * id = myNode->getId() ;
1273 obj = _poa->id_to_reference(*id);
1274 SUPERV::ELNode_var iobject = SUPERV::ELNode::_narrow(obj) ;
1275 myNode->SetObjRef( SUPERV::ELNode::_duplicate( iobject ) ) ;
1277 else if ( anInNode->IsSwitchNode() ) {
1278 SNode_Impl * myNode = new SNode_Impl( _Orb , _Poa , _ContId ,
1279 instanceName() , interfaceName() ,
1282 PortableServer::ObjectId * id = myNode->getId() ;
1283 obj = _poa->id_to_reference(*id);
1284 SUPERV::SNode_var iobject = SUPERV::SNode::_narrow(obj) ;
1285 myNode->SetObjRef( SUPERV::SNode::_duplicate( iobject ) ) ;
1287 else if ( anInNode->IsEndSwitchNode() ) {
1288 ESNode_Impl * myNode = new ESNode_Impl( _Orb , _Poa , _ContId ,
1289 instanceName() , interfaceName() ,
1292 PortableServer::ObjectId * id = myNode->getId() ;
1293 obj = _poa->id_to_reference(*id);
1294 SUPERV::ESNode_var iobject = SUPERV::ESNode::_narrow(obj) ;
1295 myNode->SetObjRef( SUPERV::ESNode::_duplicate( iobject ) ) ;
1299 SUPERV::ListOfNodes_var Graph_Impl::SetNode( SUPERV::ListOfNodes_var RetVal ,
1300 GraphBase::ComputingNode * aNode ) {
1302 // if ( _DataFlowExecutor ) {
1303 if ( DataFlowExecutor() ) {
1304 MESSAGE("Graph_Impl::SetNode " << aNode->Name() << " " << aNode->Kind() << " "
1305 << DataFlowExecutor()->StateName( DataFlowExecutor()->AutomatonState( aNode->Name() ) ) ) ;
1308 MESSAGE("Graph_Impl::SetNode " << aNode->Name() << " " << aNode->Kind() ) ;
1310 if ( aNode->IsComputingNode() ) {
1311 index = RetVal->CNodes.length() ;
1312 RetVal->CNodes.length( index+1 );
1314 else if ( aNode->IsFactoryNode() ) {
1315 index = RetVal->FNodes.length() ;
1316 RetVal->FNodes.length( index+1 );
1318 else if ( aNode->IsInLineNode() ) {
1319 index = RetVal->INodes.length() ;
1320 RetVal->INodes.length( index+1 );
1323 else if ( aNode->IsGOTONode() || aNode->IsMacroNode() ) {
1325 else if ( aNode->IsGOTONode() ) {
1327 index = RetVal->GNodes.length() ;
1328 RetVal->GNodes.length( index+1 );
1330 else if ( aNode->IsMacroNode() ) {
1331 index = RetVal->Graphs.length() ;
1332 RetVal->Graphs.length( index+1 );
1334 else if ( aNode->IsLoopNode() ) {
1335 index = RetVal->LNodes.length() ;
1336 RetVal->LNodes.length( index+1 );
1338 else if ( aNode->IsEndLoopNode() ) {
1339 index = RetVal->ELNodes.length() ;
1340 RetVal->ELNodes.length( index+1 );
1342 else if ( aNode->IsSwitchNode() ) {
1343 index = RetVal->SNodes.length() ;
1344 RetVal->SNodes.length( index+1 );
1346 else if ( aNode->IsEndSwitchNode() ) {
1347 index = RetVal->ESNodes.length() ;
1348 RetVal->ESNodes.length( index+1 );
1350 if ( CORBA::is_nil( aNode->ObjRef() ) ) {
1351 SetNodeObjRef( (GraphEditor::InNode * ) aNode->GetInNode() ) ;
1353 SUPERV::CNode_var aNodeObjRef = aNode->ObjRef() ;
1354 if ( aNode->IsComputingNode() ) {
1355 RetVal->CNodes[index] = SUPERV::CNode::_duplicate( aNodeObjRef ) ;
1357 else if ( aNode->IsFactoryNode() ) {
1358 RetVal->FNodes[index] = SUPERV::FNode::_duplicate( SUPERV::FNode::_narrow( aNodeObjRef ) ) ;
1360 else if ( aNode->IsInLineNode() ) {
1361 RetVal->INodes[index] = SUPERV::INode::_duplicate( SUPERV::INode::_narrow( aNodeObjRef ) ) ;
1364 else if ( aNode->IsGOTONode() || aNode->IsMacroNode() ) {
1366 else if ( aNode->IsGOTONode() ) {
1368 RetVal->GNodes[index] = SUPERV::GNode::_duplicate( SUPERV::GNode::_narrow( aNodeObjRef ) ) ;
1370 else if ( aNode->IsMacroNode() ) {
1371 RetVal->Graphs[index] = SUPERV::Graph::_duplicate( SUPERV::Graph::_narrow( aNodeObjRef ) ) ;
1373 else if ( aNode->IsLoopNode() ) {
1374 RetVal->LNodes[index] = SUPERV::LNode::_duplicate( SUPERV::LNode::_narrow( aNodeObjRef ) ) ;
1376 else if ( aNode->IsEndLoopNode() ) {
1377 RetVal->ELNodes[index] = SUPERV::ELNode::_duplicate( SUPERV::ELNode::_narrow( aNodeObjRef ) ) ;
1379 else if ( aNode->IsSwitchNode() ) {
1380 RetVal->SNodes[index] = SUPERV::SNode::_duplicate( SUPERV::SNode::_narrow( aNodeObjRef ) ) ;
1382 else if ( aNode->IsEndSwitchNode() ) {
1383 RetVal->ESNodes[index] = SUPERV::ESNode::_duplicate( SUPERV::ESNode::_narrow( aNodeObjRef ) ) ;
1385 return ( RetVal._retn() ) ;
1388 SUPERV::ListOfNodes * Graph_Impl::Nodes() {
1389 SUPERV::ListOfNodes_var RetVal = new SUPERV::ListOfNodes;
1390 beginService( "Graph_Impl::Nodes" );
1391 RetVal->CNodes.length(0) ;
1392 RetVal->FNodes.length(0) ;
1393 RetVal->INodes.length(0) ;
1394 RetVal->LNodes.length(0) ;
1395 RetVal->SNodes.length(0) ;
1396 RetVal->GNodes.length(0) ;
1397 RetVal->Graphs.length(0) ;
1400 MESSAGE( DataFlowEditor()->Graph()->GetGraphNodeSize() << " Nodes in the Map and "
1401 << DataFlowEditor()->Graph()->GraphNodesSize() << " Nodes int the Vector" ) ;
1402 for ( i = 0 ; i < DataFlowEditor()->Graph()->GraphNodesSize() ; i++ ) {
1403 GraphBase::ComputingNode * aNode = DataFlowEditor()->Graph()->GraphNodes( i ) ;
1405 MESSAGE( i << ". Vector : " << aNode->Name() << " Map : "
1406 << DataFlowEditor()->Graph()->GetGraphNode( aNode->Name() )->Name() ) ;
1408 RetVal = SetNode( RetVal , aNode ) ;
1411 char * aStateG = "" ;
1412 if ( DataFlowExecutor() ) {
1413 aStateG = (char *) DataFlowExecutor()->StateName( DataFlowExecutor()->AutomatonState() ) ;
1415 MESSAGE("Graph_Impl::Nodes GraphState " << aStateG << " CNodes " << RetVal->CNodes.length() ) ;
1416 for ( i = 0 ; i < RetVal->CNodes.length() ; i++ ) {
1417 MESSAGE(" " << RetVal->CNodes[ i ] ->Name() ) ;
1419 MESSAGE("FNodes " << RetVal->FNodes.length() ) ;
1420 for ( i = 0 ; i < RetVal->FNodes.length() ; i++ ) {
1421 MESSAGE(" " << RetVal->FNodes[ i ] ->Name() ) ;
1423 MESSAGE("INodes " << RetVal->INodes.length() ) ;
1424 for ( i = 0 ; i < RetVal->INodes.length() ; i++ ) {
1425 MESSAGE(" " << RetVal->INodes[ i ] ->Name() ) ;
1427 MESSAGE("GNodes " << RetVal->GNodes.length() ) ;
1428 for ( i = 0 ; i < RetVal->GNodes.length() ; i++ ) {
1429 MESSAGE(" " << RetVal->GNodes[ i ] ->Name() ) ;
1431 MESSAGE("LNodes " << RetVal->LNodes.length() ) ;
1432 for ( i = 0 ; i < RetVal->LNodes.length() ; i++ ) {
1433 MESSAGE(" " << RetVal->LNodes[ i ] ->Name() ) ;
1435 MESSAGE("ELNodes " << RetVal->ELNodes.length() ) ;
1436 for ( i = 0 ; i < RetVal->ELNodes.length() ; i++ ) {
1437 MESSAGE(" " << RetVal->ELNodes[ i ] ->Name() ) ;
1439 MESSAGE("SNodes " << RetVal->SNodes.length() ) ;
1440 for ( i = 0 ; i < RetVal->SNodes.length() ; i++ ) {
1441 MESSAGE(" " << RetVal->SNodes[ i ] ->Name() ) ;
1443 MESSAGE("ESNodes " << RetVal->ESNodes.length() ) ;
1444 for ( i = 0 ; i < RetVal->ESNodes.length() ; i++ ) {
1445 MESSAGE(" " << RetVal->ESNodes[ i ] ->Name() ) ;
1447 MESSAGE("Graphs " << RetVal->Graphs.length() ) ;
1448 for ( i = 0 ; i < RetVal->Graphs.length() ; i++ ) {
1449 MESSAGE(" " << RetVal->Graphs[ i ] ->Name() ) ;
1451 if ( DataFlowExecutor() ) {
1452 DataFlowExecutor()->EventList() ;
1456 endService( "Graph_Impl::Nodes" );
1457 return ( RetVal._retn() ) ;
1460 SUPERV::ListOfLinks * Graph_Impl::GLinks() {
1461 return Links( NULL , NULL ) ;
1464 SUPERV::ListOfLinks * Graph_Impl::Links( GraphBase::ComputingNode * theNode ,
1465 const char * anInputParam ) {
1467 SUPERV::ListOfLinks_var RetVal = new SUPERV::ListOfLinks ;
1468 RetVal->length( 0 ) ;
1470 int i , j , countlink ;
1472 for ( i = 0 ; i < DataFlowEditor()->Graph()->GraphNodesSize() ; i++ ) {
1473 GraphEditor::InNode * aNode = NULL ;
1474 aNode = (GraphEditor::InNode * ) DataFlowEditor()->Graph()->GraphNodes( i )->GetInNode() ;
1475 bool ToProcess = false ;
1476 if ( theNode == NULL ) {
1480 if ( !strcmp( theNode->Name() , aNode->Name() ) ) {
1481 if ( !theNode->IsEndSwitchNode() ) {
1485 else if ( theNode->IsEndSwitchNode() ) {
1490 for ( j = 0 ; j < aNode->GetNodeInPortsSize() ; j++ ) {
1491 GraphBase::InPort * anInPort = NULL ;
1492 anInPort = aNode->GetChangeNodeInPort( j ) ;
1493 if ( anInputParam == NULL ||
1494 !strcmp( anInPort->PortName() , anInputParam ) ) {
1495 GraphBase::OutPort * anOutPort = NULL ;
1496 anOutPort = anInPort->GetOutPort() ;
1497 if ( anOutPort && !anOutPort->IsDataStream() ) {
1498 if ( strcmp( anOutPort->NodeName() , Name() ) ) {
1499 // MESSAGE("Graph_Impl::Links " << anOutPort->NodeName() << "("
1500 // << anOutPort->PortName() << ") --> " << aNode->Name() << "("
1501 // << anInPort->PortName() << ")" ) ;
1502 if ( theNode == NULL ||
1504 //JR 14.02.2005 : Debug : we must see also that links !
1505 // ( theNode != NULL && !theNode->IsEndSwitchNode() &&
1506 !strcmp( theNode->Name() , aNode->Name() ) ) {
1507 if ( anInPort->IsLoop() || anOutPort->IsLoop() ||
1508 ( aNode->IsEndLoopNode() && !strcmp( aNode->CoupledNode()->Name() ,
1509 anOutPort->NodeName() ) ) ) {
1510 // MESSAGE( "Link " << anOutPort->NodeName() << "("
1511 // << anOutPort->PortName() << ") --> " << aNode->Name() << "("
1512 // << anInPort->PortName() << ")" << " ignored" ) ;
1514 else if ( CORBA::is_nil( anOutPort->InPortObjRef( anInPort ) ) ) {
1516 beginService( "Graph_Impl::Links" );
1519 GraphEditor::InNode * anOutNode = NULL ;
1520 anOutNode = (GraphEditor::InNode * ) DataFlowEditor()->Graph()->GetChangeGraphNode( anOutPort->NodeName() )->GetInNode() ;
1523 Link_Impl * myLink = new Link_Impl( _Orb , _Poa , _ContId ,
1524 instanceName() , interfaceName() ,
1527 anInPort->PortName() ,
1529 anOutPort->PortName() ,
1530 false , true , Success ) ;
1532 PortableServer::ObjectId * id = myLink->getId() ;
1533 CORBA::Object_var obj = _poa->id_to_reference(*id);
1534 SUPERV::Link_var iobject ;
1535 iobject = SUPERV::Link::_narrow(obj) ;
1536 RetVal->length( countlink + 1 ) ;
1537 RetVal[ countlink++ ] = SUPERV::Link::_duplicate( iobject ) ;
1538 anOutPort->AddInPortObjRef( anInPort , SUPERV::Link::_duplicate( iobject ) ) ;
1543 RetVal->length( countlink + 1 ) ;
1544 RetVal[ countlink++ ] = SUPERV::Link::_duplicate( anOutPort->InPortObjRef( anInPort ) ) ;
1546 // MESSAGE( "Link " << anOutPort->NodeName() << "("
1547 // << anOutPort->PortName() << ") --> " << aNode->Name() << "("
1548 // << anInPort->PortName() << ")" << " selected" ) ;
1551 // MESSAGE( "Link " << anOutPort->NodeName() << "("
1552 // << anOutPort->PortName() << ") --> " << aNode->Name() << "("
1553 // << anInPort->PortName() << ")" << " skipped" ) ;
1560 for ( j = 0 ; j < aNode->GetNodeOutPortsSize() ; j++ ) {
1561 GraphBase::OutPort * anOutPort = aNode->GetChangeNodeOutPort( j ) ;
1562 // MESSAGE( "Graph_Impl::Links " << aNode->Name() << " Out" << j << " " << anOutPort->PortName() << " "
1563 // << anOutPort->PortStatus() << " PortConnected to " << anOutPort->InPortsSize() << " InPorts" ) ;
1565 for ( k = 0 ; k < anOutPort->InPortsSize() ; k++ ) {
1566 GraphBase::InPort * anInPort = anOutPort->ChangeInPorts( k ) ;
1567 // MESSAGE( " --> In" << k << " " << anInPort->NodeName() << " " << anInPort->PortName()
1568 // << " " << anInPort->PortStatus() ) ;
1569 if ( anInPort->IsPortConnected() ) {
1570 GraphBase::ComputingNode * aComputingNode = DataFlowEditor()->Graph()->GetChangeGraphNode( anInPort->NodeName() ) ;
1571 GraphEditor::InNode * toNode = (GraphEditor::InNode * ) aComputingNode->GetInNode() ;
1572 if ( theNode == NULL ||
1573 !strcmp( theNode->Name() , aNode->Name() ) ) {
1574 if ( !anInPort->IsDataStream() ) {
1576 //JR 14.02.2005 : Debug : we must see also that links !
1577 // if ( theNode || ( toNode->IsEndSwitchNode() && !aNode->IsSwitchNode() ) ) {
1578 if ( anInputParam == NULL ||
1579 !strcmp( anInPort->PortName() , anInputParam ) ) {
1580 if ( anInPort->IsLoop() || anOutPort->IsLoop() ||
1581 ( toNode->IsEndLoopNode() && !strcmp( toNode->CoupledNode()->Name() ,
1582 anOutPort->NodeName() ) ) ) {
1583 // MESSAGE( "Link " << anOutPort->NodeName() << "("
1584 // << anOutPort->PortName() << ") --> " << toNode->Name() << "("
1585 // << anInPort->PortName() << ")" << " ignored" ) ;
1587 else if ( CORBA::is_nil( anOutPort->InPortObjRef( anInPort ) ) ) {
1589 beginService( "Graph_Impl::Links" );
1593 Link_Impl * myLink = new Link_Impl( _Orb , _Poa , _ContId ,
1594 instanceName() , interfaceName() ,
1597 anInPort->PortName() ,
1599 anOutPort->PortName() ,
1600 false , true , Success ) ;
1602 PortableServer::ObjectId * id = myLink->getId() ;
1603 CORBA::Object_var obj = _poa->id_to_reference(*id);
1604 SUPERV::Link_var iobject ;
1605 iobject = SUPERV::Link::_narrow(obj) ;
1606 RetVal->length( countlink + 1 ) ;
1607 RetVal[ countlink++ ] = SUPERV::Link::_duplicate( iobject ) ;
1608 anOutPort->AddInPortObjRef( anInPort , SUPERV::Link::_duplicate( iobject ) ) ;
1612 RetVal->length( countlink + 1 ) ;
1613 RetVal[ countlink++ ] = SUPERV::Link::_duplicate( SUPERV::Link::_narrow( anOutPort->InPortObjRef( anInPort ) ) ) ;
1615 // MESSAGE( "Link " << anOutPort->NodeName() << "("
1616 // << anOutPort->PortName() << ") --> " << toNode->Name() << "("
1617 // << anInPort->PortName() << ")" << " selected" ) ;
1620 // MESSAGE( "Link " << anOutPort->NodeName() << "("
1621 // << anOutPort->PortName() << ") --> " << toNode->Name() << "("
1622 // << anInPort->PortName() << ")" << " skipped" ) ;
1633 const char * NodeName = "" ;
1634 const char * InputParamName = "" ;
1636 NodeName = theNode->Name() ;
1638 if ( anInputParam ) {
1639 InputParamName = anInputParam ;
1641 MESSAGE( RetVal->length() << " Links of Node " << NodeName << " and of InPort " << InputParamName ) ;
1642 for ( i = 0 ; i < (int ) RetVal->length() ; i++ ) {
1643 MESSAGE( "Link " << RetVal[i]->OutPort()->Node()->Name() << "("
1644 << RetVal[i]->OutPort()->Name() << ") --> "
1645 << RetVal[i]->InPort()->Node()->Name() << "("
1646 << RetVal[i]->InPort()->Name() << ")" ) ;
1650 endService( "Graph_Impl::Links" );
1653 return ( RetVal._retn() ) ;
1656 Engines::Component_ptr Graph_Impl::ComponentRef( const char * aComputerContainer ,
1657 const char * aComponentName ) {
1658 Engines::Component_var objComponent = Engines::Component::_nil() ;
1660 Engines::Container_var myContainer ;
1661 DataFlowEditor()->Graph()->StartComponent( 0 , aComputerContainer , aComponentName ,
1662 myContainer , objComponent ) ;
1664 return Engines::Component::_duplicate( objComponent ) ;
1667 char * Graph_Impl::Messages() {
1668 beginService( "Graph_Impl::Messages" );
1670 MESSAGE( "Graph_Impl::Messages IsEditing " << DataFlowEditor()->IsEditing() ) ;
1671 Messages = DataFlowEditor()->Graph()->Messages() ;
1672 DataFlowEditor()->Graph()->ReSetMessages() ;
1673 if ( DataFlowExecutor() ) {
1674 Messages += DataFlowExecutor()->Graph()->Messages() ;
1675 DataFlowExecutor()->Graph()->ReSetMessages() ;
1677 endService( "Graph_Impl::Messages" );
1678 return ( CORBA::string_dup( Messages.c_str() ) ) ;
1681 bool Graph_Impl::IsValid() {
1682 // beginService( "Graph_Impl::IsValid" );
1683 bool RetVal = false ;
1685 RetVal = DataFlowEditor()->IsValid() ;
1687 // endService( "Graph_Impl::IsValid" );
1690 bool Graph_Impl::IsExecutable() {
1691 // beginService( "Graph_Impl::IsExecutable" );
1692 bool RetVal = false ;
1694 // asv : 15.11.04 : added "&& GraphMacroLevel() == 0" ->
1695 // subgraphs are not executable by themselves, RetVal = false..
1696 if ( !IsMacro() && DataFlowEditor()->Graph()->GraphMacroLevel() == 0 ) {
1697 RetVal = DataFlowEditor()->IsExecutable() ;
1699 // endService( "Graph_Impl::IsExecutable" );
1703 bool Graph_Impl::IsEditing() {
1705 bool RetVal = false ;
1707 RetVal = DataFlowEditor()->IsEditing() ;
1713 return !IsExecuting();
1716 bool Graph_Impl::IsExecuting() {
1718 bool RetVal = false ;
1720 RetVal = !DataFlowEditor()->IsEditing() ;
1724 return CNode_Impl::IsExecuting();
1727 bool Graph_Impl::IsReadOnly() {
1728 // beginService( "Graph_Impl::IsExecuting" );
1729 bool RetVal = false ;
1731 RetVal = DataFlowEditor()->IsReadOnly() ;
1733 // endService( "Graph_Impl::IsExecuting" );
1737 long Graph_Impl::LevelMax() {
1738 // beginService( "Graph_Impl::LevelMax" );
1741 RetVal = DataFlowEditor()->LevelMax() ;
1743 // endService( "Graph_Impl::LevelMax" );
1746 SUPERV::ListOfNodes * Graph_Impl::LevelNodes(long aLevel ) {
1747 // beginService( "Graph_Impl::LevelNodes" );
1748 SUPERV::ListOfNodes_var RetVal = new SUPERV::ListOfNodes;
1751 SUPERV::ListOfStrings_var Nodes = DataFlowEditor()->LevelNodes( aLevel ) ;
1752 // RetVal->length( Nodes->length() );
1753 for ( i = 0 ; i < (int ) Nodes->length() ; i++ ) {
1754 // char * aNode = Nodes[ i ] ;
1755 GraphBase::ComputingNode * aNode = DataFlowEditor()->Graph()->GetChangeGraphNode( Nodes[ i ] ) ;
1756 RetVal = SetNode( RetVal , aNode ) ;
1757 // cout << "Graph_Impl::LevelNodes( " << aLevel << " ) " << aNode->Name() << endl ;
1758 // CNode_Impl * myNode = new CNode_Impl( _Orb , _Poa , _ContId ,
1759 // instanceName() , interfaceName() ,
1760 // DataFlowEditor() ,
1761 // (GraphEditor::InNode * ) DataFlowEditor()->GetChangeGraphNode( aNode )->GetInNode() ) ;
1762 // PortableServer::ObjectId * id = myNode->getId() ;
1763 // CORBA::Object_var obj = _poa->id_to_reference(*id);
1764 // SUPERV::CNode_var iobject ;
1765 // iobject = SUPERV::CNode::_narrow(obj) ;
1766 // RetVal[i] = SUPERV::CNode::_duplicate( iobject ) ;
1769 // endService( "Graph_Impl::LevelNodes" );
1770 return ( RetVal._retn() ) ;
1772 long Graph_Impl::ThreadsMax() {
1773 // beginService( "Graph_Impl::ThreadsMax" );
1776 RetVal = DataFlowEditor()->ThreadsMax() ;
1778 // endService( "Graph_Impl::ThreadsMax" );
1781 long Graph_Impl::Threads() {
1782 // beginService( "Node_Impl::Threads" );
1783 long RetVal = false ;
1785 RetVal = DataFlowExecutor()->Threads() ;
1787 // endService( "Node_Impl::Threads" );
1790 long Graph_Impl::SuspendedThreads() {
1791 // beginService( "Node_Impl::SuspendedThreads" );
1792 long RetVal = false ;
1794 RetVal = DataFlowExecutor()->SuspendedThreads() ;
1796 // endService( "Node_Impl::SuspendedThreads" );
1800 bool Graph_Impl::Begin() {
1801 bool RetVal = false ;
1802 if ( DataFlowEditor()->IsEditing() ) {
1803 if ( pthread_mutex_lock( &_MutexExecutorWait ) ) {
1804 perror("pthread_mutex_lock _MutexExecutorWait") ;
1807 DataFlowEditor()->Graph()->ReSetMessages() ; // ==> Only one set of errors messages ...
1808 if ( DataFlowExecutor() ) {
1809 MESSAGE( "Graph_Impl::Begin " << DataFlowExecutor()->Threads() << " threads" )
1810 Editing(); // just in case it was not called before by GUI..
1812 if ( DataFlowEditor()->IsExecutable() ) {
1813 DataFlowEditor()->EditedAfterExecution( false ) ;
1814 GraphBase::ListOfSGraphs * myListOfGraphs = DataFlowEditor()->GetDataFlows() ;
1816 GraphExecutor::DataFlow * aDataFlowExecutor ;
1818 CreateExecutor( _Orb , instanceName() , (*myListOfGraphs)[ 0 ].Info.theName.c_str() , Kind() ,
1819 dbgfile , &aDataFlowExecutor ) ;
1821 MESSAGE( "Graph_Impl::Begin : DataFlowExecutor created" );
1822 if ( !CORBA::is_nil( LoadDataFlows( aDataFlowExecutor, myListOfGraphs , 0 ) ) )
1826 DataFlowExecutor()->Graph()->SetObjImpl( DataFlowEditor()->Graph()->ObjImpl() ) ;
1829 if ( pthread_mutex_unlock( &_MutexExecutorWait ) ) {
1830 perror("pthread_mutex_unlock _MutexExecutorWait") ;
1838 * run() : was created in order to reduce code dublication, Run() and Start() do the same thing
1839 * except for final call to Executor->Run( bool ) - Run() calls with AndSuspend=false
1840 * and Start() calls with AndSuspend=true flag. The rest of the actions are the same:
1841 * 1. if a MacroNode's coupled graph (MacroLevel>0) -> simply Run() it.
1842 * 2. if a Supergraph -> create executor, load dataflow in it (done in Begin()), then - Run() it.
1844 bool Graph_Impl::run( const bool andSuspend ) {
1845 bool RetVal = false ;
1847 // if Editing or Finished state, and, naturally, 'this' is not a MacroNode.
1848 if ( ( DataFlowEditor()->IsEditing() || IsDone() ) && !IsMacro() ) {
1850 if ( DataFlowEditor()->Graph()->GraphMacroLevel() ) {
1851 // MacroGraph's Executor was created in recursive function LoadDataflows(Executor), called from
1852 // Begin() of Supergraph. See Begin() and LoadDataflows(Executor) for details.
1856 // Create Executor instance and its datamodel
1860 // Set Executing flag to avoid edition operations during execution, EditedAfterExecution=false
1861 DataFlowEditor()->Executing() ;
1862 DataFlowEditor()->EditedAfterExecution( false );
1864 // THE MAIN RUN METHOD
1865 RetVal = DataFlowExecutor()->Run( andSuspend );
1873 * Run() - called on "Execute" command
1875 bool Graph_Impl::Run() {
1876 beginService( "Graph_Impl::Run" );
1877 bool RetVal = run( /*andSuspend=*/false ) ;
1878 MESSAGE( "Graph_Impl::Run " << DataFlowEditor()->Graph()->Name() << " RetVal " << RetVal ) ;
1879 endService( "Graph_Impl::Run" );
1884 * Run() - called on "Execute step-by-step" command
1886 bool Graph_Impl::Start() {
1887 beginService( "Graph_Impl::Start" );
1888 bool RetVal = run( /*andSuspend=*/true ) ;
1889 MESSAGE( "Graph_Impl::Start " << DataFlowEditor()->Graph()->Name() << " RetVal " << RetVal ) ;
1890 endService( "Graph_Impl::Start" );
1894 bool Graph_Impl::EventNoW( SUPERV::CNode_out aNode ,
1895 SUPERV::GraphEvent & anEvent ,
1896 SUPERV::GraphState & aState ) {
1897 bool RetVal = false ;
1898 char * aNodeName = NULL ;
1899 SUPERV::GraphEvent theEvent = SUPERV::UndefinedEvent ;
1900 SUPERV::GraphState theState = SUPERV::UndefinedState ;
1901 if ( pthread_mutex_lock( &_MutexExecutorWait ) ) {
1902 perror("pthread_mutex_lock _MutexExecutorWait") ;
1905 if ( DataFlowExecutor() && !IsMacro() &&
1906 ( DataFlowExecutor()->GetListSize() || !DataFlowEditor()->IsEditing() ) ) {
1907 RetVal = DataFlowExecutor()->Event( & aNodeName , theEvent , theState , false ) ;
1908 // endService( "Graph_Impl::Event" );
1909 if ( strlen( aNodeName ) ) {
1910 if ( strcmp( aNodeName , Name() ) ) {
1911 aNode = Node( aNodeName ) ;
1918 aNode = SUPERV::Graph::_duplicate( SUPERV::Graph::_nil() ) ;
1920 // cout << "Graph_Impl::EventNoW " << aNode->Name() << " QSize " << DataFlowExecutor()->GetListSize() << endl ;
1923 // cout << "Graph_Impl::EventNoW NO DataFlowExecutor() or QSize=0 " << endl ;
1925 if ( pthread_mutex_unlock( &_MutexExecutorWait ) ) {
1926 perror("pthread_mutex_unlock _MutexExecutorWait") ;
1929 anEvent = theEvent ;
1934 bool Graph_Impl::Event( SUPERV::CNode_out aNode ,
1935 SUPERV::GraphEvent & anEvent ,
1936 SUPERV::GraphState & aState ) {
1937 // beginService( "Graph_Impl::Event" );
1938 bool RetVal = false ;
1939 char * aNodeName = NULL ;
1940 SUPERV::GraphEvent theEvent = SUPERV::UndefinedEvent ;
1941 SUPERV::GraphState theState = SUPERV::UndefinedState ;
1942 if ( pthread_mutex_lock( &_MutexExecutorWait ) ) {
1943 perror("pthread_mutex_lock _MutexExecutorWait") ;
1946 if ( DataFlowExecutor() && !IsMacro() &&
1947 ( DataFlowExecutor()->GetListSize() || !DataFlowEditor()->IsEditing() ) ){
1948 RetVal = DataFlowExecutor()->Event( & aNodeName , theEvent , theState ) ;
1949 // endService( "Graph_Impl::Event" );
1950 if ( strlen( aNodeName ) ) {
1951 if ( strcmp( aNodeName , Name() ) ) {
1952 aNode = Node( aNodeName ) ;
1959 aNode = SUPERV::Graph::_duplicate( SUPERV::Graph::_nil() ) ;
1961 // cout << "Graph_Impl::Event " << aNode->Name() << " QSize " << DataFlowExecutor()->GetListSize() << endl ;
1964 // cout << "Graph_Impl::Event NO DataFlowExecutor() or QSize=0 " << endl ;
1966 if ( pthread_mutex_unlock( &_MutexExecutorWait ) ) {
1967 perror("pthread_mutex_unlock _MutexExecutorWait") ;
1970 anEvent = theEvent ;
1976 bool Graph_Impl::EventW( SUPERV::CNode_out aNode ,
1977 SUPERV::GraphEvent & anEvent ,
1978 SUPERV::GraphState & aState ) {
1979 // beginService( "Graph_Impl::EventW" );
1980 bool RetVal = false ;
1981 char * aNodeName = NULL ;
1982 SUPERV::GraphEvent theEvent = SUPERV::UndefinedEvent ;
1983 SUPERV::GraphState theState = SUPERV::UndefinedState ;
1984 if ( pthread_mutex_lock( &_MutexExecutorWait ) ) {
1985 perror("pthread_mutex_lock _MutexExecutorWait") ;
1988 if ( DataFlowExecutor() && !IsMacro() &&
1989 ( DataFlowExecutor()->GetListSize() || !DataFlowEditor()->IsEditing() ) ) {
1990 RetVal = DataFlowExecutor()->EventW( & aNodeName , theEvent , theState ) ;
1991 if ( RetVal && strcmp( aNodeName , Name() ) ) {
1992 aNode = Node( aNodeName ) ;
1998 if ( pthread_mutex_unlock( &_MutexExecutorWait ) ) {
1999 perror("pthread_mutex_unlock _MutexExecutorWait") ;
2002 anEvent = theEvent ;
2004 // endService( "Graph_Impl::EventW" );
2008 long Graph_Impl::EventQSize() {
2009 // beginService( "Graph_Impl::EventQSize" );
2011 if ( pthread_mutex_lock( &_MutexExecutorWait ) ) {
2012 perror("pthread_mutex_lock _MutexExecutorWait") ;
2015 if ( DataFlowExecutor() && !IsMacro() ) {
2016 QSize = DataFlowExecutor()->EventQSize() ;
2018 if ( pthread_mutex_unlock( &_MutexExecutorWait ) ) {
2019 perror("pthread_mutex_unlock _MutexExecutorWait") ;
2022 // endService( "Graph_Impl::EventQSize" );
2026 long Graph_Impl::LastLevelDone() {
2027 // beginService( "Graph_Impl::LastLevelDone" );
2028 if ( pthread_mutex_lock( &_MutexExecutorWait ) ) {
2029 perror("pthread_mutex_lock _MutexExecutorWait") ;
2033 if ( DataFlowExecutor() && !IsMacro() ) {
2034 RetVal = DataFlowExecutor()->LastLevelDone() ;
2036 if ( pthread_mutex_unlock( &_MutexExecutorWait ) ) {
2037 perror("pthread_mutex_unlock _MutexExecutorWait") ;
2040 // endService( "Graph_Impl::LastLevelDone" );
2044 long Graph_Impl::SubGraphsNumber() {
2045 // beginService( "Graph_Impl::SubGraphsNumber" );
2047 if ( DataFlowEditor()->IsExecutable() && !IsMacro() ) {
2048 RetVal = DataFlowEditor()->SubGraphsNumber() ;
2050 // endService( "Graph_Impl::SubGraphsNumber" );
2054 SUPERV::ListOfNodes * Graph_Impl::SubGraphsNodes( const long aSubGraphNumber ) {
2055 beginService( "Graph_Impl::SubGraphsNodes" );
2056 SUPERV::ListOfNodes_var RetVal = new SUPERV::ListOfNodes ;
2057 if ( DataFlowEditor()->IsEditing() && !IsMacro() ) {
2058 SUPERV::ListOfNodes * aGraphNodes = Nodes() ;
2061 for ( i = 0 ; i < (int ) aGraphNodes->CNodes.length() ; i++ ) {
2062 SUPERV::CNode_var aNode = (aGraphNodes->CNodes)[ i ] ;
2063 if ( aNode->SubGraph() == aSubGraphNumber ) {
2064 RetVal = SetNode( RetVal , DataFlowEditor()->Graph()->GetChangeGraphNode( aNode->Name() ) ) ;
2068 for ( i = 0 ; i < (int ) aGraphNodes->FNodes.length() ; i++ ) {
2069 SUPERV::FNode_var aNode = (aGraphNodes->FNodes)[ i ] ;
2070 if ( aNode->SubGraph() == aSubGraphNumber ) {
2071 RetVal = SetNode( RetVal , DataFlowEditor()->Graph()->GetChangeGraphNode( aNode->Name() ) ) ;
2075 for ( i = 0 ; i < (int ) aGraphNodes->INodes.length() ; i++ ) {
2076 SUPERV::INode_var aNode = (aGraphNodes->INodes)[ i ] ;
2077 if ( aNode->SubGraph() == aSubGraphNumber ) {
2078 RetVal = SetNode( RetVal , DataFlowEditor()->Graph()->GetChangeGraphNode( aNode->Name() ) ) ;
2082 for ( i = 0 ; i < (int ) aGraphNodes->GNodes.length() ; i++ ) {
2083 SUPERV::GNode_var aNode = (aGraphNodes->GNodes)[ i ] ;
2084 if ( aNode->SubGraph() == aSubGraphNumber ) {
2085 RetVal = SetNode( RetVal , DataFlowEditor()->Graph()->GetChangeGraphNode( aNode->Name() ) ) ;
2089 for ( i = 0 ; i < (int ) aGraphNodes->LNodes.length() ; i++ ) {
2090 SUPERV::LNode_var aNode = (aGraphNodes->LNodes)[ i ] ;
2091 if ( aNode->SubGraph() == aSubGraphNumber ) {
2092 RetVal = SetNode( RetVal , DataFlowEditor()->Graph()->GetChangeGraphNode( aNode->Name() ) ) ;
2096 for ( i = 0 ; i < (int ) aGraphNodes->ELNodes.length() ; i++ ) {
2097 SUPERV::ELNode_var aNode = (aGraphNodes->ELNodes)[ i ] ;
2098 if ( aNode->SubGraph() == aSubGraphNumber ) {
2099 RetVal = SetNode( RetVal , DataFlowEditor()->Graph()->GetChangeGraphNode( aNode->Name() ) ) ;
2103 for ( i = 0 ; i < (int ) aGraphNodes->SNodes.length() ; i++ ) {
2104 SUPERV::SNode_var aNode = (aGraphNodes->SNodes)[ i ] ;
2105 if ( aNode->SubGraph() == aSubGraphNumber ) {
2106 RetVal = SetNode( RetVal , DataFlowEditor()->Graph()->GetChangeGraphNode( aNode->Name() ) ) ;
2110 for ( i = 0 ; i < (int ) aGraphNodes->ESNodes.length() ; i++ ) {
2111 SUPERV::ESNode_var aNode = (aGraphNodes->ESNodes)[ i ] ;
2112 if ( aNode->SubGraph() == aSubGraphNumber ) {
2113 RetVal = SetNode( RetVal , DataFlowEditor()->Graph()->GetChangeGraphNode( aNode->Name() ) ) ;
2117 endService( "Graph_Impl::SubGraphsNodes" );
2118 return ( RetVal._retn() ) ;
2121 bool Graph_Impl::Merge(const SUPERV::Graph_ptr aGraph ) {
2122 // beginService( "Graph_Impl::Merge" );
2123 bool RetVal = true ;
2125 map< string , int > aMapOfNodes ;
2126 RetVal = Merge( aGraph , aMapOfNodes ) ;
2128 // endService( "Graph_Impl::Merge" );
2132 bool Graph_Impl::Merge(const SUPERV::Graph_ptr aGraph , map< string , int > & aMapOfNodes ) {
2133 beginService( "Graph_Impl::Merge" );
2134 bool RetVal = true ;
2135 if ( DataFlowEditor()->IsEditing() && !IsMacro() ) {
2136 SUPERV::ListOfNodes * aGraphNodes = aGraph->Nodes() ;
2138 SUPERV::Port_ptr aPort ;
2139 // SUPERV::StreamPort_ptr aStreamPort ;
2141 for ( i = 0 ; i < (int ) aGraphNodes->CNodes.length() ; i++ ) {
2142 SUPERV::CNode_var aNode = (aGraphNodes->CNodes)[ i ] ;
2143 SUPERV::CNode_ptr myNode = CNode( *(aNode->Service()) ) ;
2144 if ( !CORBA::is_nil( myNode ) ) {
2145 myNode->SetName( aNode->Name() ) ;
2146 myNode->SetAuthor( aNode->Author() ) ;
2147 myNode->SetComment( aNode->Comment() ) ;
2148 myNode->Coords( aNode->X() , aNode->Y() ) ;
2149 string * aNodetheName = new string( aNode->Name() ) ;
2150 aMapOfNodes[ *aNodetheName ] = DataFlowEditor()->Graph()->GetGraphNodeIndex( myNode->Name() ) ;
2151 delete aNodetheName ;
2158 // The following informations are now in the service from SALOME_ModuleCatalog
2159 // SUPERV::ListOfStreamPorts myStreamPorts = *(aNode->StreamPorts()) ;
2161 // for ( j = 0 ; j < (int ) myStreamPorts.length() ; j++ ) {
2162 // if ( myStreamPorts[ j ]->IsInput() && myStreamPorts[ j ]->IsDataStream() ) {
2163 // aStreamPort = myNode->InStreamPort( myStreamPorts[ j ]->Name() , myStreamPorts[ j ]->Type() ) ;
2165 // else if ( myStreamPorts[ j ]->IsDataStream() ) {
2166 // aStreamPort = myNode->OutStreamPort( myStreamPorts[ j ]->Name() , myStreamPorts[ j ]->Type() ) ;
2172 for ( i = 0 ; i < (int ) aGraphNodes->FNodes.length() ; i++ ) {
2173 SUPERV::FNode_var aNode = (aGraphNodes->FNodes)[ i ] ;
2174 SUPERV::FNode_ptr myNode = FNode( aNode->GetComponentName() ,
2175 aNode->GetInterfaceName() ,
2176 *(aNode->Service()) ) ;
2177 if ( !CORBA::is_nil( myNode ) ) {
2178 myNode->SetName( aNode->Name() ) ;
2179 myNode->SetAuthor( aNode->Author() ) ;
2180 myNode->SetComment( aNode->Comment() ) ;
2181 myNode->Coords( aNode->X() , aNode->Y() ) ;
2182 string * aNodetheName = new string( aNode->Name() ) ;
2183 aMapOfNodes[ *aNodetheName ] = DataFlowEditor()->Graph()->GetGraphNodeIndex( myNode->Name() ) ;
2184 delete aNodetheName ;
2191 // The following informations are now in the service from SALOME_ModuleCatalog
2192 // SUPERV::ListOfStreamPorts myStreamPorts = *(aNode->StreamPorts()) ;
2194 // for ( j = 0 ; j < (int ) myStreamPorts.length() ; j++ ) {
2195 // if ( myStreamPorts[ j ]->IsInput() && myStreamPorts[ j ]->IsDataStream() ) {
2196 // aStreamPort = myNode->InStreamPort( myStreamPorts[ j ]->Name() , myStreamPorts[ j ]->Type() ) ;
2198 // else if ( myStreamPorts[ j ]->IsDataStream() ) {
2199 // aStreamPort = myNode->OutStreamPort( myStreamPorts[ j ]->Name() , myStreamPorts[ j ]->Type() ) ;
2206 for ( i = 0 ; i < (int ) aGraphNodes->INodes.length() ; i++ ) {
2207 SUPERV::INode_var aNode = (aGraphNodes->INodes)[ i ] ;
2208 SUPERV::INode_ptr myNode = INode( aNode->PyFuncName() , *(aNode->PyFunction()) ) ;
2209 if ( !CORBA::is_nil( myNode ) ) {
2210 myNode->SetName( aNode->Name() ) ;
2211 myNode->SetAuthor( aNode->Author() ) ;
2212 myNode->SetComment( aNode->Comment() ) ;
2213 myNode->Coords( aNode->X() , aNode->Y() ) ;
2214 string * aNodetheName = new string( aNode->Name() ) ;
2215 aMapOfNodes[ *aNodetheName ] = DataFlowEditor()->Graph()->GetGraphNodeIndex( myNode->Name() ) ;
2216 delete aNodetheName ;
2217 SUPERV::ListOfPorts myPorts = *(aNode->Ports()) ;
2219 for ( j = 0 ; j < (int ) myPorts.length() ; j++ ) {
2220 if ( myPorts[ j ]->IsInput() ) {
2221 aPort = myNode->InPort( myPorts[ j ]->Name() , myPorts[ j ]->Type() ) ;
2224 aPort = myNode->OutPort( myPorts[ j ]->Name() , myPorts[ j ]->Type() ) ;
2227 if ( DataFlowEditor()->Graph()->IsDataStreamNode() ) {
2228 SUPERV::ListOfStreamPorts myStreamPorts = *(aNode->StreamPorts()) ;
2229 for ( j = 0 ; j < (int ) myStreamPorts.length() ; j++ ) {
2230 if ( myStreamPorts[ j ]->IsInput() ) {
2231 aPort = myNode->InStreamPort( myStreamPorts[ j ]->Name() , StringToDataStreamType( myStreamPorts[ j ]->Type() ) , myStreamPorts[ j ]->Dependency() ) ;
2234 aPort = myNode->OutStreamPort( myStreamPorts[ j ]->Name() , StringToDataStreamType( myStreamPorts[ j ]->Type() ) , myStreamPorts[ j ]->Dependency() ) ;
2248 for ( i = 0 ; i < (int ) aGraphNodes->GNodes.length() ; i++ ) {
2249 SUPERV::GNode_var aNode = (aGraphNodes->GNodes)[ i ] ;
2250 SUPERV::GNode_ptr myNode = GNode( aNode->PyFuncName() , *(aNode->PyFunction()) , aNode->Coupled()->Name() ) ;
2251 if ( !CORBA::is_nil( myNode ) ) {
2252 myNode->SetName( aNode->Name() ) ;
2253 myNode->SetAuthor( aNode->Author() ) ;
2254 myNode->SetComment( aNode->Comment() ) ;
2255 myNode->Coords( aNode->X() , aNode->Y() ) ;
2256 string * aNodetheName = new string( aNode->Name() ) ;
2257 aMapOfNodes[ *aNodetheName ] = DataFlowEditor()->Graph()->GetGraphNodeIndex( myNode->Name() ) ;
2258 delete aNodetheName ;
2259 SUPERV::ListOfPorts myPorts = *(aNode->Ports()) ;
2261 for ( j = 0 ; j < (int ) myPorts.length() ; j++ ) {
2262 if ( myPorts[ j ]->IsInput() ) {
2263 aPort = myNode->InPort( myPorts[ j ]->Name() , myPorts[ j ]->Type() ) ;
2266 aPort = myNode->OutPort( myPorts[ j ]->Name() , myPorts[ j ]->Type() ) ;
2269 if ( DataFlowEditor()->Graph()->IsDataStreamNode() ) {
2270 SUPERV::ListOfStreamPorts myStreamPorts = *(aNode->StreamPorts()) ;
2271 for ( j = 0 ; j < (int ) myStreamPorts.length() ; j++ ) {
2272 if ( myStreamPorts[ j ]->IsInput() ) {
2273 aPort = myNode->InStreamPort( myStreamPorts[ j ]->Name() , StringToDataStreamType( myStreamPorts[ j ]->Type() ) , myStreamPorts[ j ]->Dependency() ) ;
2276 aPort = myNode->OutStreamPort( myStreamPorts[ j ]->Name() , StringToDataStreamType( myStreamPorts[ j ]->Type() ) , myStreamPorts[ j ]->Dependency() ) ;
2290 for ( i = 0 ; i < (int ) aGraphNodes->LNodes.length() ; i++ ) {
2291 SUPERV::LNode_var aNode = (aGraphNodes->LNodes)[ i ] ;
2292 SUPERV::INode_ptr anEndOfLoop ;
2293 SUPERV::LNode_ptr myNode = LNode( aNode->PyInitName() ,
2294 *(aNode->PyInit()) ,
2295 aNode->PyMoreName() ,
2296 *(aNode->PyMore()) ,
2297 aNode->PyNextName() ,
2298 *(aNode->PyNext()) ,
2300 if ( !CORBA::is_nil( myNode ) ) {
2301 myNode->SetName( aNode->Name() ) ;
2302 myNode->SetAuthor( aNode->Author() ) ;
2303 myNode->SetComment( aNode->Comment() ) ;
2304 myNode->Coords( aNode->X() , aNode->Y() ) ;
2305 string * aNodetheName = new string( aNode->Name() ) ;
2306 aMapOfNodes[ *aNodetheName ] = DataFlowEditor()->Graph()->GetGraphNodeIndex( myNode->Name() ) ;
2307 delete aNodetheName ;
2308 SUPERV::ListOfPorts myPorts = *(aNode->Ports()) ;
2310 for ( j = 0 ; j < (int ) myPorts.length() ; j++ ) {
2311 if ( myPorts[ j ]->IsInput() ) {
2312 aPort = myNode->InPort( myPorts[ j ]->Name() , myPorts[ j ]->Type() ) ;
2315 aPort = myNode->OutPort( myPorts[ j ]->Name() , myPorts[ j ]->Type() ) ;
2318 if ( DataFlowEditor()->Graph()->IsDataStreamNode() ) {
2319 SUPERV::ListOfStreamPorts myStreamPorts = *(aNode->StreamPorts()) ;
2320 for ( j = 0 ; j < (int ) myStreamPorts.length() ; j++ ) {
2321 if ( myStreamPorts[ j ]->IsInput() ) {
2322 aPort = myNode->InStreamPort( myStreamPorts[ j ]->Name() , StringToDataStreamType( myStreamPorts[ j ]->Type() ) , myStreamPorts[ j ]->Dependency() ) ;
2325 aPort = myNode->OutStreamPort( myStreamPorts[ j ]->Name() , StringToDataStreamType( myStreamPorts[ j ]->Type() ) , myStreamPorts[ j ]->Dependency() ) ;
2329 SUPERV::INode_ptr myEndOfLoop = aNode->Coupled() ;
2330 anEndOfLoop->SetName( myEndOfLoop->Name() ) ;
2331 anEndOfLoop->SetAuthor( myEndOfLoop->Author() ) ;
2332 anEndOfLoop->SetComment( myEndOfLoop->Comment() ) ;
2333 anEndOfLoop->Coords( myEndOfLoop->X() , myEndOfLoop->Y() ) ;
2334 anEndOfLoop->SetPyFunction( myEndOfLoop->PyFuncName() , *(myEndOfLoop->PyFunction()) ) ;
2335 aNodetheName = new string( myEndOfLoop->Name() ) ;
2336 aMapOfNodes[ *aNodetheName ] = DataFlowEditor()->Graph()->GetGraphNodeIndex( anEndOfLoop->Name() ) ;
2337 if ( DataFlowEditor()->Graph()->IsDataStreamNode() ) {
2338 SUPERV::ListOfStreamPorts myStreamLoopPorts = *(myEndOfLoop->StreamPorts()) ;
2339 for ( j = 0 ; j < (int ) myStreamLoopPorts.length() ; j++ ) {
2340 if ( myStreamLoopPorts[ j ]->IsInput() ) {
2341 aPort = myNode->InStreamPort( myStreamLoopPorts[ j ]->Name() , StringToDataStreamType( myStreamLoopPorts[ j ]->Type() ) , myStreamLoopPorts[ j ]->Dependency() ) ;
2344 aPort = myNode->OutStreamPort( myStreamLoopPorts[ j ]->Name() , StringToDataStreamType( myStreamLoopPorts[ j ]->Type() ) , myStreamLoopPorts[ j ]->Dependency() ) ;
2348 delete aNodetheName ;
2359 for ( i = 0 ; i < (int ) aGraphNodes->SNodes.length() ; i++ ) {
2360 SUPERV::SNode_var aNode = (aGraphNodes->SNodes)[ i ] ;
2361 SUPERV::INode_ptr anEndOfSwitch ;
2362 SUPERV::SNode_ptr myNode = SNode( aNode->PyFuncName() , *(aNode->PyFunction()) , anEndOfSwitch ) ;
2363 if ( !CORBA::is_nil( myNode ) ) {
2364 myNode->SetName( aNode->Name() ) ;
2365 myNode->SetAuthor( aNode->Author() ) ;
2366 myNode->SetComment( aNode->Comment() ) ;
2367 myNode->Coords( aNode->X() , aNode->Y() ) ;
2368 string * aNodetheName = new string( aNode->Name() ) ;
2369 aMapOfNodes[ *aNodetheName ] = DataFlowEditor()->Graph()->GetGraphNodeIndex( myNode->Name() ) ;
2370 delete aNodetheName ;
2371 SUPERV::ListOfPorts myPorts = *(aNode->Ports()) ;
2373 for ( j = 0 ; j < (int ) myPorts.length() ; j++ ) {
2374 if ( myPorts[ j ]->IsInput() ) {
2375 aPort = myNode->InPort( myPorts[ j ]->Name() , myPorts[ j ]->Type() ) ;
2378 aPort = myNode->OutPort( myPorts[ j ]->Name() , myPorts[ j ]->Type() ) ;
2381 if ( DataFlowEditor()->Graph()->IsDataStreamNode() ) {
2382 SUPERV::ListOfStreamPorts myStreamPorts = *(aNode->StreamPorts()) ;
2383 for ( j = 0 ; j < (int ) myStreamPorts.length() ; j++ ) {
2384 if ( myStreamPorts[ j ]->IsInput() ) {
2385 aPort = myNode->InStreamPort( myStreamPorts[ j ]->Name() , StringToDataStreamType( myStreamPorts[ j ]->Type() ) , myStreamPorts[ j ]->Dependency() ) ;
2388 aPort = myNode->OutStreamPort( myStreamPorts[ j ]->Name() , StringToDataStreamType( myStreamPorts[ j ]->Type() ) , myStreamPorts[ j ]->Dependency() ) ;
2392 SUPERV::INode_ptr myEndOfSwitch = aNode->Coupled() ;
2393 anEndOfSwitch->SetName( myEndOfSwitch->Name() ) ;
2394 anEndOfSwitch->SetAuthor( myEndOfSwitch->Author() ) ;
2395 anEndOfSwitch->SetComment( myEndOfSwitch->Comment() ) ;
2396 anEndOfSwitch->Coords( myEndOfSwitch->X() , myEndOfSwitch->Y() ) ;
2397 anEndOfSwitch->SetPyFunction( myEndOfSwitch->PyFuncName() , *(myEndOfSwitch->PyFunction()) ) ;
2398 aNodetheName = new string( myEndOfSwitch->Name() ) ;
2399 aMapOfNodes[ *aNodetheName ] = DataFlowEditor()->Graph()->GetGraphNodeIndex( anEndOfSwitch->Name() ) ;
2400 delete aNodetheName ;
2401 myPorts = *(myEndOfSwitch->Ports()) ;
2402 for ( j = 0 ; j < (int ) myPorts.length() ; j++ ) {
2403 if ( myPorts[ j ]->IsInput() ) {
2404 aPort = myNode->InPort( myPorts[ j ]->Name() , myPorts[ j ]->Type() ) ;
2407 aPort = myNode->OutPort( myPorts[ j ]->Name() , myPorts[ j ]->Type() ) ;
2410 if ( DataFlowEditor()->Graph()->IsDataStreamNode() ) {
2411 SUPERV::ListOfStreamPorts myStreamSwitchPorts = *(myEndOfSwitch->StreamPorts()) ;
2412 for ( j = 0 ; j < (int ) myStreamSwitchPorts.length() ; j++ ) {
2413 if ( myStreamSwitchPorts[ j ]->IsInput() ) {
2414 aPort = myNode->InStreamPort( myStreamSwitchPorts[ j ]->Name() , StringToDataStreamType( myStreamSwitchPorts[ j ]->Type() ) , myStreamSwitchPorts[ j ]->Dependency() ) ;
2417 aPort = myNode->OutStreamPort( myStreamSwitchPorts[ j ]->Name() , StringToDataStreamType( myStreamSwitchPorts[ j ]->Type() ) , myStreamSwitchPorts[ j ]->Dependency() ) ;
2430 SUPERV::ListOfLinks * aGraphLinks = aGraph->GLinks() ;
2431 SUPERV::ListOfPorts * aGraphPorts = aGraph->Ports() ;
2432 // cout << "Graph_Impl::Merge " << aGraphLinks->length() << " links " << aGraphPorts->length() << " GraphPorts"
2434 for ( i = 0 ; i < (int ) aGraphLinks->length() ; i++ ) {
2435 SUPERV::Link_var aLink = (*aGraphLinks)[ i ] ;
2436 SUPERV::Port_var OutPort = aLink->OutPort() ;
2437 SUPERV::Port_var InPort = aLink->InPort() ;
2438 string * aLinkFromNodeName = new string( OutPort->Node()->Name() ) ;
2439 string * aLinkToNodeName = new string( InPort->Node()->Name() ) ;
2440 RetVal = DataFlowEditor()->AddLink( DataFlowEditor()->Graph()->GetGraphNode( aMapOfNodes[ aLinkFromNodeName->c_str() ] )->Name() ,
2442 DataFlowEditor()->Graph()->GetGraphNode( aMapOfNodes[ aLinkToNodeName->c_str() ] )->Name() ,
2446 for ( j = 1 ; j <= aLink->CoordsSize() ; j++ ) {
2448 RetVal = aLink->Coords( j , X , Y ) ;
2451 RetVal = DataFlowEditor()->AddLinkCoord( DataFlowEditor()->Graph()->GetGraphNode( aMapOfNodes[ aLinkFromNodeName->c_str() ] )->Name() ,
2453 DataFlowEditor()->Graph()->GetGraphNode( aMapOfNodes[ aLinkToNodeName->c_str() ] )->Name() ,
2461 delete aLinkFromNodeName ;
2462 delete aLinkToNodeName ;
2468 for ( i = 0 ; i < (int ) aGraphPorts->length() ; i++ ) {
2469 SUPERV::Port_var aPort = (*aGraphPorts)[ i ] ;
2470 if ( !aPort->IsGate() ) {
2471 MESSAGE( "Graph_Impl::Merge " << i << ". " << aPort->Node()->Name() << " " << aPort->Name() ) ;
2472 char * aPortName = aPort->Name() ;
2473 char * aNodeName = new char[ strlen( aPortName ) + 1 ] ;
2474 strcpy( aNodeName , aPortName ) ;
2475 // char * thePortName = strchr( aNodeName , '\\' ) ;
2476 char * thePortName = aNodeName ;
2477 while ( ( thePortName = strchr( thePortName , '_' ) ) ) {
2478 if ( thePortName[1] == '_' ) {
2479 thePortName[ 0 ] = '\0' ;
2483 thePortName = &thePortName[2] ;
2486 bool hasinput = aGraph->Node( aNodeName )->Port( thePortName + 2 )->HasInput() ;
2487 // cout << "Graph_Impl::Merge " << " aNodeName " << aNodeName << " aPort " << thePortName + 1
2488 // << " HasInput " << hasinput << endl ;
2490 RetVal = DataFlowEditor()->AddInputData( DataFlowEditor()->Graph()->GetGraphNode( aMapOfNodes[ aNodeName ] )->Name() ,
2492 *(aPort->ToAny()) ) ;
2494 delete [] aNodeName ;
2503 MESSAGE( "Graph_Impl::Merge returns " << RetVal ) ;
2504 endService( "Graph_Impl::Merge" );
2508 SUPERV::StreamGraph_ptr Graph_Impl::ToStreamGraph() {
2509 SUPERV::StreamGraph_var iobject = SUPERV::StreamGraph::_nil() ;
2510 beginService( "Graph_Impl::ToStreamGraph" );
2511 if ( IsStreamGraph() && !IsMacro() ) {
2512 // StreamGraph_Impl * myStreamGraph = new StreamGraph_Impl( _Orb , _Poa , _ContId ,
2513 // instanceName() , interfaceName() ) ;
2514 // PortableServer::ObjectId * id = myStreamGraph->getId() ;
2515 // CORBA::Object_var obj = _poa->id_to_reference(*id);
2516 iobject = SUPERV::StreamGraph::_narrow( ObjRef() ) ;
2517 if ( CORBA::is_nil( iobject ) ) {
2518 MESSAGE( "ToStreamGraph of " << Name() << " (IsStreamGraph) --> nil reference" ) ;
2522 MESSAGE( "ToStreamGraph of " << Name() << " (IsNOTStreamGraph) --> nil reference" ) ;
2524 endService( "Graph_Impl::ToStreamGraph" );
2525 return SUPERV::StreamGraph::_duplicate( iobject ) ;
2529 * Destroy Executor and use only Editor and its data model
2531 void Graph_Impl::Editing() {
2532 if ( DataFlowEditor() && DataFlowExecutor() ) {
2533 delete DataFlowExecutor() ;
2534 DataFlowEditor()->Executor( NULL );