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