Salome HOME
Merge from OCC_development_generic_2006
[modules/superv.git] / src / GraphBase / DataFlowBase_ComputingNode.cxx
1 //  SUPERV GraphBase : contains fondamental classes for Services, Input Ports, Output Ports Links and Nodes.
2 //
3 //  Copyright (C) 2003  CEA/DEN, EDF R&D
4 //
5 //
6 //
7 //  File   : DataFlowBase_ComputingNode.cxx
8 //  Author : Jean Rahuel, CEA
9 //  Module : SUPERV
10 //  $Header:
11
12 using namespace std;
13 //#include <sstream>
14 //#include <iostream>
15
16 #include "DataFlowBase_StreamGraph.hxx"
17 //#include "DataFlowBase_LoopNode.hxx"
18
19 static void InitFields( //SUPERV::KindOfNode &_Kind ,
20                         SUPERV::SDate      &_FirstCreation ,
21                         SUPERV::SDate      &_LastModification ,
22                         char *             &_EditorRelease ,
23                         char *             &_Author ,
24                         char *             &_Comment ,
25                         //bool               &_HeadNode ,
26                         bool               &_GeneratedName ,
27                         //int                &_DataStreamInPortsNumber ,
28                         //int                &_DataStreamOutPortsNumber ,
29                         int                &_ConnectedInPortsNumber ,
30                         int                &_DecrConnectedInPortsNumber ) {
31                         //int                &_LinkedNodesSize ,
32                         //int                &_SubGraphNumber ) {
33   time_t T = time(NULL);
34   struct tm * Tm = localtime(&T);
35
36 //  _Kind = SUPERV::DataFlowGraph ;
37
38   _FirstCreation.Second = _LastModification.Second = Tm->tm_sec;
39   _FirstCreation.Minute = _LastModification.Minute = Tm->tm_min;
40   _FirstCreation.Hour   = _LastModification.Hour   = Tm->tm_hour;
41   _FirstCreation.Day    = _LastModification.Day    = Tm->tm_mday;
42   _FirstCreation.Month  = _LastModification.Month  = Tm->tm_mon + 1;
43   _FirstCreation.Year   = _LastModification.Year   = Tm->tm_year + 1900; 
44
45   _EditorRelease = new char[ strlen( SuperVision_Version ) + 1 ] ;
46   strcpy( _EditorRelease , SuperVision_Version ) ;
47   _Author = NULLSTRING ;
48 //  _Computer = new char[ strlen( FACTORYSERVER ) + 1 ] ;
49 //  strcpy( _Computer  , FACTORYSERVER ) ;
50   _Comment = NULLSTRING ;
51
52 //  _SubGraphNumber = 0 ;
53 //  _HeadNode = false ;
54   _GeneratedName = false ;
55
56 //  _DataStreamInPortsNumber = 0 ;
57 //  _DataStreamOutPortsNumber = 0 ;
58
59   _ConnectedInPortsNumber = 0 ;
60   _DecrConnectedInPortsNumber = 0 ;
61 //  _LinkedNodesSize = 0 ;
62 //  _SubGraphNumber = 0 ;
63 }
64
65 GraphBase::ComputingNode::ComputingNode() :
66 //  GraphBase::PortsOfNode::PortsOfNode() {
67   GraphBase::StreamNode::StreamNode() {
68
69   InitFields( //_Kind ,
70               _FirstCreation ,
71               _LastModification ,
72               _EditorRelease ,
73               _Author ,
74               _Comment ,
75               //_HeadNode ,
76               _GeneratedName ,
77               //_DataStreamInPortsNumber ,
78               //_DataStreamOutPortsNumber ,
79               _ConnectedInPortsNumber ,
80               _DecrConnectedInPortsNumber ) ;
81               //_LinkedNodesSize ,
82               //_SubGraphNumber ) ;
83   Kind( SUPERV::DataFlowGraph ) ;
84   _NamingService = NULL ;
85   _Node_var = SUPERV::CNode::_nil() ;
86   _Node_Impl = NULL ;
87   _InNode = NULL ;
88   _ThreadNo = pthread_self() ;
89   cdebug << "GraphBase::Node::Node "  << this << " "  << endl ;
90
91 }
92
93 GraphBase::ComputingNode::ComputingNode( CORBA::ORB_ptr ORB ,
94                                          SALOME_NamingService* ptrNamingService ,
95                                          const char * aDataFlowName ,
96                                          const SUPERV::KindOfNode DataFlowkind ,
97                                          int * Graph_prof_debug ,
98                                          ofstream * Graph_fdebug ) :
99 //  GraphBase::PortsOfNode::PortsOfNode( aDataFlowName ) {
100   GraphBase::StreamNode::StreamNode( aDataFlowName , DataFlowkind ,
101                                      Graph_prof_debug , Graph_fdebug ) {
102
103 //  MESSAGE( "GraphBase::ComputingNode::ComputingNode " << aDataFlowName << " Graph_prof_debug " << Graph_prof_debug ) ;
104   InitFields( //_Kind ,
105               _FirstCreation ,
106               _LastModification ,
107               _EditorRelease ,
108               _Author ,
109               _Comment ,
110               //_HeadNode ,
111               _GeneratedName ,
112               //_DataStreamInPortsNumber ,
113               //_DataStreamOutPortsNumber ,
114               _ConnectedInPortsNumber ,
115               _DecrConnectedInPortsNumber ) ;
116               //_LinkedNodesSize ,
117               //_SubGraphNumber ) ;
118
119 //  Kind( SUPERV::DataFlowGraph ) ;
120   Kind( DataFlowkind ) ;
121   _ORB = CORBA::ORB::_duplicate( ORB ) ;
122   _NamingService = ptrNamingService ;
123   _Node_var = SUPERV::CNode::_nil() ;
124   _Node_Impl = NULL ;
125   _InNode = NULL ;
126   _ThreadNo = pthread_self() ;
127
128   if ( Graph_prof_debug ) {
129 //    MESSAGE( "GraphBase::ComputingNode::ComputingNode --> SetDebug" ) ;
130 //    cout << "GraphBase::ComputingNode::ComputingNode --> SetDebug" << endl ;
131     _Graph_prof_debug = Graph_prof_debug ;
132     _Graph_fdebug = Graph_fdebug ;
133     SetDebug( ORB , Graph_prof_debug , Graph_fdebug ) ;
134   }
135 //  else {
136 //    cout << "GraphBase::ComputingNode::ComputingNode NO SetDebug" << endl ;
137 //  }
138   DefPortsOfNode( ORB , SALOME_ModuleCatalog::Service() , NamePtr() , Kind() , Graph_prof_debug , Graph_fdebug ) ;
139   cdebug << "GraphBase::ComputingNode::ComputingNode "  << this 
140          << " Name '" << Name() << "' "  << _FirstCreation
141          << " "  << _LastModification << endl ;
142 }
143
144 GraphBase::ComputingNode::ComputingNode( CORBA::ORB_ptr ORB ,
145                                          SALOME_NamingService* ptrNamingService ,
146                                          const SALOME_ModuleCatalog::Service& aService ,
147                                          const char *NodeName ,
148                                          const SUPERV::KindOfNode akind ,
149                                          const SUPERV::SDate NodeFirstCreation ,
150                                          const SUPERV::SDate NodeLastModification  ,
151                                          const char * NodeEditorRelease ,
152                                          const char * NodeAuthor ,
153                                          const char * NodeComment ,
154                                          const bool   GeneratedName ,
155                                          const long   X ,
156                                          const long   Y ,
157                                          int * Graph_prof_debug ,
158                                          ofstream * Graph_fdebug ) :
159 //  GraphBase::PortsOfNode::PortsOfNode() {
160   GraphBase::StreamNode::StreamNode( NodeName , akind , Graph_prof_debug , Graph_fdebug ) {
161
162   _ORB = CORBA::ORB::_duplicate( ORB ) ;
163   _NamingService = ptrNamingService ;
164   _Node_var = SUPERV::CNode::_nil() ;
165   _Node_Impl = NULL ;
166   _InNode = NULL ;
167   _ThreadNo = pthread_self() ;
168
169   Kind( akind ) ;
170 //  _Kind = akind ;
171
172   time_t T = time(NULL);
173   struct tm * Tm = localtime(&T);
174
175   _FirstCreation.Second = _LastModification.Second = Tm->tm_sec;
176   _FirstCreation.Minute = _LastModification.Minute = Tm->tm_min;
177   _FirstCreation.Hour   = _LastModification.Hour   = Tm->tm_hour;
178   _FirstCreation.Day    = _LastModification.Day    = Tm->tm_mday;
179   _FirstCreation.Month  = _LastModification.Month  = Tm->tm_mon + 1;
180   _FirstCreation.Year   = _LastModification.Year   = Tm->tm_year + 1900; 
181
182   if ( NodeEditorRelease != NULLSTRING ) {
183     _EditorRelease = new char[ strlen( NodeEditorRelease ) + 1 ] ;
184     strcpy( _EditorRelease , NodeEditorRelease ) ;
185   }
186   else {
187     _EditorRelease = new char[ strlen( SuperVision_Version ) + 1 ] ;
188     strcpy( _EditorRelease , SuperVision_Version ) ;
189   }
190
191   if ( NodeAuthor != NULLSTRING ) {
192     _Author = new char[ strlen( NodeAuthor ) + 1 ] ;
193     strcpy( _Author  , NodeAuthor ) ;
194   }
195   else {
196     _Author = NULLSTRING ;
197   }
198
199   if ( NodeComment != NULLSTRING ) {
200     _Comment = new char[ strlen( NodeComment ) + 1 ] ;
201     strcpy( _Comment  , NodeComment ) ;
202   }
203   else {
204     _Comment = NULLSTRING ;
205   }
206
207 //  _SubGraphNumber = 0 ;
208 //  _HeadNode = false ;
209   _GeneratedName = GeneratedName ;
210
211 //  const char *aNodeName = NodeName ;
212 //  _Name = new char[strlen(aNodeName)+1];
213 //  strcpy(_Name , aNodeName);
214
215 //  _DataStreamInPortsNumber = 0 ;
216 //  _DataStreamOutPortsNumber = 0 ;
217
218   _ConnectedInPortsNumber = 0 ;
219   _DecrConnectedInPortsNumber = 0 ;
220 //  _LinkedNodesSize = 0 ;
221
222   _X = X ;
223   _Y = Y ;
224
225   _Graph_prof_debug = Graph_prof_debug ;
226   _Graph_fdebug = Graph_fdebug ;
227 //  MESSAGE( "GraphBase::ComputingNode::ComputingNode " << NodeName
228 //           << " _Graph_prof_debug " << _Graph_prof_debug ) ;
229   SetDebug( ORB , Graph_prof_debug , Graph_fdebug ) ;
230   cdebug_in << "GraphBase::ComputingNode::ComputingNode(" << aService.ServiceName << "," << NodeName << ","
231             << akind << ")" << endl;
232   
233
234   DefPortsOfNode( ORB , aService , NamePtr() , Kind() , Graph_prof_debug , Graph_fdebug ) ;
235   cdebug << "GraphBase::ComputingNode::ComputingNode "  << this 
236          << " Name '" << Name()
237          << "' KindOfNode " << Kind()
238          << " ServiceName '" << ServiceName() << "' In(" << ServiceInParameter().length()
239          << ") Out(" << ServiceOutParameter().length() << ")" << endl ;
240
241   cdebug_out << "GraphBase::ComputingNode::ComputingNode" << endl;
242 }
243
244 GraphBase::ComputingNode::~ComputingNode() {
245   cdebug << "GraphBase::ComputingNode::~ComputingNode "  << this 
246          << " Name() "<< Name() << " _Comment "
247          << (void *) _Comment << " "  << _Comment << " "  << endl ;
248 }
249
250 //->StreamNode bool GraphBase::ComputingNode::Name( const char * aName) {
251 //->StreamNode   cdebug_in << "GraphBase::ComputingNode::Name " << _Name << endl;
252 //->StreamNode   if ( _Name ) {
253 //->StreamNode     cdebug << "GraphBase::ComputingNode::ReName "  << _Name << " --> " << aName << endl ;
254 //->StreamNode     delete [] _Name ;
255 //->StreamNode   }
256 //->StreamNode   _Name = new char[strlen(aName)+1] ;
257 //->StreamNode   strcpy( _Name , aName ) ;
258 //->StreamNode   cdebug_out << "GraphBase::ComputingNode::Name " << _Name << endl;
259 //->StreamNode   return true ;
260 //->StreamNode }
261
262 SUPERV::SDate GraphBase::ComputingNode::FirstCreation () const {
263 //  cdebug << "GraphBase::ComputingNode::FirstCreation "
264 //         << " Name '" << Name() << "' "  << _FirstCreation << " "  
265 //         << _LastModification << endl ;
266   return _FirstCreation;
267 }
268
269 SUPERV::SDate GraphBase::ComputingNode::LastModification () const {
270   return _LastModification ;
271 }
272
273 void GraphBase::ComputingNode::FirstCreation(const SUPERV::SDate aDate ) {
274   _FirstCreation = aDate ;
275 }
276
277 void GraphBase::ComputingNode::LastModification(const SUPERV::SDate aDate ) {
278   _LastModification = aDate ;
279 }
280
281 bool GraphBase::ComputingNode::EditorRelease(const char * c){
282   if ( _EditorRelease && _EditorRelease != NULLSTRING )
283     delete _EditorRelease;
284   _EditorRelease = my_strdup(c);
285   return true ;
286 }
287
288 bool GraphBase::ComputingNode::Author(const char * a) {
289   cdebug_in << "GraphBase::ComputingNode::Author " << _Author << endl;
290   if ( _Author && _Author != NULLSTRING )
291     delete _Author;
292   _Author = my_strdup(a);
293   cdebug_out << "GraphBase::ComputingNode::Author " << _Author << endl;
294   return true ;
295 }
296
297 bool GraphBase::ComputingNode::Comment(const char *c) {
298   cdebug_in << "GraphBase::ComputingNode::Comment " << _Comment << endl;
299   if ( _Comment != NULLSTRING )
300     delete [] _Comment;
301   _Comment = my_strdup(c);
302   cdebug_out << "GraphBase::ComputingNode::Comment " << _Comment << endl;
303   return true ;
304 }
305
306 void GraphBase::ComputingNode::NodePort( const char * NodeName ,
307                                 const char * ServiceParameterName ,
308                                 char ** aNode , char ** aPort ) {
309   if ( strcmp( NodeName , Name() ) ) {
310     *aNode = my_strdup( NodeName ) ;
311     *aPort = my_strdup( ServiceParameterName ) ;
312   }
313   else {
314 //    char * BPort = strchr( ServiceParameterName , '\\' ) ;
315     char * BPort = (char * ) ServiceParameterName ;
316     while ( ( BPort = strchr( BPort , '_' ) ) ) {
317       if ( BPort[1] == '_' ) {
318         int len = BPort - ServiceParameterName ;
319         *aNode = new char [ len + 1 ] ;
320         strncpy( *aNode , ServiceParameterName , len ) ;
321         (*aNode)[ len ] = '\0' ;
322         *aPort = my_strdup( &BPort[ 2 ] ) ;
323         break ;
324       }
325       else {
326         BPort = &BPort[2] ;
327       }
328     }
329     if ( BPort == NULL ) {
330       *aNode = my_strdup( NULLSTRING ) ;
331       *aPort = my_strdup( NULLSTRING ) ;
332     }
333   }
334 }
335
336 bool GraphBase::ComputingNode::IsLinked(const char * ToServiceParameterName, bool isInput ) {
337   bool RetVal = false ;
338   if ( isInput ) { // mkr : PAL8060
339     // we have to know the type of the port, because of input and output ports 
340     // belong to one node may have the same names
341     const GraphBase::InPort * thePort = GetInPort( ToServiceParameterName ) ;
342     if ( thePort ) {
343       RetVal = thePort->IsPortConnected() ;
344     }
345   }
346   else {
347     const GraphBase::OutPort * thePort = GetOutPort( ToServiceParameterName ) ;
348     if ( thePort ) {
349       RetVal = thePort->IsPortConnected() ;
350     }
351   }
352   return RetVal ;
353 }
354
355 bool GraphBase::ComputingNode::HasInput(const char * ToServiceParameterName ) {
356   bool RetVal = false ;
357   const GraphBase::InPort * theInPort = GetInPort( ToServiceParameterName ) ;
358   if ( theInPort ) {
359     RetVal = theInPort->IsDataConnected() ;
360   }
361   else {
362     const GraphBase::OutPort * theOutPort = GetOutPort( ToServiceParameterName ) ;
363     if ( theOutPort ) {
364       RetVal = theOutPort->IsDataConnected() ;
365     }
366   }
367   return RetVal ;
368 }
369
370 GraphBase::SNode * GraphBase::ComputingNode::GetInfo() {
371   cdebug_in << "GraphBase::ComputingNode::GetInfo" << endl;
372   GraphBase::SNode * Info = new GraphBase::SNode ;
373 //  Info->theComponentName = ComponentName() ;
374 //  Info->theInterfaceName = InterfaceName() ;
375   Info->theName = Name() ;
376   Info->theKind = Kind() ;
377   if ( IsDataStreamNode() ) {
378     long Timeout ;
379     SUPERV::KindOfDataStreamTrace DataStreamTrace ;
380     double DeltaTime ;
381     ((GraphBase::StreamGraph * ) this)->StreamParams( Timeout , DataStreamTrace , DeltaTime ) ;
382     Info->theTimeout = Timeout ;
383     Info->theDataStreamTrace = DataStreamTrace ;
384     Info->theDeltaTime = DeltaTime ;
385   }
386   Info->theService = *GetService() ;
387 //  Info->theListOfParameters = *GetListOfParameters() ;
388   Info->theFirstCreation = FirstCreation() ;
389   Info->theLastModification = LastModification() ;
390   Info->theEditorRelease = EditorRelease() ;
391   Info->theAuthor = Author() ;
392 //  Info->theContainer = Computer() ;
393   Info->theComment = Comment() ;
394   Info->theCoords.theX = GraphBase::ComputingNode::XCoordinate() ;
395   Info->theCoords.theY = GraphBase::ComputingNode::YCoordinate() ;
396   cdebug_out << "GraphBase::ComputingNode::GetInfo" << endl;
397   return Info ;
398 }
399
400 void GraphBase::ComputingNode::SetMacroPorts( GraphBase::Graph * aGraph ) {
401   cdebug_in << "GraphBase::ComputingNode::SetMacroPorts fill ports of MacroNode" << endl;
402   int i ;
403   for ( i = 0 ; i < aGraph->GetNodeInPortsSize() ; i++ ) {
404     const GraphBase::InPort * anInPort = aGraph->GetNodeInPort( i ) ;
405     cdebug << "SetMacroPorts In" << i << " " << anInPort->PortName() << " " << anInPort->PortType()
406            << " " << anInPort->Kind() << endl ;
407     GraphBase::InPort * aNewInPort ;
408     if ( anInPort->IsDataStream() ) {
409       aNewInPort = AddInDataStreamPort( anInPort->PortName() , StringToDataStreamType( anInPort->PortType() ) ,
410                                         anInPort->Dependency() , anInPort->Kind() ) ;
411     }
412     else if ( anInPort->IsParam() || anInPort->IsInLine() ) {
413       aNewInPort = AddInPort( anInPort->PortName() , anInPort->PortType() , anInPort->Kind() ) ;
414     }
415   }
416   for ( i = 0 ; i < aGraph->GetNodeOutPortsSize() ; i++ ) {
417     const GraphBase::OutPort * anOutPort = aGraph->GetNodeOutPort( i ) ;
418     cdebug << "SetMacroPorts Out" << i << " " << anOutPort->PortName() << " " << anOutPort->PortType()
419            << " " << anOutPort->Kind() << endl ;
420     if ( anOutPort->IsDataStream() ) {
421       AddOutDataStreamPort( anOutPort->PortName() , StringToDataStreamType( anOutPort->PortType() ) ,
422                             anOutPort->Dependency() , anOutPort->Kind() ) ;
423     }
424     else if ( anOutPort->IsParam() || anOutPort->IsInLine() ) {
425       AddOutPort( anOutPort->PortName() , anOutPort->PortType() , anOutPort->Kind() ) ;
426     }
427   }
428   cdebug_out << "GraphBase::ComputingNode::SetMacroPorts" << endl;
429 }
430
431 void GraphBase::ComputingNode::UpdateMacroPorts( GraphBase::Graph * aGraph ) {
432   cdebug_in << "GraphBase::ComputingNode::UpdateMacroPorts fill ports of MacroNode from "
433             << aGraph->Name() << " InPorts(" << aGraph->GetNodeInPortsSize() << ") OutPorts("
434             << aGraph->GetNodeInPortsSize() << ") to MacroNode " << Name() << " InPorts(" << GetNodeInPortsSize()
435             << ") OutPorts(" << GetNodeInPortsSize() << ")" << endl;
436   cdebug << Name() << " : " << *GetService() << endl ;
437   cdebug << aGraph->Name() << " : " << *aGraph->GetService() << endl ;
438   int i ;
439 // Loop over InPorts of MacroNode ; if it does not exist in the MacroGraph ===> DelInPort in the MacroNode
440   for ( i = 0 ; i < GetNodeInPortsSize() ; i++ ) {
441     GraphBase::InPort * anInPort = aGraph->GetChangeInPort( GetNodeInPort( i )->PortName() ) ;
442     if ( anInPort && !anInPort->IsGate() && !GetNodeInPort( i )->IsGate() ) {
443       if ( strcmp( GetNodeInPort( i )->PortType() , anInPort->PortType() ) ) {
444         cdebug << Name() << " " << GetNodeInPort( i )->PortName() << " " << GetNodeInPort( i )->PortType()
445                << " " << GetNodeInPort( i )->Kind() << " " << GetNodeInPort( i )->Dependency() << endl ;
446         cdebug << "  <--> " << aGraph->Name() << " " << anInPort->PortName() << " " << anInPort->PortType()
447                << " " << anInPort->Kind() << " " << anInPort->Dependency() << endl ;
448         GetChangeNodeInPort( i )->PortType( (char * ) anInPort->PortType() ) ;
449       }
450       if ( GetNodeInPort( i )->Kind() != anInPort->Kind() ) {
451         cdebug << Name() << " " << GetNodeInPort( i )->PortName() << " " << GetNodeInPort( i )->PortType()
452                << " " << GetNodeInPort( i )->Kind() << " " << GetNodeInPort( i )->Dependency() << endl ;
453         cdebug << "  <--> " << aGraph->Name() << " " << anInPort->PortName() << " " << anInPort->PortType()
454                << " " << anInPort->Kind() << " " << anInPort->Dependency() << endl ;
455         GetChangeNodeInPort( i )->Kind( anInPort->Kind() ) ;
456       }
457       if ( GetNodeInPort( i )->Dependency() != anInPort->Dependency() ) {
458         cdebug << Name() << " " << GetNodeInPort( i )->PortName() << " " << GetNodeInPort( i )->PortType()
459                << " " << GetNodeInPort( i )->Kind() << " " << GetNodeInPort( i )->Dependency() << endl ;
460         cdebug << "  <--> " << aGraph->Name() << " " << anInPort->PortName() << " " << anInPort->PortType()
461                << " " << anInPort->Kind() << " " << anInPort->Dependency() << endl ;
462         GetChangeNodeInPort( i )->Dependency( anInPort->Dependency() ) ;
463       }
464     }
465     else if ( !GetNodeInPort( i )->IsGate() ) {
466       cdebug << "UpdateMacroPorts DelInPort In" << i << " " << GetNodeInPort( i )->PortName() << " "
467              << GetNodeInPort( i )->PortType() << " " << GetNodeInPort( i )->Kind() << endl ;
468       DelInPort( GetNodeInPort( i )->PortName() ) ;
469       i--; // mkr : fix for bug PAL8004
470     }
471   }
472   int index ;
473 // Loop over InPorts of the MacroGraph : if it does not exist in the MacroNode ==> AddInPort in the MacroNode
474   for ( index = 0 ; index < aGraph->GetNodeInPortsSize() ; index++ ) {
475     GraphBase::InPort * anInPort = aGraph->GetChangeNodeInPort( index ) ;
476     GraphBase::InPort * aMacroInPort = GetChangeInPort( anInPort->PortName() ) ;
477     if ( !anInPort->IsGate() &&
478          strcmp( GetChangeNodeInPort( index )->PortName() , anInPort->PortName() ) ) {
479       cdebug << "UpdateMacroPorts Add/MoveInPort In" << index << " " << anInPort->PortName() << " "
480              << anInPort->PortType() << " " << anInPort->Kind() << endl ;
481       if ( aMacroInPort ) {
482         MoveInPort( anInPort->PortName() , index ) ;
483       }
484       else {
485         AddInPort( anInPort->PortName() , anInPort->PortType() , anInPort->Kind() , index ) ;
486       }
487     }
488   }
489 // Loop over OutPorts of MacroNode ; if it does not exist in the MacroGraph ===> DelOutPort in the MacroNode
490   for ( i = 0 ; i < GetNodeOutPortsSize() ; i++ ) {
491     GraphBase::OutPort * anOutPort = aGraph->GetChangeOutPort( GetNodeOutPort( i )->PortName() ) ;
492     if ( anOutPort && !anOutPort->IsGate() && !GetNodeOutPort( i )->IsGate() ) {
493       if ( strcmp( GetNodeOutPort( i )->PortType() , anOutPort->PortType() ) ) {
494         cdebug << Name() << " " << GetNodeOutPort( i )->PortName() << " " << GetNodeOutPort( i )->PortType()
495                << " " << GetNodeOutPort( i )->Kind() << " " << GetNodeOutPort( i )->Dependency() << endl ;
496         cdebug << "  <--> " << aGraph->Name() << " " << anOutPort->PortName() << " " << anOutPort->PortType()
497                << " " << anOutPort->Kind() << " " << anOutPort->Dependency() << endl ;
498         GetChangeNodeOutPort( i )->PortType( (char * ) anOutPort->PortType() ) ;
499       }
500       if ( GetNodeOutPort( i )->Kind() != anOutPort->Kind() ) {
501         cdebug << Name() << " " << GetNodeOutPort( i )->PortName() << " " << GetNodeOutPort( i )->PortType()
502                << " " << GetNodeOutPort( i )->Kind() << " " << GetNodeOutPort( i )->Dependency() << endl ;
503         cdebug << "  <--> " << aGraph->Name() << " " << anOutPort->PortName() << " " << anOutPort->PortType()
504                << " " << anOutPort->Kind() << " " << anOutPort->Dependency() << endl ;
505         GetChangeNodeOutPort( i )->Kind( anOutPort->Kind() ) ;
506       }
507       if ( GetNodeOutPort( i )->Dependency() != anOutPort->Dependency() ) {
508         cdebug << Name() << " " << GetNodeOutPort( i )->PortName() << " " << GetNodeOutPort( i )->PortType()
509                << " " << GetNodeOutPort( i )->Kind() << " " << GetNodeOutPort( i )->Dependency() << endl ;
510         cdebug << "  <--> " << aGraph->Name() << " " << anOutPort->PortName() << " " << anOutPort->PortType()
511                << " " << anOutPort->Kind() << " " << anOutPort->Dependency() << endl ;
512         GetChangeNodeOutPort( i )->Dependency( anOutPort->Dependency() ) ;
513       }
514     }
515     else if ( !GetNodeOutPort( i )->IsGate() ) {
516       cdebug << "UpdateMacroPorts DelOutPort Out" << i << " " << GetNodeOutPort( i )->PortName() << " "
517              << GetNodeOutPort( i )->PortType() << " " << GetNodeOutPort( i )->Kind() << endl ;
518       DelOutPort( GetNodeOutPort( i )->PortName() ) ;
519     }
520   }
521 // Loop over OutPorts of the MacroGraph : if it does not exist in the MacroNode ==> AddOutPort in the MacroNode
522   for ( index = 0 ; index < aGraph->GetNodeOutPortsSize() ; index++ ) {
523     GraphBase::OutPort * anOutPort = aGraph->GetChangeNodeOutPort( index ) ;
524     GraphBase::OutPort * aMacroOutPort = GetChangeOutPort( anOutPort->PortName() ) ;
525     if ( !anOutPort->IsGate() && strcmp( GetNodeOutPort( index )->PortName() , anOutPort->PortName() ) ) {
526       cdebug << "UpdateMacroPorts Add/MoveOutPort Out" << index << " " << anOutPort->PortName() << " "
527              << anOutPort->PortType() << " " << anOutPort->Kind() << endl ;
528       if ( aMacroOutPort ) {
529         MoveOutPort( anOutPort->PortName() , index ) ;
530       }
531       else {
532         AddOutPort( anOutPort->PortName() , anOutPort->PortType() , anOutPort->Kind() , index ) ;
533       }
534     }
535   }
536   bool ErrPort = false ;
537   if ( aGraph->GetNodeInPortsSize() != GetNodeInPortsSize() ||
538        aGraph->GetNodeOutPortsSize() != GetNodeOutPortsSize() ) {
539     ErrPort = true ;
540   }
541   for ( i = 0 ; i < aGraph->GetNodeInPortsSize() && i < GetNodeInPortsSize() ; i++ ) {
542     if ( !strcmp( aGraph->GetNodeInPort( i )->PortName() , GetNodeInPort( i )->PortName() ) ) {
543       ErrPort = true ;
544     }
545   }
546   for ( i = 0 ; i < aGraph->GetNodeOutPortsSize() && i < GetNodeOutPortsSize() ; i++ ) {
547     if ( !strcmp( aGraph->GetNodeOutPort( i )->PortName() , GetNodeOutPort( i )->PortName() ) ) {
548       ErrPort = true ;
549     }
550   }
551   if ( ErrPort ) {
552     for ( i = 0 ; i < aGraph->GetNodeInPortsSize() || i < GetNodeInPortsSize() ; i++ ) {
553       if ( i < aGraph->GetNodeInPortsSize() && i < GetNodeInPortsSize() ) {
554         cdebug << "ComputingNode::UpdateMacroPorts In" << i << " " << aGraph->GetNodeInPort( i )->PortName()
555                << "  " << GetNodeInPort( i )->PortName() << endl ;
556       }
557       else if ( i >= GetNodeInPortsSize() ) {
558         cdebug << "ComputingNode::UpdateMacroPorts In" << i << " " << aGraph->GetNodeInPort( i )->PortName()
559                << endl ;
560       }
561       else {
562         cdebug << "ComputingNode::UpdateMacroPorts In" << i << " " << GetNodeInPort( i )->PortName()
563                << endl ;
564       }
565     }
566     for ( i = 0 ; i < aGraph->GetNodeOutPortsSize() || i < GetNodeOutPortsSize() ; i++ ) {
567       if ( i < aGraph->GetNodeOutPortsSize() && i < GetNodeOutPortsSize() ) {
568         cdebug << "ComputingNode::UpdateMacroPorts Out" << i << " " << aGraph->GetNodeOutPort( i )->PortName()
569                << " != " << GetNodeOutPort( i )->PortName() << endl ;
570       }
571       else if ( i >= GetNodeOutPortsSize() ) {
572         cdebug << "ComputingNode::UpdateMacroPorts Out" << i << " " << aGraph->GetNodeOutPort( i )->PortName()
573                << endl ;
574       }
575       else {
576         cdebug << "ComputingNode::UpdateMacroPorts Out" << i << " " << GetNodeOutPort( i )->PortName()
577                << endl ;
578       }
579     }
580   }
581   cdebug_out << "GraphBase::ComputingNode::UpdateMacroPorts"
582              << aGraph->Name() << " InPorts(" << aGraph->GetNodeInPortsSize() << ") OutPorts("
583              << aGraph->GetNodeOutPortsSize() << ") to MacroNode " << Name() << " InPorts("
584              << GetNodeInPortsSize() << ") OutPorts(" << GetNodeOutPortsSize() << ")" << endl;
585 }
586
587 void GraphBase::ComputingNode::SetMacroDatas( GraphBase::Graph * aGraph ,
588                                               GraphBase::Graph * aGraphOfMacroGraph ) {
589   cdebug_in << "GraphBase::ComputingNode::SetMacroDatas fill inputs of MacroNode" << endl;
590   int i ;
591   for ( i = 0 ; i < aGraph->GetNodeInPortsSize() ; i++ ) {
592     const GraphBase::InPort * anInPort = aGraph->GetNodeInPort( i ) ;
593     GraphBase::OutPort * anOutPort = aGraph->GetChangeNodeInDataNodePort(i) ;
594     cdebug << "                 " << Name() << " " << anOutPort->PortName() << " " << anOutPort->PortType()
595            << " " << anOutPort->Kind() << " " << anOutPort->PortStatus() << endl ;
596     if ( anOutPort->IsDataConnected() ) {
597 //JR 30.03.2005      aGraphOfMacroGraph->AddInputData( Name() , anInPort->PortName() , *(anOutPort->Value()) ) ;
598       aGraphOfMacroGraph->AddInputData( Name() , anInPort->PortName() , anOutPort->Value() ) ;
599       anOutPort->PortStatus( ExternConnected ) ;
600     }
601   }
602   cdebug_out << "GraphBase::ComputingNode::SetMacroDatas" << endl;
603 }
604
605 void GraphBase::ComputingNode::DelInPort( const char * InputParameterName ) {
606 //PAL9122
607 //JR 07.06.2005 Debug : LinkedNodes and LinkedFromNode must be updated
608 //                      LinkedInPortsNumber and LinkedFromInPortsNumber must be updated
609   cdebug_in << "ComputingNode::DelInPort " << Name() << "( " << InputParameterName << " )"
610              << endl;
611   bool RetVal = true ;
612   if ( !IsEndSwitchNode() ) {
613     GraphBase::InPort * anInPort = GetChangeInPort( InputParameterName ) ;
614     cdebug << "ComputingNode::DelInPort InPort " << Name() << "( "
615            << anInPort->PortName() << " ) " << anInPort->PortStatus() << " <-- " ;
616     GraphBase::OutPort * anOutPort = anInPort->GetOutPort() ;
617     if ( anOutPort && !( IsEndLoopNode() && anInPort->IsLoop() ) ) {
618       cdebug << anOutPort->NodeName() << "( " << anOutPort->PortName() << ") "
619              << anOutPort->PortStatus() ;
620     }
621     cdebug << endl ;
622     if ( !anInPort->IsNotConnected() ) {
623       GraphBase::ComputingNode * FromNode = NULL ;
624       RetVal = true ;
625       if ( anOutPort->IsDataConnected() || anOutPort->IsExternConnected() ) {
626         cdebug << "     Data/Extern ignored" << endl ;
627       }
628       else {
629         FromNode = GraphOfNode()->GetChangeGraphNode( anOutPort->NodeName() ) ;
630       }
631       if ( FromNode ) {
632         cdebug << "FromNode " << FromNode->Name() << " LinkedNodesSize "
633                << FromNode->LinkedNodesSize() << " and " << Name()
634                << " LinkedFromNodesSize " << LinkedFromNodesSize() << endl ;
635         if ( !FromNode->IsGOTONode() &&
636              !( FromNode->IsEndLoopNode() && anInPort->IsLoop() ) ) {
637           if ( anInPort->IsDataStream() ) {
638             RetVal = FromNode->RemoveStreamLinkedNode( this ) ;
639           }
640           else {
641             RetVal = FromNode->RemoveLinkedNode( this ) ;
642           }
643           if ( !RetVal ) {
644             cdebug << "ComputingNode::DelInPort anOutPort->RemoveLinkedNode Error RetVal "
645                    << RetVal << endl ;
646           }
647         }
648       }
649     }
650   }
651 //We have an EndSwitchNode :
652   else {
653     int i ;
654     for ( i = LinkedFromNodesSize() - 1 ; i >= 0  ; i-- ) {
655       GraphBase::ComputingNode * aLinkedFromNode = (GraphBase::ComputingNode * ) LinkedFromNodes( i ) ;
656       cdebug << aLinkedFromNode->Name() << " linked to " << Name() << endl ;
657       int j ;
658       for ( j = aLinkedFromNode->GetNodeOutPortsSize() - 1 ; j >= 0 ; j-- ) {
659         GraphBase::OutPort * anOutPort = aLinkedFromNode->GetChangeNodeOutPort( j ) ;
660         cdebug << "ComputingNode::DelInPort OutPort" << j << ". Remove " << anOutPort->InPortsSize()
661                << " InPortsof OutPort : " << anOutPort->NodeName() << "( "
662                << anOutPort->PortName() << ") "
663                << anOutPort->PortStatus() << " :" << endl ;
664         int k ;
665 //Process concerned OutPorts of LinkedFromNodes of that EndSwitchNode
666         for ( k = anOutPort->InPortsSize() - 1 ; k >= 0  ; k-- ) {
667           GraphBase::InPort * anInPort = anOutPort->ChangeInPorts( k ) ;
668           if ( !strcmp( anInPort->NodeName() , Name() ) &&
669                !strcmp( anInPort->PortName() , InputParameterName ) ) {
670 // InPort of the EndSwitchNode
671             cdebug << "       to InPort" << j << ". " << anInPort->NodeName() << "( "
672                    << anInPort->PortName() << ") "
673                    << anInPort->PortStatus() << endl ;
674             anInPort->RemoveOutPort() ;
675             if ( anOutPort->IsDataStream() ) {
676               aLinkedFromNode->RemoveStreamLinkedNode( this ) ;
677             }
678             else {
679 // false ==> No error for aNode->LinkedFromNode()
680               RetVal = aLinkedFromNode->RemoveLinkedNode( this , false ) ;
681               if ( !RetVal ) {
682                 cdebug << "ComputingNode::DelInPort aLinkedFromNode->RemoveLinkedNode Error RetVal "
683                        << RetVal << endl ;
684                 break ;
685               }
686             }
687 // Remove the InPort of the EndSwitchNode from that OutPort
688             RetVal = anOutPort->RemoveInPort( anInPort ) ;
689             if ( !RetVal ) {
690               cdebug << "ComputingNode::DelInPort anOutPort->RemoveInPort( anInPort ) Error RetVal "
691                      << RetVal << endl ;
692               break ;
693             }
694           }
695         }
696       }
697     }
698   }
699
700   GraphBase::PortsOfNode::DelInPort( InputParameterName ) ;
701   cdebug_out << "ComputingNode::DelInPort " << Name() << "( " << InputParameterName << " )"
702              << endl;
703 }
704 void GraphBase::ComputingNode::DelOutPort( const char * OutputParameterName ) {
705 //PAL9122
706 //JR 07.06.2005 Debug : LinkedNodes and LinkedFromNode must be updated
707 //                      LinkedInPortsNumber and LinkedFromInPortsNumber must be updated
708   cdebug_in << "ComputingNode::DelOutPort " << Name() << "( " << OutputParameterName << " )"
709             << endl;
710   bool RetVal = true ;
711   GraphBase::OutPort * anOutPort = GetChangeOutPort( OutputParameterName ) ;
712   cdebug << "ComputingNode::DelOutPort OutPort " << " InPortof OutPort : "
713          << anOutPort->NodeName() << "( " << anOutPort->PortName() << ") "
714          << anOutPort->PortStatus() << " :" << endl ;
715   int j ;
716   for ( j = anOutPort->InPortsSize() - 1 ; j >= 0  ; j-- ) {
717     GraphBase::InPort * anInPort = anOutPort->ChangeInPorts( j ) ;
718     GraphBase::ComputingNode * ToNode = NULL ;
719     cdebug << "       to InPort" << j << ". " << anInPort->NodeName() << "( "
720            << anInPort->PortName() << ") " << anInPort->PortStatus() ;
721     if ( anInPort->IsExternConnected() ) {
722       cdebug << " ExternConnected ignored" << endl ;
723     }
724     else {
725       cdebug << endl ;
726       ToNode = GraphOfNode()->GetChangeGraphNode( anInPort->NodeName() ) ;
727     }
728     if ( ToNode ) {
729       RetVal = anInPort->RemoveOutPort() ;
730 // JR 04.02.2005 : Bug if it is a link to an EndSwitchNode. The InPort may be multiple linked !!!
731 // PAL7990
732       if ( !RetVal ) {
733         cdebug << "ComputingNode::DelOutPort anOutPort->RemoveOutPort Error RetVal " << RetVal
734                << endl ;
735         break ;
736       }
737       if ( ( IsGOTONode() && ToNode->IsOneOfInLineNodes() ) ||
738            ( IsEndLoopNode() && ToNode->IsLoopNode( ) ) ) {
739       }
740       else if ( anOutPort->IsDataStream() ) {
741         RetVal = RemoveStreamLinkedNode( ToNode ) ;
742       }
743       else {
744         RetVal = RemoveLinkedNode( ToNode ) ;
745       }
746       if ( !RetVal ) {
747         cdebug << "ComputingNode::DelOutPort anOutPort->RemoveLinkedNode Error RetVal " << RetVal
748                << endl ;
749         break ;
750       }
751       if ( ToNode->IsEndSwitchNode() ) {
752         int i ;
753         int done = false ;
754         for ( i = 0 ; i < ToNode->LinkedFromNodesSize() ; i++ ) {
755           GraphBase::StreamNode * fromNode = ToNode->LinkedFromNodes( i ) ;
756 // Not the node that we are deleting ... :
757           if ( strcmp( fromNode->Name() , Name() ) ) {
758             int j ;
759             for ( j = 0 ; j < fromNode->GetNodeOutPortsSize() ; j++ ) {
760               GraphBase::OutPort * fromOutPort = fromNode->GetChangeNodeOutPort( j ) ;
761               int k ;
762               for ( k = 0 ; k < fromOutPort->InPortsSize() ; k++ ) {
763                 if ( strcmp( ToNode->Name() , fromOutPort->InPorts( k )->NodeName() ) == 0 ) {
764                   if ( strcmp( anInPort->PortName() , fromOutPort->InPorts( k )->PortName() ) == 0 ) {
765 // Restore an OutPort in the InPort
766                     anInPort->ChangeOutPort( fromOutPort ) ;
767                     cdebug << "ComputingNode::DelOutPort reestablish " << fromOutPort->NodeName() << "( "
768                            << fromOutPort->PortName() << " ) in the InPort of EndSwitch : "
769                            << ToNode->Name() << "( " << anInPort->PortName() << " )"
770                            << anInPort->Kind() << " " << anInPort->PortStatus()  << endl;
771                     done = true ;
772                     break ;
773                   }
774                 }
775               }
776               if ( done ) {
777                 break ;
778               }
779             }
780             if ( done ) {
781               break ;
782             }
783           }
784         }
785       }
786     }
787   }
788   if ( !RetVal ) {
789     cdebug << "Error RetVal " << RetVal << endl ;
790   }
791
792   GraphBase::PortsOfNode::DelOutPort( OutputParameterName ) ;
793   cdebug_out << "ComputingNode::DelOutPort " << Name() << "( " << OutputParameterName << " )"
794              << endl;
795 }
796
797 GraphBase::InPort * GraphBase::ComputingNode::AddInPort( const char * InputParameterName ,
798                                                          const char * InputParameterType ,
799                                                          const SUPERV::KindOfPort aKindOfPort ,
800                                                          int index ) {
801   cdebug << "AddInPort " << Name() << " ConnectedInPortsNumber " << ConnectedInPortsNumber() << endl ;
802 // JR 12.01.2005 : InitLoop and DoLoop are reserved parameter names in LoopNodes :
803   if ( IsLoopNode() && ( strcmp( InputParameterName , "InitLoop" ) == 0 ||
804                          strcmp( InputParameterName , "DoLoop" ) == 0 ) ) {
805     return NULL ;
806   }
807   return GraphBase::PortsOfNode::AddInPort( _ORB , NamePtr() ,
808                                             Kind() ,
809                                             InputParameterName ,
810                                             InputParameterType ,
811                                             aKindOfPort ,
812                                             index ,
813                                             _Graph_prof_debug , _Graph_fdebug ) ;
814 }
815 GraphBase::OutPort * GraphBase::ComputingNode::AddOutPort( const char * OutputParameterName ,
816                                                            const char * OutputParameterType ,
817                                                            const SUPERV::KindOfPort aKindOfPort ,
818                                                            int index ) {
819   cdebug << "AddOutPort " << Name() << " ConnectedInPortsNumber " << ConnectedInPortsNumber() << endl ;
820   return GraphBase::PortsOfNode::AddOutPort( _ORB , NamePtr() ,
821                                              Kind() ,
822                                              OutputParameterName ,
823                                              OutputParameterType ,
824                                              aKindOfPort ,
825                                              index ,
826                                              _Graph_prof_debug , _Graph_fdebug ) ;
827 }
828
829 void GraphBase::ComputingNode::DelInDataStreamPort( const char * InputParameterName ) {
830   GraphBase::PortsOfNode::DelInPort( InputParameterName ) ;
831 }
832 void GraphBase::ComputingNode::DelOutDataStreamPort( const char * OutputParameterName ) {
833   GraphBase::PortsOfNode::DelOutPort( OutputParameterName ) ;
834 }
835
836 GraphBase::InDataStreamPort * GraphBase::ComputingNode::AddInDataStreamPort( const char * InputParameterName ,
837                                                                              const SALOME_ModuleCatalog::DataStreamType InputParameterType ,
838                                                                              const SALOME_ModuleCatalog::DataStreamDependency aDependency ,
839                                                                              const SUPERV::KindOfPort aKindOfPort ,
840                                                                              int index ) {
841 //  IncrDataStreamInPorts() ;
842   GraphBase::InDataStreamPort * aDataStreamPort ;
843   aDataStreamPort = (GraphBase::InDataStreamPort * ) GraphBase::PortsOfNode::AddInPort( _ORB , NamePtr() ,
844                                                                                         Kind() ,
845                                                                                         InputParameterName ,
846                                                                                         DataStreamTypeToString( InputParameterType ).c_str() ,
847                                                                                         aKindOfPort ,
848                                                                                         index ,
849                                                                                         _Graph_prof_debug ,
850                                                                                         _Graph_fdebug ) ;
851   aDataStreamPort->Dependency( aDependency ) ;
852   if ( aDependency == SALOME_ModuleCatalog::DATASTREAM_TEMPORAL ) {
853     aDataStreamPort->SetParams( SUPERV::TI , SUPERV::L1 , SUPERV::EXTRANULL ) ;
854   }
855   return aDataStreamPort ;
856 }
857 GraphBase::OutDataStreamPort * GraphBase::ComputingNode::AddOutDataStreamPort( const char * OutputParameterName ,
858                                                                                const SALOME_ModuleCatalog::DataStreamType OutputParameterType ,
859                                                                                const SALOME_ModuleCatalog::DataStreamDependency aDependency ,
860                                                                                const SUPERV::KindOfPort aKindOfPort ,
861                                                                                int index ) {
862 //  IncrDataStreamOutPorts() ;
863   GraphBase::OutDataStreamPort * aDataStreamPort ;
864   aDataStreamPort = (GraphBase::OutDataStreamPort * ) GraphBase::PortsOfNode::AddOutPort( _ORB , NamePtr() ,
865                                                                                           Kind() ,
866                                                                                           OutputParameterName ,
867                                                                                           DataStreamTypeToString( OutputParameterType ).c_str() ,
868                                                                                           aKindOfPort ,
869                                                                                           index ,
870                                                                                           _Graph_prof_debug ,
871                                                                                           _Graph_fdebug ) ;
872   aDataStreamPort->Dependency( aDependency ) ;
873   return aDataStreamPort ;
874 }
875
876
877 bool GraphBase::ComputingNode::CheckLoop( GraphBase::LoopNode * aLoopNode ,
878                                           GraphBase::EndOfLoopNode * anEndLoopNode ,
879                                           string & anErrorMessage ) const {
880   cdebug_in << Name() << "->ComputingNode::CheckLoop( " << aLoopNode->Name() << " , "
881             << anEndLoopNode->Name() << ") LinkedNodesSize "
882             << LinkedNodesSize() << endl;
883
884   int i ;
885   if ( LinkedNodesSize() == 0 && !IsDataFlowNode() && !IsDataStreamNode() ) {
886     anErrorMessage = anErrorMessage + string( "The node " ) + string( Name() ) +
887                      string( " has no linked Nodes. Loop not valid\n" ) ;
888     cdebug_out << Name() << "->ComputingNode::CheckLoop( " << aLoopNode->Name()
889                << " , " << anEndLoopNode->Name() << ") LinkedNodesSize "
890                << LinkedNodesSize() << " ERROR false" << endl;
891     return false ;
892   }
893 // We check that all nodes linked to that node go to the end of LoopNode :
894   for ( i = 0 ; i < LinkedNodesSize() ; i++ ) {
895     GraphBase::ComputingNode * aNode = (GraphBase::ComputingNode * ) LinkedNodes( i ) ;
896     cdebug << i << ". " << Name() << " Linked to " << aNode->Name() << endl ;
897     if ( !aNode->IsEndLoopNode() || aNode != anEndLoopNode ) {
898       if ( !aNode->CheckLoop( aLoopNode , anEndLoopNode , anErrorMessage) ) {
899         cdebug_out << Name() << "->ComputingNode::CheckLoop( " << aLoopNode->Name()
900                    << " , " << anEndLoopNode->Name() << ") LinkedNodesSize "
901                    << LinkedNodesSize() << " ERROR false" << endl;
902         return false ;
903       }
904     }
905   }
906   cdebug_out << Name() << "->ComputingNode::CheckLoop( " << aLoopNode->Name() << " , "
907              << anEndLoopNode->Name() << ") LinkedNodesSize "
908              << LinkedNodesSize() << " true" << endl;
909   return true ;
910 }
911
912 bool GraphBase::ComputingNode::CheckEndLoop(GraphBase::LoopNode * aLoopNode ,
913                                             GraphBase::EndOfLoopNode * anEndLoopNode ,
914                                             string & anErrorMessage ) const {
915   cdebug_in << Name() << "->ComputingNode::CheckEndLoop( " << aLoopNode->Name() << " , "
916             << anEndLoopNode->Name() << ") LinkedFromNodesSize "
917             << LinkedFromNodesSize() << endl;
918
919   int i ;
920   if ( LinkedFromNodesSize() == 0 ) {
921     anErrorMessage = anErrorMessage + string( "The node " ) + string( Name() ) +
922                      string( " has no reversed linked Nodes. Loop not valid\n" ) ;
923     cdebug_out << Name() << "->ComputingNode::CheckEndLoop( " << aLoopNode->Name()
924                << " , " << anEndLoopNode->Name() << ") LinkedFromNodesSize "
925                << LinkedFromNodesSize() << " ERROR false" << endl;
926     return false ;
927   }
928 // We have to check that all nodes linked from that node go to the beginning of LoopNode : 
929   for ( i = 0 ; i < LinkedFromNodesSize() ; i++ ) {
930     GraphBase::ComputingNode * aNode = (GraphBase::ComputingNode * ) LinkedFromNodes( i ) ;
931     cdebug << i << ". " << Name() << " Linked from " << aNode->Name() << endl ;
932     if ( !aNode->IsLoopNode() || aNode != aLoopNode ) {
933       if ( !aNode->CheckEndLoop( aLoopNode , anEndLoopNode , anErrorMessage ) ) {
934         cdebug_out << Name() << "->ComputingNode::CheckEndLoop( " << aLoopNode->Name()
935                    << " , " << anEndLoopNode->Name() << ") LinkedFromNodesSize "
936                    << LinkedFromNodesSize() << " ERROR false" << endl;
937         return false ;
938       }
939     }
940   }
941   cdebug_out << Name() << "->ComputingNode::CheckEndLoop( " << aLoopNode->Name() << " , "
942              << anEndLoopNode->Name() << ") LinkedFromNodesSize "
943              << LinkedFromNodesSize() << " true" << endl;
944   return true ;
945 }
946
947 bool GraphBase::ComputingNode::InitBranchOfSwitchDone( bool AllInit ,
948                                                        GraphBase::EndOfSwitchNode * anEndSwitchNode ,
949                                                        string & anErrorMessage ) {
950   bool RetVal = true ;
951   bool sts = BranchOfSwitchDone( false ) ;
952   if ( !sts && !AllInit && anEndSwitchNode != this ) {
953 // Common Node in branchs :
954     anErrorMessage = anErrorMessage + string( "Common Node between some SwitchBranches : " ) +
955                      string( Name() ) + string("\n" ) ;
956     cdebug << Name() << "->ComputingNode::InitBranchOfSwitchDone ERROR false"
957            << endl ;
958     RetVal = false ;
959   }
960   int i ;
961   if ( !IsGOTONode() && anEndSwitchNode != this ) {
962     for ( i = 0 ; i < LinkedNodesSize() ; i++ ) {
963       GraphBase::ComputingNode * aNode ;
964       aNode = (GraphBase::ComputingNode * ) LinkedNodes( i ) ;
965       if ( !aNode->InitBranchOfSwitchDone( AllInit , anEndSwitchNode , anErrorMessage ) ) {
966         RetVal = false ;
967       }
968     }
969   }
970   return RetVal ;
971 }
972
973 bool GraphBase::ComputingNode::CheckSwitch( GraphBase::EndOfSwitchNode * anEndSwitchNode ,
974                                             string & anErrorMessage ) {
975   bool RetVal = true ;
976   cdebug_in << Name() << "->ComputingNode::CheckSwitch( "
977             << anEndSwitchNode->Name() << " ) " << Kind() << endl;
978   if ( anEndSwitchNode == this ) {
979   }
980 // if it is a SwitchNode, continue the check at the corresponding EndSwitchNode
981   else if ( IsSwitchNode() ) {
982     GraphBase::EndOfSwitchNode * anOtherEndSwitchNode ;
983     anOtherEndSwitchNode = (GraphBase::EndOfSwitchNode * ) ((GraphBase::SwitchNode * ) this)->CoupledNode() ;
984     cdebug << Name() << "->ComputingNode::CheckSwitch will Check "
985            << anOtherEndSwitchNode->Name() << endl ;
986     if ( !anOtherEndSwitchNode->CheckSwitch( anEndSwitchNode , anErrorMessage ) ) {
987       cdebug_out << Name() << "->ComputingNode::CheckSwitch "
988                  << anOtherEndSwitchNode->Name() << " ERROR false" << endl;
989       RetVal = false ;
990     }
991   }
992   else {
993     int i ;
994     for ( i = 0 ; i < GetNodeOutPortsSize() ; i++ ) {
995       GraphBase::OutPort * anOutPort = GetChangeNodeOutPort( i ) ;
996       if ( !anOutPort->IsDataStream() ) {
997         int j ;
998         for ( j = 0 ; j < anOutPort->InPortsSize() ; j++ ) {
999           GraphBase::InPort * anInPort = anOutPort->ChangeInPorts( j ) ;
1000           if ( !anInPort->IsDataStream() ) {
1001             GraphBase::ComputingNode * aNode ;
1002             aNode = GraphOfNode()->GetChangeGraphNode( anInPort->NodeName() ) ;
1003             GraphBase::LoopNode * aLoopNode = NULL ;
1004             GraphBase::EndOfLoopNode * aEndLoopNode = NULL ;
1005             if ( IsLoopNode() ) {
1006               aEndLoopNode = (GraphBase::EndOfLoopNode * ) ((GraphBase::LoopNode * ) this)->CoupledNode() ;
1007               cdebug << Name() << "->ComputingNode::CheckSwitch LoopNode " << Name() << " coupled to "
1008                      << aEndLoopNode << " " << aEndLoopNode->Name() << " aNode " << aNode << endl ;
1009             }
1010             else if ( IsEndLoopNode() ) {
1011               aLoopNode = (GraphBase::LoopNode * ) ((GraphBase::EndOfLoopNode * ) this)->CoupledNode() ;
1012               cdebug << Name() << "->ComputingNode::CheckSwitch EndLoopNode " << Name()
1013                      << " coupled to "
1014                      << aLoopNode << " " << aLoopNode->Name() << " aNode " << aNode << endl ;
1015             }
1016             if ( aNode == NULL ) {
1017               cdebug << Name() << "->ComputingNode::CheckSwitch ignore "
1018                      << anInPort->NodeName() << "( " << anInPort->PortName() << " )" << endl ;
1019             }
1020             else if ( aNode == anEndSwitchNode ) {
1021               if ( !((GraphBase::EndOfSwitchNode * ) aNode)->DecrEndSwitchInPortLinked( anInPort ,
1022                                                                                         anErrorMessage ) ) {
1023                 RetVal = false ;
1024               }
1025             }
1026             else if ( aNode->BranchOfSwitchDone() ) {
1027               cdebug << Name() << "->ComputingNode::CheckSwitch will NOT Check "
1028                      << anInPort->NodeName() << "( " << anInPort->PortName() << " ) : already checked"
1029                      << endl ;
1030             }
1031             else if ( IsLoopNode() && aNode == aEndLoopNode ) {
1032               cdebug << Name() << "->ComputingNode::CheckSwitch will NOT Check "
1033                      << anInPort->NodeName() << "( " << anInPort->PortName() << " )" << endl ;
1034             }
1035             else if ( IsEndLoopNode() && aNode == aLoopNode ) {
1036               cdebug << Name() << "->ComputingNode::CheckSwitch will NOT Check "
1037                      << anInPort->NodeName() << "( " << anInPort->PortName() << " )" << endl ;
1038             }
1039             else if ( aNode->IsGOTONode() ) {
1040               cdebug << Name() << "->ComputingNode::CheckSwitch will NOT Check "
1041                      << anInPort->NodeName() << "( " << anInPort->PortName() << " )" << endl ;
1042               anEndSwitchNode->SetSwitchWithGOTO() ;
1043             }
1044             else {
1045               cdebug << Name() << "->ComputingNode::CheckSwitch will Check "
1046                      << anInPort->NodeName() << "( " << anInPort->PortName() << " )" << endl ;
1047               if ( !aNode->CheckSwitch( anEndSwitchNode , anErrorMessage ) ) {
1048                 cdebug_out << Name() << "->ComputingNode::CheckSwitch "
1049                          << anEndSwitchNode->Name() << " ERROR false" << endl;
1050                 RetVal =  false ;
1051               }
1052 //            aNode->BranchOfSwitchDone( true ) ;
1053             }
1054           }
1055         }
1056       }
1057     }
1058   }
1059   if ( RetVal ) {
1060     BranchOfSwitchDone( true ) ;
1061   }
1062   cdebug_out << Name() << "->ComputingNode::CheckSwitch "
1063              << anEndSwitchNode->Name() << " RetVal " << RetVal << endl;
1064   return RetVal ;
1065 }
1066
1067 #include <sys/time.h>
1068 #include <sys/resource.h>
1069 #include <unistd.h>
1070
1071 const long GraphBase::ComputingNode::CpuUsed() {
1072   struct rusage usage ;
1073   if ( getrusage( RUSAGE_SELF , &usage ) == -1 ) {
1074     perror("GraphBase::CpuUsed") ;
1075     return 0 ;
1076   }
1077 //  return usage.ru_utime.__time_t tv_sec ;
1078   cdebug << "CpuUsed " << usage.ru_utime.tv_sec << " " << usage.ru_utime.tv_usec << " "
1079          << usage.ru_stime.tv_sec << " " << usage.ru_stime.tv_usec << endl ;
1080   return usage.ru_utime.tv_sec ;
1081 }
1082
1083 #if 0
1084 const GraphBase::ListOfParameters * GraphBase::ComputingNode::GetListOfParameters() const {
1085   GraphBase::ListOfParameters * aListOfParameters = new GraphBase::ListOfParameters ;
1086   if ( IsInLineNode() || IsGOTONode() ) {
1087     unsigned int i;
1088     for ( i = 0 ; i < GetNodeInPortsSize() ; i++ ) {
1089       const InPort * anInPort = GetNodeInPort( i ) ;
1090       if ( anInPort->IsBus() ) {
1091         int size = aListOfParameters->size() ;
1092         aListOfParameters->resize( size + 1 ) ;
1093         (*aListOfParameters)[size].theInParameter.Parametername = anInPort->PortName() ;
1094         (*aListOfParameters)[size].theInParameter.Parametertype = anInPort->PortType() ;
1095         const OutPort * anOutPort = GetNodeOutPort( anInPort->PortIndex() ) ;
1096         (*aListOfParameters)[size].theOutParameter.Parametername = anOutPort->PortName() ;
1097         (*aListOfParameters)[size].theOutParameter.Parametertype = anOutPort->PortType() ;
1098       }
1099     }
1100   }
1101   return aListOfParameters ;
1102 }
1103 #endif
1104
1105 bool GraphBase::ComputingNode::SaveXML( QDomDocument & Graph , QDomElement & info ,
1106                                         const char * ComponentName ,
1107                                         const char * InterfaceName ,
1108                                         const char * Computer ,
1109                                         const char * CoupledNode ,
1110                                         const ListOfFuncName FuncNames ,
1111                                         const ListOfPythonFunctions PythonFunctions ,
1112                                         int XCoordinate , int YCoordinate ) const {
1113   cdebug_in << "SaveXML Node " << Name() << endl ;
1114   QDomElement node = Graph.createElement( "node" ) ;
1115   info.appendChild( node ) ;
1116   QDomElement componentname = Graph.createElement( "component-name" ) ;
1117   QDomText aField ;
1118   if ( strlen( ComponentName ) ) {
1119 //    f << Tabs << "<component-name>" << ComponentName << "</component-name>"
1120 //      << endl ;
1121 //    componentname.setNodeValue( ComponentName ) ;
1122     aField = Graph.createTextNode( ComponentName ) ;
1123   }
1124   else {
1125 //    f << Tabs << "<component-name>?</component-name>" << endl ;
1126 //    componentname.setNodeValue( "?" ) ;
1127     aField = Graph.createTextNode( "?" ) ;
1128   }
1129   node.appendChild( componentname ) ;
1130   componentname.appendChild( aField ) ;
1131
1132   QDomElement interfacename = Graph.createElement("interface-name") ;
1133   if ( strlen( InterfaceName ) ) {
1134 //    f << Tabs << "<interface-name>" << InterfaceName << "</interface-name>"
1135 //      << endl ;
1136 //    interfacename.setAttribute("name" , InterfaceName ) ;
1137     aField = Graph.createTextNode( InterfaceName ) ;
1138   }
1139   else {
1140 //    f << Tabs << "<interface-name>?</interface-name>" << endl ;
1141 //    interfacename.setAttribute("name" , "?" ) ;
1142     aField = Graph.createTextNode( "?" ) ;
1143   }
1144   node.appendChild(interfacename) ;
1145   interfacename.appendChild( aField ) ;
1146
1147 //  f << Tabs << "<node-name>" << Name() << "</node-name>" << endl ;
1148   QDomElement nodename = Graph.createElement("node-name") ;
1149   aField = Graph.createTextNode( Name() ) ;
1150   node.appendChild( nodename ) ;
1151   nodename.appendChild( aField ) ;
1152
1153 //  f << Tabs << "<kind>" << (int ) Kind() << "</kind>" << endl ;
1154   QDomElement kind = Graph.createElement( "kind" ) ;
1155   QString aKind ;
1156
1157   // san - Presumably, data stream graphs should be always saved with kind = DataStreamGraph
1158 // JR : the bug was at line 566 : && HasDataStream() != 0 was missing
1159   if ( IsDataFlowNode() || ( IsDataStreamNode() && HasDataStream() == 0 ) ) {
1160     aKind = aKind.setNum( SUPERV::DataFlowGraph ) ;
1161   }
1162   else {
1163     aKind = aKind.setNum( Kind() ) ;
1164   }
1165   aField = Graph.createTextNode( aKind ) ;
1166   node.appendChild( kind ) ;
1167   kind.appendChild( aField ) ;
1168
1169   if ( IsDataStreamNode() && HasDataStream() != 0 ) {
1170     long Timeout ;
1171     SUPERV::KindOfDataStreamTrace DataStreamTrace ;
1172     double DeltaTime ;
1173     ((GraphBase::StreamGraph * ) this)->StreamParams( Timeout , DataStreamTrace , DeltaTime ) ;
1174
1175     QDomElement timeout = Graph.createElement("streamgraph-timeout") ;
1176     QString aTimeout ;
1177     aTimeout = aTimeout.setNum( Timeout ) ;
1178     aField = Graph.createTextNode( aTimeout ) ;
1179     node.appendChild( timeout ) ;
1180     timeout.appendChild( aField ) ;
1181
1182     QDomElement datastreamtrace = Graph.createElement("streamgraph-datastreamtrace") ;
1183     QString aDataStreamTrace ;
1184     aDataStreamTrace = aDataStreamTrace.setNum( DataStreamTrace ) ;
1185     aField = Graph.createTextNode( aDataStreamTrace ) ;
1186     node.appendChild( datastreamtrace ) ;
1187     datastreamtrace.appendChild( aField ) ;
1188
1189     QDomElement deltatime = Graph.createElement("streamgraph-deltatime") ;
1190     QString aDeltaTime ;
1191     aDeltaTime = aDeltaTime.setNum( DeltaTime ) ;
1192     aField = Graph.createTextNode( aDeltaTime ) ;
1193     node.appendChild( deltatime ) ;
1194     deltatime.appendChild( aField ) ;
1195   }
1196
1197   QDomElement couplednode = Graph.createElement("coupled-node") ;
1198   if ( IsGOTONode() || IsLoopNode() || IsEndLoopNode() ||
1199        IsSwitchNode() || IsEndSwitchNode() || IsMacroNode() ) {
1200 //    f << Tabs << "<coupled-node>" << CoupledNode << "</coupled-node>"
1201 //      << endl ;
1202     aField = Graph.createTextNode( CoupledNode ) ;
1203   }
1204   else {
1205 //    f << Tabs << "<coupled-node>?</coupled-node>" << endl ;
1206     aField = Graph.createTextNode( "?" ) ;
1207   }
1208   node.appendChild(couplednode) ;
1209   couplednode.appendChild( aField ) ;
1210
1211 //  f << Tabs << "<service>" << endl ;
1212   QDomElement service = Graph.createElement("service") ;
1213   node.appendChild(service) ;
1214   QDomElement servicename = Graph.createElement("service-name") ;
1215   if ( strlen( ServiceName() ) ) {
1216 //    f << Tabs << "    <service-name>" << ServiceName() << "</service-name>" << endl ;
1217     aField = Graph.createTextNode( ServiceName() ) ;
1218   }
1219   else {
1220 //    f << Tabs << "    <service-name>?</service-name>" << endl ;
1221     aField = Graph.createTextNode( "?" ) ;
1222   }
1223   service.appendChild(servicename) ;
1224   servicename.appendChild( aField ) ;
1225
1226   cdebug << "SaveXML " << Name() << " In(" << ServiceInParameter().length()
1227          << ") Out(" << ServiceOutParameter().length() << ")" << endl ;
1228   QDomElement inParameterlist = Graph.createElement("inParameter-list") ;
1229   service.appendChild(inParameterlist) ;
1230   unsigned int i;
1231   GraphBase::ComputingNode * aNode = (GraphBase::ComputingNode * ) this ;
1232   for ( i = 0 ; i < ServiceInParameter().length() ; i++ ) {
1233     const GraphBase::InPort * anInPort ;
1234     anInPort = aNode->GetInPort( ServiceInParameter()[i].Parametername ) ;
1235     if ( !anInPort->IsDataStream() ) {
1236       cdebug << "SaveXML " << i << ". " << ServiceInParameter()[i].Parametername
1237              << " InParameterPort " << anInPort->Kind() << endl ;
1238       QDomElement inParameter = Graph.createElement("inParameter") ;
1239       inParameterlist.appendChild(inParameter) ;
1240       QDomElement inParametertype = Graph.createElement("inParameter-type") ;
1241       if ( strlen( ServiceInParameter()[i].Parametertype ) ) {
1242         aField = Graph.createTextNode( strdup( ServiceInParameter()[i].Parametertype ) ) ;
1243       }
1244       else {
1245         aField = Graph.createTextNode( "?" ) ;
1246       }
1247       inParameter.appendChild(inParametertype) ;
1248       inParametertype.appendChild( aField ) ;
1249       QDomElement inParametername = Graph.createElement("inParameter-name") ;
1250       if ( strlen( ServiceInParameter()[i].Parametername ) ) {
1251         aField = Graph.createTextNode( strdup(ServiceInParameter()[i].Parametername) ) ;
1252       }
1253       else {
1254         aField = Graph.createTextNode( "?" ) ;
1255       }
1256       inParameter.appendChild(inParametername) ;
1257       inParametername.appendChild( aField ) ;
1258     }
1259   }
1260   QDomElement outParameterlist = Graph.createElement("outParameter-list") ;
1261   service.appendChild(outParameterlist) ;
1262   for ( i = 0 ; i < ServiceOutParameter().length() ; i++ ) {
1263     const GraphBase::OutPort * anOutPort ;
1264     anOutPort = aNode->GetOutPort( ServiceOutParameter()[i].Parametername ) ;
1265     if ( !anOutPort->IsDataStream() ) {
1266       cdebug << "SaveXML " << i << ". " << ServiceOutParameter()[i].Parametername
1267              << " OutParameterPort " << anOutPort->Kind() << endl ;
1268       QDomElement outParameter = Graph.createElement("outParameter") ;
1269       outParameterlist.appendChild(outParameter) ;
1270       QDomElement outParametertype = Graph.createElement("outParameter-type") ;
1271       if ( strlen( ServiceOutParameter()[i].Parametertype ) ) {
1272         aField = Graph.createTextNode( strdup(ServiceOutParameter()[i].Parametertype) ) ;
1273       }
1274       else {
1275         aField = Graph.createTextNode( "?" ) ;
1276       }
1277       outParameter.appendChild(outParametertype) ;
1278       outParametertype.appendChild( aField ) ;
1279       QDomElement outParametername = Graph.createElement("outParameter-name") ;
1280       if ( strlen( ServiceOutParameter()[i].Parametername ) ) {
1281         aField = Graph.createTextNode( strdup(ServiceOutParameter()[i].Parametername) ) ;
1282       }
1283       else {
1284         aField = Graph.createTextNode( "?" ) ;
1285       }
1286       outParameter.appendChild(outParametername) ;
1287       outParametername.appendChild( aField ) ;
1288     }
1289   }
1290
1291   QDomElement DataStreamlist = Graph.createElement("DataStream-list") ;
1292   node.appendChild( DataStreamlist ) ;
1293   for ( i = 0 ; i < (unsigned int ) GetNodeInPortsSize() ; i++ ) {
1294     const GraphBase::InPort * anInPort ;
1295     anInPort = aNode->GetNodeInPort( i ) ;
1296     if ( anInPort->IsDataStream() ) {
1297       cdebug << "SaveXML " << i << " " << Name() << " " << anInPort->PortName() << " " << anInPort->PortType()
1298              << " InDataStreamPort " << anInPort->Kind() << endl ;
1299       QDomElement inParameter = Graph.createElement("inParameter") ;
1300       DataStreamlist.appendChild(inParameter) ;
1301       QDomElement inParametertype = Graph.createElement("inParameter-type") ;
1302       QString aType ;
1303       aType = aType.setNum( StringToDataStreamType( anInPort->PortType() ) ) ;
1304       cdebug << "SaveXML " << anInPort->PortType() << " --> " << StringToDataStreamType( anInPort->PortType() )
1305              << " " << aType << endl ;
1306       aField = Graph.createTextNode( aType ) ;
1307       inParameter.appendChild(inParametertype) ;
1308       inParametertype.appendChild( aField ) ;
1309       QDomElement inParametername = Graph.createElement("inParameter-name") ;
1310       if ( strlen( anInPort->PortName() ) ) {
1311         aField = Graph.createTextNode( strdup(anInPort->PortName()) ) ;
1312       }
1313       else {
1314         aField = Graph.createTextNode( "?" ) ;
1315       }
1316       inParameter.appendChild(inParametername) ;
1317       inParametername.appendChild( aField ) ;
1318       cdebug << "SaveXML " << anInPort->PortName() << endl ;
1319       QDomElement inParameterdependency = Graph.createElement("inParameter-dependency") ;
1320       QString aDependency ;
1321       aDependency = aDependency.setNum( anInPort->Dependency() ) ;
1322       aField = Graph.createTextNode( aDependency ) ;
1323       inParameter.appendChild(inParameterdependency) ;
1324       inParameterdependency.appendChild( aField ) ;
1325       cdebug << "SaveXML Dependency " << anInPort->Dependency() << endl ;
1326       SUPERV::KindOfSchema        aKindOfSchema ;
1327       SUPERV::KindOfInterpolation aKindOfInterpolation ;
1328       SUPERV::KindOfExtrapolation aKindOfExtrapolation ;
1329       ((GraphBase::InDataStreamPort * ) anInPort)->Params( aKindOfSchema , aKindOfInterpolation , aKindOfExtrapolation ) ;
1330       QDomElement inParameterKindOfSchema = Graph.createElement("inParameter-schema") ;
1331       QString aSchema ;
1332       aSchema = aSchema.setNum( aKindOfSchema ) ;
1333       aField = Graph.createTextNode( aSchema ) ;
1334       inParameter.appendChild(inParameterKindOfSchema) ;
1335       inParameterKindOfSchema.appendChild( aField ) ;
1336       cdebug << "SaveXML aKindOfSchema " << aKindOfSchema << endl ;
1337       QDomElement inParameterKindOfInterpolation = Graph.createElement("inParameter-interpolation") ;
1338       QString anInterpolation ;
1339       anInterpolation = anInterpolation.setNum( aKindOfInterpolation ) ;
1340       aField = Graph.createTextNode( anInterpolation ) ;
1341       inParameter.appendChild(inParameterKindOfInterpolation) ;
1342       inParameterKindOfInterpolation.appendChild( aField ) ;
1343       cdebug << "SaveXML aKindOfInterpolation " << aKindOfInterpolation << endl ;
1344       QDomElement inParameterKindOfExtrapolation = Graph.createElement("inParameter-extrapolation") ;
1345       QString anExtrapolation ;
1346       anExtrapolation = anExtrapolation.setNum( aKindOfExtrapolation ) ;
1347       aField = Graph.createTextNode( anExtrapolation ) ;
1348       inParameter.appendChild(inParameterKindOfExtrapolation) ;
1349       inParameterKindOfExtrapolation.appendChild( aField ) ;
1350       cdebug << "SaveXML aKindOfExtrapolation " << aKindOfExtrapolation << endl ;
1351     }
1352   }
1353   for ( i = 0 ; i < (unsigned int ) GetNodeOutPortsSize() ; i++ ) {
1354     const GraphBase::OutPort * anOutPort ;
1355     anOutPort = aNode->GetNodeOutPort( i ) ;
1356     if ( anOutPort->IsDataStream() ) {
1357       cdebug << "SaveXML " << i << " " << Name() << " " << anOutPort->PortName() << " " << anOutPort->PortType()
1358              << " OutDataStreamPort " << anOutPort->Kind() << endl ;
1359       QDomElement outParameter = Graph.createElement("outParameter") ;
1360       DataStreamlist.appendChild(outParameter) ;
1361       QDomElement outParametertype = Graph.createElement("outParameter-type") ;
1362       QString aType ;
1363       aType = aType.setNum( StringToDataStreamType( anOutPort->PortType() ) ) ;
1364       cdebug << "SaveXML " << anOutPort->PortType() << " --> " << StringToDataStreamType( anOutPort->PortType() )
1365              << " " << aType << endl ;
1366       aField = Graph.createTextNode( aType ) ;
1367       outParameter.appendChild(outParametertype) ;
1368       outParametertype.appendChild( aField ) ;
1369       QDomElement outParametername = Graph.createElement("outParameter-name") ;
1370       if ( strlen( anOutPort->PortName() ) ) {
1371         aField = Graph.createTextNode( strdup(anOutPort->PortName() ) ) ;
1372       }
1373       else {
1374         aField = Graph.createTextNode( "?" ) ;
1375       }
1376       outParameter.appendChild(outParametername) ;
1377       outParametername.appendChild( aField ) ;
1378       cdebug << "SaveXML " << anOutPort->PortName() << endl ;
1379       QDomElement outParameterdependency = Graph.createElement("outParameter-dependency") ;
1380       QString aDependency ;
1381       aDependency = aDependency.setNum( anOutPort->Dependency() )  ;
1382       aField = Graph.createTextNode( aDependency ) ;
1383       outParameter.appendChild(outParameterdependency) ;
1384       outParameterdependency.appendChild( aField ) ;
1385       cdebug << "SaveXML Dependency " << anOutPort->Dependency() << endl ;
1386       long aNumberOfValues ;
1387       aNumberOfValues = ((GraphBase::OutDataStreamPort * ) anOutPort)->NumberOfValues() ;
1388       QDomElement outParameterNumberOfValues = Graph.createElement("outParameter-values") ;
1389       QString aValues ;
1390       aValues = aValues.setNum( aNumberOfValues ) ;
1391       aField = Graph.createTextNode( aValues ) ;
1392       outParameter.appendChild(outParameterNumberOfValues) ;
1393       outParameterNumberOfValues.appendChild( aField ) ;
1394       cdebug << "SaveXML NumberOfValues " << ((GraphBase::OutDataStreamPort * ) anOutPort)->NumberOfValues() << endl ;
1395     }
1396   }
1397 //  f << Tabs << "</Parameter-list>" << endl ;    
1398
1399 //  f << Tabs << "<PyFunction-list>" << endl ;
1400   QDomElement PyFunctionlist = Graph.createElement("PyFunction-list") ;
1401   node.appendChild( PyFunctionlist ) ;
1402   for ( i = 0 ; i < PythonFunctions.size() ; i++ ) {
1403 //    f << Tabs << "    <PyFunction>" << endl ;
1404     QDomElement PyFunction = Graph.createElement("PyFunction") ;
1405     PyFunctionlist.appendChild( PyFunction ) ;
1406     int j ;
1407     QDomElement FuncName = Graph.createElement("FuncName") ;
1408     if ( strlen( FuncNames[i].c_str() ) ) {
1409       aField = Graph.createTextNode( FuncNames[i].c_str() ) ;
1410     }
1411     else {
1412       aField = Graph.createTextNode( "?" ) ;
1413     }
1414     PyFunction.appendChild( FuncName ) ;
1415     FuncName.appendChild( aField ) ;
1416     if ( (*PythonFunctions[i]).length() ) {
1417       for ( j = 0 ; j < (int ) (*PythonFunctions[i]).length() ; j++ ) {
1418         QDomElement PyFunc = Graph.createElement("PyFunc") ;
1419         QDomCDATASection aCDATA ;
1420       // mpv: Linux 8.0 compiler compatibility
1421         char * aCDATAChar = strdup ((*PythonFunctions[i])[j]) ;
1422         int i ;
1423         for ( i = 0 ; i < (int ) strlen( aCDATAChar ) ; i++ ) {
1424           if ( aCDATAChar[ i ] != ' ' ) {
1425             break ;
1426           }
1427         }
1428         if ( i == (int ) strlen( aCDATAChar ) ) {
1429           aCDATA = Graph.createCDATASection( "?" ) ;
1430         }
1431         else {
1432           aCDATA = Graph.createCDATASection( aCDATAChar ) ;
1433         }
1434         PyFunction.appendChild( PyFunc ) ;
1435         PyFunc.appendChild( aCDATA ) ;
1436       }
1437     }
1438     else {
1439       QDomElement PyFunc = Graph.createElement("PyFunc") ;
1440       QDomCDATASection aCDATA = Graph.createCDATASection( "?" ) ;
1441       PyFunction.appendChild( PyFunc ) ;
1442       PyFunc.appendChild( aCDATA ) ;
1443     }
1444   }
1445
1446 //  f << Tabs << "<creation-date>" << FirstCreation() << "</creation-date>"
1447 //    << endl ;
1448   QDomElement creationdate = Graph.createElement("creation-date") ;
1449   char fdate[30] ;
1450   sprintf( fdate , "%d/%d/%d - %d:%d:%d" ,  FirstCreation().Day , FirstCreation().Month , FirstCreation().Year , FirstCreation().Hour , FirstCreation().Minute , FirstCreation().Second ) ;
1451   aField = Graph.createTextNode( fdate ) ;
1452   node.appendChild( creationdate ) ;
1453   creationdate.appendChild( aField ) ;
1454 //  f << Tabs << "<lastmodification-date>" << LastModification()
1455 //    << "</lastmodification-date>" << endl ;
1456   QDomElement lastmodificationdate = Graph.createElement("lastmodification-date") ;
1457   char ldate[30] ;
1458   sprintf( ldate , "%d/%d/%d - %d:%d:%d" , LastModification().Day , LastModification().Month , LastModification().Year , LastModification().Hour , LastModification().Minute , LastModification().Second ) ;
1459   aField = Graph.createTextNode( ldate ) ;
1460   node.appendChild( lastmodificationdate ) ;
1461   lastmodificationdate.appendChild( aField ) ;
1462 //  f << Tabs << "<editor-release>" << EditorRelease() << "</editor-release>"
1463 //    << endl ;
1464   QDomElement editorrelease = Graph.createElement("editor-release") ;
1465   aField = Graph.createTextNode( EditorRelease() ) ;
1466   node.appendChild( editorrelease ) ;
1467   editorrelease.appendChild( aField ) ;
1468   QDomElement author = Graph.createElement("author") ;
1469   if ( strlen( Author() ) ) {
1470 //    f << Tabs << "<author>" << Author() << "</author>" << endl ;
1471     aField = Graph.createTextNode( Author() ) ;
1472   }
1473   else {
1474 //    f << Tabs << "<author>?</author>" << endl ;
1475     aField = Graph.createTextNode( "?" ) ;
1476   }
1477   node.appendChild( author ) ;
1478   author.appendChild( aField ) ;
1479   QDomElement container = Graph.createElement("container") ;
1480   if ( IsFactoryNode() && strlen( Computer) ) {
1481 //    f << Tabs << "<container>" << Computer << "</container>" << endl ;
1482     aField = Graph.createTextNode( Computer ) ;
1483   }
1484   else {
1485 //    f << Tabs << "<container>?</container>" << endl ;
1486     aField = Graph.createTextNode( "?" ) ;
1487   }
1488   node.appendChild( container ) ;
1489   container.appendChild( aField ) ;
1490   QDomElement comment = Graph.createElement("comment") ;
1491   if ( strlen( Comment() ) ) {
1492 //    f << Tabs << "<comment>" << Comment() << "</comment>" << endl ;
1493     aField = Graph.createTextNode( Comment() ) ;
1494   }
1495   else {
1496 //    f << Tabs << "<comment>?</comment>" << endl ;
1497     aField = Graph.createTextNode( "?" ) ;
1498   }
1499   node.appendChild( comment ) ;
1500   comment.appendChild( aField ) ;
1501 //  f << Tabs << "<x-position>" << XCoordinate << "</x-position>" << endl ;
1502   QDomElement xposition = Graph.createElement("x-position") ;
1503   QString aXCoordinate ;
1504   aXCoordinate = aKind.setNum( XCoordinate ) ;
1505   aField = Graph.createTextNode( aXCoordinate ) ;
1506   node.appendChild( xposition ) ;
1507   xposition.appendChild( aField ) ;
1508 //  f << Tabs << "<y-position>" << YCoordinate << "</y-position>" << endl ;
1509   QDomElement yposition = Graph.createElement("y-position") ;
1510   QString aYCoordinate ;
1511   aYCoordinate = aKind.setNum( YCoordinate ) ;
1512   aField = Graph.createTextNode( aYCoordinate ) ;
1513   node.appendChild( yposition ) ;
1514   yposition.appendChild( aField ) ;
1515   cdebug_out << "SaveXML Node " << Name() << endl ;
1516   return true ;
1517 }
1518
1519 bool GraphBase::ComputingNode::SavePY( ostream &f , const char * aGraphName ,
1520                                        const char * ComponentName ,
1521                                        const char * InterfaceName ,
1522                                        const char * Computer ,
1523                                        const GraphBase::InLineNode * aCoupledNode ,
1524                                        const ListOfFuncName FuncNames ,
1525                                        const ListOfPythonFunctions PythonFunctions ,
1526                                        int XCoordinate , int YCoordinate ) const {
1527   cdebug_in << "ComputingNode::SavePY " << Name() << endl ;
1528   // san - Presumably, data stream graphs should be always saved with kind = DataStreamGraph
1529 // JR : the bug was at line 927 : && HasDataStream() != 0 was missing
1530   if ( IsDataFlowNode() || ( IsDataStreamNode() && HasDataStream() == 0 ) ) {
1531     f << "    " << Name() << " = Graph( '" << Name() << "' )" << endl ;
1532      if ( GraphMacroLevel() ) {
1533       f << "    " << Name() << ".SetCoupled( '"
1534         << ((GraphBase::GOTONode * ) this)->CoupledNodeName() << "' )" << endl ;
1535     }
1536   }
1537   else if ( IsDataStreamNode() && HasDataStream() != 0 ) {
1538     f << "    " << Name() << " = StreamGraph( '" << Name() << "' )" << endl ;
1539     long Timeout ;
1540     SUPERV::KindOfDataStreamTrace DataStreamTrace ;
1541     double DeltaTime ;
1542     ((GraphBase::StreamGraph * ) this)->StreamParams( Timeout , DataStreamTrace , DeltaTime ) ;
1543     f << "    " << aGraphName << ".SetStreamParams( " << Timeout << " , SUPERV." << DataStreamTrace
1544       << " , " << DeltaTime << " )" << endl ;
1545   }
1546   else if ( IsComputingNode() ) {
1547     int i ;
1548     f << "    " << Name() << "_ServiceinParameter = []" << endl ;
1549     for ( i = 0 ; i < (int ) ServiceInParameter().length() ; i++ ) {
1550       f << "    " << Name() << "_ServiceinParameter.append( SALOME_ModuleCatalog.ServicesParameter( '"
1551         << ServiceInParameter()[i].Parametertype << "' , '"
1552         << ServiceInParameter()[i].Parametername << "' ) )" << endl ;
1553     }
1554     f << "    " << Name() << "_ServiceoutParameter = []" << endl ;
1555     for ( i = 0 ; i < (int ) ServiceOutParameter().length() ; i++ ) {
1556       f << "    " << Name() << "_ServiceoutParameter.append( SALOME_ModuleCatalog.ServicesParameter( '"
1557         << ServiceOutParameter()[i].Parametertype << "' , '"
1558         << ServiceOutParameter()[i].Parametername << "' ) )" << endl ;
1559     }
1560     f << "    " << Name() << "_ServiceinStreamParameter = []" << endl ;
1561     for ( i = 0 ; i < (int ) ServiceInStreamParameter().length() ; i++ ) {
1562       f << "    " << Name() << "_ServiceinStreamParameter.append( SALOME_ModuleCatalog.ServicesDataStreamParameter( SALOME_ModuleCatalog."
1563         << ServiceInStreamParameter()[i].Parametertype << " , '"
1564         << ServiceInStreamParameter()[i].Parametername << "' , SALOME_ModuleCatalog."
1565         << ServiceInStreamParameter()[i].Parameterdependency << " ) )" << endl ;
1566     }
1567     f << "    " << Name() << "_ServiceoutStreamParameter = []" << endl ;
1568     for ( i = 0 ; i < (int ) ServiceOutStreamParameter().length() ; i++ ) {
1569       f << "    " << Name() << "_ServiceoutStreamParameter.append( SALOME_ModuleCatalog.ServicesDataStreamParameter( SALOME_ModuleCatalog."
1570         << ServiceOutStreamParameter()[i].Parametertype << " , '"
1571         << ServiceOutStreamParameter()[i].Parametername << "' , SALOME_ModuleCatalog."
1572         << ServiceOutStreamParameter()[i].Parameterdependency << " ) )" << endl ;
1573     }
1574     f << "    " << Name() << "_Service = SALOME_ModuleCatalog.Service( '" << ServiceName()
1575       << "' , " << Name() << "_ServiceinParameter"
1576       << " , " << Name() << "_ServiceoutParameter"
1577       << " , " << Name() << "_ServiceinStreamParameter"
1578       << " , " << Name() << "_ServiceoutStreamParameter"
1579       << " , 0 , 0 )" << endl ;
1580     f << "    " << Name() << " = " << aGraphName << ".CNode( " << Name() << "_Service" << " )"
1581       << endl ;
1582   }
1583   else if ( IsFactoryNode() ) {
1584     f << "    " << Name() << " = " << aGraphName << ".FNode( '" << ComponentName
1585       << "' , '" << InterfaceName << "' , '" << ServiceName() << "' )"
1586       << endl ;
1587   }
1588   else if ( IsEndLoopNode() || IsEndSwitchNode() ) {
1589 // It is done with LoopNode or SwitchNode with CoupledNode()
1590   }
1591   else {
1592     if ( !IsMacroNode() ) {
1593       f << "    " << "Py" << Name() << " = []" << endl ;
1594     }
1595     int i ;
1596     SUPERV::ListOfStrings aPyFunc ;
1597     if ( PythonFunctions.size() ) {
1598       aPyFunc = *PythonFunctions[0] ;
1599       for ( i = 0 ; i < (int ) aPyFunc.length() ; i++ ) {
1600         f << "    " << "Py" << Name() << ".append( '" << aPyFunc[i] << "' )" << endl ;
1601       }
1602     }
1603     if ( IsInLineNode() ) {
1604       f << "    " << Name() << " = " << aGraphName << ".INode( '" << FuncNames[0].c_str() << "' , Py"
1605         << Name() << " )" << endl ;
1606     }
1607     else if ( IsGOTONode() ) {
1608       if ( aCoupledNode ) {
1609         f << "    " << Name() << " = " << aGraphName << ".GNode( '" << FuncNames[0].c_str() << "' , Py"
1610           << Name() << " , '" << aCoupledNode->Name() << "' )" << endl ;
1611       }
1612       else {
1613         f << "    " << Name() << " = " << aGraphName << ".GNode( '" << FuncNames[0].c_str() << "' , Py"
1614           << Name() << " , '' )" << endl ;
1615       }
1616     }
1617     else if ( IsMacroNode() ) {
1618       if ( aCoupledNode ) {
1619         f << "    " << aCoupledNode->Name() << " = Def" << aCoupledNode->Name() << "()" << endl ;
1620         f << "    " << Name() << " = " << aGraphName << ".GraphMNode( " << aCoupledNode->Name() << " )" << endl ;
1621       }
1622       else {
1623         f << "    " << Name() << " = " << aGraphName << ".GraphMNode( ? )" << endl ;
1624       }
1625       f << "    " << Name() << ".SetCoupled( '" << aCoupledNode->Name() << "' )" << endl ;
1626     }
1627     else {
1628 //      char * EndName = NULL ;
1629 //      EndName = new char[ 3 + strlen( Name() ) + 1 ] ;
1630 //      strcpy( EndName , "End" ) ;
1631 //      strcat( EndName , Name() ) ;
1632       char * EndName = aCoupledNode->Name() ;
1633       cdebug << "ComputingNode::SavePY Node " << Name() << " EndName " << EndName
1634              << endl ;
1635       if ( IsLoopNode() ) {
1636         int i ;
1637         SUPERV::ListOfStrings aPyMore = *PythonFunctions[1] ;
1638         SUPERV::ListOfStrings aPyNext = *PythonFunctions[2] ;
1639         f << "    " << "PyMore" << Name() << " = []" << endl ;
1640         for ( i = 0 ; i < (int ) aPyMore.length() ; i++ ) {
1641           f << "    " << "PyMore" << Name() << ".append( '" << aPyMore[i] << "' )" << endl ;
1642         }
1643         f << "    " << "PyNext" << Name() << " = []" << endl ;
1644         for ( i = 0 ; i < (int ) aPyNext.length() ; i++ ) {
1645           f << "    " << "PyNext" << Name() << ".append( '" << aPyNext[i] << "' )" << endl ;
1646         }
1647         f << "    " << Name() << "," << EndName << " = " << aGraphName << ".LNode( '"
1648           << FuncNames[0].c_str() << "' , Py" << Name() << " , '"
1649           << FuncNames[1].c_str() << "' , PyMore" << Name()
1650           << " , '" << FuncNames[2].c_str() << "' , PyNext"
1651           << Name() << " )" << endl ;
1652         f << "    " << EndName << ".SetName( '" << aCoupledNode->Name() << "' )" << endl ;
1653         f << "    " << EndName << ".SetAuthor( '" << aCoupledNode->Author() << "' )" << endl ;
1654         f << "    " << EndName << ".SetComment( '" << aCoupledNode->Comment() << "' )" << endl ;
1655         f << "    " << EndName << ".Coords( " << aCoupledNode->XCoordinate() << " , "
1656           << aCoupledNode->YCoordinate() << " )" << endl ;
1657         SUPERV::ListOfStrings aPyFunc = *aCoupledNode->PythonFunction() ;
1658         f << "    " << "Py" << aCoupledNode->Name() << " = []" << endl ;
1659         for ( i = 0 ; i < (int ) aPyFunc.length() ; i++ ) {
1660           f << "    " << "Py" << aCoupledNode->Name() << ".append( '" << aPyFunc[i] << "' )"
1661             << endl ;
1662         }
1663         f << "    " << EndName << ".SetPyFunction( '" << aCoupledNode->PyFuncName() << "' , Py" << aCoupledNode->Name() << " )" << endl ;
1664         for ( i = 0 ; i < GetNodeInPortsSize() ; i++ ) {
1665           const GraphBase::InPort * anInPort = GetNodeInPort(i) ;
1666           cdebug << "Node " << Name() << " InPort " << anInPort->PortName()
1667                  << " " << anInPort->Kind() << endl ;
1668           if ( anInPort->IsLoop() ) {
1669             f << "    " << "I" << Name() << anInPort->PortName() << " = "
1670               << Name() << ".GetInPort( '" << anInPort->PortName() << "' )" << endl ;
1671           }
1672           else if ( anInPort->IsInLine() ) {
1673             f << "    " << "I" << Name() << anInPort->PortName() << " = "
1674               << Name() << ".InPort( '" << anInPort->PortName() << "' , '"
1675               << anInPort->PortType() << "' )" << endl ;
1676           }
1677           else if ( anInPort->IsDataStream() ) {
1678             f << "    " << "I" << Name() << anInPort->PortName() << " = " << Name()
1679               << ".InStreamPort( '" << anInPort->PortName()
1680               << "' , SALOME_ModuleCatalog." << StringToDataStreamType( anInPort->PortType() )
1681               << " , SALOME_ModuleCatalog." << anInPort->Dependency() << " )" << endl ;
1682             SUPERV::KindOfSchema        aKindOfSchema ;
1683             SUPERV::KindOfInterpolation aKindOfInterpolation ;
1684             SUPERV::KindOfExtrapolation aKindOfExtrapolation ;
1685             ((GraphBase::InDataStreamPort * ) anInPort)->Params( aKindOfSchema , aKindOfInterpolation , aKindOfExtrapolation ) ;
1686             f << "    " << "I" << Name() << anInPort->PortName() << ".SetParams( SUPERV." << aKindOfSchema << " , SUPERV."
1687               << aKindOfInterpolation << " , SUPERV." << aKindOfExtrapolation << " )" << endl ;
1688           }
1689           else if ( anInPort->IsGate() ) {
1690             f << "    " << "I" << Name() << anInPort->PortName() << " = "
1691               << Name() << ".GetInPort( '" << anInPort->PortName() << "' )" << endl ;
1692           }
1693         }
1694         for ( i = 0 ; i < GetNodeOutPortsSize() ; i++ ) {
1695           const GraphBase::OutPort * anOutPort = GetNodeOutPort(i) ;
1696           cdebug << "Node " << Name() << " OutPort " << anOutPort->PortName()
1697                  << " " << anOutPort->Kind() << endl ;
1698           if ( anOutPort->IsInLine() || anOutPort->IsLoop() ) {
1699             f << "    " << "O" << Name() << anOutPort->PortName() << " = "
1700               << Name() << ".GetOutPort( '" << anOutPort->PortName() << "' )" << endl ;
1701           }
1702           else if ( anOutPort->IsDataStream() ) {
1703             f << "    " << "O" << Name() << anOutPort->PortName() << " = " << Name()
1704               << ".OutStreamPort( '" << anOutPort->PortName()
1705               << "' , SALOME_ModuleCatalog." << StringToDataStreamType( anOutPort->PortType() )
1706               << " , SALOME_ModuleCatalog." << anOutPort->Dependency() << " )" << endl ;
1707             long aNumberOfValues ;
1708             aNumberOfValues = ((GraphBase::OutDataStreamPort * ) anOutPort)->NumberOfValues() ;
1709             f << "    " << "O" << Name() << anOutPort->PortName() << ".SetNumberOfValues( " << aNumberOfValues << " )"
1710               << endl ;
1711           }
1712 //JR 02.09.2005 : GetOutPort for Gates was missing
1713           else if ( anOutPort->IsGate() ) {
1714             f << "    " << "O" << Name() << anOutPort->PortName() << " = "
1715               << Name() << ".GetOutPort( '" << anOutPort->PortName() << "' )" << endl ;
1716           }
1717         }
1718         for ( i = 0 ; i < aCoupledNode->GetNodeInPortsSize() ; i++ ) {
1719           const GraphBase::InPort * anInPort = aCoupledNode->GetNodeInPort(i) ;
1720           cdebug << "Node " << aCoupledNode->Name() << " InPort " << anInPort->PortName()
1721                  << " " << anInPort->Kind() << endl ;
1722           if ( anInPort->IsInLine() || anInPort->IsLoop() || anInPort->IsGate() ) {
1723             f << "    " << "I" << EndName << anInPort->PortName() << " = " << EndName
1724               << ".GetInPort( '" << anInPort->PortName() << "' )" << endl ;
1725           }
1726           else if ( anInPort->IsDataStream() ) {
1727             f << "    " << "I" << EndName << anInPort->PortName() << " = " << EndName
1728               << ".InStreamPort( '" << anInPort->PortName()
1729               << "' , SALOME_ModuleCatalog." << StringToDataStreamType( anInPort->PortType() )
1730               << " , SALOME_ModuleCatalog." << anInPort->Dependency() << " )" << endl ;
1731             SUPERV::KindOfSchema        aKindOfSchema ;
1732             SUPERV::KindOfInterpolation aKindOfInterpolation ;
1733             SUPERV::KindOfExtrapolation aKindOfExtrapolation ;
1734             ((GraphBase::InDataStreamPort * ) anInPort)->Params( aKindOfSchema , aKindOfInterpolation , aKindOfExtrapolation ) ;
1735             f << "    " << "I" << EndName << anInPort->PortName() << ".SetParams( SUPERV." << aKindOfSchema << " , SUPERV."
1736               << aKindOfInterpolation << " , SUPERV." << aKindOfExtrapolation << " )" << endl ;
1737           }
1738         }
1739         for ( i = 0 ; i < aCoupledNode->GetNodeOutPortsSize() ; i++ ) {
1740           const GraphBase::OutPort * anOutPort = aCoupledNode->GetNodeOutPort(i) ;
1741           cdebug << "Node " << aCoupledNode->Name() << " OutPort " << anOutPort->PortName()
1742                  << " " << anOutPort->Kind() << endl ;
1743           if ( anOutPort->IsInLine() || anOutPort->IsLoop() || anOutPort->IsGate() ) {
1744             f << "    " << "O" << EndName << anOutPort->PortName() << " = " << EndName
1745               << ".GetOutPort( '" << anOutPort->PortName() << "' )" << endl ;
1746           }
1747           else if ( anOutPort->IsDataStream() ) {
1748             f << "    " << "O" << EndName << anOutPort->PortName() << " = " << EndName
1749               << ".OutStreamPort( '" << anOutPort->PortName()
1750               << "' , SALOME_ModuleCatalog." << StringToDataStreamType( anOutPort->PortType() )
1751               << " , SALOME_ModuleCatalog." << anOutPort->Dependency() << " )" << endl ;
1752             long aNumberOfValues ;
1753             aNumberOfValues = ((GraphBase::OutDataStreamPort * ) anOutPort)->NumberOfValues() ;
1754             f << "    " << "O" << EndName << anOutPort->PortName() << ".SetNumberOfValues( " << aNumberOfValues << " )"
1755               << endl ;
1756           }
1757         }
1758       }
1759       else if ( IsSwitchNode() ) {
1760         f << "    " << Name() << "," << EndName << " = " << aGraphName << ".SNode( '"
1761           << FuncNames[0].c_str() << "' , Py" << Name() << " )" << endl ;
1762         f << "    " << EndName << ".SetName( '" << aCoupledNode->Name() << "' )" << endl ;
1763         f << "    " << EndName << ".SetAuthor( '" << aCoupledNode->Author() << "' )" << endl ;
1764         f << "    " << EndName << ".SetComment( '" << aCoupledNode->Comment() << "' )" << endl ;
1765         f << "    " << EndName << ".Coords( " << aCoupledNode->XCoordinate() << " , "
1766           << aCoupledNode->YCoordinate() << " )" << endl ;
1767         SUPERV::ListOfStrings aPyFunc = *aCoupledNode->PythonFunction() ;
1768         f << "    " << "Py" << aCoupledNode->Name() << " = []" << endl ;
1769         for ( i = 0 ; i < (int ) aPyFunc.length() ; i++ ) {
1770           f << "    " << "Py" << aCoupledNode->Name() << ".append( '" << aPyFunc[i] << "' )"
1771             << endl ;
1772         }
1773         f << "    " << EndName << ".SetPyFunction( '" << aCoupledNode->PyFuncName() << "' , Py" << aCoupledNode->Name() << " )" << endl ;
1774         for ( i = 0 ; i < aCoupledNode->GetNodeInPortsSize() ; i++ ) {
1775           const GraphBase::InPort * anInPort = aCoupledNode->GetNodeInPort(i) ;
1776           cdebug << "Node " << aCoupledNode->Name() << " InPort " << anInPort->PortName()
1777                  << " " << anInPort->Kind() << endl ;
1778 //          if ( anInPort->IsGate() || anInPort->IsEndSwitch() ) {
1779           if ( anInPort->IsGate() ) {
1780             f << "    " << "I" << EndName << anInPort->PortName() << " = " << EndName
1781               << ".GetInPort( '" << anInPort->PortName() << "' )" << endl ;
1782           }
1783           else if ( anInPort->IsInLine() || anInPort->IsEndSwitch() ) {
1784             f << "    " << "I" << EndName << anInPort->PortName() << " = " << EndName
1785               << ".InPort( '" << anInPort->PortName()
1786               << "' , '" << anInPort->PortType() << "' )" << endl ;
1787           }
1788           else if ( anInPort->IsDataStream() ) {
1789             f << "    " << "I" << EndName << anInPort->PortName() << " = " << EndName
1790               << ".InStreamPort( '" << anInPort->PortName()
1791               << "' , SALOME_ModuleCatalog." << StringToDataStreamType( anInPort->PortType() )
1792               << " , SALOME_ModuleCatalog." << anInPort->Dependency() << " )" << endl ;
1793             SUPERV::KindOfSchema        aKindOfSchema ;
1794             SUPERV::KindOfInterpolation aKindOfInterpolation ;
1795             SUPERV::KindOfExtrapolation aKindOfExtrapolation ;
1796             ((GraphBase::InDataStreamPort * ) anInPort)->Params( aKindOfSchema , aKindOfInterpolation , aKindOfExtrapolation ) ;
1797             f << "    " << "I" << EndName << anInPort->PortName() << ".SetParams( SUPERV." << aKindOfSchema << " , SUPERV."
1798               << aKindOfInterpolation << " , SUPERV." << aKindOfExtrapolation << " )" << endl ;
1799           }
1800         }
1801         for ( i = 0 ; i < aCoupledNode->GetNodeOutPortsSize() ; i++ ) {
1802           const GraphBase::OutPort * anOutPort = aCoupledNode->GetNodeOutPort(i) ;
1803           cdebug << "Node " << aCoupledNode->Name() << " OutPort " << anOutPort->PortName()
1804                  << " " << anOutPort->Kind() << endl ;
1805 //          if ( anOutPort->IsGate() || anOutPort->IsEndSwitch() ) {
1806           if ( anOutPort->IsGate() ) {
1807             f << "    " << "O" << EndName << anOutPort->PortName() << " = " << EndName
1808               << ".GetOutPort( '" << anOutPort->PortName() << "' )" << endl ;
1809           }
1810           else if ( anOutPort->IsInLine() || anOutPort->IsSwitch() ) {
1811             f << "    " << "O" << EndName << anOutPort->PortName() << " = " << EndName
1812               << ".OutPort( '" << anOutPort->PortName()
1813               << "' , '" << anOutPort->PortType() << "' )" << endl ;
1814           }
1815           else if ( anOutPort->IsDataStream() ) {
1816             f << "    " << "O" << EndName << anOutPort->PortName() << " = " << EndName
1817               << ".OutStreamPort( '" << anOutPort->PortName()
1818               << "' , SALOME_ModuleCatalog." << StringToDataStreamType( anOutPort->PortType() )
1819               << " , SALOME_ModuleCatalog." << anOutPort->Dependency() << " )" << endl ;
1820             long aNumberOfValues ;
1821             aNumberOfValues = ((GraphBase::OutDataStreamPort * ) anOutPort)->NumberOfValues() ;
1822             f << "    " << "O" << EndName << anOutPort->PortName() << ".SetNumberOfValues( " << aNumberOfValues << " )"
1823               << endl ;
1824           }
1825         }
1826       }
1827       cdebug << "ComputingNode::SavePY Node " << Name() << " EndName " << EndName
1828              << endl ;
1829 // PAL8507
1830 //JR 24.02.2005 Debug !!!... : I should not delete myself : what a stupid thing !
1831 //      delete [] EndName ;
1832     }
1833   }
1834
1835   if ( IsEndLoopNode() || IsEndSwitchNode() ) {
1836 // It is done with LoopNode or SwitchNode with CoupledNode()
1837   }
1838   else {
1839     f << "    " << Name() << ".SetName( '" << Name() << "' )" << endl ;
1840     f << "    " << Name() << ".SetAuthor( '" << Author() << "' )" << endl ;
1841     if ( IsFactoryNode() ) {
1842       f << "    " << Name() << ".SetContainer( '" << Computer << "' )" << endl ;
1843     }
1844     f << "    " << Name() << ".SetComment( '" << Comment() << "' )" << endl ;
1845     f << "    " << Name() << ".Coords( " << XCoordinate << " , " << YCoordinate << " )" << endl ;
1846
1847     if ( IsComputingNode() || IsFactoryNode() ) {
1848       int i ;
1849       for ( i = 0 ; i < GetNodeInPortsSize() ; i++ ) {
1850         const GraphBase::InPort * anInPort = GetNodeInPort(i) ;
1851         if ( !anInPort->IsDataStream() ) {
1852           cdebug << "Node " << Name() << " InPort " << anInPort->PortName()
1853                  << " " << anInPort->Kind() << endl ;
1854           f << "    " << "I" << Name() << anInPort->PortName() << " = "
1855             << Name() << ".GetInPort( '" << anInPort->PortName() << "' )" << endl ;
1856         }
1857       }
1858       for ( i = 0 ; i < GetNodeOutPortsSize() ; i++ ) {
1859         const GraphBase::OutPort * anOutPort = GetNodeOutPort(i) ;
1860         if ( !anOutPort->IsDataStream() ) {
1861           cdebug << "Node " << Name() << " OutPort " << anOutPort->PortName()
1862                  << " " << anOutPort->Kind() << endl ;
1863           f << "    " << "O" << Name() << anOutPort->PortName() << " = "
1864             << Name() << ".GetOutPort( '" << anOutPort->PortName() << "' )" << endl ;
1865         }
1866       }
1867     }
1868     else if ( IsOneOfInLineNodes() && !IsLoopNode() ) {
1869       int i ;
1870       for ( i = 0 ; i < GetNodeInPortsSize() ; i++ ) {
1871         const GraphBase::InPort * anInPort = GetNodeInPort(i) ;
1872         cdebug << "ComputingNode::SavePY Node " << Name() << " InPort " << anInPort->PortName()
1873                << " " << anInPort->Kind() << endl ;
1874 //        if ( anInPort->IsGate() || ( anInPort->IsInLine() && IsMacroNode() ) ) {
1875         if ( anInPort->IsGate() || IsMacroNode() ) {
1876           f << "    " << "I" << Name() << anInPort->PortName() << " = "
1877             << Name() << ".GetInPort( '" << anInPort->PortName()  << "' )" << endl ;
1878         }
1879         else if ( anInPort->IsInLine() || anInPort->IsEndSwitch() ) {
1880           f << "    " << "I" << Name() << anInPort->PortName() << " = "
1881             << Name() << ".InPort( '" << anInPort->PortName() << "' , '"
1882             << anInPort->PortType() << "' )" << endl ;
1883         }
1884         else {
1885           cdebug << "Ignored " << Name() << " " << anInPort->PortName() << " " << anInPort->PortStatus() << endl ;
1886 //          f << "    " << "I" << Name() << anInPort->PortName() << " = "
1887 //            << Name() << ".GetInPort( '" << anInPort->PortName()  << "' )" << endl ;
1888         }
1889       }
1890       for ( i = 0 ; i < GetNodeOutPortsSize() ; i++ ) {
1891         const GraphBase::OutPort * anOutPort = GetNodeOutPort(i) ;
1892         cdebug << "ComputingNode::SavePY Node " << Name() << " OutPort " << anOutPort->PortName()
1893                << " " << anOutPort->Kind() << endl ;
1894 //        if ( anOutPort->IsGate() || ( anOutPort->IsInLine() && IsMacroNode() ) ) {
1895         if ( anOutPort->IsGate() || IsMacroNode() ) {
1896           f << "    " << "O" << Name() << anOutPort->PortName() << " = "
1897             << Name() << ".GetOutPort( '" << anOutPort->PortName() << "' )" << endl ;
1898         }
1899         else if ( anOutPort->IsInLine() || anOutPort->IsSwitch() ) {
1900           f << "    " << "O" << Name() << anOutPort->PortName() << " = "
1901             << Name() << ".OutPort( '" << anOutPort->PortName()
1902             << "' , '" << anOutPort->PortType() << "' )" << endl ;
1903         }
1904         else {
1905           cdebug << "Ignored " << Name() << " " << anOutPort->PortName() << " " << anOutPort->PortStatus() << endl ;
1906 //          f << "    " << "O" << Name() << anOutPort->PortName() << " = "
1907 //            << Name() << ".GetOutPort( '" << anOutPort->PortName() << "' )" << endl ;
1908         }
1909       }
1910     }
1911     if ( !IsDataFlowNode() && !IsDataStreamNode() ) {
1912       int i ;
1913       for ( i = 0 ; i < GetNodeInPortsSize() ; i++ ) {
1914         const GraphBase::InPort * anInPort = GetNodeInPort(i) ;
1915         cdebug << "Node " << Name() << " InPort " << anInPort->PortName()
1916                << " " << anInPort->Kind() << endl ;
1917         if ( anInPort->IsDataStream() ) {
1918           if ( IsOneOfInLineNodes() ) {
1919             f << "    " << "I" << Name() << anInPort->PortName() << " = "
1920               << Name() << ".InStreamPort( '" << anInPort->PortName() << "' , SALOME_ModuleCatalog."
1921               << StringToDataStreamType( anInPort->PortType() ) << " , SALOME_ModuleCatalog."
1922               << anInPort->Dependency() << " )" << endl ;
1923           }
1924           else {
1925             f << "    " << "I" << Name() << anInPort->PortName() << " = "
1926               << Name() << ".GetInStreamPort( '" << anInPort->PortName() << "' )" << endl ;
1927           }
1928           SUPERV::KindOfSchema        aKindOfSchema ;
1929           SUPERV::KindOfInterpolation aKindOfInterpolation ;
1930           SUPERV::KindOfExtrapolation aKindOfExtrapolation ;
1931           ((GraphBase::InDataStreamPort * ) anInPort)->Params( aKindOfSchema , aKindOfInterpolation , aKindOfExtrapolation ) ;
1932           f << "    " << "I" << Name() << anInPort->PortName() << ".SetParams( SUPERV." << aKindOfSchema << " , SUPERV."
1933             << aKindOfInterpolation << " , SUPERV." << aKindOfExtrapolation << " )" << endl ;
1934         }
1935       }
1936       for ( i = 0 ; i < GetNodeOutPortsSize() ; i++ ) {
1937         const GraphBase::OutPort * anOutPort = GetNodeOutPort(i) ;
1938         cdebug << "Node " << Name() << " OutPort " << anOutPort->PortName()
1939                << " " << anOutPort->Kind() << endl ;
1940         if ( anOutPort->IsDataStream() ) {
1941           if ( IsOneOfInLineNodes() ) {
1942             f << "    " << "O" << Name() << anOutPort->PortName() << " = "
1943               << Name() << ".OutStreamPort( '" << anOutPort->PortName() << "' , SALOME_ModuleCatalog."
1944               << StringToDataStreamType( anOutPort->PortType() ) << " , SALOME_ModuleCatalog."
1945               << anOutPort->Dependency() << " )" << endl ;
1946           }
1947           else {
1948             f << "    " << "O" << Name() << anOutPort->PortName() << " = "
1949               << Name() << ".GetOutStreamPort( '" << anOutPort->PortName() << "' )" << endl ;
1950           }
1951           long aNumberOfValues ;
1952           aNumberOfValues = ((GraphBase::OutDataStreamPort * ) anOutPort)->NumberOfValues() ;
1953           f << "    " << "O" << Name() << anOutPort->PortName() << ".SetNumberOfValues( " << aNumberOfValues << " )" << endl ;
1954         }
1955       }
1956     }
1957   }
1958
1959   cdebug_out << "ComputingNode::SavePY " ;
1960   NodeInfo( *_fdebug ) ;
1961   cdebug << endl ;
1962   return true ;
1963 }
1964
1965 void GraphBase::ComputingNode::NodeInfo(ostream & s) const {
1966   s << *this ;
1967   ListPorts( s , true ) ;
1968   s << ends ;
1969 }
1970
1971 ostream & operator<< (ostream & f,const GraphBase::ComputingNode & G) {
1972 //  f << "ComponentName    " << G.ComponentName() << endl ;
1973   if ( G.IsComputingNode() ) {
1974     f << "NodeName         " << G.Name() << endl ;
1975   }
1976   else {
1977     f << "DataFlowName     " << G.Name() << endl ;
1978   }
1979   f << "Kind             " << G.Kind() << endl ;
1980   f << "Service          " << *G.GetService() ;
1981   f << "FirstCreation    " << G.FirstCreation () << endl ;
1982   f << "LastModification " << G.LastModification() << endl ;
1983   f << "EditorRelease    " << G.EditorRelease() << endl ;
1984   f << "Author           " << G.Author() << endl ;
1985 //  f << "Computer         " << G.Computer() << endl ;
1986   f << "Comment          " << G.Comment() << endl ;
1987   f << endl ;
1988   
1989   return f;
1990 }
1991
1992 void GraphBase::ComputingNode::ListLinks(ostream &f ) const {
1993   int i ;
1994   for ( i = 0 ; i < GetNodeOutPortsSize() ; i++ ) {
1995     const GraphBase::OutPort* fromPort = GetNodeOutPort( i ) ;
1996     if ( fromPort->IsPortConnected() ) {
1997       int j ;
1998       for ( j = 0 ; j < fromPort->InPortsSize() ; j++ ) {
1999         if ( j == 0 ) {
2000           f << "FromNode " << Name() << endl ;
2001         }
2002         f << "         FromServiceParameterName "
2003           << fromPort->GetServicesParameter().Parametername ;
2004         const GraphBase::InPort* toPort = fromPort->InPorts( j ) ;
2005         f << " ToNode " << toPort->NodeName() ;
2006         f << " ToServiceParameterName "
2007           << toPort->GetServicesParameter().Parametername;
2008         f << " Value " ;
2009         fromPort->StringValue( f ) ;
2010         f << endl ;
2011       }
2012     }
2013   }
2014 }
2015
2016 ostream & operator<< (ostream &fOut,const SUPERV::SDate &D) {
2017 //  cdebug_in << "operator<< GraphEditor::Date" << endl;
2018
2019   fOut  << D.Day << "/" 
2020         << D.Month << "/" 
2021         << D.Year << " - " 
2022         << D.Hour << ":" 
2023         << D.Minute <<  ":"  
2024         << D.Second;
2025
2026 //  cdebug_out << "operator<< GraphEditor::Date" << endl;
2027   return fOut;
2028 }
2029