]> SALOME platform Git repositories - modules/superv.git/blob - src/GraphEditor/DataFlowEditor_OutNode.cxx
Salome HOME
End of developpement/test of Switch Python Nodes
[modules/superv.git] / src / GraphEditor / DataFlowEditor_OutNode.cxx
1 //  SUPERV GraphEditor : contains classes that permit edition of graphs
2 //
3 //  Copyright (C) 2003  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 //  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS 
5 // 
6 //  This library is free software; you can redistribute it and/or 
7 //  modify it under the terms of the GNU Lesser General Public 
8 //  License as published by the Free Software Foundation; either 
9 //  version 2.1 of the License. 
10 // 
11 //  This library is distributed in the hope that it will be useful, 
12 //  but WITHOUT ANY WARRANTY; without even the implied warranty of 
13 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU 
14 //  Lesser General Public License for more details. 
15 // 
16 //  You should have received a copy of the GNU Lesser General Public 
17 //  License along with this library; if not, write to the Free Software 
18 //  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA 
19 // 
20 //  See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org 
21 //
22 //
23 //
24 //  File   : DataFlowEditor_OutNode.cxx
25 //  Module : SUPERV
26
27 using namespace std;
28 #include <sstream>
29 #include <iostream>
30 #include "DataFlowEditor_DataFlow.hxx"
31 #include "DataFlowEditor_OutNode.hxx"
32 #include "DataFlowBase_EndOfLoopNode.hxx"
33 #include "DataFlowBase_EndOfSwitchNode.hxx"
34
35 //map< string , GraphBase::Graph * > GraphEditor::OutNode::_MapOfGraphs;
36 map< string , int > _MapOfGraphNames;
37
38 string GraphInstanceName( const char * aGraphName ) {
39   int GraphInstanceNumber = _MapOfGraphNames[ aGraphName ] ;
40   if ( GraphInstanceNumber ) {
41     _MapOfGraphNames[ aGraphName ] = GraphInstanceNumber + 1 ;
42   }
43   else {
44     GraphInstanceNumber = 0 ;
45     _MapOfGraphNames[ aGraphName ] = GraphInstanceNumber + 1 ;
46   }
47   string theGraphInstanceName = string( aGraphName ) ;
48   if ( GraphInstanceNumber ) {
49     theGraphInstanceName += "_" ;
50     ostringstream astr ;
51     astr << GraphInstanceNumber ;
52     theGraphInstanceName += astr.str() ;
53   }
54   return theGraphInstanceName ;
55 }
56
57
58 // Implementation de la classe GraphEditor::Graph
59
60 GraphEditor::OutNode::OutNode() {
61 //             Graph() {
62   cdebug_in << "GraphEditor::OutNode::OutNode()" << endl;
63
64   _Graph = NULL ;
65   _Imported = false ;
66   _Valid = false ;
67   _Executable = false ;
68
69   cdebug_out << "GraphEditor::OutNode::OutNode()" << endl;
70 }
71
72 GraphEditor::OutNode::OutNode( CORBA::ORB_ptr ORB ,
73                                SALOME_NamingService * ptrNamingService ,
74                                const char * DataFlowName ,
75                                const char * DebugFileName ,
76                                const SUPERV::KindOfNode aKindOfNode ) {
77 //             Graph( ORB , ptrNamingService , DataFlowName , DebugFileName ) {
78   _Graph = NULL ;
79   Set_prof_debug( ORB , DebugFileName ) ;
80   cdebug_in << "GraphEditor::OutNode::OutNode(" ;
81   if ( DataFlowName ) {
82     cdebug << DataFlowName ;
83   }
84   cdebug << ")" << endl;
85
86   if ( aKindOfNode == SUPERV::DataFlowGraph ) {
87     _StreamGraph = NULL ;
88     _Graph = new GraphBase::Graph( ORB , ptrNamingService , DataFlowName , aKindOfNode ,
89                                    _prof_debug , _fdebug ) ; 
90 //    MapGraph( _Graph , _Graph->Name() ) ;
91   }
92   else if ( aKindOfNode == SUPERV::DataStreamGraph ) {
93     _StreamGraph = new GraphBase::StreamGraph( ORB , ptrNamingService , DataFlowName , aKindOfNode ,
94                                                _prof_debug , _fdebug ) ;
95     _Graph = _StreamGraph ;
96 //    MapGraph( _Graph , _Graph->Name() ) ;
97   }
98   _Orb = CORBA::ORB::_duplicate( ORB ) ;
99   _Imported = false ;
100   _Valid = false ;
101   _Executable = false ;
102
103   cdebug_out << "GraphEditor::OutNode::OutNode" << endl;
104 }
105
106 GraphEditor::OutNode::OutNode(
107                      CORBA::ORB_ptr ORB ,
108                      SALOME_NamingService * ptrNamingService ,
109                      const SALOME_ModuleCatalog::Service& DataFlowService ,
110                      const char * DataFlowComponentName ,
111                      const char * DataFlowInterfaceName ,
112                      const char * DataFlowName ,
113                      const SUPERV::KindOfNode DataFlowkind ,
114                      const SUPERV::SDate DataFlowFirstCreation ,
115                      const SUPERV::SDate DataFlowLastModification ,
116                      const char * DataFlowEditorRelease ,
117                      const char * DataFlowAuthor ,
118                      const char * DataFlowComputer ,
119                      const char * DataFlowComment ,
120                      const char * DebugFileName ) {
121   _Graph = NULL ;
122   Set_prof_debug( ORB , DebugFileName ) ;
123
124   if ( DataFlowkind == SUPERV::DataFlowGraph ) {
125     _StreamGraph = NULL ;
126     _Graph = new GraphBase::Graph( ORB , ptrNamingService , DataFlowService , DataFlowComponentName ,
127                                    DataFlowInterfaceName , DataFlowName , DataFlowkind ,
128                                    DataFlowFirstCreation , DataFlowLastModification  ,
129                                    DataFlowEditorRelease , DataFlowAuthor ,
130                                    DataFlowComputer , DataFlowComment ,
131                                    _prof_debug , _fdebug ) ;
132 //    MapGraph( _Graph , _Graph->Name() ) ;
133   }
134   else if ( DataFlowkind == SUPERV::DataStreamGraph ) {
135     _StreamGraph = new GraphBase::StreamGraph( ORB , ptrNamingService , DataFlowService , DataFlowComponentName ,
136                                                DataFlowInterfaceName , DataFlowName , DataFlowkind ,
137                                                DataFlowFirstCreation , DataFlowLastModification  ,
138                                                DataFlowEditorRelease , DataFlowAuthor ,
139                                                DataFlowComputer , DataFlowComment ,
140                                                _prof_debug , _fdebug ) ;
141     _Graph = _StreamGraph ;
142 //    MapGraph( _Graph , _Graph->Name() ) ;
143   }
144   _Orb = CORBA::ORB::_duplicate( ORB ) ;
145   _Imported = false ;
146   _Valid = false ;
147   _Executable = false ;
148
149 } ;
150
151 GraphEditor::OutNode::~OutNode() {
152 //  EraseGraph( Graph->Name() ) ;
153 //  delete _DataFlowNode ;
154 //  delete _DataFlowDatas ;
155 //  delete _GT ;
156 }
157
158 bool GraphEditor::OutNode::Name( const char * aName ) {
159   bool RetVal = false ;
160 //  if ( !GraphName( aName ) ) {
161 //    char * aGraphName = Graph()->Name() ;
162     RetVal = Graph()->Name( aName ) ;
163 //    if ( RetVal ) {
164 //      EraseGraph( aGraphName ) ;
165 //      MapGraph( Graph() , aName ) ;
166 //    }
167 //  }
168   return RetVal ;
169 }
170
171 void GraphEditor::OutNode::Set_prof_debug( CORBA::ORB_ptr ORB ,
172                                            const char * DebugFileName ) {
173   _Graph_prof_debug = 0 ;
174   _prof_debug = 0 ;
175   if ( DebugFileName ) {
176     _fdebug = new ofstream( DebugFileName );
177     SetDebug( ORB , &_Graph_prof_debug , _fdebug ) ;
178     MESSAGE( endl << "Trace redirected to file " << DebugFileName << endl)
179   }
180 }
181
182 bool GraphEditor::OutNode::LoadDataFlow( const GraphBase::SGraph * aDataFlow ) {
183   bool RetVal = false ;
184   cdebug_in << "GraphEditor::OutNode::LoadDataFlow() " << (*aDataFlow).Info.theName.c_str()
185             << " GraphNodesSize " << Graph()->GraphNodesSize() << endl;
186   if ( !_Imported ) {
187     RetVal = LoadInfo( (*aDataFlow).Info ) ;
188     _Imported = true ;
189   }
190   else if ( Graph()->IsDataStreamNode() || (*aDataFlow).Info.theKind == SUPERV::DataFlowGraph ) {
191     RetVal = true ;
192   }
193   cdebug << "GraphEditor::OutNode::LoadDataFlow() _Imported " << _Imported << " RetVal " << RetVal << endl;
194
195   map< string , int > aMapOfNodes ;
196   if ( RetVal ) {
197     cdebug << "GraphEditor::OutNode::LoadDataFlow() LoadNodes GraphNodesSize " << Graph()->GraphNodesSize() << endl;
198     RetVal = LoadNodes( aMapOfNodes , (*aDataFlow).Nodes ) ;
199   }
200   if ( RetVal ) {
201     cdebug << "GraphEditor::OutNode::LoadDataFlow() LoadLinks GraphNodesSize " << Graph()->GraphNodesSize() << endl;
202     RetVal = LoadLinks( aMapOfNodes , (*aDataFlow).Links ) ;
203   }
204   if ( RetVal ) {
205     Valid() ;
206     cdebug << "GraphEditor::OutNode::LoadDataFlow() LoadDatas GraphNodesSize " << Graph()->GraphNodesSize() << endl;
207     RetVal = LoadDatas( aMapOfNodes , (*aDataFlow).Datas ) ;
208   }
209   cdebug_out << "GraphEditor::OutNode::LoadDataFlow done GraphNodesSize " << Graph()->GraphNodesSize()
210              << " _Valid " << _Valid << " _Executable " << _Executable << " RetVal " << RetVal << endl;
211   return RetVal ;
212 }
213
214 bool GraphEditor::OutNode::LoadXml( const char* myFileName , GraphBase::ListOfSGraphs & aListOfDataFlows ) {
215   bool RetVal = false ;
216 //  GraphBase::ListOfSGraphs aListOfDataFlows ;
217   if ( myFileName == NULL ) {
218     cdebug << "GraphEditor::OutNode::LoadXml() No file" << endl;
219     _Imported = true ;
220     char * aDataFlowName = Graph()->Name() ;
221 //  Name( Graph()->Name() ) ;
222     Name( GraphInstanceName( Graph()->Name() ).c_str() ) ;
223 //    MapGraph( Graph() , Graph()->Name() ) ;
224     cdebug << "GraphEditor::OutNode::LoadXml() " << aDataFlowName << " --> " << Graph()->Name() << endl;
225     RetVal = true ;
226   }
227   else {
228     cdebug_in << "GraphEditor::OutNode::LoadXml() " << myFileName << endl;
229     RetVal = Graph()->LoadXml( _Orb , myFileName , aListOfDataFlows ) ;
230 //    RetVal = LoadDataFlows( &aListOfDataFlows ) ;
231     cdebug_out << "GraphEditor::OutNode::LoadXml " << RetVal << " " << aListOfDataFlows.size()
232                << " Graphs" << endl;
233   }
234   return RetVal ;
235
236
237 #if 0
238 bool GraphEditor::OutNode::LoadXml( const char* myFileName ) {
239   bool RetVal = false ;
240   GraphBase::ListOfSGraphs aListOfDataFlows ;
241   if ( myFileName == NULL ) {
242     cdebug << "GraphEditor::OutNode::LoadXml() No file" << endl;
243     _Imported = true ;
244     RetVal = true ;
245   }
246   else if ( Graph()->LoadXml( _Orb , myFileName , aListOfDataFlows ) ) {
247     cdebug_in << "GraphEditor::OutNode::LoadXml() " << myFileName << endl;
248     RetVal = LoadDataFlows( &aListOfDataFlows ) ;
249     cdebug_out << "GraphEditor::OutNode::LoadXml " << RetVal << endl;
250   }
251   return RetVal ;
252 }
253 #endif
254
255 bool GraphEditor::OutNode::LoadInfo(const GraphBase::SNode &aDataFlowInfo ) {
256   bool RetVal = false ;
257   cdebug_in << "GraphEditor::OutNode::LoadInfo " << aDataFlowInfo.theName.c_str()
258             << endl ;
259 //  MESSAGE( "GraphEditor::OutNode::LoadInfo" );
260 //  ComponentName( aDataFlowInfo.theComponentName.c_str() ) ;
261 //  InterfaceName( aDataFlowInfo.theInterfaceName.c_str() ) ;
262   if ( Graph()->IsDataStreamNode() || aDataFlowInfo.theKind == SUPERV::DataFlowGraph ) {
263     char * aDataFlowName = Graph()->Name() ;
264 //    Graph()->Name( aDataFlowInfo.theName.c_str() ) ;
265     Graph()->Name( GraphInstanceName( aDataFlowInfo.theName.c_str() ).c_str() ) ;
266 //    MapGraph( Graph() , Graph()->Name() ) ;
267     cdebug << "GraphEditor::OutNode::LoadInfo " << aDataFlowName << " --> " << Graph()->Name()
268            << " aDataFlowInfo.Kind " << aDataFlowInfo.theKind << " Kind() " << Graph()->Kind() << endl ;
269     if ( Graph()->IsDataStreamNode() ) {
270       Graph()->Kind( SUPERV::DataStreamGraph ) ;
271       StreamGraph()->SetStreamParams( aDataFlowInfo.theTimeout , aDataFlowInfo.theDataStreamTrace , aDataFlowInfo.theDeltaTime ) ;
272     }
273     else {
274       Graph()->Kind( SUPERV::DataFlowGraph ) ;
275     }
276     Graph()->SetService( aDataFlowInfo.theService ) ;
277     Graph()->FirstCreation( aDataFlowInfo.theFirstCreation ) ;
278     Graph()->LastModification( aDataFlowInfo.theLastModification ) ;
279     Graph()->EditorRelease( aDataFlowInfo.theEditorRelease.c_str() ) ;
280     Graph()->Author( aDataFlowInfo.theAuthor.c_str()  ) ;
281 //    Graph()->Computer( aDataFlowInfo.theContainer.c_str() ) ;
282     Graph()->Comment( aDataFlowInfo.theComment.c_str() ) ;
283 // Not in OutNode/DataFlow but in InNode/DataFlow_in_an_other_DataFlow
284 //    Graph()->Coordinates( aDataFlowInfo.theX , aDataFlowInfo.theY ) ;
285     RetVal = true ;
286   }
287   else {
288     Graph()->Kind( aDataFlowInfo.theKind ) ;
289     cdebug << "GraphEditor::OutNode::LoadInfo aDataFlowInfo.Kind " << aDataFlowInfo.theKind
290            << " != IsDataStreamNode() " << Graph()->IsDataStreamNode() << endl ;
291   }
292   cdebug_out << "GraphEditor::OutNode::LoadInfo " << RetVal << endl ;
293   return RetVal ;
294 }
295
296 bool GraphEditor::OutNode::LoadNodes(map< string , int > & aMapOfNodes ,
297                                      const GraphBase::ListOfSNodes &aListOfNodes ) {
298   GraphEditor::InNode * anInNode ;
299   cdebug_in << "GraphEditor::OutNode::LoadNodes " << endl ;
300   int i ;
301   for ( i = 0 ; i < (int ) aListOfNodes.size() ; i++ ) {
302     GraphBase::SNode aNode = aListOfNodes[ i ] ;
303     const char * aNodeName = aNode.theName.c_str() ;
304 //    cout << "GraphEditor::OutNode::LoadNodes " << aNodeName << " "
305 //         << aNode.theService.ServiceinParameter.length() << " InParameters "
306 //         << aNode.theService.ServiceoutParameter.length() << " OutParameters "
307 //         << aNode.theListOfInDataStreams.size() << " InDataStreams "
308 //         << aNode.theListOfOutDataStreams.size() << " OutDataStreams "
309 //         << " _prof_debug " << _prof_debug << endl ;
310     cdebug << "GraphEditor::OutNode::LoadNodes " << aNodeName << " "
311            << aNode.theService.ServiceinParameter.length() << " InParameters "
312            << aNode.theService.ServiceoutParameter.length() << " OutParameters "
313            << aNode.theListOfInDataStreams.size() << " InDataStreams "
314            << aNode.theListOfOutDataStreams.size() << " OutDataStreams "
315            << endl ;
316     if ( aNode.theListOfFuncName.size() == 0 ) {
317       aNode.theListOfFuncName.resize( 1 ) ;
318       aNode.theListOfFuncName[ 0 ] = "" ;
319       aNode.theListOfPythonFunctions.resize( 1 ) ;
320       aNode.theListOfPythonFunctions[ 0 ] = new SUPERV::ListOfStrings() ;
321     }
322     if ( Graph()->GetGraphNode( aNode.theName.c_str() ) ) {
323       aNodeName = NULLSTRING ;
324     }
325
326     aNode.theService.ServiceinDataStreamParameter.length( aNode.theListOfInDataStreams.size() ) ;
327     aNode.theService.ServiceoutDataStreamParameter.length( aNode.theListOfOutDataStreams.size() ) ;
328     unsigned int j ;
329     for ( j = 0 ; j < aNode.theListOfInDataStreams.size() ; j++ ) {
330       aNode.theService.ServiceinDataStreamParameter[ j ].Parametername = aNode.theListOfInDataStreams[ j ].theDataStreamParameter.Parametername ,
331       aNode.theService.ServiceinDataStreamParameter[ j ].Parametertype = aNode.theListOfInDataStreams[ j ].theDataStreamParameter.Parametertype ,
332       aNode.theService.ServiceinDataStreamParameter[ j ].Parameterdependency = aNode.theListOfInDataStreams[ j ].theDataStreamParameter.Parameterdependency ;
333     }
334     for ( j = 0 ; j < aNode.theListOfOutDataStreams.size() ; j++ ) {
335       aNode.theService.ServiceoutDataStreamParameter[ j ].Parametername = aNode.theListOfOutDataStreams[ j ].theDataStreamParameter.Parametername ,
336       aNode.theService.ServiceoutDataStreamParameter[ j ].Parametertype = aNode.theListOfOutDataStreams[ j ].theDataStreamParameter.Parametertype ,
337       aNode.theService.ServiceoutDataStreamParameter[ j ].Parameterdependency = aNode.theListOfOutDataStreams[ j ].theDataStreamParameter.Parameterdependency ;
338     }
339
340     anInNode = AddNode( aNode.theService ,
341                         aNode.theListOfFuncName ,
342                         aNode.theListOfPythonFunctions ,
343                         aNode.theComponentName.c_str() ,
344                         aNode.theInterfaceName.c_str() , aNodeName ,
345                         aNode.theKind ,
346                         aNode.theFirstCreation , aNode.theLastModification ,
347                         aNode.theEditorRelease.c_str() ,
348                         aNode.theAuthor.c_str() , aNode.theContainer.c_str() ,
349                         aNode.theComment.c_str() ,
350                         aNode.theCoords.theX , aNode.theCoords.theY ) ;
351     string * aNodetheName = new string( aNode.theName ) ;
352     aMapOfNodes[ *aNodetheName ] = Graph()->GetGraphNodeIndex( anInNode->Name() ) ;
353     if ( anInNode->IsOneOfInLineNodes() || anInNode->IsMacroNode() ) {
354       anInNode->GraphEditor::InNode::InLineNode()->DefPortsOfNode(
355                 _Orb , aNode.theService , anInNode->NamePtr() ,
356                 anInNode->Kind() ,
357                 _prof_debug , _fdebug ) ;
358       GraphBase::InLineNode * aINode = anInNode->InLineNode() ;
359       GraphBase::LoopNode * aLNode = NULL ;
360       if ( aINode->IsLoopNode() ) {
361         aLNode = anInNode->LoopNode() ;
362         aLNode->SetPythonFunction( aNode.theListOfFuncName[ 0 ].c_str() ,
363                                    *aNode.theListOfPythonFunctions[ 0 ] ) ;
364         aLNode->SetMorePythonFunction( aNode.theListOfFuncName[ 1 ].c_str() ,
365                                        *aNode.theListOfPythonFunctions[ 1 ] ) ;
366         aLNode->SetNextPythonFunction( aNode.theListOfFuncName[ 2 ].c_str() ,
367                                        *aNode.theListOfPythonFunctions[ 2 ] ) ;
368       }
369       else if ( aINode->IsMacroNode() || aINode->IsInLineNode() || aINode->IsGOTONode() ||
370                 aINode->IsSwitchNode() || aINode->IsEndSwitchNode() ) {
371         aINode->SetPythonFunction( aNode.theListOfFuncName[ 0 ].c_str() ,
372                                    *aNode.theListOfPythonFunctions[ 0 ] ) ;
373       }
374     }
375
376     for ( j = 0 ; j < aNode.theListOfInDataStreams.size() ; j++ ) {
377       GraphBase::InPort * anInPort ;
378       if ( anInNode->IsOneOfInLineNodes() ) {
379         anInPort = anInNode->ComputingNode()->AddInDataStreamPort( aNode.theListOfInDataStreams[ j ].theDataStreamParameter.Parametername ,
380                                                                    aNode.theListOfInDataStreams[ j ].theDataStreamParameter.Parametertype ,
381                                                                    aNode.theListOfInDataStreams[ j ].theDataStreamParameter.Parameterdependency ,
382                                                                    SUPERV::DataStreamParameter ) ;
383       }
384       else {
385         anInPort = anInNode->ComputingNode()->GetChangeInPort( aNode.theListOfInDataStreams[ j ].theDataStreamParameter.Parametername ) ;
386       }
387       ((GraphBase::InDataStreamPort * ) anInPort)->SetParams( aNode.theListOfInDataStreams[ j ].theKindOfSchema ,
388                                                               aNode.theListOfInDataStreams[ j ].theKindOfInterpolation ,
389                                                               aNode.theListOfInDataStreams[ j ].theKindOfExtrapolation ) ;
390     }
391     for ( j = 0 ; j < aNode.theListOfOutDataStreams.size() ; j++ ) {
392       GraphBase::OutPort * anOutPort ;
393       if ( anInNode->IsOneOfInLineNodes() ) {
394         anOutPort = anInNode->ComputingNode()->AddOutDataStreamPort( aNode.theListOfOutDataStreams[ j ].theDataStreamParameter.Parametername ,
395                                                                      aNode.theListOfOutDataStreams[ j ].theDataStreamParameter.Parametertype ,
396                                                                      aNode.theListOfOutDataStreams[ j ].theDataStreamParameter.Parameterdependency ,
397                                                                      SUPERV::DataStreamParameter ) ;
398       }
399       else {
400         anOutPort = anInNode->ComputingNode()->GetChangeOutPort( aNode.theListOfOutDataStreams[ j ].theDataStreamParameter.Parametername ) ;
401       }
402       ((GraphBase::OutDataStreamPort * ) anOutPort)->NumberOfValues( aNode.theListOfOutDataStreams[ j ].theNumberOfValues ) ;
403     }
404     delete aNodetheName ;
405     if ( !anInNode ) {
406       return false ;
407     }
408   }
409
410   // setting coupled pairs of nodes: Loop-EndLoop, Switch-EndSwitch, InLine-GOTO, MacroNode-Graph
411   for ( i = 0 ; i < (int ) aListOfNodes.size() ; i++ ) {
412     GraphBase::SNode aNode = aListOfNodes[ i ] ;
413     cdebug << "GraphEditor::OutNode::LoadNodes " << aNode.theName.c_str() << " Coupled to "
414            << aNode.theCoupledNode.c_str() << endl ;
415     anInNode = (GraphEditor::InNode * ) Graph()->GetChangeGraphNode( aMapOfNodes[ aNode.theName.c_str() ] )->GetInNode() ;
416
417     if ( anInNode->IsOneOfGOTONodes() && strlen( aNode.theCoupledNode.c_str() ) ) {
418       GraphBase::GOTONode * aGOTONode;
419       aGOTONode = (GraphBase::GOTONode * ) anInNode->ComputingNode() ;
420
421       // asv : 25.10.04 : if aNode is a MacroNode, then its coupled node (another Graph) is NOT in aMapOfNodes 
422       //                  and we must couple MacroNode only with name to its subgraph
423       if ( aGOTONode->IsMacroNode() ) {
424         cdebug << "GraphEditor::OutNode::LoadNodes MacroNode " << aNode.theName.c_str()
425                << " is Coupled ONLY WITH NAME to its subgraph " << aNode.theCoupledNode.c_str() << endl;
426         aGOTONode->CoupledNodeName( aNode.theCoupledNode.c_str() ) ;
427       }
428       else { // coupling Loop-EndLoop, Switch-EndSwitch, InLine-GOTO
429         // asv : fix for 6822 : using map because if aNode's name is the same as some existing node's name
430         // aMap will give the correct index any way (aMap has already a different name for aNode, SNode still has old name)
431         int aCoupledNodeIndex = aMapOfNodes[ aNode.theCoupledNode.c_str() ] ;
432         cdebug << "GraphEditor::OutNode::LoadNodes " << aNode.theCoupledNode.c_str()
433                << " index " << aCoupledNodeIndex << endl ;
434         GraphBase::GOTONode * aCoupledNode ;
435         aCoupledNode = (GraphBase::GOTONode * ) Graph()->GetChangeGraphNode( aCoupledNodeIndex ) ;
436         cdebug << "GraphEditor::OutNode::LoadNodes " << aNode.theName.c_str()
437                << " is now Coupled to " << aNode.theCoupledNode.c_str() << endl ;
438         aGOTONode->CoupledNode( aCoupledNode ) ;
439       }
440     }
441   }
442   cdebug_out << "GraphEditor::OutNode::LoadNodes" << endl ;
443   return true ;
444 }
445
446 bool GraphEditor::OutNode::LoadLinks(map< string , int > & aMapOfNodes ,
447                                      const GraphBase::ListOfSLinks &aListOfLinks ) {
448   bool RetVal = true ;
449   bool RetAddLink ;
450   cdebug_in << "GraphEditor::OutNode::LoadLinks" << endl ;
451 //  MESSAGE( "GraphEditor::OutNode::LoadLinks" );
452   int i , j ;
453   for ( i = 0 ; i < (int ) aListOfLinks.size() ; i++ ) {
454     GraphBase::SLink aLink = aListOfLinks[ i ] ;
455     string * aLinkFromNodeName = new string( aLink.FromNodeName.c_str() ) ;
456     string * aLinkToNodeName = new string( aLink.ToNodeName.c_str() ) ;
457     cdebug << "LoadLinks " << aLinkFromNodeName->c_str() << "( "
458            << aLink.FromServiceParameterName.c_str() << " ) --> "
459            << aLinkToNodeName->c_str() << "( "
460            << aLink.ToServiceParameterName.c_str() << " )" << endl ;
461     if ( Graph()->GetGraphNode( aMapOfNodes[ aLinkFromNodeName->c_str() ] ) &&
462          Graph()->GetGraphNode( aMapOfNodes[ aLinkToNodeName->c_str() ] ) ) {
463 //JR 08.02.2005 : Rule of CEA : a bad graph may be stored in a xml
464       RetAddLink = AddLink( Graph()->GetGraphNode( aMapOfNodes[ aLinkFromNodeName->c_str() ] )->Name() ,
465                             aLink.FromServiceParameterName.c_str() ,
466                             Graph()->GetGraphNode( aMapOfNodes[ aLinkToNodeName->c_str() ] )->Name() ,
467                             aLink.ToServiceParameterName.c_str() ) ;
468     }
469     else {
470       RetVal = false ;
471     }
472     if ( RetVal && RetAddLink ) {
473       for ( j = 0 ; j < (int ) aLink.aListOfCoords.size() ; j++ ) {
474         RetVal = AddLinkCoord( Graph()->GetGraphNode( aMapOfNodes[ aLinkFromNodeName->c_str() ] )->Name() ,
475                                         aLink.FromServiceParameterName.c_str() ,
476                                         Graph()->GetGraphNode( aMapOfNodes[ aLink.ToNodeName.c_str() ] )->Name() ,
477                                         aLink.ToServiceParameterName.c_str() ,
478                                        j + 1 ,
479                                        aLink.aListOfCoords[j].theX ,
480                                        aLink.aListOfCoords[j].theY ) ;
481         if ( !RetVal )
482           break ;
483       }
484     }
485     delete aLinkFromNodeName ;
486     delete aLinkToNodeName ;
487   }
488   cdebug_out << "GraphEditor::OutNode::LoadLinks " << RetVal << endl ;
489   return RetVal ;
490 }
491
492 bool GraphEditor::OutNode::LoadDatas(map< string , int > & aMapOfNodes ,
493                                      const GraphBase::ListOfSLinks &aListOfDatas ) {
494   bool RetVal = true ;
495   bool RetAddLink ;
496   cdebug_in << "GraphEditor::OutNode::LoadDatas" << endl ;
497 //  MESSAGE( "GraphEditor::OutNode::LoadDatas" );
498   int i ;
499   for ( i = 0 ; i < (int ) aListOfDatas.size() ; i++ ) {
500     GraphBase::SLink aLink = aListOfDatas[ i ] ;
501     cdebug << "OutNode::LoadDatas " << i << aLink.FromNodeName.c_str() << "(" << aLink.FromServiceParameterName
502            << ") --> " << aLink.ToNodeName.c_str() << "(" << aLink.ToServiceParameterName << ") CORBA::tk_xxx "
503            << aLink.aLinkValue.type()->kind() << endl ;
504     string * aLinkFromNodeName = new string( aLink.FromNodeName.c_str() ) ;
505     string * aLinkToNodeName = new string( aLink.ToNodeName.c_str() ) ;
506 //      cout << "LoadDatas " << aLink.FromNodeName.c_str() << " "
507 //           << aMapOfNodes[ aLinkFromNodeName->c_str() ] << endl ;
508 //      cout << "          " << aLink.ToNodeName.c_str() << " "
509 //           << aMapOfNodes[ aLinkToNodeName->c_str() ] << endl ;
510     RetAddLink = Graph()->AddInputData( Graph()->GetGraphNode( aMapOfNodes[ aLinkToNodeName->c_str() ] )->Name() ,
511                                         aLink.ToServiceParameterName.c_str() ,
512                                         aLink.aLinkValue ) ;
513     delete aLinkFromNodeName ;
514     delete aLinkToNodeName ;
515     if ( !RetVal )
516       break ;
517   }
518   cdebug_out << "GraphEditor::OutNode::LoadDatas " << RetVal << endl ;
519   return RetVal ;
520 }
521
522 bool GraphEditor::OutNode::SaveXml(const char* filename) {
523   bool test;
524   cdebug_in << "GraphEditor::OutNode::SaveXml(" << filename << ")" << endl;
525   ofstream f(filename);
526   IsValid() ;
527   QDomDocument DomGraph ;
528   QDomElement Domsupergraph ;
529   cdebug << "OutNode::SaveXML("<< filename << ") ---> OutNode::SaveXML( ostream & f , QDomDocument & , true "
530          << " , QDomElement & ) " << Graph()->Name() << endl ;
531   test = SaveXML( f , DomGraph , true , Domsupergraph );
532   QString xml = DomGraph.toString() ;
533   f << xml << endl ;
534
535   cdebug << "OutNode::SaveXML("<< filename << ") done" << endl ;
536 //  if ( test ) {
537 //    QString xml = Graph.toString() ;
538 //    cout << "GraphEditor::OutNode::SaveXML " << xml << endl ;
539 //    f << xml << endl ;
540 //  }
541   cdebug_out << "GraphEditor::OutNode::SaveXml " << test << endl;
542   return test;
543 }
544
545
546 bool GraphEditor::OutNode::SavePy( const char* filename ) {
547   bool test;
548   cdebug_in << "GraphEditor::OutNode::SavePy(" << filename << ")" << endl;
549   ofstream f( filename ) ;
550   IsValid() ;
551   test = SavePY( f , true );
552   f << endl << Graph()->Name() << " = Def" << Graph()->Name() << "()" << endl ;
553   cdebug_out << "GraphEditor::OutNode::SavePy " << test << endl;
554   return test;
555 }
556
557 GraphBase::ListOfSGraphs * GraphEditor::OutNode::GetDataFlows( GraphBase::ListOfSGraphs * aListOfDataFlows ) {
558 //  GraphBase::ListOfSGraphs * aListOfDataFlows = new GraphBase::ListOfSGraphs;
559   int index = aListOfDataFlows->size() ;
560   aListOfDataFlows->resize( index + 1 ) ;
561   if ( Graph()->IsDataFlowNode() ) {
562     (*aListOfDataFlows)[ index ].Info = *Graph()->GetInfo() ;
563     (*aListOfDataFlows)[ index ].Nodes = *Graph()->GetNodes() ;
564     (*aListOfDataFlows)[ index ].Links = *Graph()->GetLinks( true ) ;
565     (*aListOfDataFlows)[ index ].Datas = *Graph()->GetDatas() ;
566   }
567   else {
568     (*aListOfDataFlows)[ index ].Info = *StreamGraph()->GetInfo() ;
569     (*aListOfDataFlows)[ index ].Nodes = *StreamGraph()->GetNodes() ;
570     (*aListOfDataFlows)[ index ].Links = *StreamGraph()->GetLinks( true ) ;
571     (*aListOfDataFlows)[ index ].Datas = *StreamGraph()->GetDatas() ;
572   }
573   int i ;
574   for ( i = 0 ; i < (int ) (*aListOfDataFlows)[ index ].Nodes.size() ; i++ ) {
575     const GraphBase::ComputingNode * aNode = Graph()->GetGraphNode( (*aListOfDataFlows)[ index ].Nodes[i].theName.c_str() ) ;
576     if ( aNode->IsMacroNode() ) {
577 //      string aCoupledNodeName = (*aListOfDataFlows)[ index ].Nodes[i].theCoupledNode ;
578       GraphBase::Graph * aGraph = (GraphBase::Graph * ) ((GraphBase::GOTONode * ) aNode )->CoupledNode() ;
579 //      GraphBase::Graph * aGraph = MapGraph( aCoupledNodeName.c_str() ) ;
580       aGraph->GraphEditor()->GraphEditor::OutNode::GetDataFlows( aListOfDataFlows ) ;
581     }
582   }
583   return aListOfDataFlows ;
584 }
585
586 void GraphEditor::OutNode::DateModification() {
587   time_t T = time(NULL);
588   struct tm * Tm = localtime(&T);
589   SUPERV::SDate aLastModificationDate ;
590
591   aLastModificationDate.Second = Tm->tm_sec;
592   aLastModificationDate.Minute = Tm->tm_min;
593   aLastModificationDate.Hour   = Tm->tm_hour;
594   aLastModificationDate.Day    = Tm->tm_mday;
595   aLastModificationDate.Month  = Tm->tm_mon + 1;
596   aLastModificationDate.Year   = Tm->tm_year + 1900;
597   Graph()->LastModification( aLastModificationDate ) ;
598 }
599
600 void GraphEditor::OutNode::Coordinates( const char* NodeName ,
601                                         const int X ,
602                                         const int Y ) {
603   ((GraphEditor::InNode * ) Graph()->GetChangeGraphNode( NodeName ))->Coordinates( X , Y ) ;
604 }
605
606 const int GraphEditor::OutNode::XCoordinate( const char* NodeName ) {
607   return ((GraphEditor::InNode * ) Graph()->GetChangeGraphNode( NodeName ))->XCoordinate() ;
608 }
609
610 const int GraphEditor::OutNode::YCoordinate( const char* NodeName ) {
611   return ((GraphEditor::InNode * ) Graph()->GetChangeGraphNode( NodeName ))->YCoordinate() ;
612 }
613
614 GraphEditor::InNode * GraphEditor::OutNode::AddNode(
615                       const SALOME_ModuleCatalog::Service& NodeService ,
616                       GraphBase::ListOfFuncName aFuncName ,
617                       GraphBase::ListOfPythonFunctions aPythonFunction ,
618                       const char * NodeComponentName ,
619                       const char * NodeInterfaceName ,
620                       const char * theNodeName ,
621                       const SUPERV::KindOfNode NodeKindOfNode ,
622                       const SUPERV::SDate NodeFirstCreation ,
623                       const SUPERV::SDate NodeLastModification  ,
624                       const char * NodeEditorRelease ,
625                       const char * NodeAuthor ,
626                       const char * NodeComputer ,
627                       const char * NodeComment ,
628                       const int NodeX ,
629                       const int NodeY ) {
630   cdebug_in << "GraphEditor::OutNode::AddNode( " ;
631   if ( NodeComponentName != NULLSTRING && strlen( NodeComponentName ) ) {
632     cdebug << "Component('" << NodeComponentName << "') , Node('" ;
633   }
634   else {
635     cdebug << "NodeComponentName[NULL] )" << endl;
636   }
637   if ( theNodeName == NULL ) {
638     theNodeName = NULLSTRING ;
639   }
640   if ( theNodeName != NULLSTRING && strlen( theNodeName ) ) {
641     cdebug << theNodeName << "' )" ;
642   }
643   else {
644     cdebug << "NodeName[NULLSTRING]' )" ;
645   }
646   cdebug << " " << NodeKindOfNode << endl ;
647   char * RetVal = NULLSTRING ;
648   GraphEditor::InNode *Nd = NULL ;
649   char * aNodeName = NULLSTRING ;
650   bool   GeneratedName = false ;
651 //PAL9048 JR Debug : a node may not have the same name as the graph
652   bool GraphNodeSameName = false ;
653   if ( theNodeName && !strcmp( Graph()->Name() , theNodeName ) ) {
654     GraphNodeSameName = true ;
655   }
656   if ( NodeKindOfNode == SUPERV::InLineNode ||
657        NodeKindOfNode == SUPERV::LoopNode ||
658        NodeKindOfNode == SUPERV::EndLoopNode ||
659        NodeKindOfNode == SUPERV::SwitchNode ||
660        NodeKindOfNode == SUPERV::EndSwitchNode ||
661        NodeKindOfNode == SUPERV::GOTONode ) {
662     if ( theNodeName == NULLSTRING || strlen( theNodeName ) == 0 ) {
663       if ( NodeKindOfNode == SUPERV::InLineNode ) {
664         ((SALOME_ModuleCatalog::Service& ) NodeService).ServiceName = my_strdup( "InLine" ) ;
665       }
666       else if ( NodeKindOfNode == SUPERV::LoopNode ) {
667         ((SALOME_ModuleCatalog::Service& ) NodeService).ServiceName = my_strdup( "Loop" ) ;
668       }
669       else if ( NodeKindOfNode == SUPERV::EndLoopNode ) {
670         ((SALOME_ModuleCatalog::Service& ) NodeService).ServiceName = my_strdup( "EndLoop" ) ;
671       }
672       else if ( NodeKindOfNode == SUPERV::SwitchNode ) {
673         ((SALOME_ModuleCatalog::Service& ) NodeService).ServiceName = my_strdup( "Switch" ) ;
674       }
675       else if ( NodeKindOfNode == SUPERV::EndSwitchNode ) {
676         ((SALOME_ModuleCatalog::Service& ) NodeService).ServiceName = my_strdup( "EndSwitch" ) ;
677       }
678       else if ( NodeKindOfNode == SUPERV::GOTONode ) {
679         ((SALOME_ModuleCatalog::Service& ) NodeService).ServiceName = my_strdup( "GOTO" ) ;
680       }
681     }
682     else {
683       ((SALOME_ModuleCatalog::Service& ) NodeService).ServiceName = CORBA::string_dup( theNodeName ) ;
684     }
685     theNodeName = NULLSTRING ;
686   }
687 //PAL9048 JR Debug : a node may not have the same name as the graph
688 //  if ( theNodeName == NULLSTRING || strlen( theNodeName ) == 0 || Graph()->GetGraphNode( theNodeName ) ) {
689   if ( theNodeName == NULLSTRING || strlen( theNodeName ) == 0 ||
690        Graph()->GetGraphNode( theNodeName ) || GraphNodeSameName ) {
691     cdebug << "OutNode::AddNode : '" << theNodeName << "' GraphNodeSameName "
692            << GraphNodeSameName << endl;
693     aNodeName = new char[ strlen( NodeService.ServiceName )+1 ] ;
694     strcpy( aNodeName , NodeService.ServiceName ) ;
695 //    if ( Graph()->GetGraphNode( NodeService.ServiceName ) ) {
696     if ( Graph()->GetGraphNode( NodeService.ServiceName ) || GraphNodeSameName ) {
697       GeneratedName = true ;
698       while ( Graph()->GetGraphNode( aNodeName ) || GraphNodeSameName ) {
699         cdebug << "OutNode::AddNode : '" << aNodeName << "' exists or GraphNodeSameName "
700                << GraphNodeSameName << endl;
701         if ( aNodeName ) {
702           delete [] aNodeName ;
703         }
704         char * aServiceName = (CORBA::String_member ) NodeService.ServiceName ;
705         int num = Graph()->GetNewServiceInstanceNumber( aServiceName ) ;
706         ostringstream astr ;
707         astr << num << ends ;
708         const char * n_instance = astr.str().c_str() ;
709         int lname = strlen( NodeService.ServiceName ) + 1 +
710                     strlen( n_instance ) + 1 ;
711         aNodeName = new char[lname] ;
712         strcpy( aNodeName , NodeService.ServiceName ) ;
713         strcat( aNodeName , "_" ) ;
714         strcat( aNodeName , n_instance ) ;
715         GraphNodeSameName = !strcmp( Graph()->Name() , aNodeName ) ;
716       }
717     }
718   }
719   else {
720     if ( Graph()->GetGraphNode( theNodeName ) == NULL ) {
721       aNodeName = new char[ strlen( theNodeName )+1 ] ;
722       strcpy( aNodeName , theNodeName ) ;
723     }
724     else {
725       aNodeName = NULLSTRING ;
726     }
727   }
728   if ( aNodeName != NULLSTRING ) {
729     Nd = new GraphEditor::InNode( _Orb , Graph()->NamingService() ,
730                                   aFuncName , aPythonFunction , NodeService ,
731                                   NodeComponentName , NodeInterfaceName ,
732                                   aNodeName , NodeKindOfNode ,
733                                   NodeFirstCreation , NodeLastModification ,
734                                   NodeEditorRelease , NodeAuthor ,
735                                   NodeComputer , NodeComment , GeneratedName ,
736                                   NodeX , NodeY ,
737                                   _prof_debug , _fdebug ) ;
738     
739     // asv: 28.09.04 fix for 6621
740     //if ( Nd->IsMacroNode() )
741     //  MapGraph( Nd->GraphMacroNode(), aNodeName );
742
743     if ( Graph()->IsDataStreamNode() && ( Nd->IsComputingNode() || Nd->IsFactoryNode() ) ) {
744       unsigned int i ;
745       for ( i = 0 ; i < NodeService.ServiceinDataStreamParameter.length() ; i++ ) {
746         GraphBase::InDataStreamPort * aDataStreamPort ;
747         aDataStreamPort = Nd->ComputingNode()->AddInDataStreamPort(
748 //JR 17.02.2005 Memory Leak                                         my_strdup( NodeService.ServiceinDataStreamParameter[i].Parametername ) ,
749                                          NodeService.ServiceinDataStreamParameter[i].Parametername ,
750                                          NodeService.ServiceinDataStreamParameter[i].Parametertype ,
751                                          NodeService.ServiceinDataStreamParameter[i].Parameterdependency ,
752                                          SUPERV::DataStreamParameter ) ;
753       }
754       for ( i = 0 ; i < NodeService.ServiceoutDataStreamParameter.length() ; i++ ) {
755         GraphBase::OutDataStreamPort * aDataStreamPort ;
756         aDataStreamPort = Nd->ComputingNode()->AddOutDataStreamPort(
757 //JR 17.02.2005 Memory Leak                                         my_strdup( NodeService.ServiceoutDataStreamParameter[i].Parametername ) ,
758                                          NodeService.ServiceoutDataStreamParameter[i].Parametername ,
759                                          NodeService.ServiceoutDataStreamParameter[i].Parametertype ,
760                                          NodeService.ServiceoutDataStreamParameter[i].Parameterdependency ,
761                                          SUPERV::DataStreamParameter ) ;
762       }
763     }
764
765     if ( Graph()->AddNode( Nd->ComputingNode() ) ) {
766       DateModification() ;
767       RetVal = Nd->Name() ;
768     }
769     else {
770       cdebug << "NodeName already exists." << endl ;
771     }
772   }
773   else {
774     cdebug << "ERROR NodeName is NULL or already exists." << endl ;
775   }
776 //  delete [] aNodeName ;
777   _Valid = false ;
778   if ( Nd == NULL ) {
779     cdebug_out << "GraphEditor::OutNode::AddNode : NULL" << endl;
780   }
781   else {
782     cdebug_out << "GraphEditor::OutNode::AddNode : " << Nd << " " << Nd->Name() << endl;
783   }
784   return Nd ;
785 }
786
787 bool GraphEditor::OutNode::AddLinkCoord( const char* FromNodeName ,
788                                          const char* FromServiceParameterName ,
789                                          const char* ToNodeName ,
790                                          const char* ToServiceParameterName ,
791                                          const int nXY ,
792                                          const int* X ,
793                                          const int* Y ) {
794   GraphBase::InPort * anInPort = Graph()->GetChangeInPort( ToNodeName ,
795                                                            ToServiceParameterName ) ;
796 //  cdebug << "GraphEditor::OutNode::AddLinkCoord " << ToNodeName << "( " << ToServiceParameterName
797 //         << " ) " << anInPort << " IsEndSwitch " << anInPort->IsEndSwitch() << endl ;
798   if ( anInPort ) {
799     if ( anInPort->IsEndSwitch() ) {
800 //      cdebug << "GraphEditor::OutNode::AddLinkCoord " << FromNodeName << "( " << FromServiceParameterName
801 //             << " )" << endl ;
802       return Graph()->GetChangeOutPort( FromNodeName , FromServiceParameterName )->AddCoord( nXY , X , Y ) ;
803     }
804     else {
805       return anInPort->AddCoord( nXY , X , Y ) ;
806     }
807   }
808   return false ;
809 }
810
811 bool GraphEditor::OutNode::AddLinkCoord( const char* FromNodeName ,
812                                          const char* FromServiceParameterName ,
813                                          const char* ToNodeName ,
814                                          const char* ToServiceParameterName ,
815                                          const int index ,
816                                          const int X ,
817                                          const int Y ) {
818   GraphBase::InPort * anInPort = Graph()->GetChangeInPort( ToNodeName ,
819                                                            ToServiceParameterName ) ;
820 //  cdebug << "GraphEditor::OutNode::AddLinkCoord " << ToNodeName << "( " << ToServiceParameterName
821 //         << " ) " << anInPort << " IsEndSwitch " << anInPort->IsEndSwitch() << endl ;
822   if ( anInPort ) {
823     if ( anInPort->IsEndSwitch() ) {
824 //      cdebug << "GraphEditor::OutNode::AddLinkCoord " << FromNodeName << "( " << FromServiceParameterName
825 //             << " )" << endl ;
826       return Graph()->GetChangeOutPort( FromNodeName , FromServiceParameterName )->AddCoord( index , X , Y ) ;
827     }
828     else {
829       return anInPort->AddCoord( index , X , Y ) ;
830     }
831   }
832   return false ;
833 }
834
835 bool GraphEditor::OutNode::ChangeLinkCoord( const char* FromNodeName ,
836                                             const char* FromServiceParameterName ,
837                                             const char* ToNodeName ,
838                                             const char* ToServiceParameterName ,
839                                             const int index ,
840                                             const int X ,
841                                             const int Y ) {
842   GraphBase::InPort * anInPort = Graph()->GetChangeInPort( ToNodeName ,
843                                                            ToServiceParameterName ) ;
844 //  cdebug << "GraphEditor::OutNode::ChangeLinkCoord " << ToNodeName << "( " << ToServiceParameterName
845 //         << " ) " << anInPort << " IsEndSwitch " << anInPort->IsEndSwitch() << endl ;
846   if ( anInPort ) {
847     if ( anInPort->IsEndSwitch() ) {
848 //      cdebug << "GraphEditor::OutNode::ChangeLinkCoord " << FromNodeName << "( " << FromServiceParameterName
849 //             << " )" << endl ;
850       return Graph()->GetChangeOutPort( FromNodeName , FromServiceParameterName )->ChangeCoord( index , X , Y ) ;
851     }
852     else {
853       return anInPort->ChangeCoord( index , X , Y ) ;
854     }
855   }
856   return false ;
857 }
858
859 bool GraphEditor::OutNode::RemoveLinkCoord( const char* FromNodeName ,
860                                             const char* FromServiceParameterName ,
861                                             const char* ToNodeName ,
862                                             const char* ToServiceParameterName ,
863                                             const int index ) {
864   GraphBase::InPort * anInPort = Graph()->GetChangeInPort( ToNodeName ,
865                                                            ToServiceParameterName ) ;
866 //  cdebug << "GraphEditor::OutNode::RemoveLinkCoord " << ToNodeName << "( " << ToServiceParameterName
867 //         << " ) " << anInPort << " IsEndSwitch " << anInPort->IsEndSwitch() << endl ;
868   if ( anInPort ) {
869     if ( anInPort->IsEndSwitch() ) {
870 //      cdebug << "GraphEditor::OutNode::RemoveLinkCoord " << FromNodeName << "( " << FromServiceParameterName
871 //             << " )" << endl ;
872       return Graph()->GetChangeOutPort( FromNodeName , FromServiceParameterName )->RemoveCoord( index ) ;
873     }
874     else {
875       return anInPort->RemoveCoord( index ) ;
876     }
877   }
878   return false ;
879 }
880
881 int GraphEditor::OutNode::GetLinkCoordSize( const char* FromNodeName ,
882                                             const char* FromServiceParameterName ,
883                                             const char* ToNodeName ,
884                                             const char* ToServiceParameterName ) {
885   const GraphBase::InPort * anInPort = Graph()->GetInPort( ToNodeName , ToServiceParameterName ) ;
886 //  cdebug << "GraphEditor::OutNode::GetLinkCoordSize " << ToNodeName << "( " << ToServiceParameterName
887 //         << " ) " << anInPort << " IsEndSwitch " << anInPort->IsEndSwitch() << endl ;
888   if ( anInPort ) {
889     if ( anInPort->IsEndSwitch() ) {
890 //      cdebug << "GraphEditor::OutNode::GetLinkCoordSize " << FromNodeName << "( " << FromServiceParameterName
891 //             << " )" << endl ;
892       return Graph()->GetChangeOutPort( FromNodeName , FromServiceParameterName )->GetCoord() ;
893     }
894     else {
895       return anInPort->GetCoord() ;
896     }
897   }
898   return 0 ;
899 }
900
901 bool GraphEditor::OutNode::GetLinkCoord( const char* FromNodeName ,
902                                          const char* FromServiceParameterName ,
903                                          const char* ToNodeName ,
904                                          const char* ToServiceParameterName ,
905                                          int *X , int *Y ) {
906   const GraphBase::InPort * anInPort = Graph()->GetInPort( ToNodeName , ToServiceParameterName ) ;
907 //  cdebug << "GraphEditor::OutNode::GetLinkCoord " << ToNodeName << "( " << ToServiceParameterName
908 //         << " ) " << anInPort << " IsEndSwitch " << anInPort->IsEndSwitch() << endl ;
909   if ( anInPort ) {
910     if ( anInPort->IsEndSwitch() ) {
911 //      cdebug << "GraphEditor::OutNode::GetLinkCoord " << FromNodeName << "( " << FromServiceParameterName
912 //             << " )" << endl ;
913       return Graph()->GetChangeOutPort( FromNodeName , FromServiceParameterName )->GetCoord( X , Y ) ;
914     }
915     else {
916       return anInPort->GetCoord( X , Y ) ;
917     }
918   }
919   return false ;
920 }
921
922 bool GraphEditor::OutNode::GetLinkCoord( const char* FromNodeName ,
923                                          const char* FromServiceParameterName ,
924                                          const char* ToNodeName ,
925                                          const char* ToServiceParameterName ,
926                                          const int index , long &X , long &Y ) {
927   GraphBase::InPort * anInPort = Graph()->GetChangeInPort( ToNodeName ,
928                                                            ToServiceParameterName ) ;
929 //  cdebug << "GraphEditor::OutNode::GetLinkCoord " << ToNodeName << "( " << ToServiceParameterName
930 //         << " ) " << anInPort << " IsEndSwitch " << anInPort->IsEndSwitch() << endl ;
931   if ( anInPort ) {
932     if ( anInPort->IsEndSwitch() ) {
933 //      cdebug << "GraphEditor::OutNode::GetLinkCoord " << FromNodeName << "( " << FromServiceParameterName
934 //             << " )" << endl ;
935       return Graph()->GetChangeOutPort( FromNodeName , FromServiceParameterName )->GetCoord( index , X , Y ) ;
936     }
937     else {
938       return anInPort->GetCoord( index , X , Y ) ;
939     }
940   }
941   return false ;
942 }
943
944 bool GraphEditor::OutNode::UnValid() {
945   bool RetVal = _Valid ;
946   _Valid = false ;
947   if ( Graph()->GraphMacroLevel() != 0 ) {
948     cdebug << "GraphEditor::OutNode::UnValid() GraphMacroLevel " << Graph()->GraphMacroLevel() << endl ;
949     RetVal = Valid() ;
950   }
951   return RetVal ;
952 }
953
954 //JR Optional parameter kLoopSwitch (default = true) :
955 //In some cases we do not need to check the validity of loops and switchs
956 //JR 07.07.2005 PAL9342 : that code is now in Executable() method instead of Valid() method
957 //bool GraphEditor::OutNode::Valid(bool kLoopSwitch ) {
958 bool GraphEditor::OutNode::Valid() {
959   bool RetVal = true ;
960   cdebug_in << "GraphEditor::OutNode::Valid" << endl;
961 //  if ( _Valid )
962 //    return true ;
963
964   _Executable = false ;
965
966   if ( !Graph()->CreateService() ) {
967     cdebug << "GraphEditor::OutNode::Valid ERROR _Valid " << _Valid << endl;
968     RetVal = false ;
969   }
970   
971   if ( Graph()->GraphMacroLevel() != 0 ) {
972     cdebug << "CoupledNode " << Graph()->CoupledNode() << endl ;
973     cdebug << "GraphEditor " << Graph()->CoupledNode()->GraphEditor() << endl ;
974     cdebug << "Graph " << Graph()->CoupledNode()->GraphEditor()->Graph() << endl ;
975     cdebug << "Name " << Graph()->CoupledNode()->GraphEditor()->Graph()->Name() << endl ;
976     cdebug << "Valid --> UpdateMacroPorts of " << Graph()->CoupledNodeName() << " of "
977            << Graph()->CoupledNode()->GraphEditor()->Graph()->Name() << endl ;
978     cdebug << Graph()->CoupledNode() << endl ;
979     Graph()->CoupledNode()->UpdateMacroPorts( Graph() ) ;
980     cdebug << Graph()->CoupledNode()->Name() << " Valid --> UnValid of graph "
981            << Graph()->CoupledNode()->GraphEditor()->Graph()->Name()
982            << " GraphMacroLevel " << Graph()->CoupledNode()->GraphEditor()->Graph()->GraphMacroLevel()  << endl ;
983     Graph()->CoupledNode()->GraphEditor()->UnValid() ;
984   }
985
986 //JR 07.07.2005 PAL9342 : that code is now in Executable() method instead of Valid() method
987 #if 0
988   int SubStreamGraphsNumber = 0 ;
989   if ( !Graph()->Sort( SubStreamGraphsNumber ) ) {
990     cdebug_out << "This DataFlow is not valid." << endl ;
991     RetVal = false ;
992   }
993   if ( Graph()->IsDataStreamNode() ) {
994     StreamGraph()->SubStreamGraphsNumber( SubStreamGraphsNumber ) ;
995   }
996
997   Graph()->InLineServices() ;
998
999   if ( kLoopSwitch ) {
1000     if ( !Graph()->ValidLoops() ) {
1001       cdebug_out << "This DataFlow have not valid Loops." << endl ;
1002       RetVal = false ;
1003     }
1004     if ( !Graph()->ValidSwitchs() ) {
1005       cdebug_out << "This DataFlow have not valid Switchs." << endl ;
1006       RetVal = false ;
1007     }
1008   }
1009   
1010   Graph()->ComputingNodes() ;
1011 #endif
1012
1013   if ( RetVal ) {
1014     _Valid = true ;
1015   }
1016
1017   cdebug_out << "GraphEditor::OutNode::Valid " << _Valid << " RetVal " << RetVal << endl;
1018   return RetVal ;
1019 }
1020
1021 bool GraphEditor::OutNode::Executable() {
1022   cdebug_in << "GraphEditor::OutNode::Executable" << endl;
1023   bool RetVal = true ;
1024   bool NewLink ;
1025 // LinkLoopNodes manage input values of LoopNodes and EndLoopNodes
1026   if ( Graph()->LinkLoopNodes( NewLink ) ) {
1027     if ( NewLink ) {
1028       _Valid = false ;
1029       RetVal = false ;
1030     }
1031   }
1032   else {
1033     cdebug << "Editor::OutNode::Executable This DataFlow is not executable(LinkLoopNodes)." << endl ;
1034     _Executable = false ;
1035     RetVal = false ;
1036   }
1037   if ( !IsValid() ) {
1038     Valid() ;
1039   }
1040   if ( !IsValid() ) {
1041     RetVal = false ;
1042   }
1043
1044 //JR 07.07.2005 PAL9342 : that code is now in Executable() method instead of Valid() method
1045   int SubStreamGraphsNumber = 0 ;
1046   if ( !Graph()->Sort( SubStreamGraphsNumber ) ) {
1047     cdebug << "Editor::OutNode::Executable This DataFlow is not valid(Sort)." << endl ;
1048     RetVal = false ;
1049   }
1050   if ( Graph()->IsDataStreamNode() ) {
1051     StreamGraph()->SubStreamGraphsNumber( SubStreamGraphsNumber ) ;
1052   }
1053
1054   Graph()->InLineServices() ;
1055
1056 //  if ( kLoopSwitch ) {
1057     if ( !Graph()->ValidLoops() ) {
1058       cdebug << "Editor::OutNode::Executable This DataFlow have not valid Loops(ValidLoops)." << endl ;
1059       RetVal = false ;
1060     }
1061     if ( !Graph()->ValidSwitchs() ) {
1062       cdebug << "Editor::OutNode::Executable This DataFlow have not valid Switchs(ValidSwitchs)." << endl ;
1063       RetVal = false ;
1064     }
1065 //  }
1066   
1067   Graph()->ComputingNodes() ;
1068
1069   if ( Graph()->DataServerNodes() )
1070     _Executable = true ;
1071   else {
1072     cdebug << "Editor::OutNode::Executable This DataFlow is not executable(DataServerNodes)." << endl ;
1073     _Executable = false ;
1074     RetVal = false ;
1075   }
1076
1077   if ( _Executable && Graph()->IsDataStreamNode() ) {
1078     StreamGraph()->CreateStreamTopology( "/tmp/" ) ;
1079   }
1080
1081   // asv : 13.12.04 : introducing check for compatibility of linked ports' types.
1082   if ( !IsLinksCompatible() ) {
1083     _Executable = false;
1084     RetVal = false ;
1085   }    
1086
1087   cdebug_out << "GraphEditor::OutNode::Executable _Executable " << _Executable << " RetVal " << RetVal
1088              << endl;
1089   return RetVal ;
1090 }
1091
1092 //JR 30.03.2005const CORBA::Any *GraphEditor::OutNode::GetInData(
1093 const CORBA::Any GraphEditor::OutNode::GetInData(
1094                               const char * ToNodeName ,
1095                               const char * ToParameterName ) {
1096 //  cdebug_in << "GraphEditor::OutNode::GetInData " << ToNodeName
1097 //            << " " << ToParameterName << endl ;
1098 //JR 30.03.2005  const CORBA::Any * retdata = Graph()->PortInData( ToNodeName , ToParameterName ) ;
1099   const CORBA::Any retdata = Graph()->PortInData( ToNodeName , ToParameterName ) ;
1100 //  cdebug_out << "GraphEditor::OutNode::GetInData" << endl ;
1101   return retdata ;
1102 }
1103
1104 //JR 30.03.2005const CORBA::Any *GraphEditor::OutNode::GetOutData(
1105 const CORBA::Any GraphEditor::OutNode::GetOutData(
1106                               const char * FromNodeName ,
1107                               const char * FromParameterName ) {
1108 //  cdebug_in << "GraphEditor::OutNode::GetOutData " << FromNodeName
1109 //            << " " << FromParameterName << endl ;
1110 //JR 30.03.2005  const CORBA::Any * retdata = Graph()->PortOutData( FromNodeName , FromParameterName ) ;
1111   const CORBA::Any retdata = Graph()->PortOutData( FromNodeName , FromParameterName ) ;
1112 //  cdebug_out << "GraphEditor::OutNode::GetOutData" << endl ;
1113   return retdata ;
1114 }
1115
1116 //bool GraphEditor::OutNode::LinkSaveXML( ostream &f , char *Tabs ,
1117 bool GraphEditor::OutNode::LinkSaveXML( QDomDocument & Graph , QDomElement & link ,
1118                                         GraphBase::SLink aLink ,
1119                                         bool wdata ) const {
1120   cdebug_in << "GraphEditor::OutNode::LinkSaveXML " << aLink.FromNodeName
1121             << "(" << aLink.FromServiceParameterName << ") --> "
1122             << aLink.ToNodeName << "(" << aLink.ToServiceParameterName << ")" << endl ;
1123   QDomElement fromnodename = Graph.createElement( "fromnode-name" ) ;
1124   QDomText aField ;
1125   if ( strlen( aLink.FromNodeName.c_str() ) ) {
1126 //    f << Tabs << "<fromnode-name>" << aLink.FromNodeName.c_str()
1127 //      << "</fromnode-name>" << endl ;
1128     aField = Graph.createTextNode( aLink.FromNodeName.c_str() ) ;
1129   }
1130   else {
1131 //    f << Tabs << "<fromnode-name>?</fromnode-name>" << endl ;
1132     aField = Graph.createTextNode( "?" ) ;
1133   }
1134   link.appendChild( fromnodename ) ;
1135   fromnodename.appendChild( aField ) ;
1136
1137 //  f << Tabs << "<fromserviceparameter-name>"
1138 //    << aLink.FromServiceParameterName.c_str() << "</fromserviceparameter-name>"
1139 //    << endl ;
1140   QDomElement fromserviceparametername = Graph.createElement( "fromserviceparameter-name" ) ;
1141   aField = Graph.createTextNode( aLink.FromServiceParameterName.c_str() ) ;
1142   link.appendChild( fromserviceparametername ) ;
1143   fromserviceparametername.appendChild( aField ) ;
1144
1145   QDomElement tonodename = Graph.createElement( "tonode-name" ) ;
1146   if ( strlen( aLink.ToNodeName.c_str() ) ) {
1147 //    f << Tabs << "<tonode-name>" << aLink.ToNodeName.c_str()
1148 //      << "</tonode-name>" << endl ;
1149     aField = Graph.createTextNode( aLink.ToNodeName.c_str() ) ;
1150   }
1151   else {
1152 //    f << Tabs << "<tonode-name>?</tonode-name>" << endl ;
1153     aField = Graph.createTextNode( "?" ) ;
1154   }
1155   link.appendChild( tonodename ) ;
1156   tonodename.appendChild( aField ) ;
1157
1158 //  f << Tabs << "<toserviceparameter-name>"
1159 //    << aLink.ToServiceParameterName.c_str() << "</toserviceparameter-name>"
1160 //    << endl ;
1161   QDomElement toserviceparametername = Graph.createElement( "toserviceparameter-name" ) ;
1162   aField = Graph.createTextNode( aLink.ToServiceParameterName.c_str() ) ;
1163   link.appendChild( toserviceparametername ) ;
1164   toserviceparametername.appendChild( aField ) ;
1165
1166   if ( wdata ) {
1167 //    f << Tabs << "<data-value>" << endl ;
1168     QDomElement datavalue = Graph.createElement( "data-value" ) ;
1169     link.appendChild( datavalue ) ;
1170 //    f << Tabs << "    <value-type>" << aLink.aLinkValue.type()->kind()
1171 //      << "</value-type>" << endl ;
1172     QDomElement valuetype = Graph.createElement( "value-type" ) ;
1173     QString aKind ;
1174     aKind = aKind.setNum( aLink.aLinkValue.type()->kind() ) ;
1175     aField = Graph.createTextNode( aKind ) ;
1176     datavalue.appendChild( valuetype ) ;
1177     valuetype.appendChild( aField ) ;
1178     switch (aLink.aLinkValue.type()->kind()) {
1179       case CORBA::tk_string: {
1180         char* retstr ;
1181         aLink.aLinkValue >>= retstr;
1182 //        f << Tabs << "        <value>" << retstr << "</value>" << endl ;
1183         QDomElement value = Graph.createElement( "value" ) ;
1184 //PAL9133 Debug JR : accept void strings
1185         QDomCDATASection aCDATA ;
1186         int i ;
1187         for ( i = 0 ; i < (int ) strlen( retstr ) ; i++ ) {
1188           if ( retstr[ i ] != ' ' ) {
1189             break ;
1190           }
1191         }
1192         if ( i == (int ) strlen( retstr ) ) {
1193           aCDATA = Graph.createCDATASection( "?" ) ;
1194         }
1195         else {
1196           aCDATA = Graph.createCDATASection( retstr ) ;
1197         }
1198 //        aField = Graph.createTextNode( retstr ) ;
1199         datavalue.appendChild( value ) ;
1200 //        datavalue.appendChild( value ) ;
1201         value.appendChild( aCDATA ) ;
1202 //        MESSAGE( "ToString( string ) " << retstr );
1203         break ;
1204       }
1205       case CORBA::tk_double: {
1206         double d;
1207         aLink.aLinkValue >>= d;
1208 //        f << Tabs << "        <value>" << d << "</value>" << endl ;
1209         QDomElement value = Graph.createElement( "value" ) ;
1210         QString aKind ;
1211         aKind = aKind.setNum( d ) ;
1212         aField = Graph.createTextNode( aKind ) ;
1213         datavalue.appendChild( value ) ;
1214         value.appendChild( aField ) ;
1215 //        MESSAGE( "ToString( double ) " << d );
1216         break ;
1217       }
1218       case CORBA::tk_long: {
1219         long l;
1220         aLink.aLinkValue >>= l;
1221 //        f << Tabs << "        <value>" << l << "</value>" << endl ;
1222         QDomElement value = Graph.createElement( "value" ) ;
1223         QString aKind ;
1224         aKind = aKind.setNum( l ) ;
1225         aField = Graph.createTextNode( aKind ) ;
1226         datavalue.appendChild( value ) ;
1227         value.appendChild( aField ) ;
1228 //        MESSAGE( "ToString( long ) " << l );
1229         break ;
1230       }
1231       case CORBA::tk_objref: {
1232         char* retstr ;
1233         CORBA::Object_ptr obj ;
1234         aLink.aLinkValue >>= obj ;
1235         retstr = _Orb->object_to_string(obj );
1236 //        f << Tabs << "        <value>" << retstr << "</value>" << endl ;
1237         QDomElement value = Graph.createElement( "value" ) ;
1238         aField = Graph.createTextNode( retstr ) ;
1239         datavalue.appendChild( value ) ;
1240         value.appendChild( aField ) ;
1241 //        MESSAGE( "ToString( object ) " << retstr );
1242         break ;
1243       }
1244       default: {
1245 //        f << Tabs << "        <value>?</value>" << endl ;
1246         QDomElement value = Graph.createElement( "value" ) ;
1247         aField = Graph.createTextNode( "?" ) ;
1248         datavalue.appendChild( value ) ;
1249         value.appendChild( aField ) ;
1250 //        MESSAGE( "Unknown CORBA::Any Type" );
1251         break ;
1252       }
1253     }
1254 //    f << Tabs << "</data-value>" << endl ;
1255   }
1256 //  f << Tabs << "<coord-list>" << endl ;
1257   QDomElement coordlist = Graph.createElement( "coord-list" ) ;
1258   link.appendChild( coordlist ) ;
1259   
1260   int i ;
1261   for ( i = 0 ; i < (int ) aLink.aListOfCoords.size() ; i++ ) {
1262 //    f << Tabs << "    <coord>" << endl ;
1263     QDomElement coord = Graph.createElement( "coord" ) ;
1264     coordlist.appendChild( coord ) ;
1265 //    f << Tabs << "            <x>" << aLink.aListOfCoords[ i ].theX << "</x>" << endl ;
1266     QDomElement x = Graph.createElement( "x" ) ;
1267     QString ax ;
1268     ax = ax.setNum( aLink.aListOfCoords[ i ].theX ) ;
1269     aField = Graph.createTextNode( ax ) ;
1270     coord.appendChild( x ) ;
1271     x.appendChild( aField ) ;    
1272 //    f << Tabs << "            <y>" << aLink.aListOfCoords[ i ].theY << "</y>" << endl ;
1273     QDomElement y = Graph.createElement( "y" ) ;
1274     QString ay ;
1275     ay = ay.setNum( aLink.aListOfCoords[ i ].theY ) ;
1276     aField = Graph.createTextNode( ay ) ;
1277     coord.appendChild( y ) ;
1278     y.appendChild( aField ) ;    
1279 //    f << Tabs << "    </coord>" << endl ;
1280   }
1281 //  f << Tabs << "</coord-list>" << endl ;
1282   cdebug_out << "GraphEditor::OutNode::LinkSaveXML " << aLink.FromNodeName
1283              << "(" << aLink.FromServiceParameterName << ") --> "
1284              << aLink.ToNodeName << "(" << aLink.ToServiceParameterName << ")"
1285              << endl ;
1286   return true ;
1287 }
1288
1289 bool GraphEditor::OutNode::LinkSavePY( ostream &f , const char * aGraphName ,
1290                                        GraphBase::SLink aLink ,
1291                                        bool fromparam , bool toparam ,
1292                                        bool wdata ) const {
1293   if ( !wdata ) {
1294 //    if ( intervar ) {
1295 //      f << "O" << aLink.FromNodeName.c_str() << aLink.FromServiceParameterName.c_str()
1296 //        << " = "
1297 //        << aLink.FromNodeName.c_str() << ".GetOutPort( '"
1298 //        << aLink.FromServiceParameterName.c_str()
1299 //        << "' )" << endl ;
1300 //    }
1301     f << "    " << "L" << aLink.FromNodeName.c_str() << aLink.FromServiceParameterName.c_str()
1302       << aLink.ToNodeName.c_str() << aLink.ToServiceParameterName.c_str() ;
1303     if ( ((GraphBase::Graph *) Graph())->GetChangeGraphNode( aLink.FromNodeName.c_str() )->GetChangeOutPort( aLink.FromServiceParameterName.c_str() )->IsDataStream() ) {
1304       f << " = " << aGraphName << ".StreamLink( " ;
1305     }
1306     else {
1307       f << " = " << aGraphName << ".Link( " ;
1308     }
1309 //    if ( !fromparam ) {
1310       f << "O" ;
1311 //    }
1312     f << aLink.FromNodeName.c_str() << aLink.FromServiceParameterName.c_str() << " , " ;
1313 //    if ( !toparam ) {
1314       f << "I" ;
1315 //    }
1316     f << aLink.ToNodeName.c_str() << aLink.ToServiceParameterName.c_str() << " )" << endl ;
1317   }
1318   else {
1319     f << "    " << "I"<< aLink.ToNodeName.c_str() << aLink.ToServiceParameterName.c_str()
1320 //      << " = " << aLink.ToNodeName.c_str() << ".Input( '"
1321 //      << aLink.ToServiceParameterName.c_str() << "' , " ;
1322       << ".Input( " ;
1323     switch (aLink.aLinkValue.type()->kind()) {
1324       case CORBA::tk_string: {
1325         char* retstr ;
1326         aLink.aLinkValue >>= retstr;
1327         f << "'" << retstr << "'" ;
1328         break ;
1329       }
1330       case CORBA::tk_double: {
1331         double d;
1332         aLink.aLinkValue >>= d;
1333         f << d ;
1334         break ;
1335       }
1336       case CORBA::tk_long: {
1337         long l;
1338         aLink.aLinkValue >>= l;
1339         f << l ;
1340         break ;
1341       }
1342       case CORBA::tk_objref: {
1343         char* retstr ;
1344         CORBA::Object_ptr obj ;
1345         aLink.aLinkValue >>= obj ;
1346         retstr = _Orb->object_to_string(obj );
1347         f << "'" << retstr << "'" ;
1348         break ;
1349       }
1350       default: {
1351         f << "?" ;
1352 //        MESSAGE( "Unknown CORBA::Any Type" );
1353         break ;
1354       }
1355     }
1356     f << " )" << endl ;
1357   }
1358   int i ;
1359   for ( i = 0 ; i < (int ) aLink.aListOfCoords.size() ; i++ ) {
1360     f << "    " << "L" << aLink.FromNodeName.c_str() << aLink.FromServiceParameterName.c_str()
1361       << aLink.ToNodeName.c_str() << aLink.ToServiceParameterName.c_str() << ".AddCoord( " << i+1 << " , "
1362       << aLink.aListOfCoords[ i ].theX << " , "
1363       << aLink.aListOfCoords[ i ].theY << " )" << endl ;
1364   }
1365   return true ;
1366 }
1367
1368 //bool GraphEditor::OutNode::SaveXML(ostream & f ) {
1369 bool GraphEditor::OutNode::SaveXML( ostream & f , QDomDocument & GraphQDom ,
1370                                     bool aSuperGraph , QDomElement & supergraph ) {
1371   cdebug_in << "OutNode::SaveXML( ostream & f , QDomDocument & , " << aSuperGraph << " , QDomElement & ) "
1372             << Graph()->Name() << endl ;
1373   int i ;
1374
1375   QDomElement dataflow ;
1376   if ( aSuperGraph ) {
1377     QString SuperGraph("SuperGraph") ;
1378     GraphQDom = QDomDocument(SuperGraph) ;
1379
1380     supergraph = GraphQDom.createElement( "supergraph" ) ;
1381     GraphQDom.appendChild( supergraph ) ;
1382
1383     dataflow = GraphQDom.createElement( "dataflow" ) ;
1384     supergraph.appendChild( dataflow ) ;
1385   }
1386   else {
1387 //    QString Dataflow("Dataflow") ;
1388 //    GraphQDom = QDomDocument(Dataflow) ;
1389
1390     dataflow = GraphQDom.createElement( "dataflow" ) ;
1391     supergraph.appendChild( dataflow ) ;
1392   }
1393
1394   QDomElement info = GraphQDom.createElement( "info-list" ) ;
1395   dataflow.appendChild( info ) ;
1396
1397   Graph()->SaveXML( GraphQDom , info , 0 , 0 ) ;
1398
1399   QDomElement nodelist = GraphQDom.createElement( "node-list" ) ;
1400   dataflow.appendChild( nodelist ) ;
1401   for ( i = 0 ; i < Graph()->GraphNodesSize() ; i++ ) {
1402 //      f << "          <node>" << endl ;
1403       if ( Graph()->GraphNodes( i )->IsComputingNode() ) {
1404 //        ((GraphBase::ComputingNode *)GraphNodes( i ))->SaveXML( f ,
1405 //                    "                 " ,
1406         ((GraphBase::ComputingNode *) Graph()->GraphNodes( i ))->SaveXML( GraphQDom , nodelist ,
1407                     Graph()->GraphNodes( i )->XCoordinate() ,
1408                     Graph()->GraphNodes( i )->YCoordinate() ) ;
1409       }
1410       else if ( Graph()->GraphNodes( i )->IsFactoryNode() ) {
1411 //        ((GraphBase::FactoryNode * ) GraphNodes( i ))->SaveXML( f ,
1412 //                    "                 " ,
1413         ((GraphBase::FactoryNode * ) Graph()->GraphNodes( i ))->SaveXML( GraphQDom , nodelist ,
1414                     Graph()->GraphNodes( i )->XCoordinate() ,
1415                     Graph()->GraphNodes( i )->YCoordinate() ) ;
1416       }
1417       else if ( Graph()->GraphNodes( i )->IsInLineNode()  ) {
1418 //        ((GraphBase::InLineNode * ) GraphNodes( i ))->SaveXML( f ,
1419 //                    "                 " ,
1420         ((GraphBase::InLineNode * ) Graph()->GraphNodes( i ))->SaveXML( GraphQDom , nodelist ,
1421                     Graph()->GraphNodes( i )->XCoordinate() ,
1422                     Graph()->GraphNodes( i )->YCoordinate() ) ;
1423       }
1424       else if ( Graph()->GraphNodes( i )->IsMacroNode() ) {
1425 //        ((GraphBase::InLineNode * ) GraphNodes( i ))->SaveXML( f ,
1426 //                    "                 " ,
1427         ((GraphBase::GOTONode * ) Graph()->GraphNodes( i ))->SaveXML( GraphQDom , nodelist ,
1428                     Graph()->GraphNodes( i )->XCoordinate() ,
1429                     Graph()->GraphNodes( i )->YCoordinate() ) ;
1430       }
1431       else if ( Graph()->GraphNodes( i )->IsGOTONode() ) {
1432 //        ((GraphBase::GOTONode * ) GraphNodes( i ))->SaveXML( f ,
1433 //                    "                 " ,
1434         ((GraphBase::GOTONode * ) Graph()->GraphNodes( i ))->SaveXML( GraphQDom , nodelist ,
1435                     Graph()->GraphNodes( i )->XCoordinate() ,
1436                     Graph()->GraphNodes( i )->YCoordinate() ) ;
1437       }
1438       else if ( Graph()->GraphNodes( i )->IsLoopNode() ) {
1439 //        ((GraphBase::LoopNode * ) GraphNodes( i ))->SaveXML( f ,
1440 //                    "                 " ,
1441         ((GraphBase::LoopNode * ) Graph()->GraphNodes( i ))->SaveXML( GraphQDom , nodelist ,
1442                     Graph()->GraphNodes( i )->XCoordinate() ,
1443                     Graph()->GraphNodes( i )->YCoordinate() ) ;
1444       }
1445       else if ( Graph()->GraphNodes( i )->IsEndLoopNode() ) {
1446 //        ((GraphBase::EndOfLoopNode * ) GraphNodes( i ))->SaveXML( f ,
1447 //                    "                 " ,
1448         ((GraphBase::EndOfLoopNode * ) Graph()->GraphNodes( i ))->SaveXML( GraphQDom , nodelist ,
1449                     Graph()->GraphNodes( i )->XCoordinate() ,
1450                     Graph()->GraphNodes( i )->YCoordinate() ) ;
1451       }
1452       else if ( Graph()->GraphNodes( i )->IsSwitchNode() ) {
1453 //        ((GraphBase::SwitchNode * ) GraphNodes( i ))->SaveXML( f ,
1454 //                    "                 " ,
1455         ((GraphBase::SwitchNode * ) Graph()->GraphNodes( i ))->SaveXML( GraphQDom , nodelist ,
1456                     Graph()->GraphNodes( i )->XCoordinate() ,
1457                     Graph()->GraphNodes( i )->YCoordinate() ) ;
1458       }
1459       else if ( Graph()->GraphNodes( i )->IsEndSwitchNode() ) {
1460 //        ((GraphBase::EndOfSwitchNode * ) GraphNodes( i ))->SaveXML( f ,
1461 //                    "                 " ,
1462         ((GraphBase::EndOfSwitchNode * ) Graph()->GraphNodes( i ))->SaveXML( GraphQDom , nodelist ,
1463                     Graph()->GraphNodes( i )->XCoordinate() ,
1464                     Graph()->GraphNodes( i )->YCoordinate() ) ;
1465       }
1466 //      f << "          </node>" << endl ;
1467 //    }
1468   }
1469 //  f << "      </node-list>" << endl << endl ;
1470
1471 //  f << "      <link-list>" << endl ;
1472   QDomElement linklist = GraphQDom.createElement( "link-list" ) ;
1473   dataflow.appendChild( linklist ) ;
1474   const GraphBase::ListOfSLinks * Links = Graph()->GetLinks( true ) ;
1475   for ( i = 0 ; i < (int ) Links->size() ; i++ ) {
1476 //    f << "            <link>" << endl ;
1477     QDomElement link = GraphQDom.createElement( "link" ) ;
1478     linklist.appendChild( link ) ;
1479 //    LinkSaveXML( f , "                        " , (*Links)[ i ] , false ) ;
1480     LinkSaveXML( GraphQDom , link , (*Links)[ i ] , false ) ;
1481 //    f << "            </link>" << endl ;
1482   }
1483 //  f << "      </link-list>" << endl << endl ;
1484
1485 //  f << "      <data-list>" << endl ;
1486   QDomElement datalist = GraphQDom.createElement( "data-list" ) ;
1487   dataflow.appendChild( datalist ) ;
1488   if ( Graph()->GraphMacroLevel() == 0 ) {
1489     const GraphBase::ListOfSLinks * Datas = Graph()->GetDatas() ;
1490     for ( i = 0 ; i < (int ) Datas->size() ; i++ ) {
1491 //    f << "            <data>" << endl ;
1492       QDomElement data = GraphQDom.createElement( "data" ) ;
1493       datalist.appendChild( data ) ;
1494 //    LinkSaveXML( f , "                        " , (*Datas)[ i ] , true ) ;
1495       LinkSaveXML( GraphQDom , data , (*Datas)[ i ] , true ) ;
1496 //    f << "            </data>" << endl ;
1497     }
1498   }
1499
1500   for ( i = 0 ; i < Graph()->GraphNodesSize() ; i++ ) {
1501     if ( Graph()->GraphNodes( i )->IsMacroNode() ) {
1502       GraphBase::GOTONode * aMacroNode = (GraphBase::GOTONode * ) Graph()->GraphNodes( i ) ;
1503       GraphBase::Graph * aMacroGraph = (GraphBase::Graph * ) aMacroNode->CoupledNode() ;
1504       cdebug << "OutNode::SaveXML ---> OutNode::SaveXML( ostream & f , QDomDocument & , false "
1505              << " , QDomElement & ) MacroGraph " << aMacroGraph->Name() << endl ;
1506       if ( !aMacroGraph->GraphEditor()->SaveXML( f , GraphQDom , false , supergraph ) ) {
1507         return false ;
1508       cdebug << "OutNode::SaveXML MacroGraph "<< aMacroGraph->Name() << " done" << endl ;
1509       }
1510     }
1511   }
1512
1513   cdebug_out << "OutNode::SaveXML( ostream & f , QDomDocument & , " << aSuperGraph << " , QDomElement & ) "
1514              << Graph()->Name() << endl ;
1515
1516   return true ;
1517 }
1518
1519 bool GraphEditor::OutNode::SavePY( ostream & f , bool importSuperV ) {
1520   int i ;
1521   int j ;
1522   const GraphBase::ListOfSLinks * Links ;
1523   if ( importSuperV ) {
1524     f << endl << "# Generated python file of Graph " << Graph()->Name() << endl << endl ;
1525
1526     f << "from SuperV import *" << endl << endl ;
1527   }
1528
1529   f << "# Graph creation of " << Graph()->Name() << endl ;
1530   f << "def Def" << Graph()->Name() << "() :" << endl ;
1531   Graph()->SavePY( f , Graph()->Name() , 0 , 0 ) ;
1532
1533   f << "    " << endl << "    " << "# Creation of Factory Nodes" << endl ;
1534   for ( i = 0 ; i < Graph()->GraphNodesSize() ; i++ ) {
1535     if ( Graph()->GraphNodes( i )->IsFactoryNode() ) {
1536       f << "    " << endl ;
1537       ((GraphBase::FactoryNode * ) Graph()->GraphNodes( i ))->SavePY( f , Graph()->Name() ,
1538                                                                       Graph()->GraphNodes( i )->XCoordinate() ,
1539                                                                       Graph()->GraphNodes( i )->YCoordinate() ) ;
1540     }
1541   }
1542
1543   bool first = true ;
1544   for ( i = 0 ; i < Graph()->GraphNodesSize() ; i++ ) {
1545     if ( Graph()->GraphNodes( i )->IsComputingNode() ) {
1546       if ( first ) {
1547         f << "    " << endl << "    " << "# Creation of Computing Nodes" << endl ;
1548         first = false ;
1549       }
1550       else {
1551         f << "    " << endl ;
1552       }
1553       ((GraphBase::ComputingNode * ) Graph()->GraphNodes( i ))->SavePY( f , Graph()->Name() ,
1554                                                                         Graph()->GraphNodes( i )->XCoordinate() ,
1555                                                                         Graph()->GraphNodes( i )->YCoordinate() ) ;
1556     }
1557   }
1558
1559   first = true ;
1560   for ( i = 0 ; i < Graph()->GraphNodesSize() ; i++ ) {
1561     if ( Graph()->GraphNodes( i )->IsInLineNode() ) {
1562       if ( first ) {
1563         f << "    " << endl << "    " << "# Creation of InLine Nodes" << endl ;
1564         first = false ;
1565       }
1566       else {
1567         f << "    " << endl ;
1568       }
1569       ((GraphBase::InLineNode * ) Graph()->GraphNodes( i ))->SavePY( f , Graph()->Name() ,
1570                                                                      Graph()->GraphNodes( i )->XCoordinate() ,
1571                                                                      Graph()->GraphNodes( i )->YCoordinate() ) ;
1572     }
1573   }
1574
1575   first = true ;
1576   for ( i = 0 ; i < Graph()->GraphNodesSize() ; i++ ) {
1577     if ( Graph()->GraphNodes( i )->IsLoopNode() ) {
1578       if ( first ) {
1579         f << "    " << endl << "    " << "# Creation of Loop Nodes" << endl ;
1580         first = false ;
1581       }
1582       else {
1583         f << "    " << endl ;
1584       }
1585       ((GraphBase::LoopNode * ) Graph()->GraphNodes( i ))->SavePY( f , Graph()->Name() ,
1586                                                                    Graph()->GraphNodes( i )->XCoordinate() ,
1587                                                                    Graph()->GraphNodes( i )->YCoordinate() ) ;
1588     }
1589   }
1590
1591   first = true ;
1592   for ( i = 0 ; i < Graph()->GraphNodesSize() ; i++ ) {
1593     if ( Graph()->GraphNodes( i )->IsSwitchNode() ) {
1594       if ( first ) {
1595         f << "    " << endl << "    " << "# Creation of Switch Nodes" << endl ;
1596         first = false ;
1597       }
1598       else {
1599         f << "    " << endl ;
1600       }
1601       ((GraphBase::SwitchNode * ) Graph()->GraphNodes( i ))->SavePY( f , Graph()->Name() ,
1602                                                                      Graph()->GraphNodes( i )->XCoordinate() ,
1603                                                                      Graph()->GraphNodes( i )->YCoordinate() ) ;
1604     }
1605   }
1606
1607   first = true ;
1608   for ( i = 0 ; i < Graph()->GraphNodesSize() ; i++ ) {
1609     if ( Graph()->GraphNodes( i )->IsGOTONode() ) {
1610       if ( first ) {
1611         f << "    " << endl << "    " << "# Creation of GOTO Nodes" << endl ;
1612         first = false ;
1613       }
1614       else {
1615         f << "    " << endl ;
1616       }
1617       ((GraphBase::GOTONode * ) Graph()->GraphNodes( i ))->SavePY( f , Graph()->Name() ,
1618                                                                    Graph()->GraphNodes( i )->XCoordinate() ,
1619                                                                    Graph()->GraphNodes( i )->YCoordinate() ) ;
1620     }
1621   }
1622
1623   first = true ;
1624   for ( i = 0 ; i < Graph()->GraphNodesSize() ; i++ ) {
1625     if ( Graph()->GraphNodes( i )->IsMacroNode() ) {
1626       if ( first ) {
1627         f << "    " << endl << "    " << "# Creation of Macro Nodes" << endl ;
1628         first = false ;
1629       }
1630       else {
1631         f << "    " << endl ;
1632       }
1633       ((GraphBase::GOTONode * ) Graph()->GraphNodes( i ))->SavePY( f , Graph()->Name() ,
1634                                                                    Graph()->GraphNodes( i )->XCoordinate() ,
1635                                                                    Graph()->GraphNodes( i )->YCoordinate() ) ;
1636     }
1637   }
1638
1639   Links = Graph()->GetLinks() ;
1640 //  bool intervar ;
1641 //  map< string , int > aMapOfOutPorts ;
1642   first = true ;
1643   for ( i = 0 ; i < Graph()->GraphNodesSize() ; i++ ) {
1644     for ( j = 0 ; j < (int ) Links->size() ; j++ ) {
1645       if ( !strcmp( Graph()->GraphNodes( i )->Name() , (*Links)[ j ].FromNodeName.c_str() ) ) {
1646         if ( first ) {
1647           f << "    " << endl
1648             << "    " << "# Creation of Links"
1649             << endl ;
1650           first = false ;
1651         }
1652         else {
1653           f << "    " << endl ;
1654         }
1655 //        char * NodePort = new char [ strlen( (*Links)[ j ].FromNodeName.c_str() ) +
1656 //                                     strlen( (*Links)[ j ].FromServiceParameterName.c_str() ) + 1 ] ;
1657 //        strcpy( NodePort , (*Links)[ j ].FromNodeName.c_str() ) ;
1658 //        strcat( NodePort , (*Links)[ j ].FromServiceParameterName.c_str() ) ;
1659 //        if ( aMapOfOutPorts[ NodePort ] == 0 ) {
1660 //          aMapOfOutPorts[ NodePort ] = j + 1 ;
1661 //          intervar = true ;
1662 //        }
1663 //        else {
1664 //          intervar = false ;
1665 //        }
1666         bool fromparam = false ;
1667         if ( Graph()->GraphNodes( i )->GetOutPort( (*Links)[ j ].FromServiceParameterName.c_str() )->IsParam() ) {
1668           fromparam = true ;
1669         }
1670         bool toparam = false ;
1671         if ( Graph()->GetChangeGraphNode( (*Links)[ j ].ToNodeName.c_str() )->GetInPort( (*Links)[ j ].ToServiceParameterName.c_str() )->IsParam() ) {
1672           toparam = true ;
1673         }
1674         LinkSavePY( f , Graph()->Name() , (*Links)[ j ] , fromparam , toparam , false ) ;
1675 //        delete [] NodePort ;
1676       }
1677     }
1678   }
1679
1680   if ( Graph()->GraphMacroLevel() == 0 ) {
1681     const GraphBase::ListOfSLinks * Datas = Graph()->GetDatas() ;
1682     first = true ;
1683     for ( i = 0 ; i < (int ) Datas->size() ; i++ ) {
1684       if ( first ) {
1685         f << "    " << endl << "    " << "# Input datas" << endl ;
1686         first = false ;
1687       }
1688       bool fromparam = true ;
1689       bool toparam = true ;
1690       LinkSavePY( f , Graph()->Name() , (*Datas)[ i ] , fromparam , toparam , true ) ;
1691     }
1692   }
1693
1694   first = true ;
1695   const SALOME_ModuleCatalog::ListOfServicesParameter ListOfInParam = Graph()->ServiceInParameter() ;
1696   for ( i = 0 ; i < (int ) ListOfInParam.length() ; i++ ) {
1697     string _aParam = CORBA::string_dup(ListOfInParam[ i ].Parametername) ;
1698     const char * aParam = _aParam.c_str() ;
1699     char * aNodeName ;
1700     char * aPortName ;
1701     int j ;
1702     for ( j = 0 ; j < (int ) strlen( aParam ) ; j++ ) {
1703 //      if ( aParam[ j ] == '\\' ) {
1704       if ( aParam[ j ] == '_' && aParam[ j+1 ] == '_' ) {
1705         aNodeName = new char[ j+1 ] ;
1706         strncpy( aNodeName , aParam , j ) ;
1707         aNodeName[ j ] = '\0' ;
1708         aPortName = new char[ strlen( aParam ) - j-1 ] ;
1709         strncpy( aPortName , &aParam[ j+2 ] , strlen( aParam ) - j-1 ) ;
1710         break ;
1711       }
1712     }
1713     const GraphBase::InPort * anInPort = Graph()->GetChangeGraphNode( aNodeName )->GetInPort( aPortName ) ;
1714     if ( !anInPort->IsDataConnected() ) {
1715       if ( first ) {
1716         f << "    " << endl << "    " << "# Input Ports of the graph" << endl ;
1717         first = false ;
1718       }
1719       f << "    " << "#I" << aNodeName << aPortName << " = " << aNodeName << ".GetInPort( '"
1720         << aPortName << "' )" << endl ;
1721     }
1722     delete [] aNodeName ;
1723     delete [] aPortName ;
1724   }
1725
1726   f << "    " << endl << "    # Output Ports of the graph" << endl ;
1727   const SALOME_ModuleCatalog::ListOfServicesParameter ListOfOutParam = Graph()->ServiceOutParameter() ;
1728   for ( i = 0 ; i < (int ) ListOfOutParam.length() ; i++ ) {
1729     string _aParam = CORBA::string_dup(ListOfOutParam[ i ].Parametername) ;
1730     const char * aParam = _aParam.c_str() ;
1731     char * aNodeName ;
1732     char * aPortName ;
1733     int j ;
1734     for ( j = 0 ; j < (int ) strlen( aParam ) ; j++ ) {
1735 //      if ( aParam[ j ] == '\\' ) {
1736       if ( aParam[ j ] == '_' && aParam[ j+1 ] == '_' ) {
1737         aNodeName = new char[ j+1 ] ;
1738         strncpy( aNodeName , aParam , j ) ;
1739         aNodeName[ j ] = '\0' ;
1740         aPortName = new char[ strlen( aParam ) - j-1 ] ;
1741         strncpy( aPortName , &aParam[ j+2 ] , strlen( aParam ) - j-1 ) ;
1742         break ;
1743       }
1744     }
1745     f << "    " << "#O" << aNodeName << aPortName << " = " << aNodeName << ".GetOutPort( '"
1746       << aPortName << "' )" << endl ;
1747     delete [] aNodeName ;
1748     delete [] aPortName ;
1749   }
1750
1751   f << "    " << "return " << Graph()->Name() << endl << endl ;
1752
1753 // RECURSIVE CREATION OF GRAPHS OF MACRONODES
1754   for ( i = 0 ; i < Graph()->GraphNodesSize() ; i++ ) {
1755     if ( Graph()->GraphNodes( i )->IsMacroNode() ) {
1756       GraphBase::GOTONode * aMacroNode = (GraphBase::GOTONode * ) Graph()->GraphNodes( i ) ;
1757       GraphBase::Graph * aMacroGraph = (GraphBase::Graph * ) aMacroNode->CoupledNode() ;
1758       cdebug << "OutNode::SavePY ---> OutNode::SavePY( ostream & f ) MacroGraph " << aMacroGraph->Name() << endl ;
1759       GraphEditor::DataFlow * aDataFlow = aMacroGraph->GraphEditor() ;
1760       cdebug << "SavePY of the Graph " << aDataFlow->Graph() << " of the MacroNode "
1761              << aMacroGraph->Name() << endl ;
1762       if ( !aDataFlow->SavePY( f , false ) ) {
1763         return false ;
1764       }
1765     }
1766   }
1767
1768 //  f << Graph()->Name() << " = " << Graph()->Name() << "()" << endl ;
1769
1770   return true ;
1771 }
1772
1773 /** Iterate through ALL links (OutPort-InPort pairs) and check if their types are 
1774  *  compatible - call GraphEditor::DataFlow::IsCompatible(type1, type2).
1775  *  Returns true if all are compatible.
1776  */
1777 bool GraphEditor::OutNode::IsLinksCompatible() {
1778   cdebug_in << "Editor::OutNode::IsLinksCompatible()" << endl ;
1779   bool RetVal = true;
1780   bool b ;
1781   const GraphBase::ListOfSLinks * Links = Graph()->GetLinks( true ) ;
1782   cdebug_in << "Editor::OutNode::IsLinksCompatible() " << Links->size() << " Links" << endl ;
1783 //  for ( int i = 0 ; i < (int ) Links->size() && b ; i++ ) {
1784   for ( int i = 0 ; i < (int ) Links->size() ; i++ ) {
1785     GraphBase::SLink aLink = (*Links)[i];
1786     GraphBase::ComputingNode* anOutNode = Graph()->GetChangeGraphNode( aLink.FromNodeName.c_str() );
1787     GraphBase::ComputingNode* anInNode = Graph()->GetChangeGraphNode( aLink.ToNodeName.c_str() );
1788     const GraphBase::OutPort* anOutPort = anOutNode->GetOutPort( aLink.FromServiceParameterName.c_str() );
1789     const GraphBase::InPort* anInPort = anInNode->GetInPort( aLink.ToServiceParameterName.c_str() );    
1790     b = IsCompatible( anOutPort->PortType(), anInPort->PortType() );
1791     cdebug << "GraphEditor::OutNode::IsLinksCompatible:  " << aLink.FromNodeName << "( "
1792            << aLink.FromServiceParameterName << " " << anOutPort->PortType()
1793            << " )  -->  " << aLink.ToNodeName <<"( " << aLink.ToServiceParameterName << " "
1794            << anInPort->PortType() << " ) = " << (b ? "OK" : "Not compatible (ERROR)") << endl;
1795     if ( !b ) {
1796       RetVal = false ;
1797       MESSAGE( "Graph structure ERROR: type of port \"" << aLink.FromServiceParameterName
1798                << "\" of node \"" << aLink.FromNodeName
1799                << "\" is not compatible with type of linked port \""
1800                << aLink.ToServiceParameterName << "\" of node \"" << aLink.ToNodeName<<"\"" ) ; 
1801       ostringstream aTypeOutPortstr ;
1802       aTypeOutPortstr << anOutPort->PortType() ;
1803       ostringstream aTypeInPortstr ;
1804       aTypeInPortstr << anInPort->PortType() ;
1805       string anErrorMessage = string( "PortTypes of " ) + string( aLink.FromNodeName ) +
1806                               string( "( " ) + aLink.FromServiceParameterName +
1807                               string( " ) " ) + aTypeOutPortstr.str() + string( " and " ) +
1808                               string( aLink.ToNodeName ) + string( "( " ) +
1809                               string( aLink.ToServiceParameterName ) + 
1810                               string( " ) " ) + aTypeInPortstr.str() +
1811                               string( " are not compatibles.\n" ) ;
1812       Graph()->SetMessages( anErrorMessage ) ;
1813     }
1814   }
1815   cdebug_out << "Editor::OutNode::IsLinksCompatible() RetVal " << RetVal << endl ;
1816   return RetVal ;
1817 }
1818
1819 static const char* gSimpleTypes[] = 
1820   {"boolean", "char", "short", "int", "long", "float", "double"};
1821 bool isSimpleType( string type ) {
1822   for ( int i = 0; i < 7; i++ )
1823     if ( type == gSimpleTypes[i] )
1824       return true;
1825   return false;
1826 }
1827
1828 /**Returns true if an out-port of type "OutPortType" can be bound with in-port of type "InPortType". 
1829  * Types: {"string", "boolean", "char", "short", "int", "long", "float", "double", "objref"};
1830  * Currently considered compatible ALL types except for objref - they must match exactly
1831  */
1832 bool GraphEditor::OutNode::IsCompatible( const char* OutPortType, const char* InPortType ) const {
1833   bool ret = true;
1834   string t1 = OutPortType;
1835   string t2 = InPortType;
1836   // if ANY is a string - the link is OK
1837   if ( t1 == "string" || t2 == "string" )
1838     ret = true;
1839
1840   // the next check prohibits linkage of "objref" to any simple type (int, char, etc.)
1841   // it is still possible to link "objref" to some UNKNOWN type (probably objref, too,
1842   // which interface name came from Cataloge
1843   else if ( ( t1 == "objref" && isSimpleType( t2 ) ) ||  
1844             ( t2 == "objref" && isSimpleType( t1 ) ) )
1845     ret = false; 
1846   return ret;
1847 }
1848
1849 ostream & operator<< (ostream & f,const GraphEditor::OutNode & G) {
1850   f << (GraphBase::ComputingNode ) *(G.Graph()) ;
1851   f << endl ;
1852
1853   f << "  Nodes : " << (G.Graph())->GraphNodesSize() << " node" 
1854     << ((G.Graph())->GraphNodesSize() > 1 ? "s" : "") << endl;
1855   
1856   int i ;
1857   for ( i = 0 ; i < (G.Graph())->GraphNodesSize() ; i++ ) {
1858     f
1859 //      << hex << (void *) G.Graph().GraphNodes( i ) << dec << " "
1860       << (G.Graph())->GraphNodes( i ) << endl;
1861   }
1862
1863   f << "  Links : " << endl ;
1864   for ( i = 0 ; i < (G.Graph())->GraphNodesSize() ; i++ ) {
1865     (G.Graph())->GraphNodes( i )->ListLinks( f ) ;
1866   }
1867
1868   f << "  Datas : " << endl ;
1869   (G.Graph())->ListDatas( f ) ;
1870
1871   f << "DataFlow " << (G.Graph())->Name() << " is " ;
1872   if ( G.IsNotValid() )
1873     f << "not " ;
1874   f << "valid and is " ;
1875   if ( G.IsNotExecutable() )
1876     f << "not " ;
1877   f << "executable." << endl ;
1878
1879   f << endl ;
1880   
1881   return f;
1882 }
1883
1884 ostream & operator<< (ostream &fOut,const SUPERV::SDate &D)
1885 {
1886 //  cdebug_in << "operator<< GraphEditor::Date" << endl;
1887
1888   fOut  << D.Day << "/" 
1889         << D.Month << "/" 
1890         << D.Year << " - " 
1891         << D.Hour << ":" 
1892         << D.Minute <<  ":"  
1893         << D.Second;
1894
1895 //  cdebug_out << "operator<< GraphEditor::Date" << endl;
1896   return fOut;
1897 }
1898
1899 /*
1900 GraphBase::Graph * GraphEditor::OutNode::MapGraph( const char * aGraphName ) {
1901   GraphBase::Graph * aGraph = _MapOfGraphs[ aGraphName ] ;
1902   return aGraph ;
1903 }
1904
1905 bool GraphEditor::OutNode::MapGraph( GraphBase::Graph * aGraph , const char * aGraphName ) {
1906   if ( MapGraph( aGraphName ) ) {
1907     return false ;
1908   }
1909   _MapOfGraphs[ aGraphName ] = aGraph ;
1910   return true ;
1911 }
1912
1913 void GraphEditor::OutNode::EraseGraph( const char * aGraphName ) {
1914   _MapOfGraphs.erase( aGraphName ) ;
1915 }
1916
1917 bool GraphEditor::OutNode::GraphName( const char * aGraphName ) {
1918   return  _MapOfGraphNames[ aGraphName ] ;
1919 }
1920 */
1921
1922