Salome HOME
Join modifications from BR_Dev_For_4_0 tag V4_1_1.
[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.salome-platform.org/ or email : webmaster.salome@opencascade.com
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_StreamGraph.hxx"
31
32 #include "SALOME_LifeCycleCORBA.hxx"
33
34 GraphBase::Graph::Graph() :
35            DataNode() {
36   cdebug << "GraphBase::Graph::Graph" << endl ;
37   _GraphNodesSize = 0 ;
38   GraphOfNode( this ) ;
39 }
40
41 GraphBase::Graph::Graph( CORBA::ORB_ptr ORB ,
42                          SALOME_NamingService* ptrNamingService ,
43                          const char *DataFlowName ,
44                          const SUPERV::KindOfNode DataFlowkind ,
45                          int * Graph_prof_debug ,
46                          ofstream * Graph_fdebug ) :
47 //                         const char * DebugFileName ) :
48            DataNode( ORB ,ptrNamingService , DataFlowName , DataFlowkind , Graph_prof_debug , Graph_fdebug ) {
49   _Orb = CORBA::ORB::_duplicate( ORB ) ;
50   Set_prof_debug( Graph_prof_debug , Graph_fdebug ) ;
51   cdebug << "GraphBase::Graph::Graph( " << DataFlowName << ") GraphNodesSize() " << GraphNodesSize() << endl ;
52   _GraphNodesSize = 0 ;
53   GraphOfNode( this ) ;
54 }
55
56 GraphBase::Graph::Graph( CORBA::ORB_ptr ORB ,
57                          SALOME_NamingService* ptrNamingService ,
58                          const SALOME_ModuleCatalog::Service& DataFlowService ,
59                          const char *DataFlowComponentName ,
60                          const char *DataFlowInterfaceName ,
61                          const char *DataFlowName ,
62                          const SUPERV::KindOfNode DataFlowkind ,
63                          const SUPERV::SDate DataFlowFirstCreation ,
64                          const SUPERV::SDate DataFlowLastModification ,
65                          const char * DataFlowEditorRelease ,
66                          const char * DataFlowAuthor ,
67                          const char * DataFlowComputer ,
68                          const char * DataFlowComment ,
69                          int * Graph_prof_debug ,
70                          ofstream * Graph_fdebug ) :
71 //                         const char * DebugFileName ) :
72            DataNode( ORB , ptrNamingService , DataFlowService ,
73                      DataFlowName , DataFlowkind ,
74                      DataFlowFirstCreation , DataFlowLastModification  ,
75                      DataFlowEditorRelease , DataFlowAuthor , DataFlowComment ) {
76   _Orb = CORBA::ORB::_duplicate( ORB ) ;
77   _GraphNodesSize = 0 ;
78   GraphOfNode( this ) ;
79   Set_prof_debug( Graph_prof_debug , Graph_fdebug ) ;
80   cdebug_in << "GraphBase::Graph::Graph" << endl ;
81   DataService( ORB , DataFlowService , Graph_prof_debug , Graph_fdebug ) ;
82   cdebug_out << "GraphBase::Graph::Graph" << endl ;
83 }
84
85 GraphBase::Graph::~Graph() {
86   cdebug << "GraphBase::Graph::~Graph" << endl ;
87 }
88
89 void GraphBase::Graph::Set_prof_debug( int * Graph_prof_debug ,
90                                        ofstream * Graph_fdebug ) {
91   SetDebug( _Orb , Graph_prof_debug , Graph_fdebug ) ;
92   _Graph_prof_debug = Graph_prof_debug ;
93   _Graph_fdebug = Graph_fdebug ;
94 }
95
96 GraphBase::SNode * GraphBase::Graph::GetInfo() const {
97   GraphBase::SNode * Info = new GraphBase::SNode ;
98   Info->theComponentName = "" ;
99   Info->theInterfaceName = "" ;
100   Info->theName = Name() ;
101   Info->theKind = Kind() ;
102   if ( IsDataStreamNode() ) {
103     CORBA::Long Timeout ;
104     SUPERV::KindOfDataStreamTrace DataStreamTrace ;
105     CORBA::Double DeltaTime ;
106     ((GraphBase::StreamGraph * ) this)->StreamParams( Timeout , DataStreamTrace , DeltaTime ) ;
107     Info->theTimeout = Timeout ;
108     Info->theDataStreamTrace = DataStreamTrace ;
109     Info->theDeltaTime = DeltaTime ;
110   }
111   Info->theService = *GetService() ;
112   Info->theFirstCreation = FirstCreation() ;
113   Info->theLastModification = LastModification() ;
114   Info->theEditorRelease = EditorRelease() ;
115   Info->theAuthor = Author() ;
116   Info->theContainer = "" ;
117   Info->theComment = Comment() ;
118   Info->theCoords.theX = GraphBase::ComputingNode::XCoordinate() ;
119   Info->theCoords.theY = GraphBase::ComputingNode::YCoordinate() ;
120   return Info ;
121 }
122
123 //----------------------------------------------------------------------
124 // Function : GetNodes
125 // Purpose  : get a nodes list
126 //----------------------------------------------------------------------
127 GraphBase::ListOfSNodes * GraphBase::Graph::GetNodes() const {
128   GraphBase::ListOfSNodes * _list_nodes = new GraphBase::ListOfSNodes;
129
130   cdebug_in << "GraphBase::Graph::GetNodes" << endl ;
131   // All the nodes from _InNodes are taken
132 //  vector< InNode *> Nodes = InNodes() ;
133
134   _list_nodes->resize( GraphNodesSize() );
135
136   int igoto ;
137   int ind ;
138   GraphBase::ComputingNode * aCNode = NULL ;
139   for ( igoto = 0 ; igoto < 2 ; igoto++ ) {
140     for ( ind = 0 ; ind < GraphNodesSize() ; ind++ ) {
141       aCNode = GraphNodes( ind ) ;
142       if ( ( igoto == 0 && !aCNode->IsGOTONode() ) ||
143            ( igoto == 1 && aCNode->IsGOTONode() ) ) {
144         if ( aCNode->IsFactoryNode() ) {
145           GraphBase::FactoryNode * aFNode = (GraphBase::FactoryNode * ) aCNode ;
146 //JR 24.02.2005 Memory Leak          (*_list_nodes)[ind].theComponentName = CORBA::string_dup( aFNode->ComponentName());
147           (*_list_nodes)[ind].theComponentName = string( aFNode->ComponentName());
148 //JR 24.02.2005 Memory Leak          (*_list_nodes)[ind].theInterfaceName = CORBA::string_dup( aFNode->InterfaceName());
149           (*_list_nodes)[ind].theInterfaceName = string( aFNode->InterfaceName());
150         }
151         else {
152           (*_list_nodes)[ind].theComponentName = string( "" );
153           (*_list_nodes)[ind].theInterfaceName = string( "" );
154         }
155 //JR 24.02.2005 Memory Leak        (*_list_nodes)[ind].theName = CORBA::string_dup( aCNode->Name() );
156         (*_list_nodes)[ind].theName = string( aCNode->Name() );
157         (*_list_nodes)[ind].theKind = aCNode->Kind();
158         if ( aCNode->IsInLineNode() || aCNode->IsMacroNode() ) {
159           GraphBase::InLineNode * aINode = (GraphBase::InLineNode * ) aCNode ;
160           (*_list_nodes)[ind].theListOfFuncName.resize( 1 ) ;
161 //JR 24.02.2005 Memory Leak          (*_list_nodes)[ind].theListOfFuncName[0] = CORBA::string_dup( aINode->PyFuncName() ) ;
162           (*_list_nodes)[ind].theListOfFuncName[0] = string( aINode->PyFuncName() ) ;
163           (*_list_nodes)[ind].theListOfPythonFunctions.resize( 1 ) ;
164           (*_list_nodes)[ind].theListOfPythonFunctions[0] = aINode->PythonFunction() ;
165         }
166         if ( aCNode->IsGOTONode() ) {
167           GraphBase::GOTONode * aGNode = (GraphBase::GOTONode * ) aCNode ;
168           (*_list_nodes)[ind].theListOfFuncName.resize( 1 ) ;
169 //JR 24.02.2005 Memory Leak          (*_list_nodes)[ind].theListOfFuncName[0] = CORBA::string_dup( aGNode->PyFuncName() ) ;
170           (*_list_nodes)[ind].theListOfFuncName[0] = string( aGNode->PyFuncName() ) ;
171           (*_list_nodes)[ind].theListOfPythonFunctions.resize( 1 ) ;
172           (*_list_nodes)[ind].theListOfPythonFunctions[0] = aGNode->PythonFunction() ;
173         }
174         if ( aCNode->IsLoopNode() ) {
175           GraphBase::LoopNode * aLNode = (GraphBase::LoopNode * ) aCNode ;
176 //JR 24.02.2005 Memory Leak          (*_list_nodes)[ind].theCoupledNode = CORBA::string_dup( aLNode->CoupledNode()->Name() ) ;
177           (*_list_nodes)[ind].theCoupledNode = string( aLNode->CoupledNode()->Name() ) ;
178           (*_list_nodes)[ind].theListOfFuncName.resize( 3 ) ;
179 //JR 24.02.2005 Memory Leak          (*_list_nodes)[ind].theListOfFuncName[0] = CORBA::string_dup( aLNode->PyFuncName() ) ;
180           (*_list_nodes)[ind].theListOfFuncName[0] = string( aLNode->PyFuncName() ) ;
181 //JR 24.02.2005 Memory Leak          (*_list_nodes)[ind].theListOfFuncName[1] = CORBA::string_dup( aLNode->PyMoreName() ) ;
182           (*_list_nodes)[ind].theListOfFuncName[1] = string( aLNode->PyMoreName() ) ;
183 //JR 24.02.2005 Memory Leak          (*_list_nodes)[ind].theListOfFuncName[2] = CORBA::string_dup( aLNode->PyNextName() ) ;
184           (*_list_nodes)[ind].theListOfFuncName[2] = string( aLNode->PyNextName() ) ;
185           (*_list_nodes)[ind].theListOfPythonFunctions.resize( 3 ) ;
186           (*_list_nodes)[ind].theListOfPythonFunctions[0] = aLNode->PythonFunction() ;
187           (*_list_nodes)[ind].theListOfPythonFunctions[1] = aLNode->MorePythonFunction() ;
188           (*_list_nodes)[ind].theListOfPythonFunctions[2] = aLNode->NextPythonFunction() ;
189         }
190         else if ( aCNode->IsSwitchNode() ) {
191           GraphBase::SwitchNode * aSNode = (GraphBase::SwitchNode * ) aCNode ;
192 //JR 24.02.2005 Memory Leak          (*_list_nodes)[ind].theCoupledNode = CORBA::string_dup( aSNode->CoupledNode()->Name() ) ;
193           (*_list_nodes)[ind].theCoupledNode = string( aSNode->CoupledNode()->Name() ) ;
194           (*_list_nodes)[ind].theListOfFuncName.resize( 1 ) ;
195 //JR 24.02.2005 Memory Leak          (*_list_nodes)[ind].theListOfFuncName[0] = CORBA::string_dup( aSNode->PyFuncName() ) ;
196           (*_list_nodes)[ind].theListOfFuncName[0] = string( aSNode->PyFuncName() ) ;
197           (*_list_nodes)[ind].theListOfPythonFunctions.resize( 1 ) ;
198           (*_list_nodes)[ind].theListOfPythonFunctions[0] = aSNode->PythonFunction() ;
199         }
200         else if ( aCNode->IsEndLoopNode() ) {
201           GraphBase::EndOfLoopNode * aELNode = (GraphBase::EndOfLoopNode * ) aCNode ;
202 //JR 24.02.2005 Memory Leak          (*_list_nodes)[ind].theCoupledNode = CORBA::string_dup( aELNode->CoupledNode()->Name() ) ;
203           (*_list_nodes)[ind].theCoupledNode = string( aELNode->CoupledNode()->Name() ) ;
204           (*_list_nodes)[ind].theListOfFuncName.resize( 1 ) ;
205 //JR 24.02.2005 Memory Leak          (*_list_nodes)[ind].theListOfFuncName[0] = CORBA::string_dup( aELNode->PyFuncName() ) ;
206           (*_list_nodes)[ind].theListOfFuncName[0] = string( aELNode->PyFuncName() ) ;
207           (*_list_nodes)[ind].theListOfPythonFunctions.resize( 1 ) ;
208           (*_list_nodes)[ind].theListOfPythonFunctions[0] = aELNode->PythonFunction() ;
209         }
210         else if ( aCNode->IsEndSwitchNode() ) {
211           GraphBase::EndOfSwitchNode * aESNode = (GraphBase::EndOfSwitchNode * ) aCNode ;
212 //JR 24.02.2005 Memory Leak          (*_list_nodes)[ind].theCoupledNode = CORBA::string_dup( aESNode->CoupledNode()->Name() ) ;
213           (*_list_nodes)[ind].theCoupledNode = string( aESNode->CoupledNode()->Name() ) ;
214           (*_list_nodes)[ind].theListOfFuncName.resize( 1 ) ;
215 //JR 24.02.2005 Memory Leak          (*_list_nodes)[ind].theListOfFuncName[0] = CORBA::string_dup( aESNode->PyFuncName() ) ;
216           (*_list_nodes)[ind].theListOfFuncName[0] = string( aESNode->PyFuncName() ) ;
217           (*_list_nodes)[ind].theListOfPythonFunctions.resize( 1 ) ;
218           (*_list_nodes)[ind].theListOfPythonFunctions[0] = aESNode->PythonFunction() ;
219         }
220         else if ( aCNode->IsMacroNode() ) {
221           GraphBase::Graph * aGraph = (GraphBase::Graph * ) aCNode ;
222 //JR 24.02.2005 Memory Leak          (*_list_nodes)[ind].theCoupledNode = CORBA::string_dup( aGraph->CoupledNode()->Name() ) ;
223           (*_list_nodes)[ind].theCoupledNode = string( aGraph->CoupledNode()->Name() ) ;
224           (*_list_nodes)[ind].theListOfFuncName.resize( 1 ) ;
225 //JR 24.02.2005 Memory Leak          (*_list_nodes)[ind].theListOfFuncName[0] = CORBA::string_dup( aGraph->PyFuncName() ) ;
226           (*_list_nodes)[ind].theListOfFuncName[0] = string( aGraph->PyFuncName() ) ;
227           (*_list_nodes)[ind].theListOfPythonFunctions.resize( 1 ) ;
228           (*_list_nodes)[ind].theListOfPythonFunctions[0] = aGraph->PythonFunction() ;
229         }
230         else {
231           (*_list_nodes)[ind].theCoupledNode = string( "" ) ;
232         }
233 //        (*_list_nodes)[ind].theDataStreamInArgsNumber = aCNode->DataStreamInPortsNumber() ;
234 //        (*_list_nodes)[ind].theDataStreamOutArgsNumber = aCNode->DataStreamOutPortsNumber() ;
235
236         (*_list_nodes)[ind].theListOfInDataStreams.resize( aCNode->DataStreamInPortsNumber() ) ;
237         cdebug << "GraphBase::Graph::GetNodes " << aCNode->Name() << " " << aCNode->DataStreamInPortsNumber() << " DataStreamInPortsNumber" << endl ;
238         int iostream ;
239         int streamind = 0 ;
240         for ( iostream = 0 ; iostream < aCNode->GetNodeInPortsSize() ; iostream++ ) {
241           const GraphBase::InPort * anInPort ;
242           anInPort = aCNode->GetNodeInPort( iostream ) ;
243           if ( anInPort->IsDataStream() ) {
244             cdebug << "GraphBase::Graph::GetNodes In" << iostream << " " << aCNode->Name()
245                    << " " << anInPort->NodeName() << " " << anInPort->PortName() << endl;
246             (*_list_nodes)[ind].theListOfInDataStreams[streamind].theDataStreamParameter.Parametertype = CORBA::string_dup( anInPort->PortType() ) ;
247             (*_list_nodes)[ind].theListOfInDataStreams[streamind].theDataStreamParameter.Parametername = CORBA::string_dup( anInPort->PortName() ) ;
248             (*_list_nodes)[ind].theListOfInDataStreams[streamind].theDataStreamParameter.Parameterdependency = anInPort->Dependency() ;
249             SUPERV::KindOfSchema        aKindOfSchema ;
250             SUPERV::KindOfInterpolation aKindOfInterpolation ;
251             SUPERV::KindOfExtrapolation aKindOfExtrapolation ;
252             ((GraphBase::InDataStreamPort * ) anInPort)->Params( aKindOfSchema , aKindOfInterpolation , aKindOfExtrapolation ) ;
253             (*_list_nodes)[ind].theListOfInDataStreams[streamind].theKindOfSchema = aKindOfSchema ;
254             (*_list_nodes)[ind].theListOfInDataStreams[streamind].theKindOfInterpolation = aKindOfInterpolation ;
255             (*_list_nodes)[ind].theListOfInDataStreams[streamind].theKindOfExtrapolation = aKindOfExtrapolation ;
256             cdebug << "GraphBase::Graph::GetNodes " << aCNode->Name() << " " << anInPort->NodeName() << " " << anInPort->PortName() << " "
257                    <<  anInPort->Dependency() << " " << aKindOfSchema << " " << aKindOfInterpolation << " " << aKindOfExtrapolation << " list_nodes "
258                    << (*_list_nodes)[ind].theListOfInDataStreams[streamind].theDataStreamParameter.Parametername << " "
259                    << (*_list_nodes)[ind].theListOfInDataStreams[streamind].theDataStreamParameter.Parametertype << " "
260                    << (*_list_nodes)[ind].theListOfInDataStreams[streamind].theDataStreamParameter.Parameterdependency << " "
261                    << (*_list_nodes)[ind].theListOfInDataStreams[streamind].theKindOfSchema << " "
262                    << (*_list_nodes)[ind].theListOfInDataStreams[streamind].theKindOfInterpolation << " "
263                    << (*_list_nodes)[ind].theListOfInDataStreams[streamind].theKindOfExtrapolation << " " << endl ;
264             streamind += 1 ;
265           }
266           else {
267             cdebug << "GraphBase::Graph::GetNodes " << aCNode->Name() << " " << anInPort->NodeName() << " " << anInPort->PortName() << " "
268                    << anInPort->Kind() << " IsDataStream " << anInPort->IsDataStream() << endl ;
269           }
270         }
271
272         (*_list_nodes)[ind].theListOfOutDataStreams.resize( aCNode->DataStreamOutPortsNumber() ) ;
273         cdebug << "GraphBase::Graph::GetNodes " << aCNode->Name() << " " << aCNode->DataStreamOutPortsNumber() << " DataStreamOutPortsNumber" << endl ;
274         streamind = 0 ;
275         for ( iostream = 0 ; iostream < aCNode->GetNodeOutPortsSize() ; iostream++ ) {
276           const GraphBase::OutPort * anOutPort ;
277           anOutPort = aCNode->GetNodeOutPort( iostream ) ;
278           if ( anOutPort->IsDataStream() ) {
279             cdebug << "GraphBase::Graph::GetNodes Out" << iostream << " " << aCNode->Name() << " " << anOutPort->NodeName() << " " << anOutPort->PortName() << " "
280                    << endl ;
281             (*_list_nodes)[ind].theListOfOutDataStreams[streamind].theDataStreamParameter.Parametertype = CORBA::string_dup( anOutPort->PortType() ) ;
282             (*_list_nodes)[ind].theListOfOutDataStreams[streamind].theDataStreamParameter.Parametername = CORBA::string_dup( anOutPort->PortName() ) ;
283             (*_list_nodes)[ind].theListOfOutDataStreams[streamind].theDataStreamParameter.Parameterdependency = anOutPort->Dependency() ;
284             long aNumberOfValues = ((GraphBase::OutDataStreamPort * ) anOutPort)->NumberOfValues() ;
285             (*_list_nodes)[ind].theListOfOutDataStreams[streamind].theNumberOfValues = aNumberOfValues ;
286             cdebug << "GraphBase::Graph::GetNodes " << aCNode->Name() << " " << anOutPort->NodeName() << " " << anOutPort->PortName() << " "
287                    <<  anOutPort->Dependency() << " " << aNumberOfValues << " list_nodes "
288                    << (*_list_nodes)[ind].theListOfOutDataStreams[streamind].theDataStreamParameter.Parametername << " "
289                    << (*_list_nodes)[ind].theListOfOutDataStreams[streamind].theDataStreamParameter.Parametertype << " "
290                    << (*_list_nodes)[ind].theListOfOutDataStreams[streamind].theDataStreamParameter.Parameterdependency << " "
291                    << (*_list_nodes)[ind].theListOfOutDataStreams[streamind].theNumberOfValues << endl ;
292             streamind += 1 ;
293           }
294           else {
295             cdebug << "GraphBase::Graph::GetNodes " << aCNode->Name() << " " << anOutPort->NodeName() << " " << anOutPort->PortName() << " "
296                    << anOutPort->Kind() << " IsDataStream " << anOutPort->IsDataStream() << endl ;
297           }
298         }
299
300         (*_list_nodes)[ind].theService = *aCNode->GetService();
301         cdebug << "GraphBase::Graph::GetNodes theService " << &(*_list_nodes)[ind].theService.ServiceName << endl ;
302         unsigned int i ;
303         for ( i = 0 ; i < (*_list_nodes)[ind].theService.ServiceinParameter.length() ; i++ ) {
304           cdebug << "     In" << i << " " << &(*_list_nodes)[ind].theService.ServiceinParameter[i].Parametername
305                  << " " << (*_list_nodes)[ind].theService.ServiceinParameter[i].Parametername
306                  << " " << &(*_list_nodes)[ind].theService.ServiceinParameter[i].Parametertype
307                  << " " << (*_list_nodes)[ind].theService.ServiceinParameter[i].Parametertype << endl ;
308         }
309         for ( i = 0 ; i < (*_list_nodes)[ind].theService.ServiceoutParameter.length() ; i++ ) {
310           cdebug << "     Out" << i << " " << &(*_list_nodes)[ind].theService.ServiceoutParameter[i].Parametername
311                  << " " << (*_list_nodes)[ind].theService.ServiceoutParameter[i].Parametername
312                  << " " << &(*_list_nodes)[ind].theService.ServiceoutParameter[i].Parametertype
313                  << " " << (*_list_nodes)[ind].theService.ServiceoutParameter[i].Parametertype << endl ;
314         }
315         for ( i = 0 ; i < (*_list_nodes)[ind].theService.ServiceinDataStreamParameter.length() ; i++ ) {
316           cdebug << "     InDataStream" << i << " " << &(*_list_nodes)[ind].theService.ServiceinDataStreamParameter[i].Parametername
317                  << " " << (*_list_nodes)[ind].theService.ServiceinDataStreamParameter[i].Parametername
318                  << " " << &(*_list_nodes)[ind].theService.ServiceinDataStreamParameter[i].Parametertype
319                  << " " << (*_list_nodes)[ind].theService.ServiceinDataStreamParameter[i].Parametertype << endl ;
320         }
321         for ( i = 0 ; i < (*_list_nodes)[ind].theService.ServiceoutDataStreamParameter.length() ; i++ ) {
322           cdebug << "     OutDataStream" << i << " " << &(*_list_nodes)[ind].theService.ServiceoutDataStreamParameter[i].Parametername
323                  << " " << (*_list_nodes)[ind].theService.ServiceoutDataStreamParameter[i].Parametername
324                  << " " << &(*_list_nodes)[ind].theService.ServiceoutDataStreamParameter[i].Parametertype
325                  << " " << (*_list_nodes)[ind].theService.ServiceoutDataStreamParameter[i].Parametertype << endl ;
326         }
327         if ( aCNode->IsOneOfInLineNodes() ) {
328           GraphBase::InLineNode * aINode = (GraphBase::InLineNode * ) aCNode ;
329           GraphBase::LoopNode * aLNode = NULL ;
330           if ( aCNode->IsLoopNode() ) {
331             aLNode = (GraphBase::LoopNode * ) aCNode ;
332             (*_list_nodes)[ind].theListOfPythonFunctions.resize( 3 ) ;
333             (*_list_nodes)[ind].theListOfPythonFunctions[ 0 ] = aINode->PythonFunction() ;
334             (*_list_nodes)[ind].theListOfPythonFunctions[ 1 ] = aLNode->MorePythonFunction() ;
335             (*_list_nodes)[ind].theListOfPythonFunctions[ 2 ] = aLNode->NextPythonFunction() ;
336           }
337           else if ( aCNode->IsInLineNode() || aCNode->IsGOTONode() ||
338                     aCNode->IsSwitchNode() || aCNode->IsEndSwitchNode() ) {
339             (*_list_nodes)[ind].theListOfPythonFunctions.resize( 1 ) ;
340             (*_list_nodes)[ind].theListOfPythonFunctions[ 0 ] = aINode->PythonFunction() ;
341           }
342         }
343         (*_list_nodes)[ind].theFirstCreation = aCNode->FirstCreation();
344         (*_list_nodes)[ind].theLastModification = aCNode->LastModification();
345 //JR 24.02.2005 Memory Leak        (*_list_nodes)[ind].theEditorRelease = CORBA::string_dup( aCNode->EditorRelease());
346         (*_list_nodes)[ind].theEditorRelease = string( aCNode->EditorRelease());
347 //JR 24.02.2005 Memory Leak        (*_list_nodes)[ind].theAuthor = CORBA::string_dup( aCNode->Author());
348         (*_list_nodes)[ind].theAuthor = string( aCNode->Author()); // mkr : IPAL10200
349         if ( aCNode->IsFactoryNode() ) {
350           GraphBase::FactoryNode * aFNode = (GraphBase::FactoryNode * ) aCNode ;
351 //JR 24.02.2005 Memory Leak          (*_list_nodes)[ind].theContainer = CORBA::string_dup( aFNode->Computer());
352           (*_list_nodes)[ind].theContainer = string( aFNode->Computer());
353         }
354         else {
355 //JR 24.02.2005 Memory Leak          (*_list_nodes)[ind].theContainer = CORBA::string_dup( "" );
356           (*_list_nodes)[ind].theContainer = string( "" );
357         }
358 //JR 24.02.2005 Memory Leak        (*_list_nodes)[ind].theComment = CORBA::string_dup( aCNode->Comment());
359         (*_list_nodes)[ind].theComment = string( aCNode->Comment());
360         (*_list_nodes)[ind].theCoords.theX = aCNode->XCoordinate();
361         (*_list_nodes)[ind].theCoords.theY = aCNode->YCoordinate();
362 #if 0
363         int nports = 0 ;
364         int i ;
365         for ( i = 0 ; i < aCNode->GetNodeInPortsSize() ; i++ ) {
366           const GraphBase::InPort * anInPort = aCNode->GetNodeInPort( i ) ;
367           if ( anInPort->IsBus() ) {
368             nports += 1 ;
369             (*_list_nodes)[ind].theListOfParameters.resize( nports ) ;
370 //JR 24.02.2005 Memory Leak            (*_list_nodes)[ind].theListOfParameters[ nports-1 ].theInParameter.Parametertype = CORBA::string_dup( anInPort->PortType() ) ;
371             (*_list_nodes)[ind].theListOfParameters[ nports-1 ].theInParameter.Parametertype = string( anInPort->PortType() ) ;
372 //JR 24.02.2005 Memory Leak            (*_list_nodes)[ind].theListOfParameters[ nports-1 ].theInParameter.Parametername = CORBA::string_dup( anInPort->PortName() ) ;
373             (*_list_nodes)[ind].theListOfParameters[ nports-1 ].theInParameter.Parametername = string( anInPort->PortName() ) ;
374 //JR 24.02.2005 Memory Leak            (*_list_nodes)[ind].theListOfParameters[ nports-1 ].theOutParameter.Parametertype = CORBA::string_dup( aCNode->GetNodeOutPort( anInPort->PortIndex() )->PortType() ) ;
375             (*_list_nodes)[ind].theListOfParameters[ nports-1 ].theOutParameter.Parametertype = string( aCNode->GetNodeOutPort( anInPort->PortIndex() )->PortType() ) ;
376 //JR 24.02.2005 Memory Leak            (*_list_nodes)[ind].theListOfParameters[ nports-1 ].theOutParameter.Parametername = CORBA::string_dup( aCNode->GetNodeOutPort( anInPort->PortIndex() )->PortName() ) ;
377             (*_list_nodes)[ind].theListOfParameters[ nports-1 ].theOutParameter.Parametername = string( aCNode->GetNodeOutPort( anInPort->PortIndex() )->PortName() ) ;
378           }
379         }
380 #endif
381       }
382     }
383   }
384   cdebug_out << "GraphBase::Graph::GetNodes" << endl ;
385   return _list_nodes ;
386 }
387
388
389 //----------------------------------------------------------------------
390 // Function : GetLinks
391 // Purpose  : get a links list
392 //----------------------------------------------------------------------
393 GraphBase::ListOfSLinks * GraphBase::Graph::GetLinks(bool AllLinks ) const {
394   GraphBase::ListOfSLinks * _list_links = new GraphBase::ListOfSLinks;
395
396 // All the links from _LinksList are taken
397 //  vector< InNode *> Nodes = InNodes() ;
398
399   cdebug_in << "Graph::GetLinks( " << AllLinks << " ) " << endl ;
400   int ind = 0 ;
401   int k ;
402   for ( k = 0 ; k < GraphNodesSize() ; k++ ) {
403     GraphBase::ComputingNode * fromNode = GraphNodes( k ) ;
404 //    cdebug << "GraphBase::Graph::GetLinks k" << k << ". :" << fromNode->Name() << endl ;
405     int i ;
406     for ( i = 0 ; i < fromNode->GetNodeOutPortsSize() ; i++ ) {
407       const GraphBase::OutPort* fromPort = fromNode->GetNodeOutPort( i ) ;
408 //      cdebug << "GraphBase::Graph::GetLinks k" << k << ". :" << fromNode->Name()
409 //             << " i" << i << ". : " << fromPort->PortName() << endl ;
410       int j ;
411       for ( j = 0 ; j < fromPort->InPortsSize() ; j++ ) {
412         const GraphBase::InPort* toPort = fromPort->InPorts( j ) ;
413 //        cdebug << "GraphBase::Graph::GetLinks k" << k << ". : fromNode " << fromNode << " = "
414 //               << fromNode->Name() << " i" << i << ". : fromPort " << fromPort << " = "
415 //               << fromPort->PortName() << " j" << j << ". : toPort " << toPort << " = "
416 //               << toPort->NodeName() << "( " << toPort->PortName() << " )" << endl ;
417         if ( toPort->IsPortConnected() ) {
418 // Desole pour ce cast mais avec les maps difficile de faire const ...
419 //          const GraphBase::ComputingNode * toNode = ((GraphBase::Graph * ) this)->GetGraphNode( toPort->NodeName() ) ;
420 //          cdebug << "GraphBase::Graph::GetLinks " << fromNode->Name() << " ("
421 //                 << fromPort->PortName() << " ) IsPortConnected" << fromPort->IsPortConnected()
422 //                 << " --> toNode " << toNode << " " << toPort->NodeName() << "( "
423 //                 << toPort->PortName() << " ) " << " " << fromPort->InPortsSize() << " ports"
424 //                 << endl ;
425           if ( !(fromPort->IsLoop() && toPort->IsLoop() ) || AllLinks ) {
426 //            cdebug << "GraphBase::Graph::GetLinks " << fromNode->Name() << " ("
427 //                   << fromPort->PortName() << " ) IsPortConnected" << fromPort->IsPortConnected()
428 //                   << " --> " << toNode->Name() << "( " << toPort->PortName() << " ) "
429 //                   << " " << fromPort->InPortsSize() << " ports" << endl ;
430             _list_links->resize( ind+1 );
431 //JR 23.02.2005 Memory Leak            (*_list_links)[ind].FromNodeName = CORBA::string_dup( fromNode->Name() );
432             (*_list_links)[ind].FromNodeName = string( fromNode->Name() );
433             (*_list_links)[ind].FromServiceParameterName = fromPort->GetServicesParameter().Parametername;
434 //JR 23.02.2005 Memory Leak            (*_list_links)[ind].ToNodeName = CORBA::string_dup( toPort->NodeName() );
435             (*_list_links)[ind].ToNodeName = string( toPort->NodeName() );
436             (*_list_links)[ind].ToServiceParameterName = toPort->GetServicesParameter().Parametername;
437 //JR 30.03.2005            (*_list_links)[ind].aLinkValue = *fromPort->Value() ;
438             (*_list_links)[ind].aLinkValue = fromPort->Value() ;
439             if ( toPort->IsEndSwitch() ) {
440               (*_list_links)[ind++].aListOfCoords = *(fromPort->Coords()) ;
441             }
442             else {
443               (*_list_links)[ind++].aListOfCoords = *(toPort->Coords()) ;
444             }
445           }
446         }
447         else {
448 //          cdebug << "GraphBase::Graph::GetLinks " << fromNode->Name() << " "
449 //                 << fromPort->PortName() << " ) " << fromPort->PortStatus()
450 //                 << " --> " << toPort->NodeName() << "( " << toPort->PortName() << " ) "
451 //                 << " " << toPort->PortStatus() << " " << fromPort->InPortsSize()
452 //                 << " ports ignored" << endl ;
453         }
454       }
455     }
456   }
457
458   cdebug_out << "Graph::GetLinks( " << AllLinks << " ) " << endl ;
459   return _list_links;
460 }
461
462 GraphBase::ListOfSGraphs * GraphBase::Graph::GetGraphs() const {
463   GraphBase::ListOfSGraphs * _list_graphs = new GraphBase::ListOfSGraphs;
464
465   return _list_graphs;
466 }
467
468 GraphBase::SLink * GraphBase::Graph::GetLink( GraphBase::ComputingNode * aNode ,
469                                               GraphBase::InPort* toPort ) {
470   GraphBase::SLink * _link =  new GraphBase::SLink ;
471   GraphBase::OutPort* fromPort = toPort->GetOutPort() ;
472 //JR 24.02.2005 Memory Leak  _link->FromNodeName = CORBA::string_dup( fromPort->NodeName() );
473   _link->FromNodeName = string( fromPort->NodeName() );
474   _link->FromServiceParameterName = fromPort->GetServicesParameter().Parametername;
475 //JR 24.02.2005 Memory Leak  _link->ToNodeName = CORBA::string_dup( toPort->NodeName() );
476   _link->ToNodeName = string( toPort->NodeName() );
477   _link->ToServiceParameterName = toPort->GetServicesParameter().Parametername;
478 //JR 30.03.2005  CORBA::Any aSPValue = *fromPort->Value() ;
479   CORBA::Any aSPValue = fromPort->Value() ;
480   _link->aLinkValue = aSPValue;
481   _link->aListOfCoords = *(toPort->Coords()) ;
482   return _link;
483 }
484 //----------------------------------------------------------------------
485 // Function : GetDatas
486 // Purpose  : get the datas list
487 //----------------------------------------------------------------------
488 GraphBase::ListOfSLinks * GraphBase::Graph::GetDatas() const {
489   GraphBase::ListOfSLinks * _list_datalinks = new GraphBase::ListOfSLinks;
490
491   int ind = 0 ;
492   const GraphBase::DataNode * aDataNode = this ;
493   int i ;
494   for ( i = 0 ; i < aDataNode->GetNodeInDataNodePortsSize() ; i++ ) {
495     const GraphBase::OutPort* fromDataPort = aDataNode->GetNodeInDataNodePort( i ) ;
496     if ( GraphMacroLevel() == 0 ) {
497       if ( fromDataPort->IsDataConnected() ) {
498         int j ;
499 //We may have SharedData as input of a DataFlow : same input for one or several
500 // input ports. Input(s) of a DataFlow match one or several output-virtual-dataport
501         for ( j = 0 ; j < fromDataPort->InPortsSize() ; j++ ) {
502           _list_datalinks->resize( ind+1 );
503 //JR 24.02.2005 Memory Leak          (*_list_datalinks)[ind].FromNodeName = CORBA::string_dup( aDataNode->Name() );
504           (*_list_datalinks)[ind].FromNodeName = string( aDataNode->Name() );
505           (*_list_datalinks)[ind].FromServiceParameterName = fromDataPort->GetServicesParameter().Parametername;
506           const GraphBase::InPort* toPort = fromDataPort->InPorts( j ) ;
507 //JR 24.02.2005 Memory Leak          (*_list_datalinks)[ind].ToNodeName = CORBA::string_dup( toPort->NodeName() );
508           (*_list_datalinks)[ind].ToNodeName = string( toPort->NodeName() );
509           (*_list_datalinks)[ind].ToServiceParameterName = toPort->GetServicesParameter().Parametername;
510 //JR 30.03.2005          CORBA::Any aSPValue = *fromDataPort->Value() ;
511           CORBA::Any aSPValue = fromDataPort->Value() ;
512           (*_list_datalinks)[ind].aLinkValue = aSPValue;
513           (*_list_datalinks)[ind++].aListOfCoords = *(toPort->Coords()) ;
514         }
515       }
516     }
517   }
518
519   return _list_datalinks ;
520 }
521
522 bool GraphBase::Graph::AddNode( GraphBase::ComputingNode * aNode ) {
523   cdebug_in << "GraphBase::Graph::AddNode "  << (void *) aNode << " " << aNode->Name() << " " << aNode->ServiceName() << endl;
524   bool RetVal = false ;
525   int index = GetGraphNodeIndex( aNode->Name() ) ;
526   if ( index < 0 ) {
527     cdebug << "GraphBase::Graph::AddNode " << _GraphNodesSize << " nodes + 1" << endl ;
528     _GraphNodes.resize( _GraphNodesSize+1 ) ;
529     _GraphNodes[ _GraphNodesSize ] = aNode ;
530     SetGraphNodeIndex( aNode->Name() , _GraphNodesSize ) ;
531     _GraphNodesSize += 1 ;
532     if ( SetServiceOfMap( (GraphBase::Service * ) aNode ) ) {
533       cdebug << "Graph::AddNode SetServiceOfMap " << aNode->ServiceName() << " in MapOfServices" << endl ; 
534     }
535     else {
536       cdebug << "Graph::AddNode SetServiceOfMap " << aNode->ServiceName()
537              << " was already in MapOfServices" << endl ; 
538     }
539
540     RetVal = true ;
541     int i ;
542     cdebug << "GraphBase::Graph::AddNode " << _GraphNodesSize << " Known nodes :" << endl ;
543     for ( i = 0 ; i < _GraphNodesSize ; i++ ) {
544       const GraphBase::ComputingNode * aKnownNode = GetGraphNode( i ) ;
545       if ( aKnownNode ) {
546         cdebug << i << ". " << aKnownNode->Name() << " " << _MapOfGraphNodes[ GetGraphNode( i )->Name() ] - 1 << endl ;
547       }
548       else {
549         cdebug << i << ". ERROR" << endl ;
550       }
551     }
552     aNode->GraphOfNode( this ) ;
553   }
554   cdebug_out << "GraphBase::Graph::AddNode " << _GraphNodesSize << " Nodes. "
555              << aNode->ServiceName() << endl;
556   return RetVal ;
557 }
558
559 bool GraphBase::Graph::ReNameNode( const char* OldNodeName ,
560                                    const char* NewNodeName ) {
561   cdebug_in << "GraphBase::Graph::ReNameNode (" << OldNodeName << " , " << NewNodeName << ") "
562             << endl;
563   int i ;
564   bool RetVal = true ;
565 //#if 0
566   GraphBase::ComputingNode * anOldNode = GetChangeGraphNode( OldNodeName ) ;
567   for ( i = 0 ; i < anOldNode->LinkedNodesSize() ; i++ ) {
568     cdebug << "LinkedNode " << i << " " << anOldNode->LinkedNodes( i )->Name() << endl ;
569   }
570 //#endif
571   if ( !strcmp( OldNodeName , NewNodeName ) ) {
572   }
573   else if ( strcmp( Name() , OldNodeName ) ) {
574     int index = GetGraphNodeIndex( OldNodeName ) ;
575     int newindex = GetGraphNodeIndex( NewNodeName ) ;
576     if ( index >= 0 && index < _GraphNodesSize &&
577          ( newindex < 0 || newindex > _GraphNodesSize ) ) {
578       DelGraphNodeIndex( _GraphNodes[ index ]->Name() ) ;
579       _GraphNodes[ index ]->Name( NewNodeName ) ;
580 //JR 29.06.2005 Debug ???
581 //      SetGraphNodeIndex( NewNodeName , index ) ;
582       SetGraphNodeIndex( _GraphNodes[ index ]->Name() , index ) ;
583
584       GraphBase::ComputingNode * aNode = GetChangeGraphNode( index ) ;
585 // Update 'ToNode's Map from 'aNode'
586       cdebug << "Graph::ReNameNode " << aNode->Name() << "/" << OldNodeName << " LinkedNodesSize : "
587              << aNode->LinkedNodesSize() << endl ;
588       for ( i = 0 ; i < aNode->LinkedNodesSize() ; i++ ) {
589         GraphBase::StreamNode * ToNode = aNode->LinkedNodes( i ) ;
590         ToNode->ReNameLinkedFromNode( OldNodeName , NewNodeName ) ;
591       }
592 // Rename in _MapOfLinkedNodes of 'FromNode'
593       cdebug << "Graph::ReNameNode " << aNode->Name() << "/" << OldNodeName
594              << " LinkedFromNodesSize : " << aNode->LinkedFromNodesSize() << endl ;
595       for ( i = 0 ; i < aNode->LinkedFromNodesSize() ; i++ ) {
596         GraphBase::StreamNode * FromNode = aNode->LinkedFromNodes( i ) ;
597         if ( FromNode->GetLinkedNodeIndex( OldNodeName ) >= 0 ) {
598           FromNode->ReNameLinkedNode( OldNodeName , NewNodeName ) ;
599         }
600         else {
601           FromNode->ReNameStreamLinkedNode( OldNodeName , NewNodeName ) ;
602         }
603       }
604 // Inports 'anInPort' of 'aNode'
605       for ( i = aNode->GetNodeInPortsSize()-1 ; i >= 0 ; i-- ) {
606         GraphBase::InPort * anInPort = aNode->GetChangeNodeInPort( i ) ;
607 // OutPort 'anOutPort' linked to 'anInPort'
608         GraphBase::OutPort * anOutPort = anInPort->GetOutPort() ;
609         cdebug << i << ". " << aNode->Name() << "/" << OldNodeName
610                << " GraphBase::Graph::ReNameNode of LinkedNode : from " ;
611         if ( anOutPort ) {
612           cdebug << anOutPort->NodeName() << "( " << anOutPort->PortName() << " )" ;
613         }
614         else {
615           cdebug << "without link" ;
616         }
617         cdebug << " to " << i << ". " << anInPort->PortName() << " of " << NewNodeName
618                << " OldNodeName " << OldNodeName ;
619         if ( !anInPort->IsNotConnected() ) {
620           if ( anOutPort->IsDataConnected() ) {
621             cdebug << " fromDataConnected " << anOutPort->NodeName() << endl ;
622           }
623           else {
624 // Node 'FromNode' of 'anOutPort'
625             GraphBase::ComputingNode * FromNode ;
626             if ( strcmp( anOutPort->NodeName() , Name() ) ) {
627               FromNode = GetChangeGraphNode( anOutPort->NodeName() ) ;
628             }
629             else {
630               FromNode = this ;
631             }
632             cdebug << " fromConnected " << anOutPort->NodeName() << endl ;
633           }
634           char* OldNodePortName = new char[ strlen( OldNodeName ) +
635                                             strlen( aNode->GetChangeNodeInPort( i )->PortName() ) + 3 ] ;
636           char* NewNodePortName = new char[ strlen( NewNodeName ) +
637                                             strlen( aNode->GetChangeNodeInPort( i )->PortName() ) + 3 ] ;
638           strcpy( OldNodePortName , OldNodeName ) ;
639           strcat( OldNodePortName , "__" ) ;
640           strcat( OldNodePortName , aNode->GetChangeNodeInPort( i )->PortName() ) ;
641           strcpy( NewNodePortName , NewNodeName ) ;
642           strcat( NewNodePortName , "__" ) ;
643           strcat( NewNodePortName , aNode->GetChangeNodeInPort( i )->PortName() ) ;
644           RetVal = anOutPort->ReNameInPort( OldNodePortName , NewNodePortName ) ;
645           delete [] OldNodePortName ;
646           delete [] NewNodePortName ;
647           if ( !RetVal )
648             break ;
649         }
650         else {
651           cdebug << " not connected" << endl ;
652         }
653       }
654 // PAL8508
655 //JR 02.02.2005 DEBUG : ReName in the CoupledNode was missing
656       if ( aNode->IsLoopNode() || aNode->IsEndLoopNode() ||
657            aNode->IsSwitchNode() || aNode->IsEndSwitchNode() ) {
658         GraphBase::GOTONode * theCoupledNode = NULL ;
659         theCoupledNode = (GraphBase::GOTONode * ) ((GraphBase::GOTONode * ) aNode)->CoupledNode() ;
660         theCoupledNode->CoupledNodeName( aNode->Name() ) ;
661       }
662       else if ( aNode->IsInLineNode() ) {
663         GraphBase::OutPort * anOutPort = aNode->GetNodeInGate()->GetOutPort() ;
664         if ( anOutPort ) {
665           GraphBase::ComputingNode * aLinkedNode ;
666           aLinkedNode = GetChangeGraphNode( anOutPort->NodeName() ) ;
667           if ( aLinkedNode->IsGOTONode() ) {
668             ((GraphBase::GOTONode * ) aLinkedNode)->CoupledNodeName( aNode->Name() ) ;
669           }
670         }
671       }
672     }
673     else {
674       cdebug << "ERROR Node not found or conflicting NodeName" << endl ;
675       RetVal = false ;
676     }
677   }
678   else {
679     cdebug << "ReNameNode with same name." << endl ;
680 //    RetVal = Name( NewNodeName ) ;
681   }
682
683 #if 1
684   cdebug << "Graph::ReNameNode " << _GraphNodesSize << " known nodes" << endl;
685   for ( i = 0 ; i < _GraphNodesSize ; i++ ) {
686     cdebug << "Node" << i << _GraphNodes[ i ]->Name() << endl ;
687   }
688   map< string , int >::iterator aMapOfGraphNodesIterator ;
689   i = 0 ;
690   for ( aMapOfGraphNodesIterator = _MapOfGraphNodes.begin() ;
691     aMapOfGraphNodesIterator != _MapOfGraphNodes.end() ; aMapOfGraphNodesIterator++ ) {
692     cdebug << "MapOfGraphNodes " << i++ << " " << aMapOfGraphNodesIterator->first << " --> "
693            << aMapOfGraphNodesIterator->second << " - 1" << endl ;
694   }
695 #endif
696
697   cdebug_out << "GraphBase::Graph::ReNameNode RetVal " << RetVal << endl;
698   return RetVal ;
699 }
700
701 bool GraphBase::Graph::RemoveNode( const char* aNodeName ) {
702   cdebug_in << "Graph::RemoveNode (" << aNodeName << ") " << endl;
703   int i ;
704   bool RetVal = false ;
705   int index = GetGraphNodeIndex( aNodeName ) ;
706   GraphBase::ComputingNode * aNode = NULL ;
707   if ( index >= 0 ) {
708     aNode = GetChangeGraphNode( index ) ;
709   }
710   if ( aNode ) {
711     cdebug << "Graph::RemoveNode " << aNode->Name() << " : " << aNode->GetNodeInPortsSize()
712            << " InPorts " << aNode->GetNodeOutPortsSize() << " OutPorts "
713            << aNode->LinkedNodesSize() << " LinkedNodes " << aNode->LinkedFromNodesSize()
714            << " LinkedFromNodes IsEndSwitchNode " << aNode->IsEndSwitchNode()
715            << " ConnectedInPortsNumber " << aNode->ConnectedInPortsNumber() << endl ;
716     for ( i = 0 ; i < aNode->LinkedNodesSize() ; i++ ) {
717       cdebug << "         LinkedNode" << i << ". " << aNode->LinkedNodes( i ) << " "
718              << aNode->LinkedNodes( i )->Name() << endl ;
719     }
720     if ( !aNode->IsEndLoopNode() ) { // The LoopNode is already deleted
721       for ( i = 0 ; i < aNode->LinkedFromNodesSize() ; i++ ) {
722         cdebug << "         LinkedFromNode" << i << ". " << aNode->LinkedFromNodes( i ) << " "
723                << aNode->LinkedFromNodes( i )->Name() << endl ;
724       }
725     }
726 //PAL8177-PAL8509
727 //JR 24.03.2005 : Debug : CoupledNode field of GOTONodes was not erased
728     if ( aNode->IsInLineNode() && aNode->GetNodeInPortsSize() ) { //mkr : IPAL10078
729       GraphBase::OutPort * anOutPort = aNode->GetNodeInGate()->GetOutPort() ;
730       if ( anOutPort ) {
731         GraphBase::ComputingNode * aLinkedNode ;
732         aLinkedNode = GetChangeGraphNode( anOutPort->NodeName() ) ;
733         if ( aLinkedNode->IsGOTONode() ) {
734           cdebug << "Graph::RemoveNode erase CoupledNode " << aLinkedNode->Name() << endl ;
735           ((GraphBase::GOTONode * ) aLinkedNode)->CoupledNode( NULL ) ;
736           ((GraphBase::GOTONode * ) aLinkedNode)->CoupledNodeName( "" ) ;
737         }
738       }
739     }
740     if ( !aNode->IsEndSwitchNode() ) {
741       if ( aNode->GetNodeInPortsSize() ) {
742         for ( i = aNode->GetNodeInPortsSize()-1 ; i >= 0 ; i-- ) {
743           GraphBase::InPort * anInPort = aNode->GetChangeNodeInPort( i ) ;
744           cdebug << "Graph::RemoveNode InPort" << i << ". " << aNodeName << "( "
745                  << anInPort->PortName() << ") " << anInPort->PortStatus() << " <-- " ;
746           GraphBase::OutPort * anOutPort = anInPort->GetOutPort() ;
747           if ( anOutPort && !( aNode->IsEndLoopNode() && anInPort->IsLoop() ) ) {
748             cdebug << anOutPort->NodeName() << "( " << anOutPort->PortName() << ") "
749                    << anOutPort->PortStatus() ;
750           }
751           cdebug << endl ;
752           if ( !anInPort->IsNotConnected() ) {
753             GraphBase::ComputingNode * FromNode = NULL ;
754             RetVal = true ;
755             if ( anOutPort->IsDataConnected() || anOutPort->IsExternConnected() ) {
756               cdebug << "     Data/Extern ignored" << endl ;
757             }
758             else {
759               FromNode = GetChangeGraphNode( anOutPort->NodeName() ) ;
760             }
761             if ( FromNode ) {
762               cdebug << "FromNode " << FromNode->Name() << " LinkedNodesSize "
763                      << FromNode->LinkedNodesSize() << " and " << aNode->Name()
764                      << " LinkedFromNodesSize " << aNode->LinkedFromNodesSize() << endl ;
765               // asv : 04.11.04 : IsGOTO -> IsOneOfGOTO, I believe that it fixes the bug 7120.
766 // JR 05.01.05 : IsOneOfGOTO is not ok : I shall check the bug 7120 with IsGOTONode
767 //            if ( !FromNode->IsOneOfGOTONodes() ) {
768 //            if ( !FromNode->IsGOTONode() ) {
769               if ( !FromNode->IsGOTONode() &&
770                    !( FromNode->IsEndLoopNode() && anInPort->IsLoop() ) ) {
771                 if ( anInPort->IsDataStream() ) {
772                   RetVal = FromNode->RemoveStreamLinkedNode( aNode ) ;
773                 }
774                 else {
775                   RetVal = FromNode->RemoveLinkedNode( aNode ) ;
776                 }
777                 if ( !RetVal ) {
778                   cdebug << "Graph::RemoveNode anOutPort->RemoveLinkedNode Error RetVal "
779                          << RetVal << endl ;
780                   break ;
781                 }
782               }
783             }
784             RetVal = anOutPort->RemoveInPort( anInPort ) ;
785             if ( !RetVal ) {
786               cdebug << "Graph::RemoveNode anOutPort->RemoveInPort( anInPort ) Error RetVal "
787                      << RetVal << endl ;
788               break ;
789             }
790           }
791           else {
792             RetVal = true ;
793           }
794         }
795       }
796       else {
797         RetVal = true ;
798       }
799     }
800     else {
801 // Special case of EndSwitchNodes : each Input port must be multi-connected.
802 // There is one link for each branch of the switch
803 // But in GraphBase::InPort there is only one field GraphBase::OutPort *
804 // At execution time there is no problem because only one branch of the switch
805 // may be executed and the Executor set the right OutPort in the field
806 // GraphBase::OutPort * of each InPort of the EndSwitchNode
807 // But here we must remove that node EndSwitch from the LinkedNodes field of
808 // terminal nodes of all branches.
809 // And also in the OutPorts of that terminal nodes of branches we must remove
810 // references to InPorts of the EndSwitchNode.
811
812 // Explore LinkedFromnodes of the EndSwitchNode :
813       for ( i = aNode->LinkedFromNodesSize() - 1 ; i >= 0  ; i-- ) {
814         GraphBase::ComputingNode * aLinkedFromNode = (GraphBase::ComputingNode * ) aNode->LinkedFromNodes( i ) ;
815         cdebug << aLinkedFromNode->Name() << " linked to " << aNode->Name() << endl ;
816         int j ;
817         for ( j = aLinkedFromNode->GetNodeOutPortsSize() - 1 ; j >= 0 ; j-- ) {
818           GraphBase::OutPort * anOutPort = aLinkedFromNode->GetChangeNodeOutPort( j ) ;
819           cdebug << "Graph::RemoveNode OutPort" << j << ". Remove " << anOutPort->InPortsSize()
820                  << " InPortsof OutPort : " << anOutPort->NodeName() << "( "
821                  << anOutPort->PortName() << ") "
822                  << anOutPort->PortStatus() << " :" << endl ;
823           int k ;
824           for ( k = anOutPort->InPortsSize() - 1 ; k >= 0  ; k-- ) {
825             GraphBase::InPort * anInPort = anOutPort->ChangeInPorts( k ) ;
826             if ( !strcmp( anInPort->NodeName() , aNode->Name() ) ) {
827 // InPort of the EndSwitchNode
828               cdebug << "       to InPort" << j << ". " << anInPort->NodeName() << "( "
829                      << anInPort->PortName() << ") "
830                      << anInPort->PortStatus() << endl ;
831               anInPort->RemoveOutPort() ;
832               if ( anOutPort->IsDataStream() ) {
833                 aLinkedFromNode->RemoveStreamLinkedNode( aNode ) ;
834               }
835               else {
836 // false ==> No error for aNode->LinkedFromNode()
837                 RetVal = aLinkedFromNode->RemoveLinkedNode( aNode , false ) ;
838                 if ( !RetVal ) {
839                   cdebug << "Graph::RemoveNode aLinkedFromNode->RemoveLinkedNode Error RetVal "
840                          << RetVal << endl ;
841                   break ;
842                 }
843               }
844 // the InPort of the EndSwitchNode from that OutPort was already removed by
845 // anInPort->RemoveOutPort done above :
846 #if 0
847               RetVal = anOutPort->RemoveInPort( anInPort ) ;
848               if ( !RetVal ) {
849                 cdebug << "Graph::RemoveNode anOutPort->RemoveInPort( anInPort ) Error RetVal "
850                        << RetVal << endl ;
851                 break ;
852               }
853 #endif
854             }
855           }
856         }
857       }
858       //mkr : fix for bugs IPAL9814 and IPAL9630
859       RetVal = true;
860     }
861
862     if ( RetVal ) {
863       for ( i = aNode->GetNodeOutPortsSize() - 1 ; i >= 0 ; i-- ) {
864         GraphBase::OutPort * anOutPort = aNode->GetChangeNodeOutPort( i ) ;
865         cdebug << "Graph::RemoveNode OutPort" << i << ". Remove " << anOutPort->InPortsSize()
866                << " InPortsof OutPort : " << anOutPort->NodeName() << "( "
867                << anOutPort->PortName() << ") "
868                << anOutPort->PortStatus() << " :" << endl ;
869         int j ;
870         for ( j = anOutPort->InPortsSize() - 1 ; j >= 0  ; j-- ) {
871           GraphBase::InPort * anInPort = anOutPort->ChangeInPorts( j ) ;
872           GraphBase::ComputingNode * ToNode = NULL ;
873           cdebug << "       to InPort" << j << ". " << anInPort->NodeName() << "( "
874                  << anInPort->PortName() << ") "
875                  << anInPort->PortStatus() ;
876           if ( anInPort->IsExternConnected() ) {
877             cdebug << " ExternConnected ignored" << endl ;
878           }
879           else {
880             cdebug << endl ;
881             ToNode = GetChangeGraphNode( anInPort->NodeName() ) ;
882           }
883           if ( ToNode ) {
884             RetVal = anInPort->RemoveOutPort() ;
885 // JR 04.02.2005 : Bug if it is a link to an EndSwitchNode. The InPort may be multiple linked !!!
886 // PAL7990
887             if ( !RetVal ) {
888               cdebug << "Graph::RemoveNode anOutPort->RemoveOutPort Error RetVal " << RetVal
889                      << endl ;
890               break ;
891             }
892             if ( ( aNode->IsGOTONode() && ToNode->IsOneOfInLineNodes() ) ||
893                  ( aNode->IsEndLoopNode() && ToNode->IsLoopNode( ) ) ) {
894             }
895             else if ( anOutPort->IsDataStream() ) {
896               RetVal = aNode->RemoveStreamLinkedNode( ToNode ) ;
897             }
898             else {
899               RetVal = aNode->RemoveLinkedNode( ToNode ) ;
900             }
901             if ( !RetVal ) {
902               cdebug << "Graph::RemoveNode anOutPort->RemoveLinkedNode Error RetVal " << RetVal
903                      << endl ;
904               break ;
905             }
906 // the InPort of the EndSwitchNode from that OutPort was already removed by
907 // anInPort->RemoveOutPort done above :
908 #if 0
909             RetVal = anOutPort->RemoveInPort( anInPort ) ;
910             if ( !RetVal ) {
911               cdebug << "Graph::RemoveNode anOutPort->RemoveInPort( anInPort ) Error RetVal "
912                      << RetVal << endl ;
913               break ;
914             }
915 #endif
916             if ( ToNode->IsEndSwitchNode() ) {
917               int i ;
918               int done = false ;
919               for ( i = 0 ; i < ToNode->LinkedFromNodesSize() ; i++ ) {
920                 GraphBase::StreamNode * fromNode = ToNode->LinkedFromNodes( i ) ;
921 // Not the node that we are deleting ... :
922                 if ( strcmp( fromNode->Name() , aNode->Name() ) ) {
923                   int j ;
924                   for ( j = 0 ; j < fromNode->GetNodeOutPortsSize() ; j++ ) {
925                     GraphBase::OutPort * fromOutPort = fromNode->GetChangeNodeOutPort( j ) ;
926                     int k ;
927                     for ( k = 0 ; k < fromOutPort->InPortsSize() ; k++ ) {
928                       if ( strcmp( ToNode->Name() , fromOutPort->InPorts( k )->NodeName() ) == 0 ) {
929                         if ( strcmp( anInPort->PortName() , fromOutPort->InPorts( k )->PortName() ) == 0 ) {
930 // Restore an OutPort in the InPort
931                           anInPort->ChangeOutPort( fromOutPort ) ;
932                           cdebug << "Graph::RemoveNode reestablish " << fromOutPort->NodeName() << "( "
933                                  << fromOutPort->PortName() << " ) in the InPort of EndSwitch : "
934                                  << ToNode->Name() << "( " << anInPort->PortName() << " )"
935                                  << anInPort->Kind() << " " << anInPort->PortStatus()  << endl;
936                           done = true ;
937                           break ;
938                         }
939                       }
940                     }
941                     if ( done ) {
942                       break ;
943                     }
944                   }
945                   if ( done ) {
946                     break ;
947                   }
948                 }
949               }
950             }
951           }
952         }
953         if ( !RetVal ) {
954           cdebug << "Error RetVal " << RetVal << endl ;
955           break ;
956         }
957       }
958     }
959     if ( aNode->LinkedNodesSize() || aNode->LinkedFromNodesSize() ) {
960       cdebug << "Graph::RemoveNode ERROR LinkedNodesSize " << aNode->LinkedNodesSize()
961              << " LinkedFromNodesSize " << aNode->LinkedFromNodesSize() << endl ;
962       RetVal = 0 ;
963     }
964     cdebug << "Graph::RemoveNode " << aNode->Name() << " : " << aNode->GetNodeInPortsSize()
965            << " InPorts " << aNode->GetNodeOutPortsSize() << " OutPorts "
966            << aNode->LinkedNodesSize() << " LinkedNodes " << aNode->LinkedFromNodesSize()
967            << " LinkedFromNodes " << endl ;
968     for ( i = 0 ; i < aNode->LinkedNodesSize() ; i++ ) {
969       cdebug << "         LinkedNode" << i << ". " << aNode->LinkedNodes( i ) << " "
970              << aNode->LinkedNodes( i )->Name() << endl ;
971     }
972     for ( i = 0 ; i < aNode->LinkedFromNodesSize() ; i++ ) {
973       cdebug << "         LinkedFromNode" << i << ". " << aNode->LinkedFromNodes( i ) << " "
974              << aNode->LinkedFromNodes( i )->Name() << endl ;
975     }
976 // Delete of aNode from the Graph :
977 // The LoopNode is needed by the delete of the EndLoopNode. So the LoopNode will be deleted
978 // when the EndLoopNode is deleted. It is the same for SwitchNode & EndSwitchNode
979     if ( RetVal && !aNode->IsLoopNode() && !aNode->IsSwitchNode() ) {
980       GraphBase::InLineNode * theCoupledNode = NULL ;
981       char * theCoupledNodeName = NULL ;
982       int CoupledIndex = -1 ;
983       if ( aNode->IsEndLoopNode() || aNode->IsEndSwitchNode() ) {
984         theCoupledNodeName = ((GraphBase::GOTONode * ) aNode)->CoupledNodeName() ;
985         theCoupledNode = ((GraphBase::GOTONode * ) aNode)->CoupledNode() ;
986       }
987       cdebug << "Graph::RemoveNode Node" << index << " " << _GraphNodes[ index ]->Name()
988              << " will be deleted" << endl ;
989       delete aNode ;
990       _GraphNodesSize -= 1 ;
991       for ( i = index ; i < _GraphNodesSize ; i++ ) {
992         _GraphNodes[ i ] = _GraphNodes[ i+1 ] ;
993         SetGraphNodeIndex( _GraphNodes[ i ]->Name() , i ) ;
994       }
995       _GraphNodes.resize( _GraphNodesSize+1 ) ;
996       _MapOfGraphNodes.erase( aNodeName ) ;
997 // PAL8510
998 // Delete of the LoopNode of that EndLoopNode or of the SwitchNode of that EndSwitchNode :
999       if ( theCoupledNode ) {
1000 //JR 02.02.2005 DEBUG : CoupledIndex must be here after the delete of aNode (not before)
1001         CoupledIndex = GetGraphNodeIndex( theCoupledNodeName ) ;
1002         cdebug << "Graph::RemoveNode CoupledNode" << CoupledIndex << " "
1003                << _GraphNodes[ CoupledIndex ]->Name() << " will be deleted" << endl ;
1004         delete theCoupledNode ;
1005         _GraphNodesSize -= 1 ;
1006         for ( i = CoupledIndex ; i < _GraphNodesSize ; i++ ) {
1007           _GraphNodes[ i ] = _GraphNodes[ i+1 ] ;
1008           SetGraphNodeIndex( _GraphNodes[ i ]->Name() , i ) ;
1009         }
1010         _GraphNodes.resize( _GraphNodesSize+1 ) ;
1011         _MapOfGraphNodes.erase( theCoupledNodeName ) ;
1012       }
1013       RetVal = true ;
1014     }
1015   }
1016   else {
1017     cdebug << "Graph::RemoveNode Node not found ERROR " << index << endl ;
1018   }
1019
1020 #if 1
1021   cdebug << "Graph::RemoveNode " << _GraphNodesSize << " known nodes" << endl;
1022   for ( i = 0 ; i < _GraphNodesSize ; i++ ) {
1023     cdebug << "Node" << i << _GraphNodes[ i ]->Name() << endl ;
1024   }
1025   map< string , int >::iterator aMapOfGraphNodesIterator ;
1026   i = 0 ;
1027   for ( aMapOfGraphNodesIterator = _MapOfGraphNodes.begin() ;
1028     aMapOfGraphNodesIterator != _MapOfGraphNodes.end() ; aMapOfGraphNodesIterator++ ) {
1029     cdebug << "MapOfGraphNodes " << i++ << " " << aMapOfGraphNodesIterator->first << " --> "
1030            << aMapOfGraphNodesIterator->second << " - 1" << endl ;
1031   }
1032 #endif
1033
1034   cdebug_out << "Graph::RemoveNode " << RetVal << endl;
1035   return RetVal ;
1036 }
1037
1038 bool GraphBase::Graph::AddLink( const char* FromNodeName ,
1039                                 const char* FromServiceParameterName ,
1040                                 const char* ToNodeName ,
1041                                 const char* ToServiceParameterName ) {
1042 //                                , const CORBA::Any aValue ) {
1043   bool RetVal ;
1044 //  int index ;
1045   cdebug_in << "GraphBase::Graph::AddLink(" << FromNodeName << "("
1046             << FromServiceParameterName << ") ---> " << ToNodeName << "("
1047             << ToServiceParameterName << ") , aValue )" << endl;
1048
1049   GraphBase::ComputingNode *fromNode = GetChangeGraphNode( FromNodeName ) ;
1050   GraphBase::ComputingNode *toNode = GetChangeGraphNode( ToNodeName ) ;
1051
1052   GraphBase::OutPort *fromPort = NULL ;
1053   GraphBase::InPort *toPort = NULL ;
1054
1055   if ( fromNode ) {
1056     // asv : 29.12.04 : as I understand, replacement of "InitLoop" by "DoLoop" was
1057     // done by JR in order to keep old graphs and batch test scripts working after change
1058     // of special Loop's port name from "InitLoop" to "DoLoop".  I suppose, it is not
1059     // needed, all old graphs and tests must be changed to use "DoLoop" name for addressing
1060     // this port..  It we don't do it, ANY port with "InitLoop" name will be replaced by "DoLoop"
1061     // and it can cause unexpected bugs in future...  So I comment out the replacement code. 
1062     //if ( strcmp( FromServiceParameterName , "InitLoop" ) ) {
1063 //JR 12.01.05 : Yes the test is not good ; now I test that PortName only in LoopNodes ==>
1064 //   + old graphs will runs normally (it is not possible to ask CEA to edit their graphs)
1065 //   + in old graphs "InitLoop" and "DoLoop" were reserved parameter names (but not controlled)
1066 //   + in new graphs, I have added a control at port creation of that names : they are refused
1067     if ( !(fromNode->IsLoopNode() && strcmp( FromServiceParameterName , "InitLoop" ) == 0 ) ) {
1068       fromPort = fromNode->GetChangeOutPort( FromServiceParameterName ) ;
1069     }
1070     else {
1071       fromPort = fromNode->GetChangeOutPort( "DoLoop" ) ;
1072     }
1073     if ( !fromPort ) {
1074       cdebug << "ERROR AddLink fromPort " << FromServiceParameterName << " FromNode("
1075            << FromNodeName << ") not found." << endl ;
1076     }
1077   }
1078   else {
1079     cdebug << "ERROR AddLink FromNode " << FromNodeName << " not found." << endl ;
1080   }
1081   if ( toNode ) {
1082     // see comment above
1083 //    if ( strcmp( ToServiceParameterName , "InitLoop" ) ) {
1084     if ( !(toNode->IsLoopNode() && strcmp( ToServiceParameterName , "InitLoop" ) == 0 ) ) {
1085       toPort = toNode->GetChangeInPort( ToServiceParameterName ) ;
1086     }
1087     else {
1088       toPort = toNode->GetChangeInPort( "DoLoop" ) ;
1089     }
1090     if ( !toPort ) {
1091       cdebug << "ERROR AddLink toPort " << ToServiceParameterName << " ToNode("
1092              << ToNodeName << ") not found." << endl ;
1093     }
1094   }
1095   else {
1096     cdebug << "ERROR AddLink toNode " << ToNodeName << " not found." << endl ;
1097   }
1098
1099   RetVal = AddLink( fromNode , fromPort , toNode , toPort ) ;
1100
1101   if ( RetVal ) {
1102     if ( fromPort->IsGate() && toPort->IsGate() ) {
1103       CORBA::Any aValue ;
1104 //JR 29.09.2005 Debug for CEA : we do not do that for MacroNodes :
1105       if ( !fromNode->IsMacroNode() ) {
1106         aValue <<= (CORBA::Long ) 1 ;
1107       }
1108       else {
1109         aValue <<= (CORBA::Long ) 0 ;
1110       }
1111       fromPort->SetValue( aValue ) ;
1112     }
1113 //    else {
1114 //      const CORBA::Any * aDataValue = new CORBA::Any( aValue ) ;
1115 //      fromPort->Value( aDataValue ) ;
1116 //    }
1117 //    fromPort->PortStatus( DataConnected );
1118   }
1119
1120   cdebug_out << "GraphBase::Graph::AddLink " << RetVal << endl;
1121   return RetVal ;
1122 }
1123
1124 bool GraphBase::Graph::AddLink( GraphBase::ComputingNode *fromNode ,
1125                                 GraphBase::OutPort *fromPort ,
1126                                 GraphBase::ComputingNode *toNode ,
1127                                 GraphBase::InPort *toPort ) {
1128 //  bool RetVal ;
1129
1130   if ( !fromNode ) {
1131     cdebug << "ERROR AddLink fromNode not found." << endl ;
1132     return false ;
1133   }
1134   if ( !fromPort ) {
1135     cdebug << "ERROR AddLink fromPort not found." << endl ;
1136     return false ;
1137   }
1138
1139   if ( !toNode ) {
1140     cdebug << "ERROR AddLink toNode not found." << endl ;
1141     return false ;
1142   }
1143   if ( !toPort ) {
1144     cdebug << "ERROR AddLink toPort not found." << endl ;
1145     return false ;
1146   }
1147   if ( ( fromPort->IsDataStream() && !toPort->IsDataStream() ) ||
1148        ( !fromPort->IsDataStream() && toPort->IsDataStream() ) ) {
1149     cdebug << "AddLink fromPort/toPort Stream/Flow. ERROR" << endl ;
1150     return false ;
1151   }
1152   if ( fromPort->IsDataStream() && fromPort->Dependency() == SALOME_ModuleCatalog::DATASTREAM_TEMPORAL &&
1153        toPort->Dependency() == SALOME_ModuleCatalog::DATASTREAM_ITERATIVE ) {
1154     cdebug << "AddLink fromPort/toPort Stream DATASTREAM_TEMPORAL --> DATASTREAM_ITERATIVE. ERROR" << endl ;
1155     return false ;
1156   }
1157
1158   cdebug_in << "Graph::AddLink( " << fromNode->Name() << "("
1159             << fromPort->PortName() << " " << fromPort->PortStatus() << ") " << fromPort->Kind()
1160             << " ---> " << toNode->Name() << "(" << toPort->PortName() << " " << toPort->PortStatus()
1161             << ") " << toPort->Kind() << " )" << endl;
1162   ostringstream LinkStrError ;
1163   LinkStrError << "Creation of link from " << fromNode->Name() << "( "
1164                << fromPort->PortName() << " " << fromPort->PortStatus() << " " << fromPort->Kind()
1165                << " ) ---> " << toNode->Name() << "( " << toPort->PortName() << " "
1166                << toPort->PortStatus() << " " << toPort->Kind() << " ) :\n" ;
1167   if ( fromPort->IsDataConnected() || fromPort->IsExternConnected() ) {
1168     if ( !fromPort->RemoveInPort() ) { // There is only one ===> RemoveOutPort()
1169       cdebug_out << "GraphBase::Graph::AddLink in OutPort ( " << fromNode->Name() << "("
1170                  << fromPort->PortName() << " " << fromPort->PortStatus()
1171                  << ") RemoveInPort ERROR InPortsSize " << fromPort->InPortsSize() << endl ;
1172       return false ;
1173     }
1174   }
1175   if ( toPort->IsDataConnected() || toPort->IsExternConnected() ) {
1176     if ( !toPort->GetOutPort()->RemoveInPort() ) { // There is only one ===> RemoveOutPort()
1177       cdebug_out << "GraphBase::Graph::AddLink in InPort connected to the OutPort ( "
1178                  << toNode->Name() << "(" << toPort->PortName() << " " << toPort->PortStatus()
1179                  << ") RemoveInPort ERROR InPortsSize " << toPort->GetOutPort()->InPortsSize()
1180                  << endl ;
1181       return false ;
1182     }
1183   }
1184   else if ( toPort->IsPortConnected() && !toNode->IsEndSwitchNode() ) {
1185     if ( !RemoveLink( toPort->GetOutPort()->NodeName() ,
1186                       toPort->GetOutPort()->PortName() ,
1187                       toNode->Name() , toPort->PortName() ) ) {
1188       cdebug_out << "RemoveLink(AddLink) toPort->GetOutPort()->NodeName() RemoveLink Error." << endl ;
1189       return false ;
1190     }
1191     if ( fromNode->IsGOTONode() && fromPort->IsGate() ) { // mkr : PAL12575
1192       ((GraphBase::GOTONode * ) fromNode)->CoupledNode( (GraphBase::InLineNode * ) toNode ) ;
1193     }
1194   }
1195
1196   if ( !fromNode->IsDataFlowNode() && !fromNode->IsDataStreamNode() &&
1197        !toNode->IsDataFlowNode() && !toNode->IsDataStreamNode() &&
1198        toPort->GetOutPort() ) {
1199 //JR Debug 15.06.2005 : the case of multiple links to EndSwitchNode was missing :
1200     if ( toNode->IsEndSwitchNode() && fromPort->GetInPort( toPort ) == toPort ) {
1201       LinkStrError << "Link already exists.\n" ;
1202       SetMessages( LinkStrError.str() ) ;
1203       cdebug << "Link already exists" << endl ;
1204       cdebug_out << "GraphBase::Graph::AddLink 1" << endl;
1205       return true ;
1206     }
1207     else if ( !strcmp( toPort->GetOutPort()->NodePortName() ,
1208                   fromPort->NodePortName() ) ) {
1209       LinkStrError << "Link already exists.\n" ;
1210       SetMessages( LinkStrError.str() ) ;
1211       cdebug << "Link already exists" << endl ;
1212       cdebug_out << "GraphBase::Graph::AddLink 1" << endl;
1213       return true ;
1214     }
1215     else if ( toPort->IsDataConnected() || toPort->IsExternConnected() ) {
1216       toPort->GetOutPort()->RemoveInPort( toPort ) ; //dbg
1217     }
1218     else if ( fromNode->IsGOTONode() ) {
1219       if ( !RemoveLink( toPort->GetOutPort()->NodeName() ,
1220                         toPort->GetOutPort()->PortName() ,
1221                         toNode->Name() , toPort->PortName() ) ) {
1222         cdebug << "RemoveLink(AddLink) Error."
1223                << endl ;
1224         cdebug_out << "GraphBase::Graph::AddLink" << endl;
1225         return false ;
1226       }
1227       if ( fromPort->InPortsSize() ) {
1228         if ( !RemoveLink( fromNode->Name() , fromPort->PortName() ,
1229                           fromPort->ChangeInPorts(0)->NodeName() ,
1230                           fromPort->ChangeInPorts(0)->PortName() ) ) {
1231           cdebug << "RemoveLink(AddLink) fromNode->IsGOTONode Error." << endl ;
1232           cdebug_out << "GraphBase::Graph::AddLink" << endl;
1233           return false ;
1234         }
1235       }
1236     }
1237 //PAL8511
1238 // JR 17.01.2005 : toPort is already linked : RemoveLink
1239     else if ( !toNode->IsEndSwitchNode() ) {
1240 //    else if ( !toNode->IsEndSwitchNode() ||
1241 //              ( toNode->IsEndSwitchNode() && toPort->IsGate() ) ) {
1242 //JR Debug : the fromPort was wrong !
1243 //      if ( !RemoveLink( fromNode->Name() , fromPort->PortName() ,
1244       if ( !RemoveLink( toPort->GetOutPort()->NodeName() , toPort->GetOutPort()->PortName() ,
1245                         toNode->Name() , toPort->PortName() ) ) {
1246         cdebug << "RemoveLink(AddLink) toNode->IsEndSwitchNode Error." << endl ;
1247         cdebug_out << "GraphBase::Graph::AddLink" << endl;
1248         return false ;
1249       }
1250     }
1251 //JR 15.06.2005 : disabled : GraphSwitchBranchGates ...
1252 //    else if ( fromNode->IsSwitchNode() && toNode->IsEndSwitchNode() && !toPort->IsGate() ) {
1253 //      cdebug << "fromNode->IsSwitchNode() && toNode->IsEndSwitchNode toPort(NotGate)Error."
1254 //             << endl ;
1255 //      LinkStrError << "Link from SwitchNode to EndSwitchNode is not allowed.\n" ;
1256 //      SetMessages( LinkStrError.str() ) ;
1257 //      cdebug << "Graph::AddLink ERROR Link from SwitchNode to EndSwitchNode is not allowed."
1258 //             << endl ;
1259 //      cdebug_out << "GraphBase::Graph::AddLink 0" << endl;
1260 //      return false ;
1261 //    }
1262 //JR 15.06.2005 : SwitchNode(Default) may be only linked to EndSwitchNode(Default)
1263 //PAL8511
1264 //JR Debug 15.02.2005 : Not multiple links in that case except if toPort is the DefaultPort
1265     else if ( fromNode->IsSwitchNode() && fromPort->IsGate() &&
1266               !toNode->IsEndSwitchNode() ) {
1267       LinkStrError << "Link from SwitchNode(Default) is allowed only to EndSwitchNode(Default).\n" ;
1268       SetMessages( LinkStrError.str() ) ;
1269       cdebug << "SwitchNode(Default) may be only linked to EndSwitchNode(Default) AddLink Error."
1270              << endl ;
1271       cdebug_out << "GraphBase::Graph::AddLink 0" << endl;
1272       return false ;
1273     }
1274   }
1275 //PAL7990
1276 //JR 24.03.2005 : No Link between OutPort of SwitchNode to InPort of EndSwitchNode except if
1277 // they have the same name for a special case :
1278 // Switch with no branch ==> Default is applied always : GraphSyrControl example
1279 //JR 22.06.2005 : Enhancement of the behaviour :
1280 //                For the DefaultBranch, if we have same PortsNames, Values are automatically
1281 //                    transmitted
1282 //                But for the DefaultBranch, if we have NOT same PortsNames, we may create links.
1283 //                Look at GraphSyrControlAve* ...
1284 #if 0
1285   else if ( fromNode->IsSwitchNode() && !fromPort->IsGate() &&
1286             toNode->IsEndSwitchNode() && !toPort->IsGate() &&
1287             strcmp( fromPort->PortName() , toPort->PortName() ) ) {
1288     LinkStrError << "Link from SwitchNode to EndSwitchNode with different PortNames is not allowed.\n" ;
1289     SetMessages( LinkStrError.str() ) ;
1290     cdebug << "fromNode->IsSwitchNode() && toNode->IsEndSwitchNode with different PortNames Error."
1291            << endl ;
1292     cdebug_out << "GraphBase::Graph::AddLink" << endl;
1293     return false ;
1294   }
1295 #endif
1296   else if ( fromNode->IsGOTONode() && fromPort->InPortsSize() ) {
1297     if ( !RemoveLink( fromNode->Name() , fromPort->PortName() ,
1298                       fromPort->ChangeInPorts(0)->NodeName() ,
1299                       fromPort->ChangeInPorts(0)->PortName() ) ) {
1300       cdebug << "RemoveLink(AddLink) fromNode->IsGOTONode Error." << endl ;
1301       cdebug_out << "GraphBase::Graph::AddLink" << endl;
1302       return false ;
1303     }
1304   }
1305   else if ( ( fromNode->IsDataFlowNode() || fromNode->IsDataStreamNode() ) &&
1306        ( toPort->IsDataConnected() || toPort->IsExternConnected() ) ) {
1307     fromPort->RemoveInPort( toPort ) ; //dbg
1308   }
1309   else if ( ( toNode->IsDataFlowNode() || toNode->IsDataStreamNode() ) &&
1310        ( fromPort->IsDataConnected() || fromPort->IsExternConnected() ) ) {
1311     fromPort->RemoveInPort() ; // There is only one
1312   }
1313
1314
1315 // JR 12.01.2005 : an OutPort of a SwitchNode connected to a Gate can be connected only to Gate
1316   if ( !toNode->IsDataFlowNode() && !toNode->IsDataStreamNode() &&
1317        fromNode->IsSwitchNode() && fromPort->IsSwitch() && !toPort->IsGate() ) {
1318     LinkStrError << "Link from SwitchNode Port linked to a Gate may be connected only to Gates.\n" ;
1319     SetMessages( LinkStrError.str() ) ;
1320     cdebug << "toPort->AddLink Error( fromPort->IsSwitch() && !toPort->IsGate())." << endl ;
1321     cdebug_out << "GraphBase::Graph::AddLink 0" << endl;
1322     return false ;
1323   }
1324 //JR 11.02.2005 : SwitchNode(Default) may be only linked to EndSwitchNode(Default)
1325 //                SwitchNode(Param) may be linked to EndSwitchNode(Param)
1326 //                SwitchNode(Param-UserDefault) may be linked to EndSwitchNode(Default)
1327   else if ( fromNode->IsSwitchNode() && toNode->IsEndSwitchNode() &&
1328             !( ( fromPort->IsGate() && toPort->IsGate() ) ||
1329                ( !fromPort->IsGate() ) ) ) {
1330 //               ( !fromPort->IsGate() && !toPort->IsGate() ) ) ) {
1331     LinkStrError << "Link from SwitchNode to EndSwitchNode : different kinds of ports not allowed.\n" ;
1332     SetMessages( LinkStrError.str() ) ;
1333     cdebug << "Link ERROR from SwitchNode to EndSwitchNode : different kinds of ports not allowed."
1334            << endl ;
1335     cdebug_out << "GraphBase::Graph::AddLink 0" << endl;
1336     return false ;
1337   }
1338 //JR 15.06.2005 : SwitchNode(Default) may be only linked to EndSwitchNode(Default)
1339   else if ( fromNode->IsSwitchNode() && fromPort->IsGate() &&
1340             !toNode->IsEndSwitchNode() ) {
1341     LinkStrError << "Link from SwitchNode(Default) is allowed only to EndSwitchNode(Default).\n" ;
1342     SetMessages( LinkStrError.str() ) ;
1343     cdebug << "SwitchNode(Default) may be only linked to EndSwitchNode(Default) AddLink Error."
1344            << endl ;
1345     cdebug_out << "GraphBase::Graph::AddLink 0" << endl;
1346     return false ;
1347   }
1348   else if ( toNode->IsEndSwitchNode() && !toPort->IsGate() ) {
1349 //    if ( !toPort->IsEndSwitch() || !fromPort->AddInPort( toPort ) ) {
1350     if ( !fromPort->AddInPort( toPort ) ) {
1351       cdebug << "toNode->IsEndSwitchNode() : !fromPort->AddInPort( toPort ) AddLink Error."
1352              << endl ;
1353       cdebug_out << "GraphBase::Graph::AddLink 0" << endl;
1354       return false ;
1355     }
1356     if ( !toPort->IsDataStream() ) {
1357       toPort->Kind( SUPERV::EndSwitchParameter ) ;
1358     }
1359   }
1360   else if ( !fromPort->AddInPort( toPort ) ) { // --> MapOfInports in the OutPort
1361     cdebug << "!fromPort->AddLink Error." << endl ;
1362     cdebug_out << "GraphBase::Graph::AddLink 0" << endl;
1363     return false ;
1364   }
1365
1366   if ( fromNode->IsGOTONode() && ( !fromPort->IsGate() || !toPort->IsGate() ||
1367        toNode->IsEndLoopNode() || toNode->IsEndSwitchNode() ) ) {
1368     cdebug << "toPort->AddLink Error( fromNode->IsGOTONode() && toNode->IsEndInLineNode() )." << endl ;
1369     cdebug_out << "GraphBase::Graph::AddLink 0" << endl;
1370     return false ;
1371   }
1372   else if ( !fromNode->IsSwitchNode() &&
1373             ( fromPort->IsParam() || fromPort->IsInLine() ) && toPort->IsGate() ) {
1374     LinkStrError << "Link from OutPort to a Gate is not allowed.\n" ;
1375     SetMessages( LinkStrError.str() ) ;
1376     cdebug << "toPort->AddLink Error( fromPort->IsParam() && toPort->IsGate())." << endl ;
1377     cdebug_out << "GraphBase::Graph::AddLink 0" << endl;
1378     return false ;
1379   }
1380   else if ( !toNode->IsEndSwitchNode() && !toNode->IsEndLoopNode() ) {
1381     if ( !toPort->AddOutPort( fromPort ) ) { // --> Unique OutPort of the InPort
1382       cdebug << "toPort->AddLink Error." << endl ;
1383       cdebug_out << "GraphBase::Graph::AddLink 0" << endl;
1384       return false ;
1385     }
1386   }
1387   else {
1388     toPort->AddOutPort( fromPort ) ;
1389   }
1390
1391   if ( ( fromNode->IsGOTONode() && toNode->IsOneOfInLineNodes() ) ||
1392        ( fromNode->IsEndLoopNode() && toNode->IsLoopNode() ) ) {
1393     cdebug << "AddLink fromPort->PortStatus( PortConnected ) "
1394            << "GOTONode/EndLoopNode-->InLineNode/LoopNode/SwitchNode "
1395            << fromNode->Name() << " " << fromPort->PortName()
1396            << " InLineNode/LoopNode_ConnectedInPortsNumber "
1397            << toNode->ConnectedInPortsNumber() << endl;
1398     if ( fromNode->IsGOTONode() ) {
1399       fromPort->Kind( SUPERV::GOTOParameter ) ;
1400     }
1401     fromPort->PortStatus( PortConnected ); // GOTO - Loop
1402   }
1403   else if ( fromNode->IsDataFlowNode() || fromNode->IsDataStreamNode() ) {
1404     cdebug << "AddLink IsDataFlow/StreamNode fromPort->PortStatus( DataConnected ) : "
1405            << fromNode->Name() << " " << fromPort->PortName() << endl ;
1406     fromPort->PortStatus( ExternConnected );
1407   }
1408   else if ( toNode->IsDataFlowNode() || toNode->IsDataStreamNode() ) {
1409     cdebug << "AddLink IsDataFlow/StreamNode fromPort->PortStatus( ExternConnected ) : "
1410            << fromNode->Name() << " " << fromPort->PortName() << endl ;
1411     fromPort->PortStatus( ExternConnected ) ;
1412   }
1413   else {
1414     cdebug << "AddLink fromPort->PortStatus( PortConnected ) & fromNode->toNode "
1415            << fromNode->Name() << " " << fromPort->PortName() << " "
1416            << fromPort->Kind() << " OldPortStatus " << fromPort->PortStatus() << " -> " << toNode->Name()
1417            << " " << " " << toPort->PortName() << " " << toPort->Kind() << endl;
1418     fromPort->PortStatus( PortConnected );
1419     if ( fromPort->IsDataStream() && toPort->IsDataStream() ) {
1420       fromNode->AddStreamLinkedNode( toNode ) ;
1421     }
1422     else {
1423       fromNode->AddLinkedNode( toNode ) ;
1424     }
1425   }
1426   if ( fromNode->IsSwitchNode() ) {
1427     if ( !fromPort->IsDataStream() ) {
1428 //JR 08.02.2005      if ( fromPort->IsInLine() && toPort->IsGate() && !toNode->IsEndSwitchNode() ) {
1429       if ( fromPort->IsInLine() && toPort->IsGate() ) {
1430         fromPort->Kind( SUPERV::SwitchParameter ) ;
1431       }
1432       else if ( !fromPort->IsGate() && !toPort->IsGate() ){
1433         fromPort->Kind( SUPERV::InLineParameter ) ;
1434       }
1435     }
1436     if ( fromPort->IsGate() && !toNode->IsEndSwitchNode() ) {
1437       GraphBase::InLineNode * anEndSwitchNode ;
1438       anEndSwitchNode = ((GraphBase::SwitchNode * ) fromNode)->CoupledNode() ;
1439       GraphBase::InPort * anInPort = anEndSwitchNode->GetChangeNodeInGate() ;
1440       GraphBase::OutPort * anOutPort = anInPort->GetOutPort() ;
1441       if ( anOutPort && !strcmp( fromNode->Name() , anOutPort->NodeName() ) &&
1442            !strcmp( fromPort->PortName() , anOutPort->PortName() ) &&
1443            anOutPort->IsGate() ) {
1444         if ( !RemoveLink( fromNode->Name() , anOutPort->PortName() ,
1445                           anEndSwitchNode->Name() ,
1446                           anInPort->PortName() ) ) {
1447           cdebug << "AddLink Error Removelink ( Switch , Default , EndSwitch , Default )"
1448                  << endl ;
1449           cdebug_out << "GraphBase::Graph::AddLink 0" << endl;
1450           return false ;
1451         }
1452       }
1453     }
1454   }
1455 //  cdebug << fromNode->ServiceName() << " " << toNode->ServiceName() << endl ;
1456   cdebug_out << "GraphBase::Graph::AddLink 1" << endl;
1457   return true ;
1458 }
1459
1460 bool GraphBase::Graph::RemoveLink( const char* FromNodeName ,
1461                                    const char* FromServiceParameterName ,
1462                                    const char* ToNodeName ,
1463                                    const char* ToServiceParameterName ) {
1464   cdebug_in << "GraphBase::Graph::RemoveLink from " << FromNodeName << "(" << FromServiceParameterName << ")"
1465             << " to " << ToNodeName << "(" << ToServiceParameterName << ")" << endl;
1466   bool RetVal = false ;
1467   GraphBase::ComputingNode * toNode = GetChangeGraphNode( ToNodeName ) ;
1468   if ( toNode ) {
1469     GraphBase::InPort * anInPort = toNode->GetChangeInPort( ToServiceParameterName ) ;
1470     if ( anInPort && ( anInPort->IsPortConnected() ||
1471                        anInPort->IsDataConnected() ||
1472                        anInPort->IsExternConnected() ) ) {
1473 // JR 13.01.2005 : DeBug : if it is a link to an EndSwitchNode. The OutPort may be an other one !!!
1474       GraphBase::ComputingNode * fromNode = GetChangeGraphNode( FromNodeName ) ;
1475       GraphBase::OutPort * anOutPort = NULL ;
1476       if ( toNode->IsEndSwitchNode() ) {
1477         anOutPort = fromNode->GetChangeOutPort( FromServiceParameterName ) ;
1478         RetVal = anOutPort->RemoveInPort( anInPort ) ;
1479       }
1480       else {
1481         anOutPort = anInPort->GetOutPort() ;
1482         RetVal = anOutPort->RemoveInPort( anInPort ) ;
1483       }
1484 //      anInPort->RemoveOutPort() ; // Already done in RemoveInPort
1485 //      const char * FromNodeName = anOutPort->NodeName() ;
1486       if ( RetVal ) {
1487         if ( fromNode ) {
1488           if ( anInPort->IsDataStream() ) {
1489             fromNode->RemoveStreamLinkedNode( toNode ) ;
1490           }
1491           else {
1492             fromNode->RemoveLinkedNode( toNode ) ;
1493             // mkr : PAL12575 -->
1494             if ( fromNode->IsGOTONode() ) {
1495               GraphBase::GOTONode * aGOTONode = (GraphBase::GOTONode * ) fromNode ;
1496               if ( aGOTONode->CoupledNode() && strcmp( aGOTONode->CoupledNode()->Name(), toNode->Name() ) == 0 ) {
1497                 aGOTONode->CoupledNode(NULL);
1498                 aGOTONode->CoupledNodeName("");
1499                 
1500                 // set ExternConnected status for output data port of GoTo node
1501                 for ( int aPortId = 0 ; aPortId < fromNode->GetNodeOutPortsSize() ; aPortId++ ) {
1502                   GraphBase::OutPort * anOutPort = fromNode->GetChangeNodeOutPort(aPortId) ;
1503                   if ( anOutPort->IsNotConnected() && !anOutPort->IsGate() )
1504                     anOutPort->PortStatus( ExternConnected ) ;
1505                 }
1506               }
1507             }
1508             // mkr : PAL12575 <--
1509           }
1510         }
1511 //JR PAL7990 : a SwitchPort is an OutPort of a SwitchNode connected to a InGate Port
1512 //Debug : change the kind only if there is no other InGate connected to the OutPort
1513         if ( fromNode->IsSwitchNode() && !anOutPort->IsGate() && anOutPort->InPortsSize() == 0 ) {
1514           if ( !toNode->IsEndSwitchNode() ) {
1515             anOutPort->Kind( SUPERV::InLineParameter ) ;
1516           }
1517           else if ( !anInPort->IsGate() ) {
1518             anOutPort->Kind( SUPERV::InLineParameter ) ;
1519           }
1520         }
1521 // JR 13.01.2005 : DeBug : if it is a link to an EndSwitchNode. The InPort may be multiple linked !!!
1522         if ( toNode->IsEndSwitchNode() ) {
1523           int i ;
1524           int done = false ;
1525           for ( i = 0 ; i < toNode->LinkedFromNodesSize() ; i++ ) {
1526             GraphBase::StreamNode * fromNode = toNode->LinkedFromNodes( i ) ;
1527             int j ;
1528             for ( j = 0 ; j < fromNode->GetNodeOutPortsSize() ; j++ ) {
1529               GraphBase::OutPort * fromOutPort = fromNode->GetChangeNodeOutPort( j ) ;
1530               int k ;
1531               for ( k = 0 ; k < fromOutPort->InPortsSize() ; k++ ) {
1532                 if ( strcmp( toNode->Name() , fromOutPort->InPorts( k )->NodeName() ) == 0 ) {
1533                   if ( strcmp( anInPort->PortName() , fromOutPort->InPorts( k )->PortName() ) == 0 ) {
1534 // Restore an OutPort in the InPort
1535                     anInPort->ChangeOutPort( fromOutPort ) ;
1536                     cdebug << "Graph::RemoveLink reestablish " << fromOutPort->NodeName() << "( "
1537                            << fromOutPort->PortName() << " ) in the InPort of EndSwitch : "
1538                            << toNode->Name() << "( " << anInPort->PortName() << " )"
1539                            << anInPort->Kind() << " " << anInPort->PortStatus() << endl;
1540                     done = true ;
1541                     break ;
1542                   }
1543                 }
1544               }
1545               if ( done ) {
1546                 break ;
1547               }
1548             }
1549             if ( done ) {
1550               break ;
1551             }
1552           }
1553         }
1554       }
1555     }
1556   }
1557   cdebug_out << "GraphBase::Graph::RemoveLink " << RetVal << endl;
1558   return RetVal ;
1559 }
1560
1561 bool GraphBase::Graph::GetLink(const char* ToNodeName ,
1562                                const char* ToServiceParameterName ,
1563                                char** FromNodeName ,
1564                                char** FromServiceParameterName ) {
1565 //  cdebug_in << "GraphBase::Graph::GetLink " << ToNodeName << "("
1566 //            << ToServiceParameterName << ")" << endl;
1567   bool RetVal = false ;
1568   GraphBase::ComputingNode * toNode = GetChangeGraphNode( ToNodeName ) ;
1569   if ( toNode ) {
1570     GraphBase::InPort * anInPort = toNode->GetChangeInPort( ToServiceParameterName ) ;
1571     if ( anInPort && !anInPort->IsNotConnected() ) {
1572       GraphBase::OutPort * anOutPort = anInPort->GetOutPort() ;
1573 //JR 17.02.2005 Memory Leak      *FromNodeName = my_strdup( anOutPort->NodeName() ) ;
1574       *FromNodeName = (char * ) anOutPort->NodeName() ;
1575 //JR 17.02.2005 Memory Leak      *FromServiceParameterName = my_strdup( anOutPort->PortName() ) ;
1576       *FromServiceParameterName = (char * ) anOutPort->PortName() ;
1577       RetVal = true ;
1578     }
1579     else {
1580       cdebug << "GraphBase::Graph::GetLink ERROR no InPort or NotConnected " << ToNodeName
1581              << " " << ToServiceParameterName << " " << RetVal << endl;
1582     }
1583   }
1584   else {
1585     cdebug << "GraphBase::Graph::GetLink ERROR no Node " << ToNodeName << " " << RetVal
1586            << endl;
1587   }
1588 //  cdebug_out << "GraphBase::Graph::GetLink " << RetVal << endl;
1589   return RetVal ;
1590 }
1591
1592 bool GraphBase::Graph::AddInputData( const char* ToNodeName ,
1593                                      const char* ToServiceParameterName ,
1594                                      const CORBA::Any aValue ) {
1595   bool RetVal = false ;
1596   cdebug_in << "GraphBase::Graph::AddInputData(" << ToNodeName << ","
1597             << ToServiceParameterName << " , Any " ;
1598   bool isUnknown = false;
1599   switch (aValue.type()->kind()) {
1600     case CORBA::tk_string:
1601       const char * t;
1602       aValue >>= t;
1603       cdebug << t << " (string) " ;
1604       if ( !strcmp( t, "Unknown CORBA::Any Type" ) ) 
1605         // mkr : IPAL8054 : in this case port has no input value
1606         isUnknown = true;
1607       break;
1608     case CORBA::tk_double:
1609       double d;
1610       aValue >>= d;
1611       cdebug << d << " (double) " ;
1612       break;
1613     case CORBA::tk_long:
1614       CORBA::Long l;
1615       aValue >>= l;
1616       cdebug << l << " (CORBA::Long) " ;
1617       break;
1618     case CORBA::tk_objref:
1619       cdebug << "(object reference) " ;
1620       break;
1621     default:
1622       cdebug << "(other(tk_string(" << CORBA::tk_string << "),tk_double(" << CORBA::tk_double << "),tk_long("
1623              << CORBA::tk_long << "),tk_objref)(" << CORBA::tk_objref << ")) ERROR : " << aValue.type()->kind() ;
1624       break;
1625     }
1626   cdebug << " ) in Graph " << Name() << endl;
1627  
1628   GraphBase::ComputingNode *toNode ;
1629   GraphBase::InPort *toPort ;
1630   char *aNodeName ;
1631   char *aPortName ;
1632   NodePort( ToNodeName , ToServiceParameterName , &aNodeName , &aPortName ) ;
1633   toNode = GetChangeGraphNode( aNodeName ) ;
1634   cdebug << "in Graph " << Name() << " aNodeName '" << aNodeName << "' aPortName '" << aPortName
1635          << "'" << endl;
1636   if ( toNode ) {
1637     toPort = toNode->GetChangeInPort( aPortName ) ;
1638     if ( toPort && !toPort->IsDataConnected() && toPort->GetOutPort() ) {
1639       toPort->RemoveOutPort() ;
1640     }
1641   }
1642   else {
1643     toPort = NULL ;
1644   }
1645
1646   int i ;
1647   cdebug << endl << "Graph::AddInputData ListOfInOutPorts of the Graph : " << endl ;
1648   for ( i = 0 ; i < GetNodeOutDataNodePortsSize() ; i++ ) {
1649     cdebug << "Graph::AddInputData In" << i << " " << *GetNodeOutDataNodePort(i) << endl ;
1650   }
1651   for ( i = 0 ; i < GetNodeInDataNodePortsSize() ; i++ ) {
1652     cdebug << "Graph::AddInputData Out" << i << " " << *GetNodeInDataNodePort(i) << endl ;
1653   }
1654
1655   if ( toNode && toPort ) {
1656     GraphBase::OutPort *fromDataNodePort = NULL ;
1657     fromDataNodePort = GraphBase::DataNode::GetChangeInDataNodePort( toPort->NodePortName() ) ;
1658     if ( fromDataNodePort && fromDataNodePort->GetInPort( toPort ) ) {
1659       fromDataNodePort->RemoveInPort( toPort ) ;
1660     }
1661     cdebug << "Try AddLink " << toPort->NodePortName() << " : " << Name() << "( "
1662            << fromDataNodePort->PortName() << " ) -->" << toNode->Name() << "( "
1663            << toPort->PortName() << " )" << endl ;
1664     RetVal = AddLink( (GraphBase::ComputingNode * ) this , fromDataNodePort ,
1665                       toNode , toPort ) ;
1666     if ( RetVal ) {
1667       fromDataNodePort->SetValue( aValue ) ;
1668       if ( !isUnknown ) // mkr : IPAL8054 : to avoid setting "strange" value to a port
1669         fromDataNodePort->PortStatus( DataConnected ) ;
1670     }
1671   }
1672   else {
1673     cdebug << "ERROR Node and/or Port not found : " << aNodeName << " " << aPortName << endl ;
1674   }
1675   delete [] aNodeName ;
1676   delete [] aPortName ;
1677
1678   cdebug_out << "GraphBase::Graph::AddInputData " << RetVal << endl;
1679   return RetVal ;
1680 }
1681
1682 // Used in the Executor in order to change an Input Value and ReRun
1683 bool GraphBase::Graph::ChangeInputData( const char * ToNodeName ,
1684                                         const char * ToServiceParameterName ,
1685                                         const CORBA::Any aValue ) {
1686   bool RetVal = false ;
1687   cdebug_in << "GraphBase::Graph::ChangeInputData( '" << ToNodeName << "' , '"
1688             << ToServiceParameterName << "' , Any " ;
1689   switch (aValue.type()->kind()) {
1690     case CORBA::tk_string:
1691       const char * t;
1692       aValue >>= t;
1693       cdebug << t << " (string) " ;
1694       break;
1695     case CORBA::tk_double:
1696       double d;
1697       aValue >>= d;
1698       cdebug << d << " (double) " ;
1699       break;
1700     case CORBA::tk_long:
1701       CORBA::Long l;
1702       aValue >>= l;
1703       cdebug << l << " (CORBA::Long) " ;
1704       break;
1705     case CORBA::tk_objref:
1706       cdebug << "(object reference) " ;
1707       break;
1708     default:
1709       cdebug << "(other(tk_string,tk_double,tk_long,tk_objref)) ERROR";
1710       break;
1711     }
1712   cdebug << " ) in Graph " << Name() << endl;
1713
1714   GraphBase::ComputingNode * toNode ;
1715   GraphBase::InPort * toPort = NULL ;
1716   char * aNodeName ;
1717   char * aPortName ;
1718   NodePort( ToNodeName , ToServiceParameterName , &aNodeName , &aPortName ) ;
1719   toNode = GetChangeGraphNode( aNodeName ) ;
1720   cdebug << "in Graph " << Name() << " aNodeName " << aNodeName << " aPortName " << aPortName << endl;
1721   if ( toNode ) {
1722     toPort = toNode->GetChangeInPort( aPortName ) ;
1723     if ( toPort && toPort->IsDataConnected() ) {
1724       GraphBase::OutPort * fromPort = toPort->GetOutPort();
1725       if ( fromPort ) {
1726         RetVal = true ;
1727         fromPort->SetValue( aValue ) ;
1728         fromPort->PortStatus( DataConnected ) ;
1729         toPort->PortState( SUPERV::ReadyState ) ;
1730       }
1731       else {
1732         cdebug << "ERROR ChangeInputData fromPort not found" << endl ;
1733       }
1734     }
1735     else {
1736       cdebug << "ERROR ChangeInputData toPort not found" << endl ;
1737     }
1738   }
1739   else {
1740     cdebug << "ERROR ChangeInputData Node not found : " << ToNodeName << endl ;
1741   }
1742
1743   cdebug_out << "GraphBase::Graph::ChangeInputData" << endl;
1744   return RetVal ;
1745 }
1746
1747 #if 0
1748 // To restore InputData in CreateService
1749 bool GraphBase::Graph::AddInputData( const char* ToNodeName ,
1750                                      const char* ToServiceParameterName ,
1751                                      const CORBA::Any ** aValue ) {
1752   bool RetVal = false ;
1753   cdebug_in << "GraphBase::Graph::AddInputData( " << ToNodeName << " , "
1754             << ToServiceParameterName << ", **Any " ;
1755   const CORBA::Any theValue = **aValue ;
1756   switch (theValue.type()->kind()) {
1757     case CORBA::tk_string:
1758       char * t;
1759       theValue >>= t;
1760       cdebug << t << " (string) " ;
1761       break;
1762     case CORBA::tk_double:
1763       CORBA::Double d;
1764       theValue >>= d;
1765       cdebug << d << " (double) " ;
1766       break;
1767     case CORBA::tk_long:
1768       CORBA::Long l;
1769       theValue >>= l;
1770       cdebug << l << " (CORBA::Long) " ;
1771       break;
1772     case CORBA::tk_objref:
1773       cdebug << "(object reference) " ;
1774       break;
1775     default:
1776       cdebug << "(other(tk_string,tk_double,tk_long,tk_objref)) ERROR";
1777       break;
1778     }
1779   cdebug << ") of Graph " << Name() << endl;
1780
1781   GraphBase::ComputingNode *toNode = GetChangeGraphNode( ToNodeName ) ;
1782
1783   if ( toNode ) {
1784     GraphBase::InPort *toPort = NULL ;
1785     GraphBase::OutPort *fromDataNodePort = NULL ;
1786     toPort = toNode->GetChangeInPort( ToServiceParameterName ) ;
1787     fromDataNodePort = GraphBase::DataNode::GetChangeInDataNodePort( toPort->NodePortName() ) ;
1788     cdebug << "Try AddLink " << Name() << "( " << fromDataNodePort << " ) -->"
1789            << toNode->Name() << "( " << toPort->PortName() << " )" << endl ;
1790     RetVal = AddLink( (GraphBase::ComputingNode * ) this , fromDataNodePort ,
1791                       toNode , toPort ) ;
1792     if ( RetVal ) {
1793       fromDataNodePort->Value( aValue ) ;
1794       fromDataNodePort->PortStatus( DataConnected ) ;
1795     }
1796   }
1797   else {
1798     cdebug << "ERROR Node not found " << ToNodeName << " ERROR. Known nodes :" << endl ;
1799     map< string , int >::iterator aMapOfGraphNodesIterator ;
1800     int i = 0 ;
1801     for ( aMapOfGraphNodesIterator = _MapOfGraphNodes.begin() ;
1802           aMapOfGraphNodesIterator != _MapOfGraphNodes.end() ; aMapOfGraphNodesIterator++ ) {
1803       cdebug << "MapOfGraphNodes " << i++ << " " << aMapOfGraphNodesIterator->first << " --> "
1804              << aMapOfGraphNodesIterator->second << endl ;
1805     }
1806   }
1807
1808   cdebug_out << "GraphBase::Graph::AddInputData " << RetVal << endl;
1809   return RetVal ;
1810 }
1811 #endif
1812
1813 bool GraphBase::Graph::AddOutputData( const char* FromNodeName ,
1814                                       const char* FromServiceParameterName ,
1815                                       const CORBA::Any aValue ) {
1816   bool RetVal = true ;
1817   cdebug_in << "GraphBase::Graph::AddOutputData(" << FromNodeName << ","
1818             << FromServiceParameterName << ")" << endl;
1819   GraphBase::ComputingNode *fromNode = GetChangeGraphNode( FromNodeName ) ;
1820
1821   GraphBase::OutPort *anOutPort = NULL ;
1822
1823   if ( fromNode ) {
1824     anOutPort = fromNode->GetChangeOutPort( FromServiceParameterName ) ;
1825 //    toDataNodePort = GraphBase::DataNode::GetChangeOutDataNodePort( fromPort->NodePortName() ) ;
1826 //    RetVal = AddLink( fromNode , fromPort ,
1827 //                      (GraphBase::ComputingNode * ) this , toDataNodePort ) ;
1828     anOutPort->SetValue( aValue ) ;
1829     anOutPort->PortState(  SUPERV::ReadyState ) ;
1830     anOutPort->PortDone( true ) ;
1831     cdebug << *anOutPort ;
1832 #ifdef _DEBUG_
1833     anOutPort->StringValue( *_fdebug ) ;
1834 #endif
1835     cdebug << endl ;
1836   }
1837   else {
1838     cdebug << "ERROR Node not found" << endl ;
1839     RetVal = false ;
1840   }
1841   cdebug_out << "GraphBase::Graph::AddOutputData " << RetVal << endl;
1842   return RetVal ;
1843 }
1844
1845 //JR This is used by StreamGraphs to list "CODES" and after that there is instances
1846 // for each Code (Nodes).
1847 map< string , GraphBase::Service * > GraphBase::Graph::MapOfServiceNames() {
1848                                            return _MapOfServiceNames ; }
1849
1850 GraphBase::Service * GraphBase::Graph::GetServiceOfMap( char * name ) {
1851   return _MapOfServiceNames[ name ] ;
1852 }
1853
1854 bool GraphBase::Graph::SetServiceOfMap( GraphBase::Service * aService ) {
1855   GraphBase::Service * theService = _MapOfServiceNames[ aService->ServiceName() ] ;
1856   if ( theService ) {
1857     cdebug << "SetServiceOfMap of " << aService->ServiceName()
1858            << " already in MapOfServiceNames : erase" << endl ;
1859     _MapOfServiceNames.erase( aService->ServiceName() ) ;
1860   }
1861   _MapOfServiceNames[ (char * ) aService->ServiceName() ] = aService ;
1862   cdebug << "SetServiceOfMap of " << aService->ServiceName() << " done" << endl ;
1863   return true ;
1864 }
1865
1866 //PAL7961
1867 //JR Debug 25.03.2005 : with multiple instances et delete of instances, it was wrong
1868 //Bug created with the developpement of StreamGraphs
1869 int GraphBase::Graph::GetNewServiceInstanceNumber( char * aServiceName ) {
1870   int InstanceNumber = _MapOfServiceInstanceNumber[ aServiceName ] + 1 ;
1871   _MapOfServiceInstanceNumber[ aServiceName ] = InstanceNumber ;
1872   return InstanceNumber ;
1873 }
1874
1875 void GraphBase::Graph::SetGraphPorts() {
1876   cdebug_in << "GraphBase::Graph::SetGraphPorts fill ports of Graph" << endl;
1877   int i ;
1878   for ( i = 0 ; i < GetNodeInDataNodePortsSize() ; i++ ) {
1879     GraphBase::OutPort * anOutPort = GetChangeNodeInDataNodePort( i ) ;
1880     cdebug << "SetGraphPorts Out" << i << " " << anOutPort->PortName() << " " << anOutPort->PortType()
1881            << " " << anOutPort->Kind() << " " << anOutPort->PortStatus() << " " << anOutPort->PortState() << endl ;
1882     if ( !anOutPort->IsGate() ) {
1883       anOutPort->PortStatus( ExternConnected ) ;
1884     }
1885   }
1886   for ( i = 0 ; i < GetNodeOutDataNodePortsSize() ; i++ ) {
1887     GraphBase::InPort * anInPort = GetChangeNodeOutDataNodePort( i ) ;
1888     cdebug << "SetGraphPorts In" << i << " " << anInPort->PortName() << " " << anInPort->PortType()
1889            << " " << anInPort->Kind() << " " << anInPort->PortStatus() << " " << anInPort->PortState() << endl ;
1890     if ( !anInPort->IsGate() ) {
1891       GraphBase::OutPort * anOutPort = anInPort->GetOutPort() ;
1892       anOutPort->PortStatus( ExternConnected ) ;
1893     }
1894   }
1895   cdebug_out << "GraphBase::Graph::SetGraphPorts" << endl;
1896 }
1897
1898 string GraphBase::Graph::Messages() {
1899 //  cdebug_in << "Graph::Messages" << endl ;
1900 //  cdebug_out << "Graph::Messages" << endl ;
1901   return ( CORBA::string_dup( _Messages.c_str() ) ) ;
1902 }
1903
1904 void GraphBase::Graph::ReSetMessages() {
1905   cdebug << "Graph::ReSetMessages" << endl ;
1906   _Messages = string( "" ) ;
1907 }
1908
1909 void GraphBase::Graph::SetMessages( string anErrorMessage ) {
1910   cdebug_in << "Graph::SetMessages" << endl ;
1911   _Messages = _Messages + anErrorMessage + string( "\n" ) ;
1912   cdebug_out << "Graph::SetMessages :" << endl << _Messages << endl ;
1913 }
1914
1915 bool GraphBase::Graph::CreateService() {
1916   cdebug_in << "GraphBase::Graph::CreateService " << Name() << " GraphMacroLevel : " << GraphMacroLevel() << endl;
1917   bool RetVal = true ;
1918   SALOME_ModuleCatalog::Service aService ;
1919   int i , j ;
1920   GraphBase::ComputingNode * aToNode ;
1921   int dostore ;
1922   int innbr = 0 ;
1923   int instreamnbr = 0 ;
1924   int outnbr = 0 ;
1925   int outstreamnbr = 0 ;
1926   vector< SUPERV::KindOfPort > InPortsKind ;
1927   vector< SALOME_ModuleCatalog::DataStreamDependency > InDataStreamDependency ;
1928   vector< SUPERV::KindOfSchema > InKindOfSchema ;
1929   vector< SUPERV::KindOfInterpolation > InKindOfInterpolation ;
1930   vector< SUPERV::KindOfExtrapolation > InKindOfExtrapolation ;
1931   vector< SUPERV::KindOfPort > OutPortsKind ;
1932   vector< SALOME_ModuleCatalog::DataStreamDependency > OutDataStreamDependency ;
1933   vector< long > OutNumberOfValues ;
1934 //  if ( GraphMacroLevel() == 0 ) {
1935     for ( dostore = 0 ; dostore <= 2 ; dostore++ ) {
1936       if ( dostore == 1 ) {
1937 //JR 17.02.2005 Memory Leak        aService.ServiceName = Name() ;
1938         aService.ServiceName = my_strdup( Name() ) ;
1939         aService.ServiceinParameter.length( 0 ) ;
1940         aService.ServiceinParameter.length( innbr ) ;
1941         aService.ServiceoutParameter.length( 0 ) ;
1942         aService.ServiceoutParameter.length( outnbr ) ;
1943         InPortsKind.resize( innbr ) ;
1944         InDataStreamDependency.resize( innbr ) ;
1945         InKindOfSchema.resize( innbr ) ;
1946         InKindOfInterpolation.resize( innbr ) ;
1947         InKindOfExtrapolation.resize( innbr ) ;
1948         OutPortsKind.resize( outnbr ) ;
1949         OutDataStreamDependency.resize( outnbr ) ;
1950         OutNumberOfValues.resize( outnbr ) ;
1951       }
1952       else if ( dostore == 2 ) {
1953 //JR Creation of the Service (and of the Ports) with GraphBase::DataNode::DataService :
1954         cdebug << "GraphBase::Graph::CreateService ->DataService innbr " << innbr
1955                << " instreamnbr " << instreamnbr << " outnbr " << outnbr
1956                << " outstreamnbr " << outstreamnbr << endl ;
1957         DataService( _Orb , aService , Graph_prof_debug() , Graph_fdebug() ) ;
1958         aService.ServiceinParameter.length( innbr + instreamnbr ) ;
1959         aService.ServiceoutParameter.length( outnbr + outstreamnbr ) ;
1960         InPortsKind.resize( innbr + instreamnbr ) ;
1961         InDataStreamDependency.resize( innbr + instreamnbr ) ;
1962         InKindOfSchema.resize( innbr + instreamnbr ) ;
1963         InKindOfInterpolation.resize( innbr + instreamnbr ) ;
1964         InKindOfExtrapolation.resize( innbr + instreamnbr ) ;
1965         OutPortsKind.resize( outnbr + outstreamnbr ) ;
1966         OutDataStreamDependency.resize( outnbr + outstreamnbr ) ;
1967         OutNumberOfValues.resize( outnbr + outstreamnbr ) ;
1968       }
1969       if ( dostore == 0 ) {
1970         innbr = 0 ;
1971         instreamnbr = 0 ;
1972         outnbr = 0 ;
1973         outstreamnbr = 0 ;
1974       }
1975       if ( dostore == 1 ) {
1976         innbr = 0 ;
1977         outnbr = 0 ;
1978       }
1979       for ( i = 0 ; i < GraphNodesSize() ; i++ ) {
1980         aToNode = GraphNodes( i ) ;
1981         for ( j = 0 ; j < aToNode->GetNodeInPortsSize() ; j++ ) {
1982           GraphBase::InPort *anInPort = aToNode->GetChangeNodeInPort(j) ;
1983           bool isfromcouplednode = false ;
1984           if ( !anInPort->IsNotConnected() ) {
1985             const char * aFromNodeName = anInPort->GetOutPort()->NodeName() ;
1986             GraphBase::ComputingNode * aFromNode = GetChangeGraphNode( aFromNodeName ) ;
1987             cdebug << "GraphBase::Graph::CreateService aFromNodeName " << aFromNodeName << " aToNode "
1988                    << aToNode->Name() << " InPort" << j << " " << anInPort->PortName() << endl ;
1989             if ( aFromNode && aFromNode->IsEndLoopNode() &&
1990                  ((GraphBase::EndOfLoopNode * ) aFromNode)->CoupledNode() == aToNode ) {
1991               isfromcouplednode = true ;
1992             }
1993           }
1994           if ( !anInPort->IsGate() && !anInPort->IsLoop() &&
1995                ( !anInPort->IsPortConnected() ||
1996 //                 ( anInPort->IsPortConnected() && isfromcouplednode ) ) ) {
1997 //JR PAL8914 : InPorts of EndLoopNodes may not be in the Service of the Graph
1998                  ( anInPort->IsPortConnected() && isfromcouplednode ) ) &&
1999                !aToNode->IsEndLoopNode() ) {
2000             if ( dostore == 0 ) {
2001               cdebug << "CreateService " << aToNode->Name() << " Input port "
2002                      << anInPort->PortName() << " " << anInPort->Kind() << " " << anInPort->PortStatus() ;
2003               if ( anInPort->GetOutPort() ) {
2004                 cdebug << "DataConnected from " <<  *(anInPort->GetOutPort() ) ;
2005               }
2006               cdebug << endl ;
2007               if ( anInPort->IsDataStream() ) {
2008                 instreamnbr += 1 ;
2009               }
2010               else {
2011                 innbr += 1 ;
2012               }
2013             }
2014             else if ( ( dostore == 1 && !anInPort->IsDataStream() ) ||
2015                       ( dostore == 2 && anInPort->IsDataStream() ) ) {
2016               aService.ServiceinParameter[innbr].Parametertype = CORBA::string_dup( anInPort->PortType() ) ;
2017               aService.ServiceinParameter[innbr].Parametername = CORBA::string_dup( anInPort->NodePortName() ) ;
2018               InPortsKind[ innbr ] = anInPort->Kind() ;
2019               InDataStreamDependency[ innbr ] = anInPort->Dependency() ;
2020               if ( dostore == 2 && anInPort->IsDataStream() ) {
2021                 ((GraphBase::InDataStreamPort * ) anInPort)->Params( InKindOfSchema[ innbr ] ,
2022                                                                      InKindOfInterpolation[ innbr ] ,
2023                                                                      InKindOfExtrapolation[ innbr ] ) ;
2024               }
2025               cdebug << "In" << innbr << " " << aService.ServiceinParameter[ innbr ].Parametername << " "
2026                      << anInPort->Kind() << " " << anInPort->PortStatus() << endl ;
2027               innbr += 1 ;
2028             }
2029           }
2030           else if ( dostore == 0 ) {
2031             cdebug << "CreateService " << aToNode->Name() << " Input port " << anInPort->PortName()
2032                    << " " << anInPort->PortStatus() ;
2033             if ( anInPort->IsPortConnected() ) {
2034               cdebug << " is connected " ;
2035             }
2036             else {
2037               cdebug << " is NOT connected " ;
2038             }
2039             if ( anInPort->IsGate() ) {
2040               cdebug << " IsGate " ;
2041             }
2042             if ( anInPort->GetOutPort() ) {
2043               cdebug << "DataConnected from " <<  *(anInPort->GetOutPort()) ;
2044             }
2045             else {
2046               cdebug << "NOT DataConnected" ;
2047             }
2048             cdebug << endl ;
2049           }
2050         }
2051         GraphBase::ComputingNode * aFromNode = aToNode ;
2052         for ( j = 0 ; j < aFromNode->GetNodeOutPortsSize() ; j++ ) {
2053           GraphBase::OutPort *anOutPort = aFromNode->GetChangeNodeOutPort(j) ;
2054 //          cdebug << "CreateService Node " << aFromNode->Name() << ". Output port[" << j << "] ";
2055 //          if ( anOutPort ) {
2056 //            cdebug << anOutPort->PortName() << " " << anOutPort->ServicesParameterType() << endl ;
2057 //        }
2058 //          else {
2059 //            cdebug << " NULL" << endl ;
2060 //        }
2061           if ( !aFromNode->IsGOTONode() ) {
2062             if ( !anOutPort->IsGate() && ( anOutPort->IsNotConnected() || anOutPort->IsDataConnected()  ||
2063 //JR PAL8914 : OutPorts of LoopNodes may not be in the Service of the Graph
2064 //                                           anOutPort->IsExternConnected() ) {
2065                                            anOutPort->IsExternConnected() ) &&
2066                  !aFromNode->IsLoopNode() ) {
2067               if ( dostore == 0 ) {
2068 //                cdebug << "CreateService " << aFromNode->Name() << " Output port "
2069 //                       << anOutPort->PortName() << " " << anOutPort->PortStatus() << endl ;
2070                 if ( anOutPort->IsDataStream() ) {
2071                   outstreamnbr += 1 ;
2072                 }
2073                 else {
2074                   outnbr += 1 ;
2075                 }
2076               }
2077               else if ( ( dostore == 1 && !anOutPort->IsDataStream() ) ||
2078                         ( dostore == 2 && anOutPort->IsDataStream() ) ) {
2079                 aService.ServiceoutParameter[outnbr].Parametertype = CORBA::string_dup( anOutPort->PortType() ) ;
2080                 aService.ServiceoutParameter[outnbr].Parametername = CORBA::string_dup( anOutPort->NodePortName() ) ;
2081                 OutPortsKind[ outnbr ] = anOutPort->Kind() ;
2082                 OutDataStreamDependency[ outnbr ] = anOutPort->Dependency() ;
2083                 if ( dostore == 2 && anOutPort->IsDataStream() ) {
2084                   OutNumberOfValues[ outnbr ] = ((GraphBase::OutDataStreamPort * ) anOutPort)->NumberOfValues() ;
2085                 }
2086 //                cdebug << "Out" << outnbr << " " << aService.ServiceoutParameter[ outnbr ].Parametername << " "
2087 //                       << anOutPort->Kind() << " " << anOutPort->PortStatus() << endl ;
2088                 outnbr += 1 ;
2089               }
2090             }
2091           }
2092         }
2093       }
2094     }
2095 //  }
2096
2097 #if 1
2098   cdebug << "DataFlowNode ServiceName " << aService.ServiceName << " InPorts " << innbr
2099          << " OutPorts " << outnbr << endl ;
2100   for ( i = 0 ; i < innbr ; i++ ) {
2101     cdebug << "aService.ServiceinParameter[" << i << "].Parametertype "
2102          << aService.ServiceinParameter[i].Parametertype << " Parametername "
2103          << aService.ServiceinParameter[i].Parametername << " " << InPortsKind[ i ] << endl ;
2104     if ( InPortsKind[ i ] != SUPERV::DataStreamParameter ) {
2105       cdebug << "NodeInPort[" << i << "] " << *GetChangeNodeInPort( i ) << endl ;
2106     }
2107   }
2108   for ( i = 0 ; i < outnbr ; i++ ) {
2109     cdebug << "aService.ServiceoutParameter[" << i << "].Parametertype "
2110          << aService.ServiceoutParameter[i].Parametertype << " Parametername "
2111          << aService.ServiceoutParameter[i].Parametername << " " << OutPortsKind[ i ] << endl ;
2112     if ( OutPortsKind[ i ] != SUPERV::DataStreamParameter ) {
2113       cdebug << "NodeOutPort[" << i << "] " << *GetChangeNodeOutPort( i ) << endl ;
2114     }
2115   }
2116 #endif
2117
2118 //  DataService( _Orb , aService , InPortsKind , OutPortsKind , Graph_prof_debug() , Graph_fdebug() ) ;
2119   for ( i = 0 ; i < innbr ; i++ ) {
2120     if ( InPortsKind[ i ] == SUPERV::DataStreamParameter ) {
2121       GraphBase::InDataStreamPort * anInPort = AddInDataStreamPort( aService.ServiceinParameter[ i ].Parametername,
2122                                                                     aService.ServiceinParameter[ i ].Parametertype,
2123                                                                     InDataStreamDependency[ i ] ,
2124                                                                     SUPERV::DataStreamParameter ) ;
2125       anInPort->SetParams( InKindOfSchema[ i ] ,
2126                            InKindOfInterpolation[ i ] ,
2127                            InKindOfExtrapolation[ i ] ) ;
2128 // NOT A BUG : AddOutPort for an inport (Reversed service)
2129       anInPort = (GraphBase::InDataStreamPort * ) _DataFlowDataPorts->AddOutPort(
2130                                                            _Orb , NamePtr() ,
2131                                                            Kind() ,
2132                                                            aService.ServiceinParameter[ i ].Parametername ,
2133                                                            aService.ServiceinParameter[ i ].Parametertype ,
2134                                                            SUPERV::DataStreamParameter ,
2135                                                            - 1 ,
2136                                                            _Graph_prof_debug , _Graph_fdebug ) ;
2137       anInPort->Dependency( InDataStreamDependency[ i ] ) ;
2138 // Attention : revoir les reversed DataStreamPorts
2139 //      anInPort->SetParams( InKindOfSchema[ i ] ,
2140 //                           InKindOfInterpolation[ i ] ,
2141 //                           InKindOfExtrapolation[ i ] ) ;
2142       cdebug << "InStreamPort " << GetChangeNodeInPort( i )->PortName() << " " << GetChangeNodeInPort( i )->Kind() << endl ;
2143       cdebug << "ReversedInStreamPort " << _DataFlowDataPorts->GetChangeNodeOutPort( i )->PortName() << " " << _DataFlowDataPorts->GetChangeNodeOutPort( i )->Kind()
2144              << endl ;
2145     }
2146     else {
2147       GetChangeNodeInPort( i )->Kind( InPortsKind[ i ] ) ;
2148       _DataFlowDataPorts->GetChangeNodeOutPort( i )->Kind( InPortsKind[ i ] ) ;
2149       GetChangeNodeInPort( i )->Dependency( InDataStreamDependency[ i ] ) ;
2150       _DataFlowDataPorts->GetChangeNodeOutPort( i )->Dependency( InDataStreamDependency[ i ] ) ;
2151       cdebug << "InPort " << GetChangeNodeInPort( i )->PortName() << " "
2152              << GetChangeNodeInPort( i )->Kind() << " " << GetChangeNodeInPort( i )->PortStatus()
2153              << endl ;
2154       cdebug << "ReversedInPort " << _DataFlowDataPorts->GetChangeNodeOutPort( i )->PortName() << " "
2155              << _DataFlowDataPorts->GetChangeNodeOutPort( i )->Kind() << " "
2156              << _DataFlowDataPorts->GetChangeNodeOutPort( i )->PortStatus()
2157              << endl ;
2158     }
2159   }
2160   for ( i = 0 ; i < outnbr ; i++ ) {
2161     if ( OutPortsKind[ i ] == SUPERV::DataStreamParameter ) {
2162       GraphBase::OutDataStreamPort * anOutPort = AddOutDataStreamPort( aService.ServiceoutParameter[ i ].Parametername ,
2163                                                                        aService.ServiceoutParameter[ i ].Parametertype ,
2164                                                                        OutDataStreamDependency[ i ] ,
2165                                                                        SUPERV::DataStreamParameter ) ;
2166       anOutPort->NumberOfValues( OutNumberOfValues[ i ] ) ;
2167 // NOT A BUG : AddInPort for an outport (Reversed service)
2168       anOutPort = (GraphBase::OutDataStreamPort * ) _DataFlowDataPorts->AddInPort(
2169                                                              _Orb , NamePtr() ,
2170                                                              Kind() ,
2171                                                              aService.ServiceoutParameter[ i ].Parametername ,
2172                                                              aService.ServiceoutParameter[ i ].Parametertype ,
2173                                                              SUPERV::DataStreamParameter ,
2174                                                              - 1 ,
2175                                                              _Graph_prof_debug , _Graph_fdebug ) ;
2176       anOutPort->Dependency( OutDataStreamDependency[ i ] ) ;
2177 // Attention : revoir les reversed DataStreamPorts
2178 //      anOutPort->NumberOfValues( OutNumberOfValues[ i ] ) ;
2179       cdebug << "OutStreamPort " << GetChangeNodeOutPort( i )->PortName() << " " << GetChangeNodeOutPort( i )->Kind() << endl ;
2180       cdebug << "ReversedOutStreamPort " << _DataFlowDataPorts->GetChangeNodeInPort( i )->PortName() << " " << _DataFlowDataPorts->GetChangeNodeInPort( i )->Kind()
2181              << endl ;
2182     }
2183     else {
2184       GetChangeNodeOutPort( i )->Kind( OutPortsKind[ i ] ) ;
2185       _DataFlowDataPorts->GetChangeNodeInPort( i )->Kind( OutPortsKind[ i ] ) ;
2186       GetChangeNodeOutPort( i )->Dependency( OutDataStreamDependency[ i ] ) ;
2187       _DataFlowDataPorts->GetChangeNodeInPort( i )->Dependency( OutDataStreamDependency[ i ] ) ;
2188       GetChangeNodeOutPort( i )->Dependency( OutDataStreamDependency[ i ] ) ;
2189       _DataFlowDataPorts->GetChangeNodeInPort( i )->Dependency( OutDataStreamDependency[ i ] ) ;
2190       cdebug << "OutPort " << GetChangeNodeOutPort( i )->PortName() << " "
2191              << GetChangeNodeOutPort( i )->Kind() << " " << GetChangeNodeOutPort( i )->PortStatus()
2192              << endl ;
2193       cdebug << "ReversedOutPort " << _DataFlowDataPorts->GetChangeNodeInPort( i )->PortName()
2194              << " " << _DataFlowDataPorts->GetChangeNodeInPort( i )->Kind()
2195              << " " << _DataFlowDataPorts->GetChangeNodeInPort( i )->PortStatus()
2196              << endl ;
2197     }
2198   }
2199 // Restore input datas and links :
2200   DataStreamInPortsNumber( 0 ) ;
2201   DataStreamOutPortsNumber( 0 ) ;
2202   for ( i = 0 ; i < GraphNodesSize() ; i++ ) {
2203     aToNode = GraphNodes( i ) ;
2204     DataStreamInPortsNumber( DataStreamInPortsNumber() + aToNode->DataStreamInPortsNumber() ) ;
2205     DataStreamOutPortsNumber( DataStreamOutPortsNumber() + aToNode->DataStreamOutPortsNumber() ) ;
2206     for ( j = 0 ; j < aToNode->GetNodeInPortsSize() ; j++ ) {
2207       GraphBase::InPort *anInPort = aToNode->GetChangeNodeInPort(j) ;
2208       if ( !anInPort->IsGate() && anInPort->IsDataConnected() ) {
2209         if ( !AddInputData( anInPort->NodeName() ,
2210                             anInPort->PortName() ,
2211 //JR 21.02.2005 Debug Memory leak :                            anInPort->GetOutPort()->ValuePtr() ) ) {
2212 //JR 30.03.2005                            *anInPort->GetOutPort()->Value() ) ) {
2213                             anInPort->GetOutPort()->Value() ) ) {
2214           cdebug << "CreateService In" << j << " " << anInPort->NodeName() << "(" << anInPort->PortName() << ") "
2215                  << anInPort->PortStatus() << " --> AddInputData ERROR" << endl ;
2216           RetVal = false ;
2217         }
2218         else {
2219           cdebug << "CreateService In" << j << " " << anInPort->NodeName() << "(" << anInPort->PortName() << ") "
2220                  << anInPort->PortStatus() << " --> AddInputData" << endl ;
2221         }
2222       }
2223 //JR PAL8914 : InPorts of EndLoopNodes may not be in the Service of the Graph
2224 //      else if ( !anInPort->IsGate() && anInPort->IsNotConnected() ) {
2225       else if ( !anInPort->IsGate() &&
2226                 ( anInPort->IsNotConnected() || anInPort->IsExternConnected() ) &&
2227                 !aToNode->IsEndLoopNode() ) {
2228         if ( !AddLink( this , GetChangeInDataNodePort( anInPort->NodePortName() ) , aToNode , anInPort ) ) {
2229           cdebug << "CreateService In" << j << " " << anInPort->NodeName() << "(" << anInPort->PortName() << ") "
2230                  << anInPort->PortStatus() << " --> AddInLink ERROR" << endl ;
2231           RetVal = false ;
2232         }
2233         else {
2234           cdebug << "CreateService In" << j << " " << anInPort->NodeName() << "(" << anInPort->PortName() << ") "
2235                  << anInPort->PortStatus() << " --> AddInLink" << endl ;
2236         }
2237       }
2238       else {
2239         cdebug << "CreateService In" << j << " " << anInPort->NodeName() << "(" << anInPort->PortName() << ") "
2240                << anInPort->PortStatus() << " --> NO AddInputData/AddInLink" << endl ;
2241       }
2242     }
2243     for ( j = 0 ; j < aToNode->GetNodeOutPortsSize() ; j++ ) {
2244       GraphBase::OutPort *anOutPort = aToNode->GetChangeNodeOutPort(j) ;
2245       cdebug << "CreateService Out" << j << " " << anOutPort->NodeName() << "(" << anOutPort->PortName()
2246              << ") " << anOutPort->PortStatus() << " :" << endl ;
2247 //JR PAL8914 : OutPorts of LoopNodes may not be in the Service of the Graph
2248 //      if ( !anOutPort->IsGate() && anOutPort->IsNotConnected() && !aToNode->IsGOTONode() ) {
2249       if ( !anOutPort->IsGate() && !aToNode->IsGOTONode() && !aToNode->IsLoopNode() &&
2250 //JR Debug : 06.09.2005 : recreate that link if the OutPort is ExternConnected !!!...
2251            ( anOutPort->IsNotConnected() || anOutPort->IsExternConnected() ) ) {
2252         GraphBase::InPort *anInPort = GetChangeOutDataNodePort( anOutPort->NodePortName() ) ;
2253         if ( !AddLink( aToNode , anOutPort , this , anInPort ) ) {
2254           cdebug << "       --> " << Name() << "(" << anInPort->PortName()
2255                  << ") " << anInPort->PortStatus() << " AddOutLink ERROR" << endl ;
2256           RetVal = false ;
2257         }
2258         else {
2259           cdebug << "       --> " << Name() << "(" << anInPort->PortName()
2260                  << ") " << anInPort->PortStatus() << " AddOutLink" << endl ;
2261         }
2262       }
2263     }
2264   }
2265
2266 #ifdef _DEBUG_
2267   ListPorts( *_Graph_fdebug , 0 ) ;
2268 #endif
2269
2270   if ( !RetVal ) {
2271     SetMessages( "Fail to create the Service of the graph.\n" ) ;
2272   }
2273
2274   cdebug_out << "GraphBase::Graph::CreateService " << RetVal << endl;
2275   return RetVal ;
2276 }
2277
2278 bool GraphBase::Graph::InLineServices() {
2279   cdebug_in << "GraphBase::Graph::InLineServices" << endl;
2280
2281   int i , j ;
2282
2283 #ifdef _DEBUG_
2284   ListPorts( *_Graph_fdebug , 0 ) ;
2285 #endif
2286
2287   GraphBase::InLineNode * aINode ;
2288   SALOME_ModuleCatalog::Service aService ;
2289   for ( i = 0 ; i < GraphNodesSize() ; i++ ) {
2290     aINode = (GraphBase::InLineNode * ) GraphNodes( i ) ;
2291     if ( aINode->IsOneOfInLineNodes() ) {
2292 //      cdebug << "GraphBase::Graph::InLineServices " << aINode->Name() << endl;
2293       aService.ServiceName = aINode->ServiceName() ;
2294       aService.ServiceinParameter.length( 0 ) ;
2295       aService.ServiceoutParameter.length( 0 ) ;
2296       aINode->DataStreamInPortsNumber( 0 ) ;
2297       aINode->DataStreamOutPortsNumber( 0 ) ;
2298       int InService = 0 ;
2299       int InStreamService = 0 ;
2300       for ( j = 0 ; j < aINode->GetNodeInPortsSize() ; j++ ) {
2301         if ( aINode->GetChangeNodeInPort(j)->IsGate() || aINode->GetChangeNodeInPort(j)->IsLoop() ) {
2302 #if 0
2303           cdebug << "GraphBase::Graph::InLineServices In" << j << " "
2304                  << aINode->GetChangeNodeInPort(j)->Kind() << " " 
2305                  << aINode->GetChangeNodeInPort(j)->PortType() << " " 
2306                  << aINode->GetChangeNodeInPort(j)->PortName() << " ignored "
2307                  << aINode->GetChangeNodeInPort(j)->IsGate() << " "
2308                  << aINode->GetChangeNodeInPort(j)->IsLoop() << endl;
2309 #endif
2310         }
2311         else if ( aINode->GetChangeNodeInPort(j)->IsDataStream() ) {
2312           aService.ServiceinDataStreamParameter.length( InStreamService+1 ) ;
2313           aService.ServiceinDataStreamParameter[InStreamService].Parametertype = CORBA::string_dup( aINode->GetChangeNodeInPort(j)->PortType() ) ;
2314           aService.ServiceinDataStreamParameter[InStreamService].Parametername = CORBA::string_dup( aINode->GetChangeNodeInPort(j)->PortName() ) ;
2315           aService.ServiceinDataStreamParameter[InStreamService++].Parameterdependency = aINode->GetChangeNodeInPort(j)->Dependency() ;
2316           aINode->IncrDataStreamInPorts() ;
2317 #if 0
2318           cdebug << "GraphBase::Graph::InLineServices In" << j << " "
2319                  << aINode->GetChangeNodeInPort(j)->Kind() << " " 
2320                  << aINode->GetChangeNodeInPort(j)->PortType() << " " 
2321                  << aINode->GetChangeNodeInPort(j)->PortName() << " "
2322                  << aINode->GetChangeNodeInPort(j)->IsGate() << " "
2323                  << aINode->GetChangeNodeInPort(j)->IsLoop() << endl;
2324 #endif
2325         }
2326         else {
2327           aService.ServiceinParameter.length( InService+1 ) ;
2328           aService.ServiceinParameter[InService].Parametertype = CORBA::string_dup( aINode->GetChangeNodeInPort(j)->PortType() ) ;
2329           aService.ServiceinParameter[InService++].Parametername = CORBA::string_dup( aINode->GetChangeNodeInPort(j)->PortName() ) ;
2330 #if 0
2331           cdebug << "GraphBase::Graph::InLineServices In" << j << " "
2332                  << aINode->GetChangeNodeInPort(j)->Kind() << " " 
2333                  << aINode->GetChangeNodeInPort(j)->PortType() << " " 
2334                  << aINode->GetChangeNodeInPort(j)->PortName() << " "
2335                  << aINode->GetChangeNodeInPort(j)->IsGate() << " "
2336                  << aINode->GetChangeNodeInPort(j)->IsLoop() << endl;
2337 #endif
2338         }
2339       }
2340       int OutService = 0 ;
2341       int OutStreamService = 0 ;
2342       for ( j = 0 ; j < aINode->GetNodeOutPortsSize() ; j++ ) {
2343 //        if ( aINode->GetChangeNodeOutPort(j)->IsGate() || aINode->GetChangeNodeOutPort(j)->IsLoop() || aINode->GetChangeNodeOutPort(j)->IsDataStream() ) {
2344         if ( aINode->GetChangeNodeOutPort(j)->IsGate() || aINode->GetChangeNodeOutPort(j)->IsLoop() ) {
2345 #if 0
2346           cdebug << "GraphBase::Graph::InLineServices Out" << j << " "
2347                  << aINode->GetChangeNodeOutPort(j)->Kind() << " " 
2348                  << aINode->GetChangeNodeOutPort(j)->PortType() << " " 
2349                  << aINode->GetChangeNodeOutPort(j)->PortName() << " ignored "
2350                  << aINode->GetChangeNodeOutPort(j)->IsGate() << " "
2351                  << aINode->GetChangeNodeOutPort(j)->IsLoop() << endl;
2352 #endif
2353         }
2354         else if ( aINode->GetChangeNodeOutPort(j)->IsDataStream() ) {
2355           aService.ServiceoutDataStreamParameter.length( OutStreamService+1 ) ;
2356           aService.ServiceoutDataStreamParameter[OutStreamService].Parametertype = CORBA::string_dup( aINode->GetChangeNodeOutPort(j)->PortType() ) ;
2357           aService.ServiceoutDataStreamParameter[OutStreamService].Parametername = CORBA::string_dup( aINode->GetChangeNodeOutPort(j)->PortName() ) ;
2358           aService.ServiceoutDataStreamParameter[OutStreamService++].Parameterdependency = aINode->GetChangeNodeOutPort(j)->Dependency() ;
2359           aINode->IncrDataStreamOutPorts() ;
2360 #if 0
2361           cdebug << "GraphBase::Graph::InLineServices Out" << j << " "
2362                  << aINode->GetChangeNodeOutPort(j)->Kind() << " " 
2363                  << aINode->GetChangeNodeOutPort(j)->PortType() << " " 
2364                  << aINode->GetChangeNodeOutPort(j)->PortName() << " "
2365                  << aINode->GetChangeNodeOutPort(j)->IsGate() << " "
2366                  << aINode->GetChangeNodeOutPort(j)->IsLoop() << endl;
2367 #endif
2368         }
2369         else {
2370           aService.ServiceoutParameter.length( OutService+1 ) ;
2371           aService.ServiceoutParameter[OutService].Parametertype = CORBA::string_dup( aINode->GetChangeNodeOutPort(j)->PortType() ) ;
2372           aService.ServiceoutParameter[OutService++].Parametername = CORBA::string_dup( aINode->GetChangeNodeOutPort(j)->PortName() ) ;
2373 #if 0
2374           cdebug << "GraphBase::Graph::InLineServices Out" << j << " "
2375                  << aINode->GetChangeNodeOutPort(j)->Kind() << " " 
2376                  << aINode->GetChangeNodeOutPort(j)->PortType() << " " 
2377                  << aINode->GetChangeNodeOutPort(j)->PortName()  << " "
2378                  << aINode->GetChangeNodeOutPort(j)->IsGate() << " "
2379                  << aINode->GetChangeNodeOutPort(j)->IsLoop() << endl;
2380 #endif
2381         }
2382       }
2383       aINode->SetService( aService ) ;
2384       if ( SetServiceOfMap( (GraphBase::Service * ) aINode ) ) {
2385 #if 0
2386         cdebug << "InLineServices SetServiceOfMap " << aINode->ServiceName() << " in MapOfServices"
2387                << " InStreamPort(" << aINode->DataStreamInPortsNumber() 
2388                << ") OutStreamPort(" << aINode->DataStreamOutPortsNumber() << ")" << endl ; 
2389 #endif
2390       }
2391 //      cdebug << "GraphBase::Graph::InLineServices" << *aINode->GetService() << endl;
2392     }
2393   }
2394
2395   cdebug_out << "GraphBase::Graph::InLineServices" << endl;
2396   return true ;
2397 }
2398
2399 bool GraphBase::Graph::Sort( int & SubStreamGraphsNumber ) {
2400 #ifdef _DEBUG_
2401   ListPorts( *_Graph_fdebug , 0 ) ;
2402 #endif
2403
2404   int i ;
2405   int j ;
2406   int NotSortedNumber = GraphNodesSize() ;
2407   bool NewSorted ;
2408   cdebug_in << "GraphBase::Graph::Sort" << endl;
2409   if ( NotSortedNumber ) {
2410     _LevelsNumber = 0 ;
2411     _ParallelExecutionNodes = false ;
2412     _Sorted.resize( GraphNodesSize() ) ;
2413     _CnxInPortsNumber.resize( GraphNodesSize() ) ;
2414     _DecrInPortsNumber.resize( GraphNodesSize() ) ;
2415     if ( _NodesNumber.size() ) {
2416       _NodesNumber.resize( 0 ) ;
2417       _SortedNodes.resize( 0 ) ;
2418     }
2419           
2420 // This is a simulation of the computation of the graph :
2421 // The initial state of nodes is :
2422 // - Sorted = false : the node is not sorted
2423 // - CnxInPortsNumber = ConnectedInPortsNumber : the number of ports that wait for a value from a link
2424 // - DecrInPortsNumber = 0 : there is no value available.
2425 #if 0
2426     cdebug << "GraphBase::Graph::Sort initial values :" << endl ;
2427     for ( i = 0 ; i < GraphNodesSize() ; i++ ) {
2428       GraphBase::ComputingNode * aNode = GraphNodes( i ) ;
2429       cdebug << aNode->Name() << " --> " << aNode->LinkedNodesSize() << " LinkedNodes :" << endl ;
2430       for ( j = 0 ; j < aNode->LinkedNodesSize()  ; j++ ) {
2431         cdebug << "              " << aNode->LinkedNodes( j )->Name() << endl ;
2432       }
2433     }
2434 #endif
2435     for ( i = 0 ; i < GraphNodesSize() ; i++ ) {
2436       _Sorted[ i ] = false ;
2437       _CnxInPortsNumber[ i ] = GraphNodes( i )->ConnectedInPortsNumber() ;
2438       _DecrInPortsNumber[ i ] = 0 ;
2439 //      cdebug << "Sort Node [" << i << "] " << GraphNodes( i )->Name() << " initial count "
2440 //             << _CnxInPortsNumber[ i ] << endl ;
2441     }
2442     
2443 // Nodes are linked ONLY if Ports are NOT DataStream for topological sort of node
2444 // ==============================================================================
2445     while ( NotSortedNumber ) {
2446       NewSorted = false ;
2447       
2448       for ( i = 0 ; i < GraphNodesSize() ; i++ ) {
2449         cdebug << "Sort level " << _LevelsNumber << ". [" << i << "] "
2450                << GraphNodes( i )->Name() << " count "
2451                << _CnxInPortsNumber[ i ] << endl ;
2452         if ( !_Sorted[ i ] && _CnxInPortsNumber[ i ] == 0 ) {
2453 // All inputs of GraphNodes( i ) are available : "AllDataReady"
2454           if ( (int ) _NodesNumber.size() != _LevelsNumber+1 ) {
2455             _NodesNumber.resize( _LevelsNumber+1 ) ;
2456             _SortedNodes.resize( _LevelsNumber+1 ) ;
2457             _NodesNumber[ _LevelsNumber ] = -1 ;
2458           }
2459 // There is one more node at that level
2460           _NodesNumber[ _LevelsNumber ]++ ;
2461           (_SortedNodes[ _LevelsNumber ]).resize( _NodesNumber[ _LevelsNumber ]+1 ) ;
2462           (_SortedNodes[ _LevelsNumber ])[ _NodesNumber[ _LevelsNumber ] ] = GraphNodes( i ) ;
2463           _Sorted[ i ] = true ;
2464           NewSorted = true ;
2465           NotSortedNumber -= 1 ;
2466           cdebug << GraphNodes( i )->Name() << " belongs to level "
2467                  << _LevelsNumber << ". " << GraphNodes( i )->LinkedNodesSize() << " linkednodes" << endl ;
2468 // GraphNodes( i ) has the state "AllDataReady". We simulate the end of its execution :
2469 // So we loop over all nodes that have a link from that node
2470 // And we increment the number of input ports of GraphNodes( i )->LinkedNodes( j ) that this
2471 // execution will give a value in DecrInPortsNumber : "SomeDataReady"
2472           for ( j = 0 ; j < GraphNodes( i )->LinkedNodesSize() ; j++ ) {
2473 // OutputPorts of GraphNodes( i ) will satisfy 
2474 //   GraphNodes( i )->LinkedInPortsNumber( j ) InPorts of
2475 //      GraphNodes( i )->LinkedNodes( j )
2476             GraphBase::StreamNode * aLinkedNode = GraphNodes( i )->LinkedNodes( j ) ;
2477             int aLinkedInPortsNumber = GraphNodes( i )->LinkedInPortsNumber( j ) ;
2478             cdebug << j << ". LinkedNode " << aLinkedNode->Name() ;
2479             if ( !aLinkedNode->IsDataFlowNode() && !aLinkedNode->IsDataStreamNode() ) {
2480               cdebug << " _DecrInPortsNumber[ "
2481                      << GetGraphNodeIndex( aLinkedNode->Name() )
2482                      << " ] = "
2483                      << _DecrInPortsNumber[ GetGraphNodeIndex( aLinkedNode->Name() ) ]
2484                      << " += " << aLinkedInPortsNumber ;
2485               _DecrInPortsNumber[ GetGraphNodeIndex( aLinkedNode->Name() ) ] += aLinkedInPortsNumber ;
2486             }
2487             cdebug << endl ;
2488           }
2489         }
2490       }
2491 // If no node was found, that FlowGraph is not valid : if we try to execute it, that FlowGraph
2492 // will wait for data(s) from node(s) not executed or not executing for ever
2493       if ( !NewSorted ) {
2494         SetMessages( "That graph is cyclic.\n" ) ;
2495         cdebug << "ERROR Loop detected at level " << _LevelsNumber << endl ;
2496         return false ; // Loop in the Graph
2497       }
2498 //      cdebug << "Bilan level " << _LevelsNumber << " : " << endl ;
2499       bool ChangeCount = false ;
2500 // We update now the number of InPorts with a link that are waiting for a value
2501       for ( i = 0 ; i < GraphNodesSize() ; i++ ) {
2502         if ( _DecrInPortsNumber[ i ] ) {
2503 //          int prevcount = _CnxInPortsNumber[ i ] ;
2504           _CnxInPortsNumber[ i ] -= _DecrInPortsNumber[ i ]  ;
2505           _DecrInPortsNumber[ i ] = 0 ;
2506           ChangeCount = true ;
2507 //          cdebug << "    " << GraphNodes( i )->Name() << " count " << prevcount
2508 //                 << " --> new count " << _CnxInPortsNumber[ i ] << endl ;
2509         }
2510       }
2511 // If there is no loop and if the number of InPorts with a link that are waiting for a value
2512 // does not change, the sort is finished. But there is also NotSortedNumber ...
2513 //      if ( !ChangeCount )
2514 //        break ;
2515       if ( NotSortedNumber ) {
2516         _LevelsNumber += 1 ;
2517       }
2518     }
2519     _ThreadsMax = 0 ;
2520     int AllSortedNodes = 0 ;
2521     _HeadNodes = _SortedNodes[ 0 ] ;
2522     _HeadNodesSize = _SortedNodes[ 0 ].size() ;
2523 // QueueNodes was used in the past in order to know if the execution of a graph is finished
2524 // But because of loop nodes that was changed. So that part of code is a "clutter"
2525 // Now a graph has finished its execution when the number of executing threads is zero
2526     _QueueNodes = _SortedNodes[ _LevelsNumber ] ;
2527     _QueueNodesSize = _SortedNodes[ _LevelsNumber ].size() ;
2528     for ( i = 0 ; i < _QueueNodesSize ; i++ ) {
2529       if ( !_QueueNodes[ i ]->IsGOTONode() ) {
2530         break ;
2531       }
2532     }
2533     if ( i == _QueueNodesSize && _LevelsNumber ) {
2534       _QueueNodes = _SortedNodes[ _LevelsNumber - 1 ] ;
2535       _QueueNodesSize = _SortedNodes[ _LevelsNumber - 1 ].size() ;
2536     }
2537 // Computation of the maximum number of threads == the maximum number of nodes of all levels
2538     for ( i = 0 ; i <= _LevelsNumber ; i++ ) {
2539       AllSortedNodes += _NodesNumber[ i ]+1 ;
2540       if ( _NodesNumber[ i ] + 1 > _ThreadsMax ) {
2541         _ThreadsMax = _NodesNumber[ i ] + 1 ;
2542       }
2543       cdebug << _NodesNumber[ i ]+1 << " Nodes of level " << i << " : "
2544              << (_SortedNodes[ i ])[ 0 ]->Name() << endl ;
2545       for ( j = 1 ; j <= _NodesNumber[ i ] ; j++ ) {
2546         _ParallelExecutionNodes = true ;
2547         cdebug << "                     " << (_SortedNodes[ i ])[ j ]->Name()
2548                << endl ;
2549       }
2550     }
2551     if ( _ParallelExecutionNodes ) {
2552 //      cdebug << "Parallel Execution Nodes detected." << endl ;
2553     }
2554     else {
2555 //      cdebug << "No Parallel Execution Nodes detected." << endl ;
2556     }
2557     if ( AllSortedNodes != GraphNodesSize() ) {
2558       SetMessages( "That graph is cyclic.\n" ) ;
2559       cdebug << "ERROR Loop detected at level " << _LevelsNumber << endl ;
2560       return false ; // Loop in the Graph
2561     }
2562
2563     cdebug << "Graph::Sort " << _NodesNumber[ 0 ] << " HeadNodes :" << endl ;
2564     for ( i= 0 ; i <= _NodesNumber[ 0 ] ; i++ ) {
2565       (_SortedNodes[ 0 ])[ i ]->HeadNode( true ) ;
2566       cdebug << "            " << i << ". : " << (_SortedNodes[ 0 ])[ i ]->Name() << endl ;
2567     }
2568
2569 // Give a subgraph/substreamgraph number > 0 to HeadNodes (level 0)
2570 // There is no substreamgraph for nodes without StreamPorts
2571     for ( j = 0 ; j <= _NodesNumber[ 0 ] ; j++ ) {
2572       (_SortedNodes[ 0 ])[ j ]->Level( 0 ) ;
2573       (_SortedNodes[ 0 ])[ j ]->SortedIndex( j ) ;
2574       (_SortedNodes[ 0 ])[ j ]->SubGraph( j + 1 ) ;
2575       if ( (_SortedNodes[ 0 ])[ j ]->HasDataStream() ) {
2576         (_SortedNodes[ 0 ])[ j ]->SubStreamGraph( j + 1 ) ;
2577       }
2578       else {
2579         (_SortedNodes[ 0 ])[ j ]->SubStreamGraph( -1 ) ;
2580       }
2581     }
2582
2583 // Give a subgraph/substreamgraph number = 0 to all other nodes :
2584 // the SubGraph of that nodes is unknown
2585 // There is no substreamgraph for nodes without StreamPorts
2586     for ( i = 1 ; i <= _LevelsNumber ; i++ ) {
2587       for ( j = 0 ; j <= _NodesNumber[ i ] ; j++ ) {
2588         (_SortedNodes[ i ])[ j ]->Level( i ) ;
2589         (_SortedNodes[ i ])[ j ]->SortedIndex( j ) ;
2590         (_SortedNodes[ i ])[ j ]->SubGraph( 0 ) ;
2591         if ( (_SortedNodes[ i ])[ j ]->HasDataStream() ) {
2592           (_SortedNodes[ i ])[ j ]->SubStreamGraph( 0 ) ;
2593         }
2594         else {
2595           (_SortedNodes[ i ])[ j ]->SubStreamGraph( -1 ) ;
2596         }
2597       }
2598     }
2599
2600 // Computation of independent SubGraphs which have NO link between them
2601     cdebug << endl << "Computation of SubGraphs" << endl ;
2602     bool Graphs = true ;
2603     while ( Graphs ) {
2604       for ( i = 0 ; i <= _LevelsNumber ; i++ ) {
2605         cdebug << endl << "LevelsNumber " << _LevelsNumber << " " << _NodesNumber[ i ]
2606                << " Nodes :" << endl ;
2607         for ( j = 0 ; j <= _NodesNumber[ i ] ; j++ ) {
2608           GraphBase::ComputingNode * aNode = (_SortedNodes[ i ])[ j ] ;
2609           cdebug << "    " << aNode->Name() << " SubGraph " << aNode->SubGraph() << endl ;
2610           int k ;
2611           for ( k = 0 ; k < aNode->LinkedNodesSize() ; k++ ) {
2612           if ( aNode->LinkedNodes( k )->SubGraph() ) {
2613               if ( aNode->LinkedNodes( k )->SubGraph() != aNode->SubGraph() ) {
2614 //                   && aNode->LinkedNodes( k )->Level() == aNode->Level()+1 ) {
2615 //            aNode->SubGraph( aNode->LinkedNodes( k )->SubGraph() ) ;
2616                 int OldSub = aNode->SubGraph() ;
2617                 int NewSub = aNode->LinkedNodes( k )->SubGraph() ;
2618               cdebug << "        " << aNode->Name() << " changed SubGraph "
2619                        << aNode->LinkedNodes( k )->SubGraph() << endl ;
2620                 int l ;
2621                 for ( l = 0 ; l <= _LevelsNumber ; l++ ) {
2622                   int m ;
2623                   for ( m = 0 ; m <= _NodesNumber[ l ] ; m++ ) {
2624                     if ( (_SortedNodes[ l ])[ m ]->SubGraph() == OldSub ) {
2625                       GraphBase::ComputingNode * aSubNode = (_SortedNodes[ l ])[ m ] ;
2626                       aSubNode->SubGraph( NewSub ) ;
2627                 }
2628                 }
2629               }
2630                 Graphs = false ;
2631                 break ;
2632             }
2633               else {
2634                 cdebug << "        Linked " << aNode->LinkedNodes( k )->Name()
2635                        << " same SubGraph " << aNode->LinkedNodes( k )->SubGraph() << endl ;
2636             }
2637           }
2638             else {
2639               cdebug << "        LinkedNode " << aNode->LinkedNodes( k )->Name()
2640                      << " initial SubGraph " << aNode->SubGraph() << endl ;
2641               aNode->LinkedNodes( k )->SubGraph( aNode->SubGraph() ) ;
2642           }
2643         }
2644           if ( !Graphs ) {
2645             break ;
2646           }
2647         }
2648         if ( !Graphs ) {
2649           break ;
2650         }
2651       }
2652       if ( Graphs ) {
2653         cdebug << endl << "SubGraphs result : " << endl ;
2654         break ;
2655       }
2656       cdebug << endl << "One more time" << endl ;
2657       Graphs = true ;
2658     }
2659 // Make a sequential renumbering of SubGraphs :
2660     _SubGraphsNumber = 0 ;
2661     int CurrGraphsNumber = 0;
2662     int k ;
2663     for ( k = 0 ; k <= _NodesNumber[ 0 ] ; k++ ) {
2664       if ( (_SortedNodes[ 0 ])[ k ]->SubGraph() > CurrGraphsNumber ) {
2665         CurrGraphsNumber = (_SortedNodes[ 0 ])[ k ]->SubGraph() ;
2666         _SubGraphsNumber += 1 ;
2667         for ( i = 0 ; i <= _LevelsNumber ; i++ ) {
2668           for ( j = 0 ; j <= _NodesNumber[ i ] ; j++ ) {
2669             if ( (_SortedNodes[ i ])[ j ]->SubGraph() == CurrGraphsNumber ) {
2670               (_SortedNodes[ i ])[ j ]->SubGraph( _SubGraphsNumber ) ;
2671               cdebug << "SubGraphsNumber " << _SubGraphsNumber << " " << " Level "
2672                      << i << " : " << (_SortedNodes[ i ])[ j ]->Name()
2673                      << endl ;
2674             }
2675           }
2676         }
2677       }
2678     }
2679
2680 //    cdebug << endl << "Computation of SubStreamGraphs" << endl ;
2681     for ( i = 0 ; i < GraphNodesSize() ; i++ ) {
2682       GraphBase::ComputingNode * aNode = GraphNodes( i ) ;
2683       if ( aNode->SubStreamGraph() < 0 ) {
2684 //      cdebug << "Graph " << aNode->Name() << " has NO streamport" << endl ;
2685       }
2686       else {
2687 //        cdebug << aNode->Name() << " SubGraph " << aNode->SubGraph() << " --> "
2688 //               << aNode->LinkedStreamNodesSize() << " LinkedStreamNodes :" << endl ;
2689         for ( j = 0 ; j < aNode->LinkedStreamNodesSize()  ; j++ ) {
2690 //          cdebug << "              " << aNode->LinkedStreamNodes( j )->Name() << endl ;
2691         }
2692       }
2693     }
2694
2695 // Computation of independent SubStreamGraphs which have NO StreamLink between them
2696     SubStreamGraphsNumber = 0 ;
2697     int ilevel ;
2698     for ( ilevel = 0 ; ilevel <= _LevelsNumber ; ilevel++ ) {
2699 // Loop for _NodesNumber[ ilevel ] nodes of the level ilevel
2700       int jnode ;
2701       for ( jnode = 0 ; jnode <= _NodesNumber[ ilevel ] ; jnode++ ) {
2702         GraphBase::ComputingNode * aNode = (_SortedNodes[ ilevel ])[ jnode ] ;
2703         if ( aNode->SubStreamGraph() < 0 ) {
2704 //        cdebug << "Graph " << aNode->SubStreamGraph() << " " << aNode->Name()
2705 //                 << " has NO streamport" << endl ;
2706         }
2707         else {
2708           int CurStreamGraphsNumber ;
2709           if ( aNode->SubStreamGraph() > 0 ) {
2710 //          cdebug << "SubStreamGraph " << aNode->SubStreamGraph() << " " << aNode->Name()
2711 //                   << " has streamport LinkedStreamNodesSize already in a SubStreamGraph" << endl ;
2712             CurStreamGraphsNumber = aNode->SubStreamGraph() ;
2713           }
2714           else {
2715             CurStreamGraphsNumber = SubStreamGraphsNumber+1 ;
2716           }
2717           int RetVal = 0 ;
2718           while ( RetVal != CurStreamGraphsNumber ) {
2719             RetVal = CurStreamGraphsNumber ;
2720             aNode->SetSubStreamGraph( CurStreamGraphsNumber , RetVal ) ;
2721             if ( RetVal != CurStreamGraphsNumber ) {
2722               for ( i = 0 ; i < GraphNodesSize() ; i++ ) {
2723                 GraphBase::ComputingNode * aNode = GraphNodes( i ) ;
2724                 if ( aNode->SubStreamGraph() == CurStreamGraphsNumber ) {
2725                   aNode->SubStreamGraph( RetVal ) ;
2726                 }
2727               }
2728               CurStreamGraphsNumber = RetVal ;
2729               RetVal = 0 ;
2730             }
2731             if ( CurStreamGraphsNumber > SubStreamGraphsNumber ) {
2732               SubStreamGraphsNumber = CurStreamGraphsNumber ;
2733             }
2734           }
2735         }
2736       }
2737     }
2738 // Make a sequential renumbering of SubGraphs :
2739 //    cdebug << endl << "Last SubStreamGraphsNumber : " << SubStreamGraphsNumber << endl ;
2740     int CurrStreamGraphsNumber = 0 ;
2741     int count = 0 ;
2742     for ( CurrStreamGraphsNumber = 0 ; CurrStreamGraphsNumber <= SubStreamGraphsNumber ; CurrStreamGraphsNumber++ ) {
2743       bool SearchCurrStreamGraphsNumber = true ;
2744       for ( k = 0 ; k <= _LevelsNumber && SearchCurrStreamGraphsNumber ; k++ ) {
2745         int l ;
2746         for ( l = 0 ; l <= _NodesNumber[ k ] && SearchCurrStreamGraphsNumber ; l++ ) {
2747           if ( (_SortedNodes[ k ])[ l ]->SubStreamGraph() == CurrStreamGraphsNumber ) {
2748             SearchCurrStreamGraphsNumber = false ;
2749             count = count + 1 ;
2750             if ( CurrStreamGraphsNumber != count ) {
2751 //              cdebug << "CurrStreamGraphsNumber " << CurrStreamGraphsNumber << " count " << count
2752 //                     << " Level " << k << " n " << l << endl ;
2753               for ( i = k ; i <= _LevelsNumber ; i++ ) {
2754                 for ( j = 0 ; j <= _NodesNumber[ i ] ; j++ ) {
2755                   if ( (_SortedNodes[ i ])[ j ]->SubStreamGraph() == CurrStreamGraphsNumber ) {
2756                     (_SortedNodes[ i ])[ j ]->SubStreamGraph( count ) ;
2757 //                    cdebug << "SubStreamGraphsNumber " << CurrStreamGraphsNumber << " --> " << count << " "
2758 //                           << " Level " << i << " : " << (_SortedNodes[ i ])[ j ]->Name() << endl ;
2759                   }
2760                   else if ( (_SortedNodes[ i ])[ j ]->SubStreamGraph() > 0 ) {
2761 //                    cdebug << "SubStreamGraphsNumber " << (_SortedNodes[ i ])[ j ]->SubStreamGraph()
2762 //                           << " != " << CurrStreamGraphsNumber << " Level " << i << " : "
2763 //                           << (_SortedNodes[ i ])[ j ]->Name() << endl ;
2764                   }
2765                 }
2766               }
2767             }
2768           }
2769         }
2770       }
2771     }
2772     SubStreamGraphsNumber = count ;
2773 //    cdebug << endl << "SubStreamGraphs result : " << SubStreamGraphsNumber << " SubStreamGraphs" << endl ;
2774 //    int CurrStreamGraphsNumber ;
2775 //    for ( CurrStreamGraphsNumber = 1 ; CurrStreamGraphsNumber <= SubStreamGraphsNumber  ; CurrStreamGraphsNumber++ ) {
2776 //      for ( ilevel = 0 ; ilevel <= _LevelsNumber ; ilevel++ ) {
2777 //        for ( k = 0 ; k <= _NodesNumber[ ilevel ] ; k++ ) {
2778 //          if ( (_SortedNodes[ ilevel ])[ k ]->SubStreamGraph() == CurrStreamGraphsNumber ) {
2779 //            cdebug << "SubStreamGraphsNumber " << CurrStreamGraphsNumber << " : "
2780 //                   << (_SortedNodes[ ilevel ])[ k ]->Name() << endl ;
2781 //        }
2782 //      }
2783 //      }
2784 //    }
2785   }
2786
2787 #ifdef _DEBUG_
2788   ListPorts( *_Graph_fdebug , 0 ) ;
2789 #endif
2790
2791   cdebug_out << "GraphBase::Graph::Sort" << endl;
2792   return true ;
2793 }
2794
2795 // mkr : PAL12575
2796 bool GraphBase::Graph::ValidGOTO() {
2797   cdebug_in << "GraphBase::Graph::ValidGOTO" << endl;
2798   bool RetVal = true ;
2799   int i, j ;
2800   GraphBase::ComputingNode * aNode ;
2801   for ( i = 0 ; i < GraphNodesSize() ; i++ ) {
2802     aNode = GraphNodes( i ) ;
2803     if ( aNode->IsGOTONode() ) {
2804       GraphBase::GOTONode * aGoToNode = (GraphBase::GOTONode * ) aNode ;
2805       GraphBase::InLineNode * aCoupledNode ;
2806       aCoupledNode = (GraphBase::InLineNode * ) aGoToNode->CoupledNode() ;
2807       if ( aCoupledNode ) {
2808         ostringstream ErrorMessage ;
2809         // 1. Check the number of ports (the number of OutPorts of a GOTONode and of InPorts of its linked
2810         //    InLine node must be the same)
2811         if ( aNode->GetNodeOutPortsSize() != aCoupledNode->GetNodeInPortsSize() ) {
2812           cdebug << "GraphBase::Graph::ValidGOTO : Different ports number!" << endl ;
2813           ReSetMessages() ;
2814           ErrorMessage << "Different ports number : the number of OutPorts of a " << aNode->Name()
2815                        << " node (GoTo node) and of InPorts of its linked " << aCoupledNode->Name()
2816                        << " node (InLine node) must be the same!\n" ;
2817           SetMessages( ErrorMessage.str() ) ;
2818           RetVal = false ;
2819         }
2820         // 2. Check ports names (the names of OutPorts of a GOTONode and of InPorts of its linked
2821         //    InLine node must be the same)
2822         else {
2823           for ( j = 0 ; j < aNode->GetNodeOutPortsSize() ; j++ ) {
2824             GraphBase::OutPort * aBusParamOutPort = aNode->GetChangeNodeOutPort( j ) ;
2825             if ( !aBusParamOutPort->IsGate() ) {
2826               GraphBase::InPort * aBusParamChangeInPort = NULL ;
2827               aBusParamChangeInPort = aCoupledNode->GetChangeInPort( aBusParamOutPort->PortName() ) ;
2828               if ( !aBusParamChangeInPort ) {
2829                 cdebug << "GraphBase::Graph::ValidGOTO : Different names of ports!" << endl ;
2830                 ReSetMessages() ;
2831                 ErrorMessage << "Different names of ports : there is no input port of " << aCoupledNode->Name()
2832                              << " node (InLine node) coupled to " << aBusParamOutPort->PortName() 
2833                              << " output port of a " << aNode->Name()
2834                              << " node (GoTo node)\n" ;
2835                 SetMessages( ErrorMessage.str() ) ;
2836                 RetVal = false ;
2837               }
2838             }
2839           }
2840         }
2841       }
2842     }
2843   }
2844   cdebug_out << "GraphBase::Graph::ValidGOTO RetVal " << RetVal << endl;
2845   return RetVal ;
2846 }
2847
2848 bool GraphBase::Graph::ValidLoops() const {
2849   cdebug_in << "GraphBase::Graph::ValidLoops" << endl;
2850   bool RetVal = true ;
2851   int i ;
2852   GraphBase::ComputingNode * aNode ;
2853   for ( i = 0 ; i < GraphNodesSize() ; i++ ) {
2854     aNode = GraphNodes( i ) ;
2855     if ( aNode->IsLoopNode() ) {
2856       GraphBase::LoopNode * aLoopNode = (GraphBase::LoopNode * ) aNode ;
2857       GraphBase::EndOfLoopNode * anEndLoopNode ;
2858       anEndLoopNode = (GraphBase::EndOfLoopNode * ) aLoopNode->CoupledNode() ;
2859       string anErrorMessage = string( "CheckLoop " ) + string( aLoopNode->Name() ) +
2860                               string( " --> " ) + string( anEndLoopNode->Name() ) +
2861                               string( " :\n" ) ;
2862       if ( !aLoopNode->CheckLoop( aLoopNode , anEndLoopNode , anErrorMessage ) ) {
2863         ((GraphBase::Graph * ) this)->SetMessages( anErrorMessage ) ;
2864         cdebug << "GraphBase::Graph::ValidLoops false aLoopNode " << aLoopNode->Name()
2865                << endl;
2866         RetVal = false ;
2867       }
2868       anErrorMessage = string( "CheckEndLoop " ) + string( aLoopNode->Name() ) +
2869                        string( " --> " ) + string( anEndLoopNode->Name() ) + string( " :\n" ) ;
2870       if ( !anEndLoopNode->CheckEndLoop( aLoopNode , anEndLoopNode , anErrorMessage ) ) {
2871         ((GraphBase::Graph * ) this)->SetMessages( anErrorMessage ) ;
2872         cdebug << "GraphBase::Graph::ValidLoops false anEndLoopNode " << anEndLoopNode->Name()
2873                << endl;
2874         RetVal = false ;
2875       }
2876     }
2877   }
2878   cdebug_out << "GraphBase::Graph::ValidLoops RetVal " << RetVal << endl;
2879   return RetVal ;
2880 }
2881
2882 bool GraphBase::Graph::ValidSwitchs() const {
2883   cdebug_in << "GraphBase::Graph::ValidSwitchs" << endl;
2884   bool RetVal = true ;
2885   int i ;
2886   GraphBase::ComputingNode * aNode ;
2887   for ( i = 0 ; i < GraphNodesSize() ; i++ ) {
2888     aNode = GraphNodes( i ) ;
2889     if ( aNode->IsSwitchNode() ) {
2890       GraphBase::SwitchNode * aSwitchNode = (GraphBase::SwitchNode * ) aNode ;
2891       if ( !aSwitchNode->CheckSwitch() ) {
2892         cdebug << "GraphBase::Graph::ValidSwitchs false aSwitchNode " << aSwitchNode->Name()
2893                << endl;
2894         RetVal = false ;
2895       }
2896     }
2897   }
2898   cdebug_out << "GraphBase::Graph::ValidSwitchs RetVal " << RetVal << endl;
2899   return RetVal ;
2900 }
2901
2902 // Controle de la coherence des noeuds de calcul
2903 // Enregistrement dans la liste des noeuds "tete" de graphe
2904
2905 bool GraphBase::Graph::ComputingNodes() const {
2906   bool RetVal = true ;
2907   cdebug << "GraphExecutor::Graph::ComputingNodes ()" << endl;
2908
2909 //  list<GraphEditor::Node *> aComputingNodesList = _G->ComputingNodesList() ;
2910 //  list<GraphEditor::Node *>::iterator aNode = aComputingNodesList.begin();
2911 //  GraphEditor::Port *  iP;
2912
2913 //  for (aNode = _G->ComputingNodesList().begin(); aNode !=_G->ComputingNodesList().end(); aNode++) {
2914 //  while ( aNode != aComputingNodesList.end() ) {
2915   int i ;
2916   GraphBase::ComputingNode * aNode ;
2917   for ( i = 0 ; i < GraphNodesSize() ; i++ ) {
2918     aNode = GraphNodes( i ) ;
2919     cdebug << "Graph::ComputingNodes " << i << ". " << aNode->Name() << " Head " << aNode->IsHeadNode()
2920            << endl ;
2921     // Tous les ports d'entree de tous les noeuds de calcul sont bien connectes
2922     // Enregistrement eventuel dans la liste des noeuds "tete" de graphe
2923 //    if ((*aNode)->GetNodeInPortsSize() == 0)
2924 //      _headNodes.push_front(*aNode);
2925     int j ;
2926     for ( j = 1 ; j < aNode->GetNodeInPortsSize() ; j++ ) {
2927       const GraphBase::InPort *iP = aNode->GetNodeInPort(j);
2928       if ( iP->IsNotConnected() ){
2929 //      cdebug << "Le port d'entree " << iP->PortName()
2930 //               << " du noeud de calcul " << aNode->Name() << " du graphe  "
2931 //               << Name() << " n'est pas connecte "<< endl;
2932 //        string anErrorMessage = string( "That graph have InPort not connected " ) +
2933 //                                string( iP->NodeName() ) +
2934 //                                string( "( " ) + string( iP->PortName() ) + string( " )\n" ) ;
2935 //        ((GraphBase::Graph * ) this)->SetMessages( anErrorMessage ) ;
2936         RetVal = false ;
2937       };
2938
2939     };
2940
2941     // Tous les noeuds de calcul ont au moins un port de sortie connecte
2942     bool oneOutPortConnected = false;
2943     for ( j = 1 ; j < aNode->GetNodeOutPortsSize() ; j++) {
2944       const GraphBase::OutPort *iP = aNode->GetNodeOutPort(j);
2945       if ( iP->IsPortConnected() || iP->IsDataConnected() ){
2946         oneOutPortConnected = true ;
2947 //      break;
2948       }
2949       else {
2950 //      cdebug << "Le port de sortie " << iP->PortName()
2951 //               << " du noeud de calcul " << aNode->Name() << " du graphe  "
2952 //               << Name() << " n'est pas connecte "<< endl;
2953 //        string anErrorMessage = string( "That graph have OutPort not connected " ) +
2954 //                                string( iP->NodeName() ) +
2955 //                                string( "( " ) + string( iP->PortName() ) + string( " )\n" ) ;
2956 //        ((GraphBase::Graph * ) this)->SetMessages( anErrorMessage ) ;
2957         RetVal = false ;
2958       }
2959     };
2960     if (!oneOutPortConnected) {
2961 //      cdebug << "Le noeud de calcul " << aNode->Name() << " du graphe  "
2962 //               << Name() << " n'a aucun port de sortie connecte "<< endl;
2963 //      _computingError.push_front(2);
2964     }
2965   };
2966 //  return _computingError.size () ;
2967   return RetVal ;
2968 }
2969
2970 bool GraphBase::Graph::LinkLoopNodes(bool & NewLink ) {
2971   bool RetVal = true ;
2972   NewLink = false ;
2973   int i , j ;
2974   cdebug_in << "GraphBase::Graph::LinkLoopNodes()" << endl;
2975   for ( i = 0 ; i < GraphNodesSize() ; i++ ) {
2976     GraphBase::ComputingNode * aNode = GraphNodes( i ) ;
2977     if ( aNode->IsLoopNode() ) {
2978       GraphBase::LoopNode * aLoopNode = (GraphBase::LoopNode * ) aNode ;
2979       for ( j = 0 ; j < aLoopNode->GetNodeInPortsSize() ; j++ ) {
2980         GraphBase::InPort *anInPort = aLoopNode->GetChangeNodeInPort(j) ;
2981         cdebug << "Graph::LinkLoopNodes " << aLoopNode->Name() << "( " << anInPort->PortName()
2982                << " ) InPort " << anInPort->PortStatus() << endl ;
2983         if ( !anInPort->IsGate() && anInPort->IsNotConnected() ) {
2984           if ( !AddLink( aLoopNode->CoupledNode() , aLoopNode->CoupledNode()->GetChangeNodeOutPort( j ) ,
2985                          aLoopNode , anInPort ) ) {
2986             cdebug << "Graph::LinkLoopNodes AddLink ERROR "
2987                    << aLoopNode->CoupledNode()->Name()
2988                    << "( " << aLoopNode->CoupledNode()->GetChangeNodeOutPort( j )->PortName()
2989                    << " ) --> " << aLoopNode->Name() << "( " << anInPort->PortName() << " )"
2990                    << endl ;
2991             RetVal = false ;
2992           }
2993           else {
2994             NewLink = true ;
2995           }
2996         }
2997       }
2998       for ( j = 0 ; j < aLoopNode->CoupledNode()->GetNodeInPortsSize() ; j++ ) {
2999         GraphBase::EndOfLoopNode * anEndLoopNode ;
3000         anEndLoopNode = (GraphBase::EndOfLoopNode * ) aLoopNode->CoupledNode() ;
3001         GraphBase::InPort *anInPort = anEndLoopNode->GetChangeNodeInPort( j ) ;
3002         cdebug << "Graph::LinkLoopNodes " << anEndLoopNode->Name() << "( " << anInPort->PortName()
3003                << " ) InPort " << anInPort->PortStatus() << endl ;
3004         if ( !anInPort->IsGate() && anInPort->IsNotConnected() ) {
3005           if ( !AddLink( aLoopNode , aLoopNode->GetChangeNodeOutPort( j ) ,
3006                          anEndLoopNode , anInPort ) ) {
3007             cdebug << "Graph::LinkLoopNodes AddLink ERROR " << aLoopNode->Name() << "( "
3008                    << aLoopNode->GetChangeNodeOutPort( j )->PortName() << " ) --> "
3009                    << anEndLoopNode->Name() << "( " << anInPort->PortName() << " )"
3010                    << endl ;
3011             RetVal = false ;
3012           }
3013           else {
3014             NewLink = true ;
3015           }
3016         }
3017       }
3018     }
3019     else if ( aNode->IsGOTONode() ) {
3020       GraphBase::GOTONode * aGOTONode = (GraphBase::GOTONode * ) aNode ;
3021       GraphBase::OutPort *anOutGate = aGOTONode->GetChangeNodeOutGate() ;
3022       if ( anOutGate->IsNotConnected() ) {
3023         if ( aGOTONode->CoupledNode() ) {
3024           cdebug << "Graph::LinkLoopNodes aNode " << aNode << " : " << aNode->Name()
3025                  << aGOTONode->CoupledNode() << " : " << aGOTONode->CoupledNode()->Name()
3026                  << endl ;
3027           RetVal = AddLink( aGOTONode , anOutGate , aGOTONode->CoupledNode() ,
3028                             aGOTONode->CoupledNode()->GetChangeNodeInGate() );
3029           cdebug << "GraphBase::Graph::LinkLoopNodes AddLink ERROR " << aGOTONode->Name() << "( "
3030                  << anOutGate->PortName() << " ) --> " << aGOTONode->CoupledNode()->Name() << "( "
3031                  << aGOTONode->CoupledNode()->GetChangeNodeInGate()->PortName() << " )" << endl ;
3032           if ( !RetVal )
3033             NewLink = true;
3034         }
3035       }
3036     }
3037   }
3038   cdebug_out << "GraphBase::Graph::LinkLoopNodes() NewLink " << NewLink << " returns " << RetVal
3039              << endl;
3040   return RetVal ;
3041 }
3042
3043 // Controle de la coherence des noeuds de calcul
3044 // Enregistrement dans la liste des noeuds "tete" de graphe
3045
3046 bool GraphBase::Graph::DataServerNodes() const {
3047
3048   cdebug_in << "GraphBase::Graph::DataServerNodes ()" << endl;
3049
3050 //  const GraphExecutor::InNode *DataFlowDatas = GetDataFlowDatas() ;
3051   int i , j , ierr = 0 ;
3052
3053 //  if ( DataFlowDatas == NULL ) {
3054 //    MESSAGE( "No input data available in the DataFlow " << _G->Name() );
3055 //    return 0 ;
3056 //  }
3057
3058 //  const GraphExecutor::InNode *DataFlowNode = _G->GetDataFlowNode() ;
3059 //  MESSAGE( "DataServerNodes DataFlowNode : " << *DataFlowNode );
3060
3061 //  MESSAGE( "DataServerNodes DataFlowDatas : " << *DataFlowDatas );
3062
3063 // cout are inversed because DataFlowDatas is a mirror node of the DataFlow
3064
3065   ierr = CheckDataServerNodes() ;
3066
3067 //  list<GraphExecutor::InNode *> aComputingNodesList = _G->ComputingNodesList() ;
3068 //  list<GraphExecutor::InNode *>::iterator aNode = aComputingNodesList.begin();
3069   if ( GraphNodesSize() == 0 ) {
3070     ierr++ ;
3071   }
3072   else {
3073     GraphBase::ComputingNode * aNode ;
3074     for ( i = 0 ; i < GraphNodesSize() ; i++ ) {
3075       aNode = GraphNodes( i ) ;
3076 //  while ( aNode != aComputingNodesList.end() ) {
3077       if ( aNode->IsFactoryNode() ) {
3078         GraphBase::FactoryNode * FaNode = (GraphBase::FactoryNode * ) aNode ;
3079         if ( !strlen( FaNode->Computer() ) ) {
3080 //          cdebug << "ComputerName missing for node " << FaNode->Name() ;
3081           if ( !strlen( FaNode->Computer() ) ) {
3082             ierr++ ;
3083             cdebug << endl ;
3084           }
3085           else {
3086 //            cdebug << ". " << FaNode->Computer() << " will be used." << endl ;
3087           }
3088         }
3089     }
3090 // For Outputs of the DataFlow :
3091       for ( j = 0 ; j < aNode->GetNodeOutPortsSize() ; j++ ) {
3092         const GraphBase::OutPort * anOutPort = aNode->GetNodeOutPort(j) ;
3093 //JR Debug 06.06.2005 : if it is not a Gate !
3094 //        if ( anOutPort->IsNotConnected() ) {
3095         if ( anOutPort->IsNotConnected() && !anOutPort->IsGate() && !aNode->IsGOTONode() ) { // mkr : PAL12575
3096           cdebug << "Graph::DataServerNodes Add[Stream]LinkedNode for OutPort "
3097                  << aNode->Name() << "( " << anOutPort->PortName() << " , "
3098                  << anOutPort->PortStatus() << " )" << endl ;
3099           if ( anOutPort->IsDataStream() ) {
3100             aNode->AddStreamLinkedNode( (GraphBase::ComputingNode *) this ) ;
3101           }
3102           else {
3103             aNode->AddLinkedNode( (GraphBase::ComputingNode *) this ) ;
3104           }
3105         }
3106       }
3107     }
3108   }
3109
3110 // Chaque noeud dataserver ne possede qu'un seul port entree ou sortie et il est bien connecte
3111
3112 //  list<GraphExecutor::InNode *> aDataServerNodesList = _G->DataServerNodesList() ;
3113 //  list<GraphExecutor::InNode *>::iterator it = aDataServerNodesList.begin() ;
3114
3115 //  for (it = _G->DataServerNodesList().begin(); it !=_G->DataServerNodesList().end(); it++){
3116 //  while ( it != aDataServerNodesList.end() ) {
3117 //    if ( (*it)->GetNodeOutPortsSize() && (*it)->GetNodeInPortsSize() ) {
3118 //      cerr << "Erreur dans le noeud serveur de donnees " 
3119 //           << (*it)->Name() << " du graphe  " << _G->Name() << endl;
3120 //      cerr << "A la fois importation et exportation de donnees" << endl;
3121 //      _dataServerError.push_front(1);
3122 //    }
3123
3124 //    if ((*it)->GetNodeOutPortsSize()) {
3125 //      if ((*it)->GetNodeOutPortsSize()==1){
3126 //      if ( (*it)->GetNodeOutPort(0)->IsPortConnected() ){
3127 //        _headNodes.push_front(*it);
3128 //      }
3129 //      else {
3130 //        cerr << "Le port de sortie du noeud serveur de donnees "
3131 //               << (*it)->Name() << " du graphe  " << _G->Name()
3132 //               << " n'est pas connecte "<< endl;
3133 //        _dataServerError.push_front(4);
3134 //      }
3135 //      }
3136 //      else {
3137 //      cerr << "Plus d'une donnee importee du noeud serveur de donnees "
3138 //             << (*it)->Name() << " du graphe  " << _G->Name() << endl;
3139 //      _dataServerError.push_front(2);
3140 //      }
3141 //    }
3142
3143 //    if ((*it)->GetNodeInPortsSize()) {
3144 //      if ((*it)->GetNodeInPortsSize() > 1){
3145 //      cerr << "Plus d'une donnee exportee vers le noeud serveur de donnees "
3146 //             << (*it)->Name() << " du graphe  " << _G->Name() << endl;
3147 //      _dataServerError.push_front(3);
3148 //      }
3149 //      else
3150 //      if ( !(*it)->GetNodeInPort(0)->IsPortConnected() ){
3151 //      cerr << "Le port d'entree du noeud serveur de donnees "
3152 //             << (*it)->Name() << " du graphe  " << _G->Name()
3153 //             << " n'est pas connecte "<< endl;
3154 //      _dataServerError.push_front(5);
3155 //      }
3156 //    }
3157 //    it++ ;
3158 //  };
3159
3160 //  return _dataServerError.size ();
3161   cdebug_out << "GraphBase::Graph::DataServerNodes ierr " << ierr << endl;
3162   return ( ierr == 0 ) ;
3163 }
3164
3165 SUPERV::GraphState GraphBase::Graph::PortState(
3166                                    const char* NodeName ,
3167                                    const char* ServiceParameterName ) {
3168   SUPERV::GraphState aRet = SUPERV::UndefinedState ;
3169 //  cdebug << "GraphBase::Graph::PortState( " << NodeName << " , "
3170 //         << ServiceParameterName << " )" << endl ;
3171
3172   char *theNode ;
3173   char *aPort ;
3174   NodePort( NodeName , ServiceParameterName , &theNode , &aPort ) ;
3175
3176   GraphBase::ComputingNode * aNode = GetChangeGraphNode( theNode ) ;
3177   if ( aNode ) {
3178     GraphBase::OutPort *anOutPort ;
3179     anOutPort = aNode->GetChangeOutPort( aPort );
3180     if ( anOutPort == NULL ) {
3181       GraphBase::InPort *anInPort = aNode->GetChangeInPort( aPort );
3182       if ( anInPort )
3183         anOutPort = anInPort->GetOutPort() ;
3184       else {
3185         cdebug << "ERROR GraphBase::Graph::PortState OutPort/InPort not found --> "
3186                << aRet << endl ;
3187       }
3188     }
3189     if ( anOutPort ) {
3190       aRet = anOutPort->PortState() ;
3191 //      cdebug << "GraphBase::Graph::PortState --> " << aRet << endl ;
3192     }
3193   }
3194   else {
3195     cdebug << "ERROR GraphBase::Graph::PortState Node not found --> " << aRet
3196            << endl ;
3197   }
3198   delete theNode ;
3199   delete aPort ;
3200   return aRet ;
3201 }
3202
3203 #define TracePortInOutData 0
3204 //JR 30.03.2005const CORBA::Any * GraphBase::Graph::PortInData( const char* ToNodeName ,
3205 const CORBA::Any GraphBase::Graph::PortInData( const char* ToNodeName ,
3206                                                const char* ToServiceParameterName ) {
3207 //JR 30.03.2005  const CORBA::Any * aRet = new CORBA::Any() ;
3208   CORBA::Any aRet = CORBA::Any() ;
3209   char *theNode ;
3210   char *aPort ;
3211 #if TracePortInOutData
3212   cdebug_in << "GraphBase::Graph::PortInData " << ToNodeName << " "
3213             << ToServiceParameterName << endl ;
3214 #endif
3215   NodePort( ToNodeName , ToServiceParameterName , &theNode , &aPort ) ;
3216
3217   GraphBase::ComputingNode * aNode = GetChangeGraphNode( theNode ) ;
3218
3219   if ( aNode ) {
3220     GraphBase::OutPort *anOutPort = NULL ;
3221     GraphBase::InPort *anInPort = aNode->GetChangeInPort( aPort );
3222     if ( anInPort ) {
3223       anOutPort = anInPort->GetOutPort() ;
3224       if ( anOutPort ) {
3225 #if TracePortInOutData
3226         cdebug << "-->PortInData " << ToNodeName << " " << ToServiceParameterName << " "
3227                << endl ;
3228 #endif
3229         aRet = anOutPort->Value() ;
3230 #if TracePortInOutData
3231         cdebug << "<--PortInData " << ToNodeName << " " << ToServiceParameterName << " " ;
3232         anOutPort->StringValue( *GraphBase::Base::_fdebug ) ;
3233         cdebug << endl ;
3234         cdebug << "Graph::PortInData OutPort value " << anOutPort->NodeName() << "("
3235                << anOutPort->PortName() << ") --> InPort " << anInPort->NodeName()
3236                << "(" << anInPort->PortName() << ") " << anInPort->PortStatus() << endl ;
3237 #endif
3238       }
3239       else {
3240         cdebug << "Graph::PortInData GraphBase::Graph::PortInData " << ToNodeName << " "
3241                << ToServiceParameterName << " ERROR no OutPort" << endl ;
3242       }
3243     }
3244     else {
3245       cdebug << "GraphBase::Graph::PortInData " << ToNodeName << " "
3246              << ToServiceParameterName << " ERROR no InPort" << endl ;
3247     }
3248   }
3249   else if ( !strcmp( ToNodeName , Name() ) &&
3250             !strcmp( ToServiceParameterName , "Gate" ) ) {
3251     cdebug << "GraphBase::Graph::PortInData " << ToNodeName << " "
3252            << ToServiceParameterName << " InGate ignored" << endl ;
3253   }
3254   else {
3255     cdebug << "GraphBase::Graph::PortInData " << ToNodeName << " "
3256            << ToServiceParameterName << " ERROR no Node" << endl ;
3257   }
3258   delete [] theNode ;
3259   delete [] aPort ;
3260 #if TracePortInOutData
3261   cdebug_out << "GraphBase::Graph::PortInData " << endl ;
3262 #endif
3263   return aRet ;
3264 }
3265
3266 //JR 30.03.2005const CORBA::Any * GraphBase::Graph::PortOutData( const char* FromNodeName ,
3267 const CORBA::Any GraphBase::Graph::PortOutData( const char* FromNodeName ,
3268                                                 const char* FromServiceParameterName ) {
3269 //JR 30.03.2005  const CORBA::Any * aRet = new CORBA::Any() ;
3270   CORBA::Any aRet = CORBA::Any() ;
3271   char *theNode ;
3272   char *aPort ;
3273 #if TracePortInOutData
3274   cdebug_in << "GraphBase::Graph::PortOutData " << FromNodeName << " "
3275             << FromServiceParameterName << endl ;
3276 #endif
3277   NodePort( FromNodeName , FromServiceParameterName , &theNode , &aPort ) ;
3278
3279   GraphBase::ComputingNode * aNode = GetChangeGraphNode( theNode ) ;
3280
3281   if ( aNode ) {
3282     GraphBase::OutPort *anOutPort ;
3283     anOutPort = aNode->GetChangeOutPort( aPort );
3284     if ( anOutPort ) {
3285 #if TracePortInOutData
3286       cdebug << "-->PortOutData " << FromNodeName << " " << FromServiceParameterName << " "
3287              << endl ;
3288 #endif
3289       aRet = anOutPort->Value() ;
3290 #if TracePortInOutData
3291       cdebug << "<--PortOutData " << FromNodeName << " " << FromServiceParameterName << " " ;
3292       anOutPort->StringValue( *GraphBase::Base::_fdebug ) ;
3293       cdebug << endl ;
3294 #endif
3295     }
3296     else {
3297       cdebug << "GraphBase::Graph::PortOutData " << FromNodeName << " "
3298              << FromServiceParameterName << " ERROR no OutPort" << endl ;
3299     }
3300   }
3301   else if ( !strcmp( FromNodeName , Name() ) &&
3302             !strcmp( FromServiceParameterName , "Gate" ) ) {
3303     cdebug << "GraphBase::Graph::PortOutData " << FromNodeName << " "
3304            << FromServiceParameterName << " OutGate ignored" << endl ;
3305   }
3306   else {
3307     cdebug << "GraphBase::Graph::PortOutData " << FromNodeName << " "
3308            << FromServiceParameterName << " ERROR no Node" << endl ;
3309   }
3310   delete [] theNode ;
3311   delete [] aPort ;
3312 #if TracePortInOutData
3313   cdebug_out << "GraphBase::Graph::PortOutData " << endl ;
3314 #endif
3315   return aRet ;
3316 }
3317
3318 SUPERV::ListOfStrings * GraphBase::Graph::LevelNodes(long aLevel ) {
3319   SUPERV::ListOfStrings_var RetVal = new SUPERV::ListOfStrings;
3320   if ( aLevel >= 0 && aLevel <= _LevelsNumber ) {
3321     int i ;
3322     RetVal->length( _NodesNumber[ aLevel ] + 1 );
3323     for ( i= 0 ; i <= _NodesNumber[ aLevel ] ; i++ ) {
3324       RetVal[i] = CORBA::string_dup( (_SortedNodes[ aLevel ])[ i ]->Name() ) ;
3325     }
3326   }
3327   return ( RetVal._retn() ) ;
3328 }
3329
3330 bool GraphBase::Graph::StartComponent(const int aThread ,
3331                                       const char * aComputerContainer ,
3332                                       const char * ComponentName ,
3333                                       Engines::Container_var & myContainer ,
3334                                       Engines::Component_var & objComponent ) {
3335   cdebug_in << aThread
3336             << " GraphBase::Graph::StartComponent " << aComputerContainer
3337             << " " << ComponentName << endl;
3338   bool RetVal = true ;
3339   objComponent = Engines::Component::_nil() ;
3340   SALOME_LifeCycleCORBA LCC( NamingService() ) ;
3341   try {
3342     objComponent = LCC.FindOrLoad_Component( aComputerContainer ,
3343                                              ComponentName );
3344   }
3345   catch (...) {
3346     RetVal = 0 ;
3347   }
3348   if ( CORBA::is_nil( objComponent ) ) {
3349     cdebug_out << aThread 
3350                << " StartComponent cannot FindOrLoad " << aComputerContainer
3351                << " " << ComponentName << " ERROR" << endl;
3352     RetVal = 0 ;
3353   }
3354   /* asv : 24.01.05 : FindContainer() method does not exist any more.  FindOrLoad_Component()
3355                       starts the container for us.  If it fails to start the container, then it
3356                       returns nil component.  We don't need to check for if the container was 
3357                       successfully started..
3358   else {
3359     myContainer = LCC.FindContainer( aComputerContainer );
3360     if ( CORBA::is_nil( myContainer ) ) {
3361       cdebug_out << aThread
3362                  << " GraphBase::Graph::StartComponent myContainer = LCC.FindContainer( '"
3363                  << aComputerContainer << "' ) Container does not exist ERROR"
3364                  << endl ;
3365       return 0 ;
3366     }
3367   }
3368   */
3369   if ( !RetVal ) {
3370     string anErrorMessage = string( "Error while FindOrLoad_Component " ) +
3371                             string( ComponentName ) + string( " in Container " ) +
3372                             string( aComputerContainer )  ;
3373     SetMessages( anErrorMessage ) ;
3374   }
3375   cdebug_out << aThread << " GraphBase::Graph::StartComponent RetVal " << RetVal << endl;
3376   return RetVal ;
3377 }