]> SALOME platform Git repositories - modules/superv.git/blob - src/GraphBase/DataFlowBase_Graph.cxx
Salome HOME
*** empty log message ***
[modules/superv.git] / src / GraphBase / DataFlowBase_Graph.cxx
1 //  SUPERV GraphBase : contains fondamental classes for Services, Input Ports, Output Ports Links and Nodes.
2 //
3 //  Copyright (C) 2003  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 //  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS 
5 // 
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. 
10 // 
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. 
15 // 
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 
19 // 
20 //  See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org 
21 //
22 //
23 //
24 //  File   : DataFlowBase_Graph.cxx
25 //  Author : Jean Rahuel, CEA
26 //  Module : SUPERV
27 //  $Header:
28
29 using namespace std;
30 #include "DataFlowBase_Graph.hxx"
31
32 #include "SALOME_LifeCycleCORBA.hxx"
33
34 GraphBase::Graph::Graph() :
35            DataNode() {
36   cdebug << "GraphBase::Graph::Graph" << endl ;
37   _GraphNodesSize = 0 ;
38 }
39
40 GraphBase::Graph::Graph( CORBA::ORB_ptr ORB ,
41                          SALOME_NamingService* ptrNamingService ,
42                          const char *DataFlowName ,
43                          const char * DebugFileName ) :
44            DataNode( ORB ,ptrNamingService , DataFlowName ) {
45   Set_prof_debug( ORB , DebugFileName ) ;
46   cdebug << "GraphBase::Graph::Graph( " << DataFlowName << ")" << endl ;
47   _Orb = CORBA::ORB::_duplicate( ORB ) ;
48   _GraphNodesSize = 0 ;
49 }
50
51 GraphBase::Graph::Graph( CORBA::ORB_ptr ORB ,
52                          SALOME_NamingService* ptrNamingService ,
53                          const SALOME_ModuleCatalog::Service& DataFlowService ,
54                          const char *DataFlowComponentName ,
55                          const char *DataFlowInterfaceName ,
56                          const char *DataFlowName ,
57                          const SUPERV::KindOfNode DataFlowkind ,
58                          const SUPERV::SDate DataFlowFirstCreation ,
59                          const SUPERV::SDate DataFlowLastModification ,
60                          const char * DataFlowEditorRelease ,
61                          const char * DataFlowAuthor ,
62                          const char * DataFlowComputer ,
63                          const char * DataFlowComment ,
64                          const char * DebugFileName ) :
65            DataNode( ORB , ptrNamingService , DataFlowService ,
66                      DataFlowName , DataFlowkind ,
67                      DataFlowFirstCreation , DataFlowLastModification  ,
68                      DataFlowEditorRelease , DataFlowAuthor , DataFlowComment ) {
69   _Orb = CORBA::ORB::_duplicate( ORB ) ;
70   _GraphNodesSize = 0 ;
71   Set_prof_debug( ORB , DebugFileName ) ;
72   cdebug_in << "GraphBase::Graph::Graph" << endl ;
73   DataService( ORB , DataFlowService , Graph_prof_debug() , Graph_fdebug() ) ;
74   cdebug_out << "GraphBase::Graph::Graph" << endl ;
75 }
76
77 GraphBase::Graph::~Graph() {
78   cdebug << "GraphBase::Graph::~Graph" << endl ;
79 }
80
81 void GraphBase::Graph::Set_prof_debug( CORBA::ORB_ptr ORB ,
82                                        const char * DebugFileName ) {
83   _Graph_prof_debug = 0 ;
84   if ( DebugFileName ) {
85     _Graph_fdebug = new ofstream( DebugFileName );
86     MESSAGE( endl << "Trace redirected to file " << DebugFileName << endl)
87     SetDebug( ORB , &_Graph_prof_debug , _Graph_fdebug ) ;
88   }
89   cdebug << "GraphBase::Graph::Set_prof_debug redirect Trace to file " << DebugFileName << endl ;
90 }
91
92 GraphBase::SNode * GraphBase::Graph::GetInfo() const {
93   GraphBase::SNode * Info = new GraphBase::SNode ;
94   Info->theComponentName = "" ;
95   Info->theInterfaceName = "" ;
96   Info->theName = Name() ;
97   Info->theKind = Kind() ;
98   Info->theService = *GetService() ;
99   Info->theFirstCreation = FirstCreation() ;
100   Info->theLastModification = LastModification() ;
101   Info->theEditorRelease = EditorRelease() ;
102   Info->theAuthor = Author() ;
103   Info->theContainer = "" ;
104   Info->theComment = Comment() ;
105   Info->theCoords.theX = GraphBase::ComputingNode::XCoordinate() ;
106   Info->theCoords.theY = GraphBase::ComputingNode::YCoordinate() ;
107   return Info ;
108 }
109
110 //----------------------------------------------------------------------
111 // Function : GetNodes
112 // Purpose  : get a nodes list
113 //----------------------------------------------------------------------
114 GraphBase::ListOfNodes * GraphBase::Graph::GetNodes() const {
115   GraphBase::ListOfNodes * _list_nodes = 
116                                   new GraphBase::ListOfNodes;
117
118   // All the nodes from _InNodes are taken
119 //  vector< InNode *> Nodes = InNodes() ;
120
121   _list_nodes->resize( GraphNodesSize() );
122
123   int igoto ;
124   int ind ;
125   GraphBase::ComputingNode * aCNode = NULL ;
126   for ( igoto = 0 ; igoto < 2 ; igoto++ ) {
127     for ( ind = 0 ; ind < GraphNodesSize() ; ind++ ) {
128       aCNode = GraphNodes( ind ) ;
129       if ( ( igoto == 0 && !aCNode->IsGOTONode() ) ||
130            ( igoto == 1 && aCNode->IsGOTONode() ) ) {
131         if ( aCNode->IsFactoryNode() ) {
132           GraphBase::FactoryNode * aFNode = (GraphBase::FactoryNode * ) aCNode ;
133           (*_list_nodes)[ind].theComponentName = CORBA::string_dup( aFNode->ComponentName());
134           (*_list_nodes)[ind].theInterfaceName = CORBA::string_dup( aFNode->InterfaceName());
135         }
136         else {
137           (*_list_nodes)[ind].theComponentName = CORBA::string_dup( "" );
138           (*_list_nodes)[ind].theInterfaceName = CORBA::string_dup( "" );
139         }
140         (*_list_nodes)[ind].theName = CORBA::string_dup( aCNode->Name() );
141         (*_list_nodes)[ind].theKind = aCNode->Kind();
142         if ( aCNode->IsInLineNode() ) {
143           GraphBase::InLineNode * aINode = (GraphBase::InLineNode * ) aCNode ;
144           (*_list_nodes)[ind].theListOfFuncName.resize( 1 ) ;
145           (*_list_nodes)[ind].theListOfFuncName[0] = CORBA::string_dup( aINode->PyFuncName() ) ;
146           (*_list_nodes)[ind].theListOfPythonFunctions.resize( 1 ) ;
147           (*_list_nodes)[ind].theListOfPythonFunctions[0] = aINode->PythonFunction() ;
148         }
149         if ( aCNode->IsGOTONode() ) {
150           GraphBase::GOTONode * aGNode = (GraphBase::GOTONode * ) aCNode ;
151           (*_list_nodes)[ind].theListOfFuncName.resize( 1 ) ;
152           (*_list_nodes)[ind].theListOfFuncName[0] = CORBA::string_dup( aGNode->PyFuncName() ) ;
153           (*_list_nodes)[ind].theListOfPythonFunctions.resize( 1 ) ;
154           (*_list_nodes)[ind].theListOfPythonFunctions[0] = aGNode->PythonFunction() ;
155         }
156         if ( aCNode->IsLoopNode() ) {
157           GraphBase::LoopNode * aLNode = (GraphBase::LoopNode * ) aCNode ;
158           (*_list_nodes)[ind].theCoupledNode = CORBA::string_dup( aLNode->CoupledNode()->Name() ) ;
159           (*_list_nodes)[ind].theListOfFuncName.resize( 3 ) ;
160           (*_list_nodes)[ind].theListOfFuncName[0] = CORBA::string_dup( aLNode->PyFuncName() ) ;
161           (*_list_nodes)[ind].theListOfFuncName[1] = CORBA::string_dup( aLNode->PyMoreName() ) ;
162           (*_list_nodes)[ind].theListOfFuncName[2] = CORBA::string_dup( aLNode->PyNextName() ) ;
163           (*_list_nodes)[ind].theListOfPythonFunctions.resize( 3 ) ;
164           (*_list_nodes)[ind].theListOfPythonFunctions[0] = aLNode->PythonFunction() ;
165           (*_list_nodes)[ind].theListOfPythonFunctions[1] = aLNode->MorePythonFunction() ;
166           (*_list_nodes)[ind].theListOfPythonFunctions[2] = aLNode->NextPythonFunction() ;
167         }
168         else if ( aCNode->IsSwitchNode() ) {
169           GraphBase::SwitchNode * aSNode = (GraphBase::SwitchNode * ) aCNode ;
170           (*_list_nodes)[ind].theCoupledNode = CORBA::string_dup( aSNode->CoupledNode()->Name() ) ;
171           (*_list_nodes)[ind].theListOfFuncName.resize( 1 ) ;
172           (*_list_nodes)[ind].theListOfFuncName[0] = CORBA::string_dup( aSNode->PyFuncName() ) ;
173           (*_list_nodes)[ind].theListOfPythonFunctions.resize( 1 ) ;
174           (*_list_nodes)[ind].theListOfPythonFunctions[0] = aSNode->PythonFunction() ;
175         }
176         else if ( aCNode->IsEndLoopNode() ) {
177           GraphBase::EndOfLoopNode * aELNode = (GraphBase::EndOfLoopNode * ) aCNode ;
178           (*_list_nodes)[ind].theCoupledNode = CORBA::string_dup( aELNode->CoupledNode()->Name() ) ;
179           (*_list_nodes)[ind].theListOfFuncName.resize( 1 ) ;
180           (*_list_nodes)[ind].theListOfFuncName[0] = CORBA::string_dup( aELNode->PyFuncName() ) ;
181           (*_list_nodes)[ind].theListOfPythonFunctions.resize( 1 ) ;
182           (*_list_nodes)[ind].theListOfPythonFunctions[0] = aELNode->PythonFunction() ;
183         }
184         else if ( aCNode->IsEndSwitchNode() ) {
185           GraphBase::EndOfSwitchNode * aESNode = (GraphBase::EndOfSwitchNode * ) aCNode ;
186           (*_list_nodes)[ind].theCoupledNode = CORBA::string_dup( aESNode->CoupledNode()->Name() ) ;
187           (*_list_nodes)[ind].theListOfFuncName.resize( 1 ) ;
188           (*_list_nodes)[ind].theListOfFuncName[0] = CORBA::string_dup( aESNode->PyFuncName() ) ;
189           (*_list_nodes)[ind].theListOfPythonFunctions.resize( 1 ) ;
190           (*_list_nodes)[ind].theListOfPythonFunctions[0] = aESNode->PythonFunction() ;
191         }
192         else {
193           (*_list_nodes)[ind].theCoupledNode = CORBA::string_dup( "" ) ;
194         }
195         (*_list_nodes)[ind].theDataStreamInArgsNumber = aCNode->DataStreamInPortsNumber() ;
196         (*_list_nodes)[ind].theDataStreamOutArgsNumber = aCNode->DataStreamOutPortsNumber() ;
197         (*_list_nodes)[ind].theService = *aCNode->GetService();
198 //        (*_list_nodes)[ind].theListOfParameters = *aCNode->GetListOfParameters() ;
199         if ( aCNode->IsOneOfInLineNodes() ) {
200           GraphBase::InLineNode * aINode = (GraphBase::InLineNode * ) aCNode ;
201           GraphBase::LoopNode * aLNode = NULL ;
202           if ( aCNode->IsLoopNode() ) {
203             aLNode = (GraphBase::LoopNode * ) aCNode ;
204             (*_list_nodes)[ind].theListOfPythonFunctions.resize( 3 ) ;
205             (*_list_nodes)[ind].theListOfPythonFunctions[ 0 ] = aINode->PythonFunction() ;
206             (*_list_nodes)[ind].theListOfPythonFunctions[ 1 ] = aLNode->MorePythonFunction() ;
207             (*_list_nodes)[ind].theListOfPythonFunctions[ 2 ] = aLNode->NextPythonFunction() ;
208           }
209           else if ( aCNode->IsInLineNode() || aCNode->IsGOTONode() ||
210                     aCNode->IsSwitchNode() || aCNode->IsEndSwitchNode() ) {
211             (*_list_nodes)[ind].theListOfPythonFunctions.resize( 1 ) ;
212             (*_list_nodes)[ind].theListOfPythonFunctions[ 0 ] = aINode->PythonFunction() ;
213           }
214         }
215         (*_list_nodes)[ind].theFirstCreation = aCNode->FirstCreation();
216         (*_list_nodes)[ind].theLastModification = aCNode->LastModification();
217         (*_list_nodes)[ind].theEditorRelease = CORBA::string_dup( aCNode->EditorRelease());
218         (*_list_nodes)[ind].theAuthor = CORBA::string_dup( aCNode->Author());
219         if ( aCNode->IsFactoryNode() ) {
220           GraphBase::FactoryNode * aFNode = (GraphBase::FactoryNode * ) aCNode ;
221           (*_list_nodes)[ind].theContainer = CORBA::string_dup( aFNode->Computer());
222         }
223         else {
224           (*_list_nodes)[ind].theContainer = CORBA::string_dup( "" );
225         }
226         (*_list_nodes)[ind].theComment = CORBA::string_dup( aCNode->Comment());
227         (*_list_nodes)[ind].theCoords.theX = aCNode->XCoordinate();
228         (*_list_nodes)[ind].theCoords.theY = aCNode->YCoordinate();
229 #if 0
230         int nports = 0 ;
231         int i ;
232         for ( i = 0 ; i < aCNode->GetNodeInPortsSize() ; i++ ) {
233           const GraphBase::InPort * anInPort = aCNode->GetNodeInPort( i ) ;
234           if ( anInPort->IsBus() ) {
235             nports += 1 ;
236             (*_list_nodes)[ind].theListOfParameters.resize( nports ) ;
237             (*_list_nodes)[ind].theListOfParameters[ nports-1 ].theInParameter.Parametertype = CORBA::string_dup( anInPort->PortType() ) ;
238             (*_list_nodes)[ind].theListOfParameters[ nports-1 ].theInParameter.Parametername = CORBA::string_dup( anInPort->PortName() ) ;
239             (*_list_nodes)[ind].theListOfParameters[ nports-1 ].theOutParameter.Parametertype = CORBA::string_dup( aCNode->GetNodeOutPort( anInPort->PortIndex() )->PortType() ) ;
240             (*_list_nodes)[ind].theListOfParameters[ nports-1 ].theOutParameter.Parametername = CORBA::string_dup( aCNode->GetNodeOutPort( anInPort->PortIndex() )->PortName() ) ;
241           }
242         }
243 #endif
244       }
245     }
246   }
247   return _list_nodes ;
248 }
249
250
251 //----------------------------------------------------------------------
252 // Function : GetLinks
253 // Purpose  : get a links list
254 //----------------------------------------------------------------------
255 GraphBase::ListOfLinks * GraphBase::Graph::GetLinks(bool AllLinks ) const {
256   GraphBase::ListOfLinks * _list_links = 
257                                new GraphBase::ListOfLinks;
258
259 // All the links from _LinksList are taken
260 //  vector< InNode *> Nodes = InNodes() ;
261
262   int ind = 0 ;
263   int k ;
264   for ( k = 0 ; k < GraphNodesSize() ; k++ ) {
265     GraphBase::ComputingNode * fromNode = GraphNodes( k ) ;
266     int i ;
267     for ( i = 0 ; i < fromNode->GetNodeOutPortsSize() ; i++ ) {
268       const GraphBase::OutPort* fromPort = fromNode->GetNodeOutPort( i ) ;
269 //      if ( fromPort->IsPortConnected() && ( !fromPort->IsLoop() || AllLinks ) ) {
270         int j ;
271         for ( j = 0 ; j < fromPort->InPortsSize() ; j++ ) {
272           const GraphBase::InPort* toPort = fromPort->InPorts( j ) ;
273 // Desole pour ce cast mais avec les maps difficile de faire const ...
274           const GraphBase::ComputingNode * toNode = ((GraphBase::Graph * ) this)->GetGraphNode( toPort->NodeName() ) ;
275           if ( !(fromPort->IsLoop() && toPort->IsLoop() ) || AllLinks ) {
276             cdebug << "GraphBase::Graph::GetLinks " << fromNode->Name() << " ("
277                    << fromPort->PortName() << " ) IsPortConnected" << fromPort->IsPortConnected()
278                    << " --> " << toNode->Name() << "( " << toPort->PortName() << " ) "
279                    << " " << fromPort->InPortsSize() << " ports" << endl ;
280             _list_links->resize( ind+1 );
281             (*_list_links)[ind].FromNodeName = CORBA::string_dup( fromNode->Name() );
282             (*_list_links)[ind].FromServiceParameterName = fromPort->GetServicesParameter().Parametername;
283             (*_list_links)[ind].ToNodeName = CORBA::string_dup( toPort->NodeName() );
284             (*_list_links)[ind].ToServiceParameterName = toPort->GetServicesParameter().Parametername;
285             (*_list_links)[ind].aLinkValue = *fromPort->Value() ;
286             if ( toPort->IsEndSwitch() ) {
287               (*_list_links)[ind++].aListOfCoords = *(fromPort->Coords()) ;
288             }
289             else {
290               (*_list_links)[ind++].aListOfCoords = *(toPort->Coords()) ;
291             }
292           }
293           else {
294             cdebug << "GraphBase::Graph::GetLinks " << fromNode->Name() << " "
295                    << fromPort->PortName() << " ) IsPortConnected" << fromPort->IsPortConnected()
296                    << " --> " << toNode->Name() << "( " << toPort->PortName() << " ) "
297                    << " " << fromPort->InPortsSize() << " ports ignored" << endl ;
298           }
299         }
300 //      }
301     }
302   }
303
304   return _list_links;
305 }
306
307 GraphBase::ListOfGraphs * GraphBase::Graph::GetGraphs() const {
308   GraphBase::ListOfGraphs * _list_graphs = 
309                                new GraphBase::ListOfGraphs;
310
311   return _list_graphs;
312 }
313
314 GraphBase::SLink * GraphBase::Graph::GetLink( GraphBase::ComputingNode * aNode ,
315                                               GraphBase::InPort* toPort ) {
316   GraphBase::SLink * _link =  new GraphBase::SLink ;
317   GraphBase::OutPort* fromPort = toPort->GetOutPort() ;
318   _link->FromNodeName = CORBA::string_dup( fromPort->NodeName() );
319   _link->FromServiceParameterName = fromPort->GetServicesParameter().Parametername;
320   _link->ToNodeName = CORBA::string_dup( toPort->NodeName() );
321   _link->ToServiceParameterName = toPort->GetServicesParameter().Parametername;
322   CORBA::Any aSPValue = *fromPort->Value() ;
323   _link->aLinkValue = aSPValue;
324   _link->aListOfCoords = *(toPort->Coords()) ;
325   return _link;
326 }
327 //----------------------------------------------------------------------
328 // Function : GetDatas
329 // Purpose  : get the datas list
330 //----------------------------------------------------------------------
331 GraphBase::ListOfLinks * GraphBase::Graph::GetDatas() const {
332   GraphBase::ListOfLinks * _list_datalinks = 
333                                new GraphBase::ListOfLinks;
334
335   int ind = 0 ;
336   const GraphBase::DataNode * aDataNode = this ;
337   int i ;
338   for ( i = 0 ; i < aDataNode->GetNodeInDataNodePortsSize() ; i++ ) {
339     const GraphBase::OutPort* fromDataPort = aDataNode->GetNodeInDataNodePort( i ) ;
340     if ( fromDataPort->IsDataConnected() ) {
341       int j ;
342 //We may have SharedData as input of a DataFlow : same input for one or several
343 // input ports. Input(s) of a DataFlow match one or several output-virtual-dataport
344       for ( j = 0 ; j < fromDataPort->InPortsSize() ; j++ ) {
345         _list_datalinks->resize( ind+1 );
346         (*_list_datalinks)[ind].FromNodeName = CORBA::string_dup( aDataNode->Name() );
347         (*_list_datalinks)[ind].FromServiceParameterName = fromDataPort->GetServicesParameter().Parametername;
348         const GraphBase::InPort* toPort = fromDataPort->InPorts( j ) ;
349         (*_list_datalinks)[ind].ToNodeName = CORBA::string_dup( toPort->NodeName() );
350         (*_list_datalinks)[ind].ToServiceParameterName = toPort->GetServicesParameter().Parametername;
351           CORBA::Any aSPValue = *fromDataPort->Value() ;
352         (*_list_datalinks)[ind].aLinkValue = aSPValue;
353         (*_list_datalinks)[ind++].aListOfCoords = *(toPort->Coords()) ;
354       }
355     }
356   }
357
358 #if 0
359 // Output(s) of a DataFlow match only one input-virtual-dataport
360   for ( i = 0 ; i < aDataNode->GetNodeOutDataNodePortsSize() ; i++ ) {
361     GraphBase::InPort* toDataPort = aDataNode->GetChangeNodeOutDataNodePort( i ) ;
362     const GraphBase::OutPort* fromPort = toDataPort->GetLink() ;
363     if ( fromPort->IsDataConnected() ) {
364       _list_datalinks->length( ind+1 );
365       _list_datalinks[ind].FromNodeName = CORBA::string_dup( fromPort->NodeName() );
366       _list_datalinks[ind].FromServiceParameterName = fromPort->GetServicesParameter().Parametername;
367       _list_datalinks[ind].ToNodeName = CORBA::string_dup( aDataNode->Name() );
368       _list_datalinks[ind].ToServiceParameterName = toDataPort->GetServicesParameter().Parametername;
369 //      SALOME_SuperVisionBase::ServicesParameterValue aSPValue;
370           CORBA::Any aSPValue = *fromPort->Value() ;
371 //      aSPValue.Value = CORBA::string_dup( fromPort->Value() );
372 //      aSPValue.Kind = fromPort->Kind();
373       _list_datalinks[ind].aLinkValue = aSPValue;
374       _list_datalinks[ind++].aListOfCoords = toDataPort->Coords() ;
375     }
376   }
377 #endif
378
379   return _list_datalinks ;
380 }
381
382 bool GraphBase::Graph::AddNode( GraphBase::ComputingNode * aNode ) {
383   cdebug_in << "GraphBase::Graph::AddNode "  << (void *) aNode << " "
384             << aNode->Name() << " " << aNode->ServiceName() << endl;
385   bool RetVal = false ;
386   int index = GetGraphNodeIndex( aNode->Name() ) ;
387   if ( index < 0 ) {
388     _GraphNodes.resize( _GraphNodesSize+1 ) ;
389     _GraphNodes[ _GraphNodesSize ] = aNode ;
390     SetGraphNodeIndex( aNode->Name() , _GraphNodesSize ) ;
391     _GraphNodesSize += 1 ;
392     RetVal = true ;
393   }
394 //  cout << "GraphBase::Graph::AddNode(" << aNode->ComponentName() << " , "
395 //       << aNode->Name() << ")" << endl;
396   int i ;
397   cdebug << "GraphBase::Graph::AddNode Known nodes :" << endl ;
398   for ( i = 0 ; i < _GraphNodesSize ; i++ ) {
399     cdebug << i << ". " << GetGraphNode( i )->Name() << " "
400            << _MapOfGraphNodes[ GetGraphNode( i )->Name() ] - 1 << endl ;
401   }
402   cdebug_out << "GraphBase::Graph::AddNode " << _GraphNodesSize << " Nodes. "
403              << aNode->ServiceName() << endl;
404   return RetVal ;
405 }
406
407 bool GraphBase::Graph::ReNameNode( const char* OldNodeName ,
408                                    const char* NewNodeName ) {
409   cdebug_in << "GraphBase::Graph::ReNameNode (" << OldNodeName << " , "
410             << NewNodeName << ")" << endl;
411   int i ;
412   bool RetVal = false ;
413   if ( !strcmp( OldNodeName , NewNodeName ) ) {
414     RetVal = true ;
415   }
416   else if ( strcmp( Name() , OldNodeName ) ) {
417     int index = GetGraphNodeIndex( OldNodeName ) ;
418     int newindex = GetGraphNodeIndex( NewNodeName ) ;
419     if ( index >= 0 && index < _GraphNodesSize &&
420          ( newindex < 0 || newindex > _GraphNodesSize ) ) {
421       _GraphNodes[ index ]->Name( NewNodeName ) ;
422       _MapOfGraphNodes.erase( OldNodeName ) ;
423       SetGraphNodeIndex( NewNodeName , index ) ;
424
425       GraphBase::ComputingNode * aNode = GetChangeGraphNode( index ) ;
426       for ( i = aNode->GetNodeInPortsSize()-1 ; i >= 0 ; i-- ) {
427         cdebug << i << ". GraphBase::Graph::ReNameNode of LinkedNode : from " ;
428         GraphBase::InPort * anInPort = aNode->GetChangeNodeInPort( i ) ;
429         GraphBase::OutPort * anOutPort = anInPort->GetOutPort() ;
430         if ( anOutPort ) {
431           cdebug << anOutPort->NodeName() ;
432         }
433         else {
434           cdebug << "without link" ;
435         }
436         cdebug << " to " << i << ". " << anInPort->PortName()
437                << " of " << NewNodeName ;
438         if ( anInPort->IsConnected() ) {
439           if ( anOutPort->IsDataConnected() ) {
440             cdebug << " fromDataConnected "
441                    << anOutPort->NodeName()
442                    << endl ;
443           }
444           else {
445             GraphBase::ComputingNode * FromNode = GetChangeGraphNode( anOutPort->NodeName() ) ;
446             cdebug << " fromConnected " << FromNode->Name() << endl ;
447             FromNode->ReNameLink( OldNodeName , NewNodeName ) ;
448           }
449           char* OldNodePortName = new char[ strlen( OldNodeName ) +
450                                             strlen( aNode->GetChangeNodeInPort( i )->PortName() ) + 2 ] ;
451           char* NewNodePortName = new char[ strlen( NewNodeName ) +
452                                             strlen( aNode->GetChangeNodeInPort( i )->PortName() ) + 2 ] ;
453           strcpy( OldNodePortName , OldNodeName ) ;
454           strcat( OldNodePortName , "\\" ) ;
455           strcat( OldNodePortName , aNode->GetChangeNodeInPort( i )->PortName() ) ;
456           strcpy( NewNodePortName , NewNodeName ) ;
457           strcat( NewNodePortName , "\\" ) ;
458           strcat( NewNodePortName , aNode->GetChangeNodeInPort( i )->PortName() ) ;
459           RetVal = anOutPort->ReNameInPort( OldNodePortName , NewNodePortName ) ;
460           delete [] OldNodePortName ;
461           delete [] NewNodePortName ;
462           if ( !RetVal )
463             break ;
464         }
465         else {
466           cdebug << " not connected" << endl ;
467           RetVal = true ;
468         }
469       }
470       RetVal = true ;
471     }
472     else {
473       cdebug << "Node not found" << endl ;
474     }
475   }
476   else {
477     RetVal = Name( NewNodeName ) ;
478   }
479
480   cdebug_out << "GraphBase::Graph::ReNameNode" << endl;
481   return RetVal ;
482 }
483
484 bool GraphBase::Graph::RemoveNode( const char* aNodeName ) {
485   cdebug_in << "GraphBase::Graph::RemoveNode (" << aNodeName << ")" << endl;
486   int i ;
487   bool RetVal = false ;
488   int index = GetGraphNodeIndex( aNodeName ) ;
489   GraphBase::ComputingNode * aNode = GetChangeGraphNode( index ) ;
490   if ( aNode ) {
491     if ( aNode->GetNodeInPortsSize() ) {
492       for ( i = aNode->GetNodeInPortsSize()-1 ; i >= 0 ; i-- ) {
493         cdebug << i << ". GraphBase::Graph::RemoveNode of LinkedNode : from " ;
494         GraphBase::InPort * anInPort = aNode->GetChangeNodeInPort( i ) ;
495         GraphBase::OutPort * anOutPort = anInPort->GetOutPort() ;
496         if ( anOutPort ) {
497           cdebug << anOutPort->NodeName() ;
498         }
499         else {
500           cdebug << "without link" ;
501         }
502         cdebug << " to " << i << ". " << anInPort->PortName()
503                << " of " << aNodeName ;
504         if ( anInPort->IsConnected() ) {
505           if ( anOutPort->IsDataConnected() ) {
506             cdebug << " fromDataConnected " << anOutPort->NodeName() << endl ;
507           }
508           else {
509             GraphBase::ComputingNode * FromNode = GetChangeGraphNode( anOutPort->NodeName() ) ;
510             cdebug << " fromConnected " << FromNode->Name() << endl ;
511             FromNode->RemoveLink( aNode ) ;
512           }
513           RetVal = anOutPort->RemoveInPort( anInPort ) ;
514           if ( !RetVal )
515             break ;
516         }
517         else {
518           cdebug << " not connected" << endl ;
519           RetVal = true ;
520         }
521       }
522     }
523     else {
524       RetVal = true ;
525     }
526     if ( RetVal ) {
527       for ( i = aNode->GetNodeOutPortsSize() - 1 ; i >= 0 ; i-- ) {
528         GraphBase::OutPort * anOutPort = aNode->GetChangeNodeOutPort( i ) ;
529         cdebug << "GraphBase::Graph::Remove " <<anOutPort->InPortsSize()
530                << " Links of OutPort : " << i << ". "
531                << *aNode->GetChangeNodeOutPort( i ) ;
532         int j ;
533         for ( j = anOutPort->InPortsSize() - 1 ; j >= 0  ; j-- ) {
534           cdebug << "       to " << j << ". " << *anOutPort->InPorts( j )
535                  << endl ;
536           RetVal = anOutPort->ChangeInPorts( j )->RemoveOutPort() ;
537           if ( !RetVal )
538             break ;
539           GraphBase::ComputingNode * ToNode = GetChangeGraphNode( anOutPort->InPorts( j )->NodeName() ) ;
540           aNode->RemoveLink( ToNode ) ;
541           RetVal = anOutPort->RemoveInPort( anOutPort->ChangeInPorts( j ) ) ;
542           if ( !RetVal )
543             break ;
544         }
545 //        RetVal = aNode->GetChangeNodeOutPort( j )->RemoveLinks() ;
546         if ( !RetVal )
547           break ;
548       }
549     }
550 //    RetVal = aNode->RemoveLinks() ; // In PortsOfNode
551 //    if ( RetVal ) {
552 //      if ( aNode->IsLoopNode() || aNode->IsEndLoopNode() || aNode->IsSwitchNode() || aNode->IsEndSwitchNode() ) {
553 //        GraphBase::InLineNode * anInLineNode =  ((GraphBase::GOTONode * ) aNode)->CoupledNode() ;
554 //        if ( anInLineNode ) {
555 //          RetVal = RemoveNode( anInLineNode->Name() ) ;
556 //        }
557 //      }
558 //    }
559     if ( RetVal ) {
560       delete aNode ;
561       _GraphNodesSize -= 1 ;
562       for ( i = index ; i < _GraphNodesSize ; i++ ) {
563         SetGraphNodeIndex( _GraphNodes[ i+1 ]->Name() , i ) ;
564         _GraphNodes[ i ] = _GraphNodes[ i+1 ] ;
565       }
566       _GraphNodes.resize( _GraphNodesSize+1 ) ;
567       _MapOfGraphNodes.erase( aNodeName ) ;
568       RetVal = true ;
569     }
570   }
571   else {
572     cdebug << "Node not found" << endl ;
573   }
574
575   cdebug_out << "GraphBase::Graph::RemoveNode" << endl;
576   return RetVal ;
577 }
578
579 bool GraphBase::Graph::AddLink( const char* FromNodeName ,
580                                 const char* FromServiceParameterName ,
581                                 const char* ToNodeName ,
582                                 const char* ToServiceParameterName ,
583                                 const CORBA::Any aValue ) {
584   bool RetVal ;
585 //  int index ;
586   cdebug_in << "GraphBase::Graph::AddLink(" << FromNodeName << "("
587             << FromServiceParameterName << ") ---> " << ToNodeName << "("
588             << ToServiceParameterName << ") )" << endl;
589
590   GraphBase::ComputingNode *fromNode = GetChangeGraphNode( FromNodeName ) ;
591   GraphBase::ComputingNode *toNode = GetChangeGraphNode( ToNodeName ) ;
592
593   GraphBase::OutPort *fromPort = NULL ;
594   GraphBase::InPort *toPort = NULL ;
595
596   if ( fromNode ) {
597     fromPort = fromNode->GetChangeOutPort( FromServiceParameterName ) ;
598     if ( !fromPort ) {
599       cdebug << "AddLink fromPort " << FromServiceParameterName << " FromNode("
600            << FromNodeName << ") not found." << endl ;
601     }
602   }
603   else {
604     cdebug << "AddLink FromNode " << FromNodeName << " not found." << endl ;
605   }
606   if ( toNode ) {
607     toPort = toNode->GetChangeInPort( ToServiceParameterName ) ;
608     if ( !toPort ) {
609       cdebug << "AddLink toPort " << ToServiceParameterName << " ToNode("
610              << ToNodeName << ") not found." << endl ;
611     }
612   }
613   else {
614     cdebug << "AddLink toNode " << ToNodeName << " not found." << endl ;
615   }
616
617   RetVal = AddLink( fromNode , fromPort , toNode , toPort ) ;
618
619   if ( RetVal ) {
620     if ( fromPort->IsGate() && toPort->IsGate() ) {
621       CORBA::Any aValue ;
622       aValue <<= (long ) 1 ;
623       fromPort->Value( aValue ) ;
624     }
625     else {
626       const CORBA::Any * aDataValue = new CORBA::Any( aValue ) ;
627       fromPort->Value( aDataValue ) ;
628     }
629   }
630
631   cdebug_out << "GraphBase::Graph::AddLink" << endl;
632   return RetVal ;
633 }
634
635 bool GraphBase::Graph::AddLink( GraphBase::ComputingNode *fromNode ,
636                                 GraphBase::OutPort *fromPort ,
637                                 GraphBase::ComputingNode *toNode ,
638                                 GraphBase::InPort *toPort ) {
639 //  bool RetVal ;
640
641   if ( !fromNode ) {
642     cdebug << "AddLink fromNode not found." << endl ;
643     return false ;
644   }
645   if ( !fromPort ) {
646     cdebug << "AddLink fromPort not found." << endl ;
647     return false ;
648   }
649
650   if ( !toNode ) {
651     cdebug << "AddLink toNode not found." << endl ;
652     return false ;
653   }
654   if ( !toPort ) {
655     cdebug << "AddLink toPort not found." << endl ;
656     return false ;
657   }
658
659   cdebug_in << "GraphBase::Graph::AddLink(" << fromNode->Name() << "("
660             << fromPort->PortName() << ") ---> " << toNode->Name() << "("
661             << toPort->PortName() << ") )" << endl;
662   if ( !fromNode->IsDataFlowNode() && !toNode->IsDataFlowNode() &&
663        toPort->GetOutPort() ) {
664     if ( !strcmp( toPort->GetOutPort()->NodePortName() ,
665                   fromPort->NodePortName() ) ) {
666       cdebug << "Link already exists" << endl ;
667       cdebug_out << "GraphBase::Graph::AddLink" << endl;
668       return true ;
669     }
670     else if ( toPort->IsDataConnected() ) {
671       toPort->RemoveOutPort() ;
672     }
673     else if ( fromNode->IsGOTONode() ) {
674       if ( !RemoveLink( toPort->GetOutPort()->NodeName() ,
675                         toPort->GetOutPort()->PortName() ,
676                         toNode->Name() , toPort->PortName() ) ) {
677         cdebug << "RemoveLink(AddLink) toPort->GetOutPort()->NodeName() Error."
678                << endl ;
679         cdebug_out << "GraphBase::Graph::AddLink" << endl;
680         return false ;
681       }
682       if ( fromPort->InPortsSize() ) {
683         if ( !RemoveLink( fromNode->Name() , fromPort->PortName() ,
684                           fromPort->ChangeInPorts(0)->NodeName() ,
685                           fromPort->ChangeInPorts(0)->PortName() ) ) {
686           cdebug << "RemoveLink(AddLink) fromNode->IsGOTONode Error." << endl ;
687           cdebug_out << "GraphBase::Graph::AddLink" << endl;
688           return false ;
689         }
690       }
691     }
692     else if ( !toNode->IsEndSwitchNode() ||
693               ( toNode->IsEndSwitchNode() && toPort->IsGate() ) ) {
694       if ( !RemoveLink( fromNode->Name() , fromPort->PortName() ,
695                         toNode->Name() , toPort->PortName() ) ) {
696         cdebug << "RemoveLink(AddLink) toNode->IsEndSwitchNode Error." << endl ;
697         cdebug_out << "GraphBase::Graph::AddLink" << endl;
698         return false ;
699       }
700     }
701   }
702   else if ( fromNode->IsGOTONode() && fromPort->InPortsSize() ) {
703     if ( !RemoveLink( fromNode->Name() , fromPort->PortName() ,
704                       fromPort->ChangeInPorts(0)->NodeName() ,
705                       fromPort->ChangeInPorts(0)->PortName() ) ) {
706       cdebug << "RemoveLink(AddLink) fromNode->IsGOTONode Error." << endl ;
707       cdebug_out << "GraphBase::Graph::AddLink" << endl;
708       return false ;
709     }
710   }
711
712   if ( toNode->IsEndSwitchNode() && !toPort->IsGate() ) {
713 //    if ( !toPort->IsEndSwitch() || !fromPort->AddInPort( toPort ) ) {
714     if ( !fromPort->AddInPort( toPort ) ) {
715       cdebug << "toNode->IsEndSwitchNode() : !fromPort->AddInPort( toPort ) AddLink Error."
716              << endl ;
717       cdebug_out << "GraphBase::Graph::AddLink" << endl;
718       return false ;
719     }
720     toPort->Kind( SUPERV::EndSwitchParameter ) ;
721   }
722   else if ( !fromPort->AddInPort( toPort ) ) { // --> MapOfInports in the OutPort
723     cdebug << "!fromPort->AddLink Error." << endl ;
724     cdebug_out << "GraphBase::Graph::AddLink" << endl;
725     return false ;
726   }
727
728   if ( fromNode->IsDataFlowNode() && toPort->IsDataConnected() ) {
729     toPort->RemoveOutPort() ;
730   }
731
732   if ( fromNode->IsGOTONode() && ( !fromPort->IsGate() || !toPort->IsGate() ||
733        toNode->IsEndLoopNode() || toNode->IsEndSwitchNode() ) ) {
734     cdebug << "toPort->AddLink Error( fromNode->IsGOTONode() && toNode->IsEndInLineNode() )." << endl ;
735     cdebug_out << "GraphBase::Graph::AddLink" << endl;
736     return false ;
737   }
738   else if ( !fromNode->IsSwitchNode() && fromPort->IsParam() && toPort->IsGate() ) {
739     cdebug << "toPort->AddLink Error( fromPort->IsParam() && toPort->IsGate())." << endl ;
740     cdebug_out << "GraphBase::Graph::AddLink" << endl;
741     return false ;
742   }
743   else if ( !toNode->IsEndSwitchNode() && !toNode->IsEndLoopNode() ) {
744     if ( !toPort->AddOutPort( fromPort ) ) { // --> Unique OutPort of the InPort
745       cdebug << "toPort->AddLink Error." << endl ;
746       cdebug_out << "GraphBase::Graph::AddLink" << endl;
747       return false ;
748     }
749   }
750   else {
751     toPort->AddOutPort( fromPort ) ;
752   }
753
754   if ( ( fromNode->IsGOTONode() && toNode->IsOneOfInLineNodes() ) ||
755        ( fromNode->IsEndLoopNode() && toNode->IsLoopNode() ) ) {
756     cdebug << "AddLink fromPort->PortStatus( PortConnected ) "
757            << "GOTONode/EndLoopNode-->InLineNode/LoopNode/SwitchNode "
758            << fromNode->Name() << " " << fromPort->PortName()
759            << " InLineNode/LoopNode_ConnectedInPortsNumber "
760            << toNode->ConnectedInPortsNumber() << endl;
761     if ( fromNode->IsGOTONode() ) {
762       fromPort->Kind( SUPERV::GOTOParameter ) ;
763     }
764     fromPort->PortStatus( PortConnected ); // GOTO - Loop
765   }
766   else if ( fromNode->IsDataFlowNode() || toNode->IsDataFlowNode() ) {
767     cdebug << "AddLink IsDataFlowNode fromPort->PortStatus( DataConnected ) "
768            << fromNode->Name() << " " << fromPort->PortName() << endl ;
769     fromPort->PortStatus( DataConnected );
770   }
771   else {
772     cdebug << "AddLink fromPort->PortStatus( PortConnected ) & fromNode->toNode "
773            << fromNode->Name() << " " << fromPort->PortName() << " "
774            << fromPort->Kind() << " -> " << toNode->Name() << " " << " "
775            << toPort->PortName() << " " << toPort->Kind() << endl;
776     fromPort->PortStatus( PortConnected );
777     if ( !fromPort->IsDataStream() && !toPort->IsDataStream() ) {
778       fromNode->AddLink( toNode ) ;
779     }
780   }
781   if ( fromNode->IsSwitchNode() ) {
782     if ( fromPort->IsInLine() && toPort->IsGate() && !toNode->IsEndSwitchNode() ) {
783       fromPort->Kind( SUPERV::SwitchParameter ) ;
784     }
785     else if ( !fromPort->IsGate() && !toPort->IsGate() ){
786       fromPort->Kind( SUPERV::InLineParameter ) ;
787     }
788     if ( fromPort->IsGate() && !toNode->IsEndSwitchNode() ) {
789       GraphBase::InLineNode * anEndSwitchNode ;
790       anEndSwitchNode = ((GraphBase::SwitchNode * ) fromNode)->CoupledNode() ;
791       GraphBase::InPort * anInPort = anEndSwitchNode->GetChangeNodeInGate() ;
792       GraphBase::OutPort * anOutPort = anInPort->GetOutPort() ;
793       if ( anOutPort && !strcmp( fromNode->Name() , anOutPort->NodeName() ) &&
794            !strcmp( fromPort->PortName() , anOutPort->PortName() ) &&
795            anOutPort->IsGate() ) {
796         if ( !RemoveLink( fromNode->Name() , anOutPort->PortName() ,
797                           anEndSwitchNode->Name() ,
798                           anInPort->PortName() ) ) {
799           cdebug << "AddLink Error Removelink ( Switch , Default , EndSwitch , Default )"
800                  << endl ;
801           cdebug_out << "GraphBase::Graph::AddLink" << endl;
802           return false ;
803         }
804       }
805     }
806   }
807 //  cdebug << fromNode->ServiceName() << " " << toNode->ServiceName() << endl ;
808   cdebug_out << "GraphBase::Graph::AddLink" << endl;
809   return true ;
810 }
811
812 bool GraphBase::Graph::RemoveLink( const char* FromNodeName ,
813                                    const char* FromServiceParameterName ,
814                                    const char* ToNodeName ,
815                                    const char* ToServiceParameterName ) {
816   cdebug_in << "GraphBase::Graph::RemoveLink from " << FromNodeName << "(" << FromServiceParameterName << ")"
817             << " to " << ToNodeName << "(" << ToServiceParameterName << ")" << endl;
818   bool RetVal = false ;
819   GraphBase::ComputingNode * toNode = GetChangeGraphNode( ToNodeName ) ;
820   if ( toNode ) {
821     GraphBase::InPort * anInPort = toNode->GetChangeInPort( ToServiceParameterName ) ;
822     if ( anInPort && ( anInPort->IsConnected() ||
823                        anInPort->IsDataConnected() ) ) {
824       GraphBase::OutPort * anOutPort = anInPort->GetOutPort() ;
825       RetVal = anOutPort->RemoveInPort( anInPort ) ;
826       anInPort->RemoveOutPort() ;
827       const char * FromNodeName = anOutPort->NodeName() ;
828       GraphBase::ComputingNode * fromNode = GetChangeGraphNode( FromNodeName ) ;
829       if ( RetVal ) {
830         if ( fromNode ) {
831           fromNode->RemoveLink( toNode ) ;
832         }
833         if ( fromNode->IsSwitchNode() && !anOutPort->IsGate() && !toNode->IsEndSwitchNode() ) {
834           anOutPort->Kind( SUPERV::InLineParameter ) ;
835         }
836 #if 0
837         if ( fromNode->IsEndLoopNode() ) {
838           toNode = ((GraphBase::EndOfLoopNode * ) fromNode)->CoupledNode() ;
839           if ( toNode ) {
840             anInPort = toNode->GetChangeInPort( ToServiceParameterName ) ;
841             RetVal = AddLink( fromNode , anOutPort , toNode , anInPort ) ;
842           }
843           else {
844             RetVal = false ;
845           }
846         }
847         if ( toNode->IsLoopNode() ) {
848           fromNode = ((GraphBase::LoopNode * ) toNode)->CoupledNode() ;
849           if ( fromNode ) {
850             anOutPort = fromNode->GetChangeOutPort( FromServiceParameterName ) ;
851             RetVal = AddLink( fromNode , anOutPort , toNode , toNode->GetChangeInPort( ToServiceParameterName ) ) ;
852           }
853           else {
854             RetVal = false ;
855           }
856         }
857 #endif
858       }
859     }
860   }
861   cdebug_out << "GraphBase::Graph::RemoveLink " << RetVal << endl;
862   return RetVal ;
863 }
864
865 bool GraphBase::Graph::GetLink(const char* ToNodeName ,
866                                const char* ToServiceParameterName ,
867                                char** FromNodeName ,
868                                char** FromServiceParameterName ) {
869 //  cdebug_in << "GraphBase::Graph::GetLink " << ToNodeName << "("
870 //            << ToServiceParameterName << ")" << endl;
871   bool RetVal = false ;
872   GraphBase::ComputingNode * toNode = GetChangeGraphNode( ToNodeName ) ;
873   if ( toNode ) {
874     GraphBase::InPort * anInPort = toNode->GetChangeInPort( ToServiceParameterName ) ;
875     if ( anInPort && anInPort->IsConnected() ) {
876       GraphBase::OutPort * anOutPort = anInPort->GetOutPort() ;
877       *FromNodeName = my_strdup( anOutPort->NodeName() ) ;
878       *FromServiceParameterName = my_strdup( anOutPort->PortName() ) ;
879       RetVal = true ;
880     }
881     else {
882       cdebug << "GraphEditor::OutNode::GetLink ERROR no InPort or NotConnected " << ToNodeName
883              << " " << ToServiceParameterName << " " << RetVal << endl;
884     }
885   }
886   else {
887     cdebug << "GraphEditor::OutNode::GetLink ERROR no Node " << ToNodeName << " " << RetVal
888            << endl;
889   }
890 //  cdebug_out << "GraphEditor::OutNode::GetLink " << RetVal << endl;
891   return RetVal ;
892 }
893
894 bool GraphBase::Graph::AddInputData( const char* ToNodeName ,
895                                      const char* ToServiceParameterName ,
896                                      const CORBA::Any aValue ) {
897   bool RetVal = false ;
898   cdebug_in << "GraphBase::Graph::AddInputData(" << ToNodeName << ","
899             << ToServiceParameterName << " , Any " ;
900   switch (aValue.type()->kind()) {
901     case CORBA::tk_string:
902       char * t;
903       aValue >>= t;
904       cdebug << t << " (string) " ;
905       break;
906     case CORBA::tk_double:
907       double d;
908       aValue >>= d;
909       cdebug << d << " (double) " ;
910       break;
911     case CORBA::tk_long:
912       long l;
913       aValue >>= l;
914       cdebug << l << " (long) " ;
915       break;
916     case CORBA::tk_objref:
917       cdebug << "(object reference) " ;
918       break;
919     default:
920       cdebug << "(other(tk_string,tk_double,tk_long,tk_objref)) ERROR";
921       break;
922     }
923   cdebug << ")" << endl;
924
925   GraphBase::OutPort *fromDataNodePort = NULL ;
926
927   GraphBase::ComputingNode *toNode ;
928   GraphBase::InPort *toPort ;
929   char *aNode ;
930   char *aPort ;
931   NodePort( ToNodeName , ToServiceParameterName , &aNode , &aPort ) ;
932   toNode = GetChangeGraphNode( aNode ) ;
933   if ( toNode ) {
934     toPort = toNode->GetChangeInPort( aPort ) ;
935     if ( toPort && !toPort->IsDataConnected() ) {
936       toPort->RemoveOutPort() ;
937     }
938   }
939   else {
940     toPort = NULL ;
941   }
942   delete aNode ;
943   delete aPort ;
944
945 #if 0
946   int i ;
947   for ( i = 0 ; i < GetNodeOutDataNodePortsSize() ; i++ ) {
948     cdebug "GraphBase::Graph::AddInputData " << GetNodeOutDataNodePort(i) << endl ;
949   }
950   for ( i = 0 ; i < GetNodeInDataNodePortsSize() ; i++ ) {
951     cdebug "GraphBase::Graph::AddInputData " << GetNodeInDataNodePort(i) << endl ;
952   }
953 #endif
954
955   if ( toNode && toPort ) {
956     fromDataNodePort = GraphBase::DataNode::GetChangeInDataNodePort( toPort->NodePortName() ) ;
957     if ( fromDataNodePort && fromDataNodePort->GetInPort( toPort ) ) {
958       fromDataNodePort->RemoveInPort( toPort ) ;
959     }
960     cdebug << "Try AddLink " << toPort->NodePortName() << " : " << Name() << "( "
961            << fromDataNodePort->PortName() << " ) -->" << toNode->Name() << "( "
962            << toPort->PortName() << " )" << endl ;
963     RetVal = AddLink( (GraphBase::ComputingNode * ) this , fromDataNodePort ,
964                       toNode , toPort ) ;
965     if ( RetVal ) {
966       fromDataNodePort->Value( aValue ) ;
967     }
968   }
969   else {
970     cdebug << "Node not found" << endl ;
971   }
972
973   cdebug_out << "GraphBase::Graph::AddInputData " << RetVal << endl;
974   return RetVal ;
975 }
976
977 bool GraphBase::Graph::ChangeInputData( const char * ToNodeName ,
978                                         const char * ToServiceParameterName ,
979                                         const CORBA::Any aValue ) {
980   bool RetVal = false ;
981   cdebug_in << "GraphBase::Graph::ChangeInputData( '" << ToNodeName << "' , '"
982             << ToServiceParameterName << "' , Any " ;
983   switch (aValue.type()->kind()) {
984     case CORBA::tk_string:
985       char * t;
986       aValue >>= t;
987       cdebug << t << " (string) " ;
988       break;
989     case CORBA::tk_double:
990       double d;
991       aValue >>= d;
992       cdebug << d << " (double) " ;
993       break;
994     case CORBA::tk_long:
995       long l;
996       aValue >>= l;
997       cdebug << l << " (long) " ;
998       break;
999     case CORBA::tk_objref:
1000       cdebug << "(object reference) " ;
1001       break;
1002     default:
1003       cdebug << "(other(tk_string,tk_double,tk_long,tk_objref)) ERROR";
1004       break;
1005     }
1006   cdebug << ")" << endl;
1007
1008   GraphBase::ComputingNode *toNode = GetChangeGraphNode( ToNodeName ) ;
1009
1010   GraphBase::OutPort *fromPort = NULL ;
1011   GraphBase::InPort *toPort = NULL ;
1012
1013   if ( toNode ) {
1014     toPort = toNode->GetChangeInPort( ToServiceParameterName ) ;
1015     if ( toPort ) {
1016       fromPort = toPort->GetOutPort();
1017       if ( fromPort ) {
1018         RetVal = true ;
1019         fromPort->Value( aValue ) ;
1020         toPort->State( SUPERV::ReadyState ) ;
1021       }
1022       else {
1023         cdebug << "ChangeInputData fromPort not found" << endl ;
1024       }
1025     }
1026     else {
1027       cdebug << "ChangeInputData toPort not found" << endl ;
1028     }
1029   }
1030   else {
1031     cdebug << "ChangeInputData Node not found : " << ToNodeName << endl ;
1032   }
1033
1034   cdebug_out << "GraphBase::Graph::ChangeInputData" << endl;
1035   return RetVal ;
1036 }
1037
1038 bool GraphBase::Graph::AddInputData(
1039             const char* ToNodeName1 ,
1040             const char* ToServiceParameterName1 ,
1041             const char* ToNodeName2 ,
1042             const char* ToServiceParameterName2 ) {
1043   bool RetVal = false ;
1044   cdebug_in << "GraphBase::Graph::AddInputSharedData(" << ToNodeName1 << ","
1045             << ToServiceParameterName1 << ", " << ToNodeName2 << ","
1046             << ToServiceParameterName2 << " )" << endl;
1047
1048   GraphBase::ComputingNode *toNode1 = GetChangeGraphNode( ToNodeName1 ) ;
1049   GraphBase::ComputingNode *toNode2 = GetChangeGraphNode( ToNodeName2 ) ;
1050
1051   GraphBase::OutPort *fromDataNodePort1 = NULL ;
1052   GraphBase::OutPort *fromDataNodePort2 = NULL ;
1053   GraphBase::InPort *toPort1 = NULL ;
1054   GraphBase::InPort *toPort2 = NULL ;
1055
1056   if ( toNode1 && toNode2 ) {
1057     toPort1 = toNode1->GetChangeInPort( ToServiceParameterName1 ) ;
1058     toPort2 = toNode2->GetChangeInPort( ToServiceParameterName2 ) ;
1059     fromDataNodePort1 = GraphBase::DataNode::GetChangeInDataNodePort( toPort1->NodePortName() ) ;
1060 //    const char* aDataValue = fromDataNodePort->Value() ;
1061     const CORBA::Any ** aDataValue1 = fromDataNodePort1->ValuePtr() ;
1062     fromDataNodePort2 = GraphBase::DataNode::GetChangeInDataNodePort( toPort2->NodePortName() ) ;
1063     RetVal = AddLink( (GraphBase::ComputingNode * ) this , fromDataNodePort1 ,
1064                       toNode2 , toPort2 ) ;
1065 //                      aDataValue ) ;
1066     fromDataNodePort2->Value( aDataValue1 ) ;
1067   }
1068   else {
1069     cdebug << "Node not found" << endl ;
1070   }
1071
1072   cdebug_out << "GraphBase::Graph::AddInputSharedData" << endl;
1073   return RetVal ;
1074 }
1075
1076 bool GraphBase::Graph::AddInputData( const char* ToNodeName ,
1077                                      const char* ToServiceParameterName ,
1078                                      const CORBA::Any ** aValue ) {
1079   bool RetVal = false ;
1080   cdebug_in << "GraphBase::Graph::AddInputData(" << ToNodeName << ","
1081             << ToServiceParameterName << " **Any " ;
1082   const CORBA::Any theValue = **aValue ;
1083   switch (theValue.type()->kind()) {
1084     case CORBA::tk_string:
1085       char * t;
1086       theValue >>= t;
1087       cdebug << t << " (string) " ;
1088       break;
1089     case CORBA::tk_double:
1090       double d;
1091       theValue >>= d;
1092       cdebug << d << " (double) " ;
1093       break;
1094     case CORBA::tk_long:
1095       long l;
1096       theValue >>= l;
1097       cdebug << l << " (long) " ;
1098       break;
1099     case CORBA::tk_objref:
1100       cdebug << "(object reference) " ;
1101       break;
1102     default:
1103       cdebug << "(other(tk_string,tk_double,tk_long,tk_objref)) ERROR";
1104       break;
1105     }
1106   cdebug << ")" << endl;
1107
1108   GraphBase::ComputingNode *toNode = GetChangeGraphNode( ToNodeName ) ;
1109
1110   GraphBase::OutPort *fromDataNodePort = NULL ;
1111   GraphBase::InPort *toPort = NULL ;
1112
1113   if ( toNode ) {
1114     toPort = toNode->GetChangeInPort( ToServiceParameterName ) ;
1115     fromDataNodePort = GraphBase::DataNode::GetChangeInDataNodePort( toPort->NodePortName() ) ;
1116     cdebug << "Try AddLink " << Name() << "( " << fromDataNodePort << " ) -->"
1117            << toNode->Name() << "( " << toPort->PortName() << " )" << endl ;
1118     RetVal = AddLink( (GraphBase::ComputingNode * ) this , fromDataNodePort ,
1119                       toNode , toPort ) ;
1120     if ( RetVal ) {
1121       fromDataNodePort->Value( aValue ) ;
1122     }
1123   }
1124   else {
1125     cdebug << "Node not found" << endl ;
1126   }
1127
1128   cdebug_out << "GraphBase::Graph::AddInputData" << endl;
1129   return RetVal ;
1130 }
1131
1132 bool GraphBase::Graph::AddOutputData(
1133                        const char* FromNodeName ,
1134                        const char* FromServiceParameterName ,
1135                        const CORBA::Any aValue ) {
1136 //            const char* DataValue ,
1137 //            const SUPERV::KindOfPortValue aKindOfPortValue ) {
1138   bool RetVal = false ;
1139   cdebug_in << "GraphBase::Graph::AddOutputData(" << FromNodeName << ","
1140             << FromServiceParameterName
1141 //            << FromServiceParameterName << ", " << DataValue << ","
1142 //            << aKindOfPortValue
1143             << ")" << endl;
1144 #if 0
1145   GraphBase::ComputingNode *fromNode = GetChangeGraphNode( FromNodeName ) ;
1146
1147   GraphBase::OutPort *fromPort = NULL ;
1148   GraphBase::InPort *toDataNodePort = NULL ;
1149
1150   if ( fromNode ) {
1151     fromPort = fromNode->GetChangeOutPort( FromServiceParameterName ) ;
1152     toDataNodePort = GraphBase::DataNode::GetChangeOutDataNodePort( fromPort->NodePortName() ) ;
1153     RetVal = AddLink( fromNode , fromPort ,
1154                       (GraphBase::ComputingNode * ) this , toDataNodePort ,
1155                       aValue ) ;
1156 //                      DataValue , aKindOfPortValue ) ;
1157   }
1158   else {
1159     cdebug << "Node not found" << endl ;
1160   }
1161 #endif
1162   cdebug_out << "GraphBase::Graph::AddOutputData" << endl;
1163   return RetVal ;
1164 }
1165
1166 bool GraphBase::Graph::CreateService() {
1167   cdebug_in << "GraphBase::Graph::CreateService" << endl;
1168   bool RetVal = true ;
1169   SALOME_ModuleCatalog::Service aService ;
1170   int i , j ;
1171   GraphBase::ComputingNode * aToNode ;
1172   int dostore ;
1173   int innbr ;
1174   int outnbr ;
1175   vector< SUPERV::KindOfPort > InPortsKind ;
1176   vector< SUPERV::KindOfPort > OutPortsKind ;
1177   for ( dostore = 0 ; dostore <= 2 ; dostore++ ) {
1178     if ( dostore == 1 ) {
1179       aService.ServiceName = Name() ;
1180       aService.ServiceinParameter.length( 0 ) ;
1181       aService.ServiceinParameter.length( innbr ) ;
1182       aService.ServiceoutParameter.length( 0 ) ;
1183       aService.ServiceoutParameter.length( outnbr ) ;
1184       InPortsKind.resize( innbr ) ;
1185       OutPortsKind.resize( outnbr ) ;
1186     }
1187     if ( dostore <= 1 ) {
1188       innbr = 0 ;
1189       outnbr = 0 ;
1190     }
1191     for ( i = 0 ; i < GraphNodesSize() ; i++ ) {
1192       aToNode = GraphNodes( i ) ;
1193       for ( j = 0 ; j < aToNode->GetNodeInPortsSize() ; j++ ) {
1194         GraphBase::InPort *anInPort = aToNode->GetChangeNodeInPort(j) ;
1195         bool isfromcouplednode = false ;
1196         if ( anInPort->IsConnected() && anInPort->GetOutPort() ) {
1197           GraphBase::ComputingNode * aFromNode = GetChangeGraphNode( anInPort->GetOutPort()->NodeName() ) ;
1198           if ( aFromNode->IsEndLoopNode() && ((GraphBase::EndOfLoopNode * ) aFromNode)->CoupledNode() == aToNode ) {
1199             isfromcouplednode = true ;
1200           }
1201         }
1202         if ( !anInPort->IsGate() && !anInPort->IsLoop() &&
1203              ( !anInPort->IsConnected() || ( anInPort->IsConnected() && isfromcouplednode ) ) ) {
1204           if ( dostore == 0 ) {
1205             cdebug << "CreateService " << aToNode->Name() << " Input port "
1206                    << anInPort->PortName() << " " << anInPort->Kind() << " is NOT connected " ;
1207             if ( anInPort->GetOutPort() ) {
1208               cdebug << "DataConnected from " <<  *(anInPort->GetOutPort() ) ;
1209             }
1210             cdebug << endl ;
1211             innbr += 1 ;
1212           }
1213           else if ( ( dostore == 1 && !anInPort->IsDataStream() ) ||
1214                     ( dostore == 2 && anInPort->IsDataStream() ) ) {
1215             aService.ServiceinParameter[innbr].Parametertype = CORBA::string_dup( anInPort->PortType() ) ;
1216             aService.ServiceinParameter[innbr].Parametername = CORBA::string_dup( anInPort->NodePortName() ) ;
1217             InPortsKind[ innbr++ ] = anInPort->Kind() ;
1218             cdebug << "In " << aService.ServiceinParameter[ innbr - 1 ].Parametername << " " << anInPort->Kind() << endl ;
1219           }
1220         }
1221         else {
1222           cdebug << "CreateService " << aToNode->Name() << " Input port " << anInPort->PortName() ;
1223           if ( anInPort->IsConnected() ) {
1224             cdebug << " is connected " ;
1225           }
1226           else {
1227             cdebug << " is NOT connected " ;
1228           }
1229           if ( anInPort->IsGate() ) {
1230             cdebug << " IsGate " ;
1231           }
1232           if ( anInPort->GetOutPort() ) {
1233             cdebug << "DataConnected from " <<  *(anInPort->GetOutPort()) ;
1234           }
1235           else {
1236             cdebug << "NOT DataConnected" ;
1237           }
1238           cdebug << endl ;
1239         }
1240       }
1241       GraphBase::ComputingNode * aFromNode = aToNode ;
1242       for ( j = 0 ; j < aFromNode->GetNodeOutPortsSize() ; j++ ) {
1243         GraphBase::OutPort *anOutPort = aFromNode->GetChangeNodeOutPort(j) ;
1244         cdebug << "CreateService Node " << aFromNode->Name() << ". Output port[" << j << "] ";
1245         if ( anOutPort ) {
1246           cdebug << anOutPort->PortName() << " " << anOutPort->ServicesParameterType() << endl ;
1247         }
1248         else {
1249           cdebug << " NULL" << endl ;
1250         }
1251         if ( !aFromNode->IsGOTONode() ) {
1252           if ( !anOutPort->IsGate() && 
1253                ( anOutPort->IsNotConnected() || anOutPort->IsDataConnected() ) ) {
1254             if ( dostore == 0 ) {
1255               cdebug << "CreateService " << aFromNode->Name() << " Output port "
1256                      << anOutPort->PortName() << endl ;
1257               outnbr += 1 ;
1258             }
1259             else if ( ( dostore == 1 && !anOutPort->IsDataStream() ) ||
1260                       ( dostore == 2 && anOutPort->IsDataStream() ) ) {
1261               aService.ServiceoutParameter[outnbr].Parametertype = CORBA::string_dup( anOutPort->PortType() ) ;
1262               aService.ServiceoutParameter[outnbr].Parametername = CORBA::string_dup( anOutPort->NodePortName() ) ;
1263               OutPortsKind[ outnbr++ ] = anOutPort->Kind() ;
1264               cdebug << "Out " << aService.ServiceoutParameter[ outnbr - 1 ].Parametername << " " << anOutPort->Kind() << endl ;
1265             }
1266           }
1267         }
1268       }
1269     }
1270   }
1271
1272 //  MESSAGE( "DataFlowNode ServiceName " << aService.ServiceName );
1273 //  for ( i = 0 ; i < innbr ; i++ ) {
1274 //    cout << "aService.ServiceinParameter[" << i << "].Parametertype "
1275 //         << aService.ServiceinParameter[i].Parametertype << endl ;
1276 //    cout << "aService.ServiceinParameter[" << i << "].Parametername "
1277 //         << aService.ServiceinParameter[i].Parametername << endl ;
1278 //  }
1279 //  for ( i = 0 ; i < outnbr ; i++ ) {
1280 //    cout << "aService.ServiceoutParameter[" << i << "].Parametertype "
1281 //         << aService.ServiceoutParameter[i].Parametertype << endl ;
1282 //    cout << "aService.ServiceoutParameter[" << i << "].Parametername "
1283 //         << aService.ServiceoutParameter[i].Parametername << endl ;
1284 //  }
1285
1286   DataService( _Orb , aService , Graph_prof_debug() , Graph_fdebug() ) ;
1287   for ( i = 0 ; i < innbr ; i++ ) {
1288     GetChangeNodeInPort( i )->Kind( InPortsKind[ i ] ) ;
1289     cdebug << "In " << GetChangeNodeInPort( i )->PortName() << " " << GetChangeNodeInPort( i )->Kind() << endl ;
1290     _DataFlowDataPorts->GetChangeNodeOutPort( i )->Kind( InPortsKind[ i ] ) ;
1291     cdebug << "ReversedIn " << _DataFlowDataPorts->GetChangeNodeOutPort( i )->PortName() << " " << _DataFlowDataPorts->GetChangeNodeOutPort( i )->Kind() << endl ;
1292   }
1293   for ( i = 0 ; i < outnbr ; i++ ) {
1294     GetChangeNodeOutPort( i )->Kind( OutPortsKind[ i ] ) ;
1295     cdebug << "Out " << GetChangeNodeOutPort( i )->PortName() << " " << GetChangeNodeOutPort( i )->Kind() << endl ;
1296     _DataFlowDataPorts->GetChangeNodeInPort( i )->Kind( OutPortsKind[ i ] ) ;
1297     cdebug << "ReversedOut " << _DataFlowDataPorts->GetChangeNodeInPort( i )->PortName() << " " << _DataFlowDataPorts->GetChangeNodeInPort( i )->Kind() << endl ;
1298   }
1299 // Restore input datas :
1300   for ( i = 0 ; i < GraphNodesSize() ; i++ ) {
1301     aToNode = GraphNodes( i ) ;
1302     for ( j = 0 ; j < aToNode->GetNodeInPortsSize() ; j++ ) {
1303       GraphBase::InPort *anInPort = aToNode->GetChangeNodeInPort(j) ;
1304       if ( anInPort->IsDataConnected() ) {
1305         AddInputData( anInPort->NodeName() ,
1306                       anInPort->PortName() ,
1307                       anInPort->GetOutPort()->ValuePtr() ) ;
1308       }
1309     }
1310   }
1311
1312   cdebug_out << "GraphBase::Graph::CreateService" << endl;
1313   return RetVal ;
1314 }
1315
1316 bool GraphBase::Graph::InLineServices() {
1317   cdebug_in << "GraphBase::Graph::InLineServices" << endl;
1318
1319   int i , j ;
1320   ListPorts( *_Graph_fdebug , 0 ) ;
1321   GraphBase::InLineNode * aINode ;
1322   SALOME_ModuleCatalog::Service aService ;
1323   for ( i = 0 ; i < GraphNodesSize() ; i++ ) {
1324     aINode = (GraphBase::InLineNode * ) GraphNodes( i ) ;
1325     if ( aINode->IsOneOfInLineNodes() || aINode->HasDataStream() ) {
1326       cdebug << "GraphBase::Graph::InLineServices " << aINode->Name() << endl;
1327       aService.ServiceName = aINode->ServiceName() ;
1328       aService.ServiceinParameter.length( 0 ) ;
1329       aService.ServiceoutParameter.length( 0 ) ;
1330       int InService = 0 ;
1331       for ( j = 0 ; j < aINode->GetNodeInPortsSize() ; j++ ) {
1332         if ( aINode->GetChangeNodeInPort(j)->IsGate() ||
1333              aINode->GetChangeNodeInPort(j)->IsLoop() ) {
1334           cdebug << "GraphBase::Graph::InLineServices In" << j << " "
1335                  << aINode->GetChangeNodeInPort(j)->Kind() << " " 
1336                  << aINode->GetChangeNodeInPort(j)->PortType() << " " 
1337                  << aINode->GetChangeNodeInPort(j)->PortName() << " ignored "
1338                  << aINode->GetChangeNodeInPort(j)->IsGate() << " "
1339                  << aINode->GetChangeNodeInPort(j)->IsLoop() << endl;
1340         }
1341         else {
1342           aService.ServiceinParameter.length( InService+1 ) ;
1343           aService.ServiceinParameter[InService].Parametertype = CORBA::string_dup( aINode->GetChangeNodeInPort(j)->PortType() ) ;
1344           aService.ServiceinParameter[InService++].Parametername = CORBA::string_dup( aINode->GetChangeNodeInPort(j)->PortName() ) ;
1345           cdebug << "GraphBase::Graph::InLineServices In" << j << " "
1346                  << aINode->GetChangeNodeInPort(j)->Kind() << " " 
1347                  << aINode->GetChangeNodeInPort(j)->PortType() << " " 
1348                  << aINode->GetChangeNodeInPort(j)->PortName() << " "
1349                  << aINode->GetChangeNodeInPort(j)->IsGate() << " "
1350                  << aINode->GetChangeNodeInPort(j)->IsLoop() << endl;
1351         }
1352       }
1353       int OutService = 0 ;
1354       for ( j = 0 ; j < aINode->GetNodeOutPortsSize() ; j++ ) {
1355         if ( aINode->GetChangeNodeOutPort(j)->IsGate() ||
1356              aINode->GetChangeNodeOutPort(j)->IsLoop() ) {
1357           cdebug << "GraphBase::Graph::InLineServices Out" << j << " "
1358                  << aINode->GetChangeNodeOutPort(j)->Kind() << " " 
1359                  << aINode->GetChangeNodeOutPort(j)->PortType() << " " 
1360                  << aINode->GetChangeNodeOutPort(j)->PortName() << " ignored "
1361                  << aINode->GetChangeNodeOutPort(j)->IsGate() << " "
1362                  << aINode->GetChangeNodeOutPort(j)->IsLoop() << endl;
1363         }
1364         else {
1365           aService.ServiceoutParameter.length( OutService+1 ) ;
1366           aService.ServiceoutParameter[OutService].Parametertype = CORBA::string_dup( aINode->GetChangeNodeOutPort(j)->PortType() ) ;
1367           aService.ServiceoutParameter[OutService++].Parametername = CORBA::string_dup( aINode->GetChangeNodeOutPort(j)->PortName() ) ;
1368           cdebug << "GraphBase::Graph::InLineServices Out" << j << " "
1369                  << aINode->GetChangeNodeOutPort(j)->Kind() << " " 
1370                  << aINode->GetChangeNodeOutPort(j)->PortType() << " " 
1371                  << aINode->GetChangeNodeOutPort(j)->PortName()  << " "
1372                  << aINode->GetChangeNodeOutPort(j)->IsGate() << " "
1373                  << aINode->GetChangeNodeOutPort(j)->IsLoop() << endl;
1374         }
1375       }
1376       aINode->SetService( aService ) ;
1377 //      cdebug << "GraphBase::Graph::InLineServices" << *aINode->GetService() << endl;
1378     }
1379   }
1380
1381   cdebug_out << "GraphBase::Graph::InLineServices" << endl;
1382   return true ;
1383 }
1384
1385 bool GraphBase::Graph::Sort() {
1386   int i ;
1387   int j ;
1388   int NotSortedNumber = GraphNodesSize() ;
1389   bool NewSorted ;
1390   if ( NotSortedNumber ) {
1391     _LevelsNumber = 0 ;
1392     _ParallelExecutionNodes = false ;
1393     _Sorted.resize( GraphNodesSize() ) ;
1394     _CnxInPortsNumber.resize( GraphNodesSize() ) ;
1395     _DecrInPortsNumber.resize( GraphNodesSize() ) ;
1396     if ( _NodesNumber.size() )
1397       _NodesNumber.resize( 0 ) ;
1398       _SortedNodes.resize( 0 ) ;
1399           
1400     for ( i = 0 ; i < GraphNodesSize() ; i++ ) {
1401       _Sorted[ i ] = false ;
1402       _CnxInPortsNumber[ i ] = GraphNodes( i )->ConnectedInPortsNumber() ;
1403       _DecrInPortsNumber[ i ] = 0 ;
1404     }
1405     
1406     while ( NotSortedNumber ) {
1407       NewSorted = false ;
1408       
1409       for ( i = 0 ; i < GraphNodesSize() ; i++ ) {
1410         cdebug << "Sort level " << _LevelsNumber << ". [" << i << "] "
1411                << GraphNodes( i )->Name() << " count "
1412                << _CnxInPortsNumber[ i ] << endl ;
1413         if ( !_Sorted[ i ] && _CnxInPortsNumber[ i ] == 0 ) {
1414 // All inputs of GraphNodes( i ) are available
1415           if ( (int ) _NodesNumber.size() != _LevelsNumber+1 ) {
1416             _NodesNumber.resize( _LevelsNumber+1 ) ;
1417             _SortedNodes.resize( _LevelsNumber+1 ) ;
1418             _NodesNumber[ _LevelsNumber ] = -1 ;
1419           }
1420           _NodesNumber[ _LevelsNumber ]++ ;
1421           (_SortedNodes[ _LevelsNumber ]).resize( _NodesNumber[ _LevelsNumber ]+1 ) ;
1422           (_SortedNodes[ _LevelsNumber ])[ _NodesNumber[ _LevelsNumber ] ] = GraphNodes( i ) ;
1423           _Sorted[ i ] = true ;
1424           NewSorted = true ;
1425           cdebug << GraphNodes( i )->Name() << " belongs to level "
1426                  << _LevelsNumber << "." << endl ;
1427           for ( j = 0 ; j < GraphNodes( i )->LinkedNodesSize() ; j++ ) {
1428 // Outputs of GraphNodes( i ) will satisfy 
1429 //   GraphNodes( i )->LinkedInPortsNumber( j ) InPorts of
1430 //      GraphNodes( i )->LinkedNodes( j )
1431             GraphBase::ComputingNode * aLinkedNode = GraphNodes( i )->LinkedNodes( j ) ;
1432             int aLinkedInPortsNumber = GraphNodes( i )->LinkedInPortsNumber( j ) ;
1433             cdebug << j << ". LinkedNode " << aLinkedNode->Name() ;
1434             if ( !aLinkedNode->IsDataFlowNode() ) {
1435               cdebug << " _DecrInPortsNumber[ "
1436                      << GetGraphNodeIndex( aLinkedNode->Name() )
1437                      << " ] = "
1438                      << _DecrInPortsNumber[ GetGraphNodeIndex( aLinkedNode->Name() ) ]
1439                      << " += " << aLinkedInPortsNumber ;
1440               _DecrInPortsNumber[ GetGraphNodeIndex( aLinkedNode->Name() ) ] += aLinkedInPortsNumber ;
1441             }
1442             cdebug << endl ;
1443 //            GraphNodes( i )->LinkedNodes( j )->IncrDecrConnectedInPortsNumber( GraphNodes( i )->LinkedInPortsNumber( j ) ) ;
1444           }
1445         }
1446       }
1447       if ( !NewSorted ) {
1448         cdebug << "Loop detected level " << _LevelsNumber << endl ;
1449         return false ; // Loop in the Graph
1450       }
1451       cdebug << "Bilan level " << _LevelsNumber << " : " << endl ;
1452       bool ChangeCount = false ;
1453       for ( i = 0 ; i < GraphNodesSize() ; i++ ) {
1454 //        if ( GraphNodes( i )->DecrIncrDecrConnectedInPortsNumber() ) {
1455         if ( _DecrInPortsNumber[ i ] ) {
1456           int prevcount = _CnxInPortsNumber[ i ] ;
1457           _CnxInPortsNumber[ i ] -= _DecrInPortsNumber[ i ]  ;
1458           _DecrInPortsNumber[ i ] = 0 ;
1459           ChangeCount = true ;
1460           cdebug << "    " << GraphNodes( i )->Name() << " count " << prevcount
1461                  << " --> new count " << _CnxInPortsNumber[ i ] << endl ;
1462         }
1463       }
1464       
1465       if ( !ChangeCount )
1466         break ;
1467       _LevelsNumber += 1 ;
1468     }
1469     _ThreadsMax = 0 ;
1470     int AllSortedNodes = 0 ;
1471     _HeadNodes = _SortedNodes[ 0 ] ;
1472     _HeadNodesSize = _SortedNodes[ 0 ].size() ;
1473     _QueueNodes = _SortedNodes[ _LevelsNumber ] ;
1474     _QueueNodesSize = _SortedNodes[ _LevelsNumber ].size() ;
1475     for ( i = 0 ; i < _QueueNodesSize ; i++ ) {
1476       if ( !_QueueNodes[ i ]->IsGOTONode() ) {
1477         break ;
1478       }
1479     }
1480     if ( i == _QueueNodesSize && _LevelsNumber ) {
1481       _QueueNodes = _SortedNodes[ _LevelsNumber - 1 ] ;
1482       _QueueNodesSize = _SortedNodes[ _LevelsNumber - 1 ].size() ;
1483     }
1484     for ( i = 0 ; i <= _LevelsNumber ; i++ ) {
1485       AllSortedNodes += _NodesNumber[ i ]+1 ;
1486       if ( _NodesNumber[ i ] + 1 > _ThreadsMax )
1487         _ThreadsMax = _NodesNumber[ i ] + 1 ;
1488       cdebug << _NodesNumber[ i ]+1 << " Nodes of level " << i << " : "
1489              << (_SortedNodes[ i ])[ 0 ]->Name() << endl ;
1490       for ( j = 1 ; j <= _NodesNumber[ i ] ; j++ ) {
1491         _ParallelExecutionNodes = true ;
1492         cdebug << "                     " << (_SortedNodes[ i ])[ j ]->Name()
1493                << endl ;
1494       }
1495     }
1496     if ( _ParallelExecutionNodes ) {
1497       cdebug << "Parallel Execution Nodes detected." << endl ;
1498     }
1499     else {
1500       cdebug << "No Parallel Execution Nodes detected." << endl ;
1501     }
1502     if ( AllSortedNodes != GraphNodesSize() ) {
1503       cdebug << "Loop detected level " << _LevelsNumber << endl ;
1504       return false ; // Loop in the Graph
1505     }
1506
1507     for ( i= 0 ; i <= _NodesNumber[ 0 ] ; i++ ) {
1508       (_SortedNodes[ 0 ])[ i ]->HeadNode( true ) ;
1509     }
1510
1511     for ( i = 0 ; i <= _NodesNumber[ 0 ] ; i++ ) {
1512       (_SortedNodes[ 0 ])[ i ]->Level( 0 ) ;
1513       (_SortedNodes[ 0 ])[ i ]->SubGraph( i + 1 ) ;
1514     }
1515
1516     for ( i = 1 ; i <= _LevelsNumber ; i++ ) {
1517       for ( j = 0 ; j <= _NodesNumber[ i ] ; j++ ) {
1518         (_SortedNodes[ i ])[ j ]->Level( i ) ;
1519         (_SortedNodes[ i ])[ j ]->SubGraph( 0 ) ;
1520       }
1521     }
1522
1523     bool Graphs = true ;
1524     while ( Graphs ) {
1525       for ( i = 0 ; i <= _LevelsNumber ; i++ ) {
1526         for ( j = 0 ; j <= _NodesNumber[ i ] ; j++ ) {
1527           GraphBase::ComputingNode * aNode = (_SortedNodes[ i ])[ j ] ;
1528           cdebug << "Graph " << aNode->SubGraph() << " " << aNode->Name()
1529                  << endl ;
1530           int k ;
1531           for ( k = 0 ; k < aNode->LinkedNodesSize() ; k++ ) {
1532             if ( aNode->LinkedNodes( k )->SubGraph() ) {
1533               if ( aNode->LinkedNodes( k )->SubGraph() != aNode->SubGraph() &&
1534                    aNode->LinkedNodes( k )->Level() == aNode->Level()+1 ) {
1535                 aNode->SubGraph( aNode->LinkedNodes( k )->SubGraph() ) ;
1536                 cdebug << "   Linked " << aNode->LinkedNodes( k )->Name()
1537                        << " Graph(" << aNode->LinkedNodes( k )->SubGraph()
1538                        << ") ==>" << endl ;
1539                 cdebug << "   Graph " << aNode->SubGraph() << " for "
1540                        << aNode->Name() << " ==> again" << endl ;
1541                 int l ;
1542                 for ( l = 0 ; l < aNode->LinkedNodesSize() ; l++ ) {
1543                   aNode->LinkedNodes( l )->SubGraph( aNode->SubGraph() ) ;
1544                 }
1545                 Graphs = false ;
1546                 break ;
1547               }
1548               else {
1549                 cdebug << "   Linked " << aNode->LinkedNodes( k )->Name()
1550                        << " Graph(" << aNode->LinkedNodes( k )->SubGraph()
1551                        << ") distance > 1 ignored" << endl ;
1552               }
1553             }
1554             else {
1555               cdebug << "   Linked " << aNode->LinkedNodes( k )->Name()
1556                      << " GraphInit to " << aNode->SubGraph() << " from "
1557                      << aNode->Name() << endl ;
1558               aNode->LinkedNodes( k )->SubGraph( aNode->SubGraph() ) ;
1559             }
1560           }
1561         }
1562         if ( !Graphs )
1563           break ;
1564       }
1565       if ( Graphs ) {
1566         cdebug << endl << "Graphs result : " << endl ;
1567         break ;
1568       }
1569       cdebug << endl << "One more time" << endl ;
1570       Graphs = true ;
1571     }
1572     _GraphsNumber = 0 ;
1573     int CurrGraphsNumber = 0;
1574     int k ;
1575     for ( k = 0 ; k <= _NodesNumber[ 0 ] ; k++ ) {
1576       if ( (_SortedNodes[ 0 ])[ k ]->SubGraph() > CurrGraphsNumber ) {
1577         CurrGraphsNumber = (_SortedNodes[ 0 ])[ k ]->SubGraph() ;
1578         _GraphsNumber += 1 ;
1579         for ( i = 0 ; i <= _LevelsNumber ; i++ ) {
1580           for ( j = 0 ; j <= _NodesNumber[ i ] ; j++ ) {
1581             if ( (_SortedNodes[ i ])[ j ]->SubGraph() == CurrGraphsNumber ) {
1582               (_SortedNodes[ i ])[ j ]->SubGraph( _GraphsNumber ) ;
1583               cdebug << "GraphsNumber " << _GraphsNumber << " " << " Level "
1584                      << i << " : " << (_SortedNodes[ i ])[ j ]->Name()
1585                      << endl ;
1586             }
1587           }
1588         }
1589       }
1590     }
1591   }
1592
1593   ListPorts( *_Graph_fdebug , 0 ) ;
1594
1595   return true ;
1596 }
1597
1598 // Controle de la coherence des noeuds de calcul
1599 // Enregistrement dans la liste des noeuds "tete" de graphe
1600
1601 bool GraphBase::Graph::ComputingNodes() const {
1602   bool RetVal = true ;
1603   cdebug << "GraphExecutor::GraphControl::ComputingNodes ()" << endl;
1604
1605 //  list<GraphEditor::Node *> aComputingNodesList = _G->ComputingNodesList() ;
1606 //  list<GraphEditor::Node *>::iterator aNode = aComputingNodesList.begin();
1607 //  GraphEditor::Port *  iP;
1608
1609 //  for (aNode = _G->ComputingNodesList().begin(); aNode !=_G->ComputingNodesList().end(); aNode++) {
1610 //  while ( aNode != aComputingNodesList.end() ) {
1611   int i ;
1612   GraphBase::ComputingNode * aNode ;
1613   for ( i = 0 ; i < GraphNodesSize() ; i++ ) {
1614     aNode = GraphNodes( i ) ;
1615     // Tous les ports d'entree de tous les noeuds de calcul sont bien connectes
1616     // Enregistrement eventuel dans la liste des noeuds "tete" de graphe
1617 //    if ((*aNode)->GetNodeInPortsSize() == 0)
1618 //      _headNodes.push_front(*aNode);
1619     int j ;
1620     for ( j = 1 ; j < aNode->GetNodeInPortsSize() ; j++ ) {
1621       const GraphBase::InPort *iP = aNode->GetNodeInPort(j);
1622       if ( !iP->IsConnected() ){
1623         cdebug << "Le port d'entree " << iP->PortName()
1624                << " du noeud de calcul " << aNode->Name() << " du graphe  "
1625                << Name() << " n'est pas connecte "<< endl;
1626         RetVal = false ;
1627       };
1628
1629     };
1630
1631     // Tous les noeuds de calcul ont au moins un port de sortie connecte
1632     bool oneOutPortConnected = false;
1633     for ( j = 1 ; j < aNode->GetNodeOutPortsSize() ; j++) {
1634       const GraphBase::OutPort *iP = aNode->GetNodeOutPort(j);
1635       if ( iP->IsPortConnected() || iP->IsDataConnected() ){
1636         oneOutPortConnected = true ;
1637 //      break;
1638       }
1639       else {
1640         cdebug << "Le port de sortie " << iP->PortName()
1641                << " du noeud de calcul " << aNode->Name() << " du graphe  "
1642                << Name() << " n'est pas connecte "<< endl;
1643         RetVal = false ;
1644       }
1645     };
1646     if (!oneOutPortConnected) {
1647         cdebug << "Le noeud de calcul " << aNode->Name() << " du graphe  "
1648                << Name() << " n'a aucun port de sortie connecte "<< endl;
1649 //      _computingError.push_front(2);
1650     }
1651   };
1652 //  return _computingError.size () ;
1653   return RetVal ;
1654 }
1655
1656 bool GraphBase::Graph::LinkLoopNodes(bool & NewLink ) {
1657   bool RetVal = true ;
1658   NewLink = false ;
1659   int i , j ;
1660   cdebug_in << "GraphBase::Graph::LinkLoopNodes()" << endl;
1661   for ( i = 0 ; i < GraphNodesSize() ; i++ ) {
1662     GraphBase::ComputingNode * aNode = GraphNodes( i ) ;
1663     if ( aNode->IsLoopNode() ) {
1664       GraphBase::LoopNode * aLoopNode = (GraphBase::LoopNode * ) aNode ;
1665       for ( j = 0 ; j < aLoopNode->GetNodeInPortsSize() ; j++ ) {
1666         GraphBase::InPort *anInPort = aLoopNode->GetChangeNodeInPort(j) ;
1667         if ( !anInPort->IsGate() && !anInPort->IsConnected() && !anInPort->IsDataConnected() ) {
1668           if ( !AddLink( aLoopNode->CoupledNode() , aLoopNode->CoupledNode()->GetChangeNodeOutPort( j ) ,
1669                          aLoopNode , anInPort ) ) {
1670             cdebug << "GraphBase::Graph::CreateService AddLink ERROR " << aLoopNode->CoupledNode()->Name()
1671                    << "( " << aLoopNode->CoupledNode()->GetChangeNodeOutPort( j )->PortName() << " ) --> "
1672                    << aLoopNode->Name() << "( " << anInPort->PortName() << " )" << endl ;
1673             RetVal = false ;
1674           }
1675           else {
1676             NewLink = true ;
1677           }
1678         }
1679       }
1680       for ( j = 0 ; j < aLoopNode->CoupledNode()->GetNodeInPortsSize() ; j++ ) {
1681         GraphBase::InPort *anInPort = aLoopNode->CoupledNode()->GetChangeNodeInPort( j ) ;
1682         if ( !anInPort->IsConnected() ) {
1683           if ( !AddLink( aLoopNode , aLoopNode->GetChangeNodeOutPort( j ) ,
1684                          aLoopNode->CoupledNode() , anInPort ) ) {
1685             cdebug << "GraphBase::Graph::CreateService AddLink ERROR " << aLoopNode->Name() << "( "
1686                    << aLoopNode->GetChangeNodeOutPort( j )->PortName() << " ) --> "
1687                    << aLoopNode->CoupledNode()->Name() << "( " << anInPort->PortName() << " )" << endl ;
1688             RetVal = false ;
1689           }
1690           else {
1691             NewLink = true ;
1692           }
1693         }
1694       }
1695     }
1696     else if ( aNode->IsGOTONode() ) {
1697       GraphBase::GOTONode * aGOTONode = (GraphBase::GOTONode * ) aNode ;
1698       GraphBase::OutPort *anOutGate = aGOTONode->GetChangeNodeOutGate() ;
1699       if ( !anOutGate->IsConnected() ) {
1700         if ( !AddLink( aGOTONode , anOutGate ,
1701                        aGOTONode->CoupledNode() , aGOTONode->CoupledNode()->GetChangeNodeInGate() ) ) {
1702           cdebug << "GraphBase::Graph::CreateService AddLink ERROR " << aGOTONode->Name() << "( "
1703                  << anOutGate->PortName() << " ) --> " << aGOTONode->CoupledNode()->Name() << "( "
1704                  << aGOTONode->CoupledNode()->GetChangeNodeInGate()->PortName() << " )" << endl ;
1705           RetVal = false ;
1706         }
1707         else {
1708           NewLink = true ;
1709         }
1710       }
1711     }
1712   }
1713   cdebug_out << "GraphBase::Graph::LinkLoopNodes() " << RetVal << endl;
1714   return RetVal ;
1715 }
1716
1717 // Controle de la coherence des noeuds de calcul
1718 // Enregistrement dans la liste des noeuds "tete" de graphe
1719
1720 bool GraphBase::Graph::DataServerNodes() const {
1721
1722   cdebug << "GraphBase::Graph::DataServerNodes ()" << endl;
1723
1724 //  const GraphExecutor::InNode *DataFlowDatas = GetDataFlowDatas() ;
1725   int i , j , ierr = 0 ;
1726
1727 //  if ( DataFlowDatas == NULL ) {
1728 //    MESSAGE( "No input data available in the DataFlow " << _G->Name() );
1729 //    return 0 ;
1730 //  }
1731
1732 //  const GraphExecutor::InNode *DataFlowNode = _G->GetDataFlowNode() ;
1733 //  MESSAGE( "DataServerNodes DataFlowNode : " << *DataFlowNode );
1734
1735 //  MESSAGE( "DataServerNodes DataFlowDatas : " << *DataFlowDatas );
1736
1737 // cout are inversed because DataFlowDatas is a mirror node of the DataFlow
1738
1739   ierr = CheckDataServerNodes() ;
1740
1741 //  list<GraphExecutor::InNode *> aComputingNodesList = _G->ComputingNodesList() ;
1742 //  list<GraphExecutor::InNode *>::iterator aNode = aComputingNodesList.begin();
1743   if ( GraphNodesSize() == 0 ) {
1744     ierr++ ;
1745   }
1746   else {
1747     GraphBase::ComputingNode * aNode ;
1748     for ( i = 0 ; i < GraphNodesSize() ; i++ ) {
1749       aNode = GraphNodes( i ) ;
1750 //  while ( aNode != aComputingNodesList.end() ) {
1751       if ( aNode->IsFactoryNode() ) {
1752       GraphBase::FactoryNode * FaNode = (GraphBase::FactoryNode * ) aNode ;
1753         if ( !strlen( FaNode->Computer() ) ) {
1754           cdebug << "ComputerName missing for node " << FaNode->Name() ;
1755           if ( !strlen( FaNode->Computer() ) ) {
1756             ierr++ ;
1757             cdebug << endl ;
1758           }
1759           else {
1760             cdebug << ". " << FaNode->Computer() << " will be used." << endl ;
1761           }
1762         }
1763     }
1764 // For Outputs of the DataFlow :
1765       for ( j = 0 ; j < aNode->GetNodeOutPortsSize() ; j++ ) {
1766         if ( !aNode->GetNodeOutPort(j)->IsConnected() ) {
1767           aNode->AddLink( (GraphBase::ComputingNode *) this ) ;
1768         }
1769       }
1770     }
1771   }
1772
1773 // Chaque noeud dataserver ne possede qu'un seul port entree ou sortie et il est bien connecte
1774
1775 //  list<GraphExecutor::InNode *> aDataServerNodesList = _G->DataServerNodesList() ;
1776 //  list<GraphExecutor::InNode *>::iterator it = aDataServerNodesList.begin() ;
1777
1778 //  for (it = _G->DataServerNodesList().begin(); it !=_G->DataServerNodesList().end(); it++){
1779 //  while ( it != aDataServerNodesList.end() ) {
1780 //    if ( (*it)->GetNodeOutPortsSize() && (*it)->GetNodeInPortsSize() ) {
1781 //      cerr << "Erreur dans le noeud serveur de donnees " 
1782 //           << (*it)->Name() << " du graphe  " << _G->Name() << endl;
1783 //      cerr << "A la fois importation et exportation de donnees" << endl;
1784 //      _dataServerError.push_front(1);
1785 //    }
1786
1787 //    if ((*it)->GetNodeOutPortsSize()) {
1788 //      if ((*it)->GetNodeOutPortsSize()==1){
1789 //      if ( (*it)->GetNodeOutPort(0)->IsPortConnected() ){
1790 //        _headNodes.push_front(*it);
1791 //      }
1792 //      else {
1793 //        cerr << "Le port de sortie du noeud serveur de donnees "
1794 //               << (*it)->Name() << " du graphe  " << _G->Name()
1795 //               << " n'est pas connecte "<< endl;
1796 //        _dataServerError.push_front(4);
1797 //      }
1798 //      }
1799 //      else {
1800 //      cerr << "Plus d'une donnee importee du noeud serveur de donnees "
1801 //             << (*it)->Name() << " du graphe  " << _G->Name() << endl;
1802 //      _dataServerError.push_front(2);
1803 //      }
1804 //    }
1805
1806 //    if ((*it)->GetNodeInPortsSize()) {
1807 //      if ((*it)->GetNodeInPortsSize() > 1){
1808 //      cerr << "Plus d'une donnee exportee vers le noeud serveur de donnees "
1809 //             << (*it)->Name() << " du graphe  " << _G->Name() << endl;
1810 //      _dataServerError.push_front(3);
1811 //      }
1812 //      else
1813 //      if ( !(*it)->GetNodeInPort(0)->IsPortConnected() ){
1814 //      cerr << "Le port d'entree du noeud serveur de donnees "
1815 //             << (*it)->Name() << " du graphe  " << _G->Name()
1816 //             << " n'est pas connecte "<< endl;
1817 //      _dataServerError.push_front(5);
1818 //      }
1819 //    }
1820 //    it++ ;
1821 //  };
1822
1823 //  return _dataServerError.size ();
1824   return ( ierr == 0 ) ;
1825 }
1826
1827 SUPERV::GraphState GraphBase::Graph::PortState(
1828                                    const char* NodeName ,
1829                                    const char* ServiceParameterName ) {
1830   SUPERV::GraphState aRet = SUPERV::UndefinedState ;
1831 //  cdebug << "GraphBase::Graph::PortState( " << NodeName << " , "
1832 //         << ServiceParameterName << " )" << endl ;
1833
1834   char *theNode ;
1835   char *aPort ;
1836   NodePort( NodeName , ServiceParameterName , &theNode , &aPort ) ;
1837
1838   GraphBase::ComputingNode * aNode = GetChangeGraphNode( theNode ) ;
1839   if ( aNode ) {
1840     GraphBase::OutPort *anOutPort ;
1841     anOutPort = aNode->GetChangeOutPort( aPort );
1842     if ( anOutPort == NULL ) {
1843       GraphBase::InPort *anInPort = aNode->GetChangeInPort( aPort );
1844       if ( anInPort )
1845         anOutPort = anInPort->GetOutPort() ;
1846       else {
1847         cdebug << "GraphBase::Graph::PortState OutPort/InPort not found --> "
1848                << aRet << endl ;
1849       }
1850     }
1851     if ( anOutPort ) {
1852       aRet = anOutPort->State() ;
1853 //      cdebug << "GraphBase::Graph::PortState --> " << aRet << endl ;
1854     }
1855   }
1856   else {
1857     cdebug << "GraphBase::Graph::PortState Node not found --> " << aRet
1858            << endl ;
1859   }
1860   delete theNode ;
1861   delete aPort ;
1862   return aRet ;
1863 }
1864
1865 const CORBA::Any * GraphBase::Graph::PortInData( const char* ToNodeName ,
1866                                                  const char* ToServiceParameterName ) {
1867   const CORBA::Any * aRet = new CORBA::Any() ;
1868   char *theNode ;
1869   char *aPort ;
1870 //  cdebug_in << "GraphBase::Graph::PortInData " << ToNodeName << " "
1871 //            << ToServiceParameterName << endl ;
1872   NodePort( ToNodeName , ToServiceParameterName , &theNode , &aPort ) ;
1873
1874   GraphBase::ComputingNode * aNode = GetChangeGraphNode( theNode ) ;
1875
1876   if ( aNode ) {
1877     GraphBase::OutPort *anOutPort = NULL ;
1878     GraphBase::InPort *anInPort = aNode->GetChangeInPort( aPort );
1879     if ( anInPort ) {
1880       anOutPort = anInPort->GetOutPort() ;
1881       if ( anOutPort ) {
1882         aRet = anOutPort->Value() ;
1883 //        cdebug << "OutPort value " << anOutPort->NodeName() << "("
1884 //               << anOutPort->PortName() << ") --> InPort " << anInPort->NodeName()
1885 //               << "(" << anInPort->PortName() << ")" << endl ;
1886       }
1887       else {
1888         cdebug << "GraphBase::Graph::PortInData " << ToNodeName << " "
1889                << ToServiceParameterName << " ERROR no OutPort" << endl ;
1890       }
1891     }
1892     else {
1893       cdebug << "GraphBase::Graph::PortInData " << ToNodeName << " "
1894              << ToServiceParameterName << " ERROR no InPort" << endl ;
1895     }
1896   }
1897   else {
1898     cdebug << "GraphBase::Graph::PortInData " << ToNodeName << " "
1899            << ToServiceParameterName << " ERROR no Node" << endl ;
1900   }
1901   delete theNode ;
1902   delete aPort ;
1903 //  cdebug_out << "GraphBase::Graph::PortInData " << endl ;
1904   return aRet ;
1905 }
1906
1907 const CORBA::Any * GraphBase::Graph::PortOutData( const char* FromNodeName ,
1908                                                   const char* FromServiceParameterName ) {
1909   const CORBA::Any * aRet = new CORBA::Any() ;
1910   char *theNode ;
1911   char *aPort ;
1912 //  cdebug_in << "GraphBase::Graph::PortOutData " << FromNodeName << " "
1913 //            << FromServiceParameterName << endl ;
1914   NodePort( FromNodeName , FromServiceParameterName , &theNode , &aPort ) ;
1915
1916   GraphBase::ComputingNode * aNode = GetChangeGraphNode( theNode ) ;
1917
1918   if ( aNode ) {
1919     GraphBase::OutPort *anOutPort ;
1920     anOutPort = aNode->GetChangeOutPort( aPort );
1921     if ( anOutPort ) {
1922       aRet = anOutPort->Value() ;
1923     }
1924     else {
1925       cdebug << "GraphBase::Graph::PortOutData " << FromNodeName << " "
1926              << FromServiceParameterName << " ERROR no OutPort" << endl ;
1927     }
1928   }
1929   else {
1930     cdebug << "GraphBase::Graph::PortOutData " << FromNodeName << " "
1931            << FromServiceParameterName << " ERROR no Node" << endl ;
1932   }
1933   delete theNode ;
1934   delete aPort ;
1935 //  cdebug_out << "GraphBase::Graph::PortOutData " << endl ;
1936   return aRet ;
1937 }
1938
1939 SUPERV::ListOfStrings * GraphBase::Graph::LevelNodes(long aLevel ) {
1940   SUPERV::ListOfStrings_var RetVal = new SUPERV::ListOfStrings;
1941   if ( aLevel >= 0 && aLevel <= _LevelsNumber ) {
1942     int i ;
1943     RetVal->length( _NodesNumber[ aLevel ] + 1 );
1944     for ( i= 0 ; i <= _NodesNumber[ aLevel ] ; i++ ) {
1945       RetVal[i] = CORBA::string_dup( (_SortedNodes[ aLevel ])[ i ]->Name() ) ;
1946     }
1947   }
1948   return ( RetVal._retn() ) ;
1949 }
1950
1951 bool GraphBase::Graph::StartComponent(const int aThread ,
1952                                       const char * aComputerContainer ,
1953                                       const char * ComponentName ,
1954                                       Engines::Container_var & myContainer ,
1955                                       Engines::Component_var & objComponent ) {
1956   cdebug_in << aThread
1957             << " GraphBase::Graph::StartComponent " << aComputerContainer
1958             << " " << ComponentName << endl;
1959   bool RetVal = true ;
1960
1961   SALOME_LifeCycleCORBA LCC( NamingService() ) ;
1962   objComponent = LCC.FindOrLoad_Component( aComputerContainer ,
1963                                            ComponentName );
1964   if ( CORBA::is_nil( objComponent ) ) {
1965     cdebug_out << aThread 
1966                << " StartComponent cannot FindOrLoad " << aComputerContainer
1967                << " " << ComponentName << endl;
1968     return 0 ;
1969   }
1970   else {
1971     myContainer = LCC.FindContainer( aComputerContainer );
1972     if ( CORBA::is_nil( myContainer ) ) {
1973       cdebug_out << aThread
1974                  << " GraphBase::Graph::StartComponent myContainer = LCC.FindContainer( '"
1975                  << aComputerContainer << "' ) Container does not exist"
1976                  << endl ;
1977       return 0 ;
1978     }
1979   }
1980   cdebug_out << aThread << " GraphBase::Graph::StartComponent" << endl;
1981   return RetVal ;
1982 }
1983