]> SALOME platform Git repositories - modules/superv.git/blob - src/GraphBase/DataFlowBase_ComputingNode.cxx
Salome HOME
PAL9122
[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 ) const {
874   cdebug_in << Name() << "->ComputingNode::CheckLoop( " << aLoopNode->Name() << " , "
875             << anEndLoopNode->Name() << ") LinkedNodesSize "
876             << LinkedNodesSize() << endl;
877
878   int i ;
879   if ( LinkedNodesSize() == 0 && !IsDataFlowNode() && !IsDataStreamNode() ) {
880     cdebug_out << Name() << "->ComputingNode::CheckLoop( " << aLoopNode->Name()
881                << " , " << anEndLoopNode->Name() << ") LinkedNodesSize "
882                << LinkedNodesSize() << " WARNING false" << endl;
883     return false ;
884   }
885 // We check that all nodes linked to that node go to the end of LoopNode :
886   for ( i = 0 ; i < LinkedNodesSize() ; i++ ) {
887     GraphBase::ComputingNode * aNode = (GraphBase::ComputingNode * ) LinkedNodes( i ) ;
888     cdebug << i << ". " << Name() << " Linked to " << aNode->Name() << endl ;
889     if ( !aNode->IsEndLoopNode() || aNode != anEndLoopNode ) {
890       if ( !aNode->CheckLoop( aLoopNode , anEndLoopNode ) ) {
891         cdebug_out << Name() << "->ComputingNode::CheckLoop( " << aLoopNode->Name()
892                    << " , " << anEndLoopNode->Name() << ") LinkedNodesSize "
893                    << LinkedNodesSize() << " WARNING false" << endl;
894         return false ;
895       }
896     }
897   }
898   cdebug_out << Name() << "->ComputingNode::CheckLoop( " << aLoopNode->Name() << " , "
899              << anEndLoopNode->Name() << ") LinkedNodesSize "
900              << LinkedNodesSize() << " true" << endl;
901   return true ;
902 }
903
904 bool GraphBase::ComputingNode::CheckEndLoop(GraphBase::LoopNode * aLoopNode ,
905                                             GraphBase::EndOfLoopNode * anEndLoopNode ) const {
906   cdebug_in << Name() << "->ComputingNode::CheckEndLoop( " << aLoopNode->Name() << " , "
907             << anEndLoopNode->Name() << ") LinkedFromNodesSize "
908             << LinkedFromNodesSize() << endl;
909
910   int i ;
911   if ( LinkedFromNodesSize() == 0 ) {
912     cdebug_out << Name() << "->ComputingNode::CheckEndLoop( " << aLoopNode->Name()
913                << " , " << anEndLoopNode->Name() << ") LinkedFromNodesSize "
914                << LinkedFromNodesSize() << " WARNING false" << endl;
915     return false ;
916   }
917 // We have to check that all nodes linked from that node go to the beginning of LoopNode : 
918   for ( i = 0 ; i < LinkedFromNodesSize() ; i++ ) {
919     GraphBase::ComputingNode * aNode = (GraphBase::ComputingNode * ) LinkedFromNodes( i ) ;
920     cdebug << i << ". " << Name() << " Linked from " << aNode->Name() << endl ;
921     if ( !aNode->IsLoopNode() || aNode != aLoopNode ) {
922       if ( !aNode->CheckEndLoop( aLoopNode , anEndLoopNode ) ) {
923         cdebug_out << Name() << "->ComputingNode::CheckEndLoop( " << aLoopNode->Name()
924                    << " , " << anEndLoopNode->Name() << ") LinkedFromNodesSize "
925                    << LinkedFromNodesSize() << " WARNING false" << endl;
926         return false ;
927       }
928     }
929   }
930   cdebug_out << Name() << "->ComputingNode::CheckEndLoop( " << aLoopNode->Name() << " , "
931              << anEndLoopNode->Name() << ") LinkedFromNodesSize "
932              << LinkedFromNodesSize() << " true" << endl;
933   return true ;
934 }
935
936 bool GraphBase::ComputingNode::InitBranchOfSwitchDone(bool AllInit ,
937                                                       GraphBase::EndOfSwitchNode * anEndSwitchNode ) {
938   bool sts = BranchOfSwitchDone( false ) ;
939   if ( !sts && !AllInit && anEndSwitchNode != this ) {
940 // Common Node in branchs :
941     cdebug << Name() << "->ComputingNode::InitBranchOfSwitchDone WARNING false"
942            << endl ;
943     return false ;
944   }
945   int i ;
946   if ( !IsGOTONode() && anEndSwitchNode != this ) {
947     for ( i = 0 ; i < LinkedNodesSize() ; i++ ) {
948       GraphBase::ComputingNode * aNode ;
949       aNode = (GraphBase::ComputingNode * ) LinkedNodes( i ) ;
950       if ( !aNode->InitBranchOfSwitchDone( AllInit , anEndSwitchNode ) ) {
951         return false ;
952       }
953     }
954   }
955   return true ;
956 }
957
958 bool GraphBase::ComputingNode::CheckSwitch(GraphBase::EndOfSwitchNode * anEndSwitchNode ) {
959   cdebug_in << Name() << "->ComputingNode::CheckSwitch( "
960             << anEndSwitchNode->Name() << " ) " << Kind() << endl;
961   if ( anEndSwitchNode == this ) {
962   }
963 // if it is a SwitchNode, continue the check at the corresponding EndSwitchNode
964   else if ( IsSwitchNode() ) {
965     GraphBase::EndOfSwitchNode * anOtherEndSwitchNode ;
966     anOtherEndSwitchNode = (GraphBase::EndOfSwitchNode * ) ((GraphBase::SwitchNode * ) this)->CoupledNode() ;
967     cdebug << Name() << "->ComputingNode::CheckSwitch will Check "
968            << anOtherEndSwitchNode->Name() << endl ;
969     if ( !anOtherEndSwitchNode->CheckSwitch( anEndSwitchNode ) ) {
970       cdebug_out << Name() << "->ComputingNode::CheckSwitch "
971                  << anOtherEndSwitchNode->Name() << " WARNING false" << endl;
972       return false ;
973     }
974   }
975   else {
976     int i ;
977     for ( i = 0 ; i < GetNodeOutPortsSize() ; i++ ) {
978       GraphBase::OutPort * anOutPort = GetChangeNodeOutPort( i ) ;
979       if ( !anOutPort->IsDataStream() ) {
980         int j ;
981         for ( j = 0 ; j < anOutPort->InPortsSize() ; j++ ) {
982           GraphBase::InPort * anInPort = anOutPort->ChangeInPorts( j ) ;
983           if ( !anInPort->IsDataStream() ) {
984             GraphBase::ComputingNode * aNode ;
985             aNode = GraphOfNode()->GetChangeGraphNode( anInPort->NodeName() ) ;
986             GraphBase::LoopNode * aLoopNode = NULL ;
987             GraphBase::EndOfLoopNode * aEndLoopNode = NULL ;
988             if ( IsLoopNode() ) {
989               aEndLoopNode = (GraphBase::EndOfLoopNode * ) ((GraphBase::LoopNode * ) this)->CoupledNode() ;
990               cdebug << Name() << "->ComputingNode::CheckSwitch LoopNode " << Name() << " coupled to "
991                      << aEndLoopNode << " " << aEndLoopNode->Name() << " aNode " << aNode << endl ;
992             }
993             else if ( IsEndLoopNode() ) {
994               aLoopNode = (GraphBase::LoopNode * ) ((GraphBase::EndOfLoopNode * ) this)->CoupledNode() ;
995               cdebug << Name() << "->ComputingNode::CheckSwitch EndLoopNode " << Name()
996                      << " coupled to "
997                      << aLoopNode << " " << aLoopNode->Name() << " aNode " << aNode << endl ;
998             }
999             if ( aNode == NULL ) {
1000               cdebug << Name() << "->ComputingNode::CheckSwitch ignore "
1001                      << anInPort->NodeName() << "( " << anInPort->PortName() << " )" << endl ;
1002             }
1003             else if ( aNode == anEndSwitchNode ) {
1004               ((GraphBase::EndOfSwitchNode * ) aNode)->DecrEndSwitchInPortLinked( anInPort ) ;
1005             }
1006             else if ( aNode->BranchOfSwitchDone() ) {
1007               cdebug << Name() << "->ComputingNode::CheckSwitch will NOT Check "
1008                      << anInPort->NodeName() << "( " << anInPort->PortName() << " ) : already checked"
1009                      << endl ;
1010             }
1011             else if ( IsLoopNode() && aNode == aEndLoopNode ) {
1012               cdebug << Name() << "->ComputingNode::CheckSwitch will NOT Check "
1013                      << anInPort->NodeName() << "( " << anInPort->PortName() << " )" << endl ;
1014             }
1015             else if ( IsEndLoopNode() && aNode == aLoopNode ) {
1016               cdebug << Name() << "->ComputingNode::CheckSwitch will NOT Check "
1017                      << anInPort->NodeName() << "( " << anInPort->PortName() << " )" << endl ;
1018             }
1019             else if ( aNode->IsGOTONode() ) {
1020               cdebug << Name() << "->ComputingNode::CheckSwitch will NOT Check "
1021                      << anInPort->NodeName() << "( " << anInPort->PortName() << " )" << endl ;
1022               anEndSwitchNode->SetSwitchWithGOTO() ;
1023             }
1024             else {
1025               cdebug << Name() << "->ComputingNode::CheckSwitch will Check "
1026                      << anInPort->NodeName() << "( " << anInPort->PortName() << " )" << endl ;
1027               if ( !aNode->CheckSwitch( anEndSwitchNode ) ) {
1028                 cdebug_out << Name() << "->ComputingNode::CheckSwitch "
1029                          << anEndSwitchNode->Name() << " WARNING false" << endl;
1030                 return false ;
1031               }
1032 //            aNode->BranchOfSwitchDone( true ) ;
1033             }
1034           }
1035         }
1036       }
1037     }
1038   }
1039   BranchOfSwitchDone( true ) ;
1040   cdebug_out << Name() << "->ComputingNode::CheckSwitch BranchOfSwitchDone == true "
1041              << anEndSwitchNode->Name() << " true" << endl;
1042   return true ;
1043 }
1044
1045 #include <sys/time.h>
1046 #include <sys/resource.h>
1047 #include <unistd.h>
1048
1049 const long GraphBase::ComputingNode::CpuUsed() {
1050   struct rusage usage ;
1051   if ( getrusage( RUSAGE_SELF , &usage ) == -1 ) {
1052     perror("GraphBase::CpuUsed") ;
1053     return 0 ;
1054   }
1055 //  return usage.ru_utime.__time_t tv_sec ;
1056   cdebug << "CpuUsed " << usage.ru_utime.tv_sec << " " << usage.ru_utime.tv_usec << " "
1057          << usage.ru_stime.tv_sec << " " << usage.ru_stime.tv_usec << endl ;
1058   return usage.ru_utime.tv_sec ;
1059 }
1060
1061 #if 0
1062 const GraphBase::ListOfParameters * GraphBase::ComputingNode::GetListOfParameters() const {
1063   GraphBase::ListOfParameters * aListOfParameters = new GraphBase::ListOfParameters ;
1064   if ( IsInLineNode() || IsGOTONode() ) {
1065     unsigned int i;
1066     for ( i = 0 ; i < GetNodeInPortsSize() ; i++ ) {
1067       const InPort * anInPort = GetNodeInPort( i ) ;
1068       if ( anInPort->IsBus() ) {
1069         int size = aListOfParameters->size() ;
1070         aListOfParameters->resize( size + 1 ) ;
1071         (*aListOfParameters)[size].theInParameter.Parametername = anInPort->PortName() ;
1072         (*aListOfParameters)[size].theInParameter.Parametertype = anInPort->PortType() ;
1073         const OutPort * anOutPort = GetNodeOutPort( anInPort->PortIndex() ) ;
1074         (*aListOfParameters)[size].theOutParameter.Parametername = anOutPort->PortName() ;
1075         (*aListOfParameters)[size].theOutParameter.Parametertype = anOutPort->PortType() ;
1076       }
1077     }
1078   }
1079   return aListOfParameters ;
1080 }
1081 #endif
1082
1083 bool GraphBase::ComputingNode::SaveXML( QDomDocument & Graph , QDomElement & info ,
1084                                         const char * ComponentName ,
1085                                         const char * InterfaceName ,
1086                                         const char * Computer ,
1087                                         const char * CoupledNode ,
1088                                         const ListOfFuncName FuncNames ,
1089                                         const ListOfPythonFunctions PythonFunctions ,
1090                                         int XCoordinate , int YCoordinate ) const {
1091   cdebug_in << "SaveXML Node " << Name() << endl ;
1092   QDomElement node = Graph.createElement( "node" ) ;
1093   info.appendChild( node ) ;
1094   QDomElement componentname = Graph.createElement( "component-name" ) ;
1095   QDomText aField ;
1096   if ( strlen( ComponentName ) ) {
1097 //    f << Tabs << "<component-name>" << ComponentName << "</component-name>"
1098 //      << endl ;
1099 //    componentname.setNodeValue( ComponentName ) ;
1100     aField = Graph.createTextNode( ComponentName ) ;
1101   }
1102   else {
1103 //    f << Tabs << "<component-name>?</component-name>" << endl ;
1104 //    componentname.setNodeValue( "?" ) ;
1105     aField = Graph.createTextNode( "?" ) ;
1106   }
1107   node.appendChild( componentname ) ;
1108   componentname.appendChild( aField ) ;
1109
1110   QDomElement interfacename = Graph.createElement("interface-name") ;
1111   if ( strlen( InterfaceName ) ) {
1112 //    f << Tabs << "<interface-name>" << InterfaceName << "</interface-name>"
1113 //      << endl ;
1114 //    interfacename.setAttribute("name" , InterfaceName ) ;
1115     aField = Graph.createTextNode( InterfaceName ) ;
1116   }
1117   else {
1118 //    f << Tabs << "<interface-name>?</interface-name>" << endl ;
1119 //    interfacename.setAttribute("name" , "?" ) ;
1120     aField = Graph.createTextNode( "?" ) ;
1121   }
1122   node.appendChild(interfacename) ;
1123   interfacename.appendChild( aField ) ;
1124
1125 //  f << Tabs << "<node-name>" << Name() << "</node-name>" << endl ;
1126   QDomElement nodename = Graph.createElement("node-name") ;
1127   aField = Graph.createTextNode( Name() ) ;
1128   node.appendChild( nodename ) ;
1129   nodename.appendChild( aField ) ;
1130
1131 //  f << Tabs << "<kind>" << (int ) Kind() << "</kind>" << endl ;
1132   QDomElement kind = Graph.createElement( "kind" ) ;
1133   QString aKind ;
1134
1135   // san - Presumably, data stream graphs should be always saved with kind = DataStreamGraph
1136 // JR : the bug was at line 566 : && HasDataStream() != 0 was missing
1137   if ( IsDataFlowNode() || ( IsDataStreamNode() && HasDataStream() == 0 ) ) {
1138     aKind = aKind.setNum( SUPERV::DataFlowGraph ) ;
1139   }
1140   else {
1141     aKind = aKind.setNum( Kind() ) ;
1142   }
1143   aField = Graph.createTextNode( aKind ) ;
1144   node.appendChild( kind ) ;
1145   kind.appendChild( aField ) ;
1146
1147   if ( IsDataStreamNode() && HasDataStream() != 0 ) {
1148     long Timeout ;
1149     SUPERV::KindOfDataStreamTrace DataStreamTrace ;
1150     double DeltaTime ;
1151     ((GraphBase::StreamGraph * ) this)->StreamParams( Timeout , DataStreamTrace , DeltaTime ) ;
1152
1153     QDomElement timeout = Graph.createElement("streamgraph-timeout") ;
1154     QString aTimeout ;
1155     aTimeout = aTimeout.setNum( Timeout ) ;
1156     aField = Graph.createTextNode( aTimeout ) ;
1157     node.appendChild( timeout ) ;
1158     timeout.appendChild( aField ) ;
1159
1160     QDomElement datastreamtrace = Graph.createElement("streamgraph-datastreamtrace") ;
1161     QString aDataStreamTrace ;
1162     aDataStreamTrace = aDataStreamTrace.setNum( DataStreamTrace ) ;
1163     aField = Graph.createTextNode( aDataStreamTrace ) ;
1164     node.appendChild( datastreamtrace ) ;
1165     datastreamtrace.appendChild( aField ) ;
1166
1167     QDomElement deltatime = Graph.createElement("streamgraph-deltatime") ;
1168     QString aDeltaTime ;
1169     aDeltaTime = aDeltaTime.setNum( DeltaTime ) ;
1170     aField = Graph.createTextNode( aDeltaTime ) ;
1171     node.appendChild( deltatime ) ;
1172     deltatime.appendChild( aField ) ;
1173   }
1174
1175   QDomElement couplednode = Graph.createElement("coupled-node") ;
1176   if ( IsGOTONode() || IsLoopNode() || IsEndLoopNode() ||
1177        IsSwitchNode() || IsEndSwitchNode() || IsMacroNode() ) {
1178 //    f << Tabs << "<coupled-node>" << CoupledNode << "</coupled-node>"
1179 //      << endl ;
1180     aField = Graph.createTextNode( CoupledNode ) ;
1181   }
1182   else {
1183 //    f << Tabs << "<coupled-node>?</coupled-node>" << endl ;
1184     aField = Graph.createTextNode( "?" ) ;
1185   }
1186   node.appendChild(couplednode) ;
1187   couplednode.appendChild( aField ) ;
1188
1189 //  f << Tabs << "<service>" << endl ;
1190   QDomElement service = Graph.createElement("service") ;
1191   node.appendChild(service) ;
1192   QDomElement servicename = Graph.createElement("service-name") ;
1193   if ( strlen( ServiceName() ) ) {
1194 //    f << Tabs << "    <service-name>" << ServiceName() << "</service-name>" << endl ;
1195     aField = Graph.createTextNode( ServiceName() ) ;
1196   }
1197   else {
1198 //    f << Tabs << "    <service-name>?</service-name>" << endl ;
1199     aField = Graph.createTextNode( "?" ) ;
1200   }
1201   service.appendChild(servicename) ;
1202   servicename.appendChild( aField ) ;
1203
1204   cdebug << "SaveXML " << Name() << " In(" << ServiceInParameter().length()
1205          << ") Out(" << ServiceOutParameter().length() << ")" << endl ;
1206   QDomElement inParameterlist = Graph.createElement("inParameter-list") ;
1207   service.appendChild(inParameterlist) ;
1208   unsigned int i;
1209   GraphBase::ComputingNode * aNode = (GraphBase::ComputingNode * ) this ;
1210   for ( i = 0 ; i < ServiceInParameter().length() ; i++ ) {
1211     const GraphBase::InPort * anInPort ;
1212     anInPort = aNode->GetInPort( ServiceInParameter()[i].Parametername ) ;
1213     if ( !anInPort->IsDataStream() ) {
1214       cdebug << "SaveXML " << i << ". " << ServiceInParameter()[i].Parametername
1215              << " InParameterPort " << anInPort->Kind() << endl ;
1216       QDomElement inParameter = Graph.createElement("inParameter") ;
1217       inParameterlist.appendChild(inParameter) ;
1218       QDomElement inParametertype = Graph.createElement("inParameter-type") ;
1219       if ( strlen( ServiceInParameter()[i].Parametertype ) ) {
1220         aField = Graph.createTextNode( strdup( ServiceInParameter()[i].Parametertype ) ) ;
1221       }
1222       else {
1223         aField = Graph.createTextNode( "?" ) ;
1224       }
1225       inParameter.appendChild(inParametertype) ;
1226       inParametertype.appendChild( aField ) ;
1227       QDomElement inParametername = Graph.createElement("inParameter-name") ;
1228       if ( strlen( ServiceInParameter()[i].Parametername ) ) {
1229         aField = Graph.createTextNode( strdup(ServiceInParameter()[i].Parametername) ) ;
1230       }
1231       else {
1232         aField = Graph.createTextNode( "?" ) ;
1233       }
1234       inParameter.appendChild(inParametername) ;
1235       inParametername.appendChild( aField ) ;
1236     }
1237   }
1238   QDomElement outParameterlist = Graph.createElement("outParameter-list") ;
1239   service.appendChild(outParameterlist) ;
1240   for ( i = 0 ; i < ServiceOutParameter().length() ; i++ ) {
1241     const GraphBase::OutPort * anOutPort ;
1242     anOutPort = aNode->GetOutPort( ServiceOutParameter()[i].Parametername ) ;
1243     if ( !anOutPort->IsDataStream() ) {
1244       cdebug << "SaveXML " << i << ". " << ServiceOutParameter()[i].Parametername
1245              << " OutParameterPort " << anOutPort->Kind() << endl ;
1246       QDomElement outParameter = Graph.createElement("outParameter") ;
1247       outParameterlist.appendChild(outParameter) ;
1248       QDomElement outParametertype = Graph.createElement("outParameter-type") ;
1249       if ( strlen( ServiceOutParameter()[i].Parametertype ) ) {
1250         aField = Graph.createTextNode( strdup(ServiceOutParameter()[i].Parametertype) ) ;
1251       }
1252       else {
1253         aField = Graph.createTextNode( "?" ) ;
1254       }
1255       outParameter.appendChild(outParametertype) ;
1256       outParametertype.appendChild( aField ) ;
1257       QDomElement outParametername = Graph.createElement("outParameter-name") ;
1258       if ( strlen( ServiceOutParameter()[i].Parametername ) ) {
1259         aField = Graph.createTextNode( strdup(ServiceOutParameter()[i].Parametername) ) ;
1260       }
1261       else {
1262         aField = Graph.createTextNode( "?" ) ;
1263       }
1264       outParameter.appendChild(outParametername) ;
1265       outParametername.appendChild( aField ) ;
1266     }
1267   }
1268
1269   QDomElement DataStreamlist = Graph.createElement("DataStream-list") ;
1270   node.appendChild( DataStreamlist ) ;
1271   for ( i = 0 ; i < (unsigned int ) GetNodeInPortsSize() ; i++ ) {
1272     const GraphBase::InPort * anInPort ;
1273     anInPort = aNode->GetNodeInPort( i ) ;
1274     if ( anInPort->IsDataStream() ) {
1275       cdebug << "SaveXML " << i << " " << Name() << " " << anInPort->PortName() << " " << anInPort->PortType()
1276              << " InDataStreamPort " << anInPort->Kind() << endl ;
1277       QDomElement inParameter = Graph.createElement("inParameter") ;
1278       DataStreamlist.appendChild(inParameter) ;
1279       QDomElement inParametertype = Graph.createElement("inParameter-type") ;
1280       QString aType ;
1281       aType = aType.setNum( StringToDataStreamType( anInPort->PortType() ) ) ;
1282       cdebug << "SaveXML " << anInPort->PortType() << " --> " << StringToDataStreamType( anInPort->PortType() )
1283              << " " << aType << endl ;
1284       aField = Graph.createTextNode( aType ) ;
1285       inParameter.appendChild(inParametertype) ;
1286       inParametertype.appendChild( aField ) ;
1287       QDomElement inParametername = Graph.createElement("inParameter-name") ;
1288       if ( strlen( anInPort->PortName() ) ) {
1289         aField = Graph.createTextNode( strdup(anInPort->PortName()) ) ;
1290       }
1291       else {
1292         aField = Graph.createTextNode( "?" ) ;
1293       }
1294       inParameter.appendChild(inParametername) ;
1295       inParametername.appendChild( aField ) ;
1296       cdebug << "SaveXML " << anInPort->PortName() << endl ;
1297       QDomElement inParameterdependency = Graph.createElement("inParameter-dependency") ;
1298       QString aDependency ;
1299       aDependency = aDependency.setNum( anInPort->Dependency() ) ;
1300       aField = Graph.createTextNode( aDependency ) ;
1301       inParameter.appendChild(inParameterdependency) ;
1302       inParameterdependency.appendChild( aField ) ;
1303       cdebug << "SaveXML Dependency " << anInPort->Dependency() << endl ;
1304       SUPERV::KindOfSchema        aKindOfSchema ;
1305       SUPERV::KindOfInterpolation aKindOfInterpolation ;
1306       SUPERV::KindOfExtrapolation aKindOfExtrapolation ;
1307       ((GraphBase::InDataStreamPort * ) anInPort)->Params( aKindOfSchema , aKindOfInterpolation , aKindOfExtrapolation ) ;
1308       QDomElement inParameterKindOfSchema = Graph.createElement("inParameter-schema") ;
1309       QString aSchema ;
1310       aSchema = aSchema.setNum( aKindOfSchema ) ;
1311       aField = Graph.createTextNode( aSchema ) ;
1312       inParameter.appendChild(inParameterKindOfSchema) ;
1313       inParameterKindOfSchema.appendChild( aField ) ;
1314       cdebug << "SaveXML aKindOfSchema " << aKindOfSchema << endl ;
1315       QDomElement inParameterKindOfInterpolation = Graph.createElement("inParameter-interpolation") ;
1316       QString anInterpolation ;
1317       anInterpolation = anInterpolation.setNum( aKindOfInterpolation ) ;
1318       aField = Graph.createTextNode( anInterpolation ) ;
1319       inParameter.appendChild(inParameterKindOfInterpolation) ;
1320       inParameterKindOfInterpolation.appendChild( aField ) ;
1321       cdebug << "SaveXML aKindOfInterpolation " << aKindOfInterpolation << endl ;
1322       QDomElement inParameterKindOfExtrapolation = Graph.createElement("inParameter-extrapolation") ;
1323       QString anExtrapolation ;
1324       anExtrapolation = anExtrapolation.setNum( aKindOfExtrapolation ) ;
1325       aField = Graph.createTextNode( anExtrapolation ) ;
1326       inParameter.appendChild(inParameterKindOfExtrapolation) ;
1327       inParameterKindOfExtrapolation.appendChild( aField ) ;
1328       cdebug << "SaveXML aKindOfExtrapolation " << aKindOfExtrapolation << endl ;
1329     }
1330   }
1331   for ( i = 0 ; i < (unsigned int ) GetNodeOutPortsSize() ; i++ ) {
1332     const GraphBase::OutPort * anOutPort ;
1333     anOutPort = aNode->GetNodeOutPort( i ) ;
1334     if ( anOutPort->IsDataStream() ) {
1335       cdebug << "SaveXML " << i << " " << Name() << " " << anOutPort->PortName() << " " << anOutPort->PortType()
1336              << " OutDataStreamPort " << anOutPort->Kind() << endl ;
1337       QDomElement outParameter = Graph.createElement("outParameter") ;
1338       DataStreamlist.appendChild(outParameter) ;
1339       QDomElement outParametertype = Graph.createElement("outParameter-type") ;
1340       QString aType ;
1341       aType = aType.setNum( StringToDataStreamType( anOutPort->PortType() ) ) ;
1342       cdebug << "SaveXML " << anOutPort->PortType() << " --> " << StringToDataStreamType( anOutPort->PortType() )
1343              << " " << aType << endl ;
1344       aField = Graph.createTextNode( aType ) ;
1345       outParameter.appendChild(outParametertype) ;
1346       outParametertype.appendChild( aField ) ;
1347       QDomElement outParametername = Graph.createElement("outParameter-name") ;
1348       if ( strlen( anOutPort->PortName() ) ) {
1349         aField = Graph.createTextNode( strdup(anOutPort->PortName() ) ) ;
1350       }
1351       else {
1352         aField = Graph.createTextNode( "?" ) ;
1353       }
1354       outParameter.appendChild(outParametername) ;
1355       outParametername.appendChild( aField ) ;
1356       cdebug << "SaveXML " << anOutPort->PortName() << endl ;
1357       QDomElement outParameterdependency = Graph.createElement("outParameter-dependency") ;
1358       QString aDependency ;
1359       aDependency = aDependency.setNum( anOutPort->Dependency() )  ;
1360       aField = Graph.createTextNode( aDependency ) ;
1361       outParameter.appendChild(outParameterdependency) ;
1362       outParameterdependency.appendChild( aField ) ;
1363       cdebug << "SaveXML Dependency " << anOutPort->Dependency() << endl ;
1364       long aNumberOfValues ;
1365       aNumberOfValues = ((GraphBase::OutDataStreamPort * ) anOutPort)->NumberOfValues() ;
1366       QDomElement outParameterNumberOfValues = Graph.createElement("outParameter-values") ;
1367       QString aValues ;
1368       aValues = aValues.setNum( aNumberOfValues ) ;
1369       aField = Graph.createTextNode( aValues ) ;
1370       outParameter.appendChild(outParameterNumberOfValues) ;
1371       outParameterNumberOfValues.appendChild( aField ) ;
1372       cdebug << "SaveXML NumberOfValues " << ((GraphBase::OutDataStreamPort * ) anOutPort)->NumberOfValues() << endl ;
1373     }
1374   }
1375 //  f << Tabs << "</Parameter-list>" << endl ;    
1376
1377 //  f << Tabs << "<PyFunction-list>" << endl ;
1378   QDomElement PyFunctionlist = Graph.createElement("PyFunction-list") ;
1379   node.appendChild( PyFunctionlist ) ;
1380   for ( i = 0 ; i < PythonFunctions.size() ; i++ ) {
1381 //    f << Tabs << "    <PyFunction>" << endl ;
1382     QDomElement PyFunction = Graph.createElement("PyFunction") ;
1383     PyFunctionlist.appendChild( PyFunction ) ;
1384     int j ;
1385     QDomElement FuncName = Graph.createElement("FuncName") ;
1386     if ( strlen( FuncNames[i].c_str() ) ) {
1387       aField = Graph.createTextNode( FuncNames[i].c_str() ) ;
1388     }
1389     else {
1390       aField = Graph.createTextNode( "?" ) ;
1391     }
1392     PyFunction.appendChild( FuncName ) ;
1393     FuncName.appendChild( aField ) ;
1394     if ( (*PythonFunctions[i]).length() ) {
1395       for ( j = 0 ; j < (int ) (*PythonFunctions[i]).length() ; j++ ) {
1396         QDomElement PyFunc = Graph.createElement("PyFunc") ;
1397         QDomCDATASection aCDATA ;
1398       // mpv: Linux 8.0 compiler compatibility
1399         char * aCDATAChar = strdup ((*PythonFunctions[i])[j]) ;
1400         int i ;
1401         for ( i = 0 ; i < (int ) strlen( aCDATAChar ) ; i++ ) {
1402           if ( aCDATAChar[ i ] != ' ' ) {
1403             break ;
1404           }
1405         }
1406         if ( i == (int ) strlen( aCDATAChar ) ) {
1407           aCDATA = Graph.createCDATASection( "?" ) ;
1408         }
1409         else {
1410           aCDATA = Graph.createCDATASection( aCDATAChar ) ;
1411         }
1412         PyFunction.appendChild( PyFunc ) ;
1413         PyFunc.appendChild( aCDATA ) ;
1414       }
1415     }
1416     else {
1417       QDomElement PyFunc = Graph.createElement("PyFunc") ;
1418       QDomCDATASection aCDATA = Graph.createCDATASection( "?" ) ;
1419       PyFunction.appendChild( PyFunc ) ;
1420       PyFunc.appendChild( aCDATA ) ;
1421     }
1422   }
1423
1424 //  f << Tabs << "<creation-date>" << FirstCreation() << "</creation-date>"
1425 //    << endl ;
1426   QDomElement creationdate = Graph.createElement("creation-date") ;
1427   char fdate[30] ;
1428   sprintf( fdate , "%d/%d/%d - %d:%d:%d" ,  FirstCreation().Day , FirstCreation().Month , FirstCreation().Year , FirstCreation().Hour , FirstCreation().Minute , FirstCreation().Second ) ;
1429   aField = Graph.createTextNode( fdate ) ;
1430   node.appendChild( creationdate ) ;
1431   creationdate.appendChild( aField ) ;
1432 //  f << Tabs << "<lastmodification-date>" << LastModification()
1433 //    << "</lastmodification-date>" << endl ;
1434   QDomElement lastmodificationdate = Graph.createElement("lastmodification-date") ;
1435   char ldate[30] ;
1436   sprintf( ldate , "%d/%d/%d - %d:%d:%d" , LastModification().Day , LastModification().Month , LastModification().Year , LastModification().Hour , LastModification().Minute , LastModification().Second ) ;
1437   aField = Graph.createTextNode( ldate ) ;
1438   node.appendChild( lastmodificationdate ) ;
1439   lastmodificationdate.appendChild( aField ) ;
1440 //  f << Tabs << "<editor-release>" << EditorRelease() << "</editor-release>"
1441 //    << endl ;
1442   QDomElement editorrelease = Graph.createElement("editor-release") ;
1443   aField = Graph.createTextNode( EditorRelease() ) ;
1444   node.appendChild( editorrelease ) ;
1445   editorrelease.appendChild( aField ) ;
1446   QDomElement author = Graph.createElement("author") ;
1447   if ( strlen( Author() ) ) {
1448 //    f << Tabs << "<author>" << Author() << "</author>" << endl ;
1449     aField = Graph.createTextNode( Author() ) ;
1450   }
1451   else {
1452 //    f << Tabs << "<author>?</author>" << endl ;
1453     aField = Graph.createTextNode( "?" ) ;
1454   }
1455   node.appendChild( author ) ;
1456   author.appendChild( aField ) ;
1457   QDomElement container = Graph.createElement("container") ;
1458   if ( IsFactoryNode() && strlen( Computer) ) {
1459 //    f << Tabs << "<container>" << Computer << "</container>" << endl ;
1460     aField = Graph.createTextNode( Computer ) ;
1461   }
1462   else {
1463 //    f << Tabs << "<container>?</container>" << endl ;
1464     aField = Graph.createTextNode( "?" ) ;
1465   }
1466   node.appendChild( container ) ;
1467   container.appendChild( aField ) ;
1468   QDomElement comment = Graph.createElement("comment") ;
1469   if ( strlen( Comment() ) ) {
1470 //    f << Tabs << "<comment>" << Comment() << "</comment>" << endl ;
1471     aField = Graph.createTextNode( Comment() ) ;
1472   }
1473   else {
1474 //    f << Tabs << "<comment>?</comment>" << endl ;
1475     aField = Graph.createTextNode( "?" ) ;
1476   }
1477   node.appendChild( comment ) ;
1478   comment.appendChild( aField ) ;
1479 //  f << Tabs << "<x-position>" << XCoordinate << "</x-position>" << endl ;
1480   QDomElement xposition = Graph.createElement("x-position") ;
1481   QString aXCoordinate ;
1482   aXCoordinate = aKind.setNum( XCoordinate ) ;
1483   aField = Graph.createTextNode( aXCoordinate ) ;
1484   node.appendChild( xposition ) ;
1485   xposition.appendChild( aField ) ;
1486 //  f << Tabs << "<y-position>" << YCoordinate << "</y-position>" << endl ;
1487   QDomElement yposition = Graph.createElement("y-position") ;
1488   QString aYCoordinate ;
1489   aYCoordinate = aKind.setNum( YCoordinate ) ;
1490   aField = Graph.createTextNode( aYCoordinate ) ;
1491   node.appendChild( yposition ) ;
1492   yposition.appendChild( aField ) ;
1493   cdebug_out << "SaveXML Node " << Name() << endl ;
1494   return true ;
1495 }
1496
1497 bool GraphBase::ComputingNode::SavePY( ostream &f , const char * aGraphName ,
1498                                        const char * ComponentName ,
1499                                        const char * InterfaceName ,
1500                                        const char * Computer ,
1501                                        const GraphBase::InLineNode * aCoupledNode ,
1502                                        const ListOfFuncName FuncNames ,
1503                                        const ListOfPythonFunctions PythonFunctions ,
1504                                        int XCoordinate , int YCoordinate ) const {
1505   cdebug_in << "ComputingNode::SavePY " << Name() << endl ;
1506   // san - Presumably, data stream graphs should be always saved with kind = DataStreamGraph
1507 // JR : the bug was at line 927 : && HasDataStream() != 0 was missing
1508   if ( IsDataFlowNode() || ( IsDataStreamNode() && HasDataStream() == 0 ) ) {
1509     f << "    " << Name() << " = Graph( '" << Name() << "' )" << endl ;
1510      if ( GraphMacroLevel() ) {
1511       f << "    " << Name() << ".SetCoupled( '"
1512         << ((GraphBase::GOTONode * ) this)->CoupledNodeName() << "' )" << endl ;
1513     }
1514   }
1515   else if ( IsDataStreamNode() && HasDataStream() != 0 ) {
1516     f << "    " << Name() << " = StreamGraph( '" << Name() << "' )" << endl ;
1517     long Timeout ;
1518     SUPERV::KindOfDataStreamTrace DataStreamTrace ;
1519     double DeltaTime ;
1520     ((GraphBase::StreamGraph * ) this)->StreamParams( Timeout , DataStreamTrace , DeltaTime ) ;
1521     f << "    " << aGraphName << ".SetStreamParams( " << Timeout << " , SUPERV." << DataStreamTrace
1522       << " , " << DeltaTime << " )" << endl ;
1523   }
1524   else if ( IsComputingNode() ) {
1525     int i ;
1526     f << "    " << Name() << "_ServiceinParameter = []" << endl ;
1527     for ( i = 0 ; i < (int ) ServiceInParameter().length() ; i++ ) {
1528       f << "    " << Name() << "_ServiceinParameter.append( SALOME_ModuleCatalog.ServicesParameter( '"
1529         << ServiceInParameter()[i].Parametertype << "' , '"
1530         << ServiceInParameter()[i].Parametername << "' ) )" << endl ;
1531     }
1532     f << "    " << Name() << "_ServiceoutParameter = []" << endl ;
1533     for ( i = 0 ; i < (int ) ServiceOutParameter().length() ; i++ ) {
1534       f << "    " << Name() << "_ServiceoutParameter.append( SALOME_ModuleCatalog.ServicesParameter( '"
1535         << ServiceOutParameter()[i].Parametertype << "' , '"
1536         << ServiceOutParameter()[i].Parametername << "' ) )" << endl ;
1537     }
1538     f << "    " << Name() << "_ServiceinStreamParameter = []" << endl ;
1539     for ( i = 0 ; i < (int ) ServiceInStreamParameter().length() ; i++ ) {
1540       f << "    " << Name() << "_ServiceinStreamParameter.append( SALOME_ModuleCatalog.ServicesDataStreamParameter( SALOME_ModuleCatalog."
1541         << ServiceInStreamParameter()[i].Parametertype << " , '"
1542         << ServiceInStreamParameter()[i].Parametername << "' , SALOME_ModuleCatalog."
1543         << ServiceInStreamParameter()[i].Parameterdependency << " ) )" << endl ;
1544     }
1545     f << "    " << Name() << "_ServiceoutStreamParameter = []" << endl ;
1546     for ( i = 0 ; i < (int ) ServiceOutStreamParameter().length() ; i++ ) {
1547       f << "    " << Name() << "_ServiceoutStreamParameter.append( SALOME_ModuleCatalog.ServicesDataStreamParameter( SALOME_ModuleCatalog."
1548         << ServiceOutStreamParameter()[i].Parametertype << " , '"
1549         << ServiceOutStreamParameter()[i].Parametername << "' , SALOME_ModuleCatalog."
1550         << ServiceOutStreamParameter()[i].Parameterdependency << " ) )" << endl ;
1551     }
1552     f << "    " << Name() << "_Service = SALOME_ModuleCatalog.Service( '" << ServiceName()
1553       << "' , " << Name() << "_ServiceinParameter"
1554       << " , " << Name() << "_ServiceoutParameter"
1555       << " , " << Name() << "_ServiceinStreamParameter"
1556       << " , " << Name() << "_ServiceoutStreamParameter"
1557       << " , 0 , 0 )" << endl ;
1558     f << "    " << Name() << " = " << aGraphName << ".CNode( " << Name() << "_Service" << " )"
1559       << endl ;
1560   }
1561   else if ( IsFactoryNode() ) {
1562     f << "    " << Name() << " = " << aGraphName << ".FNode( '" << ComponentName
1563       << "' , '" << InterfaceName << "' , '" << ServiceName() << "' )"
1564       << endl ;
1565   }
1566   else if ( IsEndLoopNode() || IsEndSwitchNode() ) {
1567 // It is done with LoopNode or SwitchNode with CoupledNode()
1568   }
1569   else {
1570     if ( !IsMacroNode() ) {
1571       f << "    " << "Py" << Name() << " = []" << endl ;
1572     }
1573     int i ;
1574     SUPERV::ListOfStrings aPyFunc ;
1575     if ( PythonFunctions.size() ) {
1576       aPyFunc = *PythonFunctions[0] ;
1577       for ( i = 0 ; i < (int ) aPyFunc.length() ; i++ ) {
1578         f << "    " << "Py" << Name() << ".append( '" << aPyFunc[i] << "' )" << endl ;
1579       }
1580     }
1581     if ( IsInLineNode() ) {
1582       f << "    " << Name() << " = " << aGraphName << ".INode( '" << FuncNames[0].c_str() << "' , Py"
1583         << Name() << " )" << endl ;
1584     }
1585     else if ( IsGOTONode() ) {
1586       if ( aCoupledNode ) {
1587         f << "    " << Name() << " = " << aGraphName << ".GNode( '" << FuncNames[0].c_str() << "' , Py"
1588           << Name() << " , '" << aCoupledNode->Name() << "' )" << endl ;
1589       }
1590       else {
1591         f << "    " << Name() << " = " << aGraphName << ".GNode( '" << FuncNames[0].c_str() << "' , Py"
1592           << Name() << " , '' )" << endl ;
1593       }
1594     }
1595     else if ( IsMacroNode() ) {
1596       if ( aCoupledNode ) {
1597         f << "    " << aCoupledNode->Name() << " = Def" << aCoupledNode->Name() << "()" << endl ;
1598         f << "    " << Name() << " = " << aGraphName << ".GraphMNode( " << aCoupledNode->Name() << " )" << endl ;
1599       }
1600       else {
1601         f << "    " << Name() << " = " << aGraphName << ".GraphMNode( ? )" << endl ;
1602       }
1603       f << "    " << Name() << ".SetCoupled( '" << aCoupledNode->Name() << "' )" << endl ;
1604     }
1605     else {
1606 //      char * EndName = NULL ;
1607 //      EndName = new char[ 3 + strlen( Name() ) + 1 ] ;
1608 //      strcpy( EndName , "End" ) ;
1609 //      strcat( EndName , Name() ) ;
1610       char * EndName = aCoupledNode->Name() ;
1611       cdebug << "ComputingNode::SavePY Node " << Name() << " EndName " << EndName
1612              << endl ;
1613       if ( IsLoopNode() ) {
1614         int i ;
1615         SUPERV::ListOfStrings aPyMore = *PythonFunctions[1] ;
1616         SUPERV::ListOfStrings aPyNext = *PythonFunctions[2] ;
1617         f << "    " << "PyMore" << Name() << " = []" << endl ;
1618         for ( i = 0 ; i < (int ) aPyMore.length() ; i++ ) {
1619           f << "    " << "PyMore" << Name() << ".append( '" << aPyMore[i] << "' )" << endl ;
1620         }
1621         f << "    " << "PyNext" << Name() << " = []" << endl ;
1622         for ( i = 0 ; i < (int ) aPyNext.length() ; i++ ) {
1623           f << "    " << "PyNext" << Name() << ".append( '" << aPyNext[i] << "' )" << endl ;
1624         }
1625         f << "    " << Name() << "," << EndName << " = " << aGraphName << ".LNode( '"
1626           << FuncNames[0].c_str() << "' , Py" << Name() << " , '"
1627           << FuncNames[1].c_str() << "' , PyMore" << Name()
1628           << " , '" << FuncNames[2].c_str() << "' , PyNext"
1629           << Name() << " )" << endl ;
1630         f << "    " << EndName << ".SetName( '" << aCoupledNode->Name() << "' )" << endl ;
1631         f << "    " << EndName << ".SetAuthor( '" << aCoupledNode->Author() << "' )" << endl ;
1632         f << "    " << EndName << ".SetComment( '" << aCoupledNode->Comment() << "' )" << endl ;
1633         f << "    " << EndName << ".Coords( " << aCoupledNode->XCoordinate() << " , "
1634           << aCoupledNode->YCoordinate() << " )" << endl ;
1635         SUPERV::ListOfStrings aPyFunc = *aCoupledNode->PythonFunction() ;
1636         f << "    " << "Py" << aCoupledNode->Name() << " = []" << endl ;
1637         for ( i = 0 ; i < (int ) aPyFunc.length() ; i++ ) {
1638           f << "    " << "Py" << aCoupledNode->Name() << ".append( '" << aPyFunc[i] << "' )"
1639             << endl ;
1640         }
1641         f << "    " << EndName << ".SetPyFunction( '" << aCoupledNode->PyFuncName() << "' , Py" << aCoupledNode->Name() << " )" << endl ;
1642         for ( i = 0 ; i < GetNodeInPortsSize() ; i++ ) {
1643           const GraphBase::InPort * anInPort = GetNodeInPort(i) ;
1644           cdebug << "Node " << Name() << " InPort " << anInPort->PortName()
1645                  << " " << anInPort->Kind() << endl ;
1646           if ( anInPort->IsLoop() ) {
1647             f << "    " << "I" << Name() << anInPort->PortName() << " = "
1648               << Name() << ".GetInPort( '" << anInPort->PortName() << "' )" << endl ;
1649           }
1650           else if ( anInPort->IsInLine() ) {
1651             f << "    " << "I" << Name() << anInPort->PortName() << " = "
1652               << Name() << ".InPort( '" << anInPort->PortName() << "' , '"
1653               << anInPort->PortType() << "' )" << endl ;
1654           }
1655           else if ( anInPort->IsDataStream() ) {
1656             f << "    " << "I" << Name() << anInPort->PortName() << " = " << Name()
1657               << ".InStreamPort( '" << anInPort->PortName()
1658               << "' , SALOME_ModuleCatalog." << StringToDataStreamType( anInPort->PortType() )
1659               << " , SALOME_ModuleCatalog." << anInPort->Dependency() << " )" << endl ;
1660             SUPERV::KindOfSchema        aKindOfSchema ;
1661             SUPERV::KindOfInterpolation aKindOfInterpolation ;
1662             SUPERV::KindOfExtrapolation aKindOfExtrapolation ;
1663             ((GraphBase::InDataStreamPort * ) anInPort)->Params( aKindOfSchema , aKindOfInterpolation , aKindOfExtrapolation ) ;
1664             f << "    " << "I" << Name() << anInPort->PortName() << ".SetParams( SUPERV." << aKindOfSchema << " , SUPERV."
1665               << aKindOfInterpolation << " , SUPERV." << aKindOfExtrapolation << " )" << endl ;
1666           }
1667           else if ( anInPort->IsGate() ) {
1668             f << "    " << "I" << Name() << anInPort->PortName() << " = "
1669               << Name() << ".GetInPort( '" << anInPort->PortName() << "' )" << endl ;
1670           }
1671         }
1672         for ( i = 0 ; i < GetNodeOutPortsSize() ; i++ ) {
1673           const GraphBase::OutPort * anOutPort = GetNodeOutPort(i) ;
1674           cdebug << "Node " << Name() << " OutPort " << anOutPort->PortName()
1675                  << " " << anOutPort->Kind() << endl ;
1676           if ( anOutPort->IsInLine() || anOutPort->IsLoop() ) {
1677             f << "    " << "O" << Name() << anOutPort->PortName() << " = "
1678               << Name() << ".GetOutPort( '" << anOutPort->PortName() << "' )" << endl ;
1679           }
1680           else if ( anOutPort->IsDataStream() ) {
1681             f << "    " << "O" << Name() << anOutPort->PortName() << " = " << Name()
1682               << ".OutStreamPort( '" << anOutPort->PortName()
1683               << "' , SALOME_ModuleCatalog." << StringToDataStreamType( anOutPort->PortType() )
1684               << " , SALOME_ModuleCatalog." << anOutPort->Dependency() << " )" << endl ;
1685             long aNumberOfValues ;
1686             aNumberOfValues = ((GraphBase::OutDataStreamPort * ) anOutPort)->NumberOfValues() ;
1687             f << "    " << "O" << Name() << anOutPort->PortName() << ".SetNumberOfValues( " << aNumberOfValues << " )"
1688               << endl ;
1689           }
1690         }
1691         for ( i = 0 ; i < aCoupledNode->GetNodeInPortsSize() ; i++ ) {
1692           const GraphBase::InPort * anInPort = aCoupledNode->GetNodeInPort(i) ;
1693           cdebug << "Node " << aCoupledNode->Name() << " InPort " << anInPort->PortName()
1694                  << " " << anInPort->Kind() << endl ;
1695           if ( anInPort->IsInLine() || anInPort->IsLoop() || anInPort->IsGate() ) {
1696             f << "    " << "I" << EndName << anInPort->PortName() << " = " << EndName
1697               << ".GetInPort( '" << anInPort->PortName() << "' )" << endl ;
1698           }
1699           else if ( anInPort->IsDataStream() ) {
1700             f << "    " << "I" << EndName << anInPort->PortName() << " = " << EndName
1701               << ".InStreamPort( '" << anInPort->PortName()
1702               << "' , SALOME_ModuleCatalog." << StringToDataStreamType( anInPort->PortType() )
1703               << " , SALOME_ModuleCatalog." << anInPort->Dependency() << " )" << endl ;
1704             SUPERV::KindOfSchema        aKindOfSchema ;
1705             SUPERV::KindOfInterpolation aKindOfInterpolation ;
1706             SUPERV::KindOfExtrapolation aKindOfExtrapolation ;
1707             ((GraphBase::InDataStreamPort * ) anInPort)->Params( aKindOfSchema , aKindOfInterpolation , aKindOfExtrapolation ) ;
1708             f << "    " << "I" << EndName << anInPort->PortName() << ".SetParams( SUPERV." << aKindOfSchema << " , SUPERV."
1709               << aKindOfInterpolation << " , SUPERV." << aKindOfExtrapolation << " )" << endl ;
1710           }
1711         }
1712         for ( i = 0 ; i < aCoupledNode->GetNodeOutPortsSize() ; i++ ) {
1713           const GraphBase::OutPort * anOutPort = aCoupledNode->GetNodeOutPort(i) ;
1714           cdebug << "Node " << aCoupledNode->Name() << " OutPort " << anOutPort->PortName()
1715                  << " " << anOutPort->Kind() << endl ;
1716           if ( anOutPort->IsInLine() || anOutPort->IsLoop() || anOutPort->IsGate() ) {
1717             f << "    " << "O" << EndName << anOutPort->PortName() << " = " << EndName
1718               << ".GetOutPort( '" << anOutPort->PortName() << "' )" << endl ;
1719           }
1720           else if ( anOutPort->IsDataStream() ) {
1721             f << "    " << "O" << EndName << anOutPort->PortName() << " = " << EndName
1722               << ".OutStreamPort( '" << anOutPort->PortName()
1723               << "' , SALOME_ModuleCatalog." << StringToDataStreamType( anOutPort->PortType() )
1724               << " , SALOME_ModuleCatalog." << anOutPort->Dependency() << " )" << endl ;
1725             long aNumberOfValues ;
1726             aNumberOfValues = ((GraphBase::OutDataStreamPort * ) anOutPort)->NumberOfValues() ;
1727             f << "    " << "O" << EndName << anOutPort->PortName() << ".SetNumberOfValues( " << aNumberOfValues << " )"
1728               << endl ;
1729           }
1730         }
1731       }
1732       else if ( IsSwitchNode() ) {
1733         f << "    " << Name() << "," << EndName << " = " << aGraphName << ".SNode( '"
1734           << FuncNames[0].c_str() << "' , Py" << Name() << " )" << endl ;
1735         f << "    " << EndName << ".SetName( '" << aCoupledNode->Name() << "' )" << endl ;
1736         f << "    " << EndName << ".SetAuthor( '" << aCoupledNode->Author() << "' )" << endl ;
1737         f << "    " << EndName << ".SetComment( '" << aCoupledNode->Comment() << "' )" << endl ;
1738         f << "    " << EndName << ".Coords( " << aCoupledNode->XCoordinate() << " , "
1739           << aCoupledNode->YCoordinate() << " )" << endl ;
1740         SUPERV::ListOfStrings aPyFunc = *aCoupledNode->PythonFunction() ;
1741         f << "    " << "Py" << aCoupledNode->Name() << " = []" << endl ;
1742         for ( i = 0 ; i < (int ) aPyFunc.length() ; i++ ) {
1743           f << "    " << "Py" << aCoupledNode->Name() << ".append( '" << aPyFunc[i] << "' )"
1744             << endl ;
1745         }
1746         f << "    " << EndName << ".SetPyFunction( '" << aCoupledNode->PyFuncName() << "' , Py" << aCoupledNode->Name() << " )" << endl ;
1747         for ( i = 0 ; i < aCoupledNode->GetNodeInPortsSize() ; i++ ) {
1748           const GraphBase::InPort * anInPort = aCoupledNode->GetNodeInPort(i) ;
1749           cdebug << "Node " << aCoupledNode->Name() << " InPort " << anInPort->PortName()
1750                  << " " << anInPort->Kind() << endl ;
1751 //          if ( anInPort->IsGate() || anInPort->IsEndSwitch() ) {
1752           if ( anInPort->IsGate() ) {
1753             f << "    " << "I" << EndName << anInPort->PortName() << " = " << EndName
1754               << ".GetInPort( '" << anInPort->PortName() << "' )" << endl ;
1755           }
1756           else if ( anInPort->IsInLine() || anInPort->IsEndSwitch() ) {
1757             f << "    " << "I" << EndName << anInPort->PortName() << " = " << EndName
1758               << ".InPort( '" << anInPort->PortName()
1759               << "' , '" << anInPort->PortType() << "' )" << endl ;
1760           }
1761           else if ( anInPort->IsDataStream() ) {
1762             f << "    " << "I" << EndName << anInPort->PortName() << " = " << EndName
1763               << ".InStreamPort( '" << anInPort->PortName()
1764               << "' , SALOME_ModuleCatalog." << StringToDataStreamType( anInPort->PortType() )
1765               << " , SALOME_ModuleCatalog." << anInPort->Dependency() << " )" << endl ;
1766             SUPERV::KindOfSchema        aKindOfSchema ;
1767             SUPERV::KindOfInterpolation aKindOfInterpolation ;
1768             SUPERV::KindOfExtrapolation aKindOfExtrapolation ;
1769             ((GraphBase::InDataStreamPort * ) anInPort)->Params( aKindOfSchema , aKindOfInterpolation , aKindOfExtrapolation ) ;
1770             f << "    " << "I" << EndName << anInPort->PortName() << ".SetParams( SUPERV." << aKindOfSchema << " , SUPERV."
1771               << aKindOfInterpolation << " , SUPERV." << aKindOfExtrapolation << " )" << endl ;
1772           }
1773         }
1774         for ( i = 0 ; i < aCoupledNode->GetNodeOutPortsSize() ; i++ ) {
1775           const GraphBase::OutPort * anOutPort = aCoupledNode->GetNodeOutPort(i) ;
1776           cdebug << "Node " << aCoupledNode->Name() << " OutPort " << anOutPort->PortName()
1777                  << " " << anOutPort->Kind() << endl ;
1778 //          if ( anOutPort->IsGate() || anOutPort->IsEndSwitch() ) {
1779           if ( anOutPort->IsGate() ) {
1780             f << "    " << "O" << EndName << anOutPort->PortName() << " = " << EndName
1781               << ".GetOutPort( '" << anOutPort->PortName() << "' )" << endl ;
1782           }
1783           else if ( anOutPort->IsInLine() || anOutPort->IsSwitch() ) {
1784             f << "    " << "O" << EndName << anOutPort->PortName() << " = " << EndName
1785               << ".OutPort( '" << anOutPort->PortName()
1786               << "' , '" << anOutPort->PortType() << "' )" << endl ;
1787           }
1788           else if ( anOutPort->IsDataStream() ) {
1789             f << "    " << "O" << EndName << anOutPort->PortName() << " = " << EndName
1790               << ".OutStreamPort( '" << anOutPort->PortName()
1791               << "' , SALOME_ModuleCatalog." << StringToDataStreamType( anOutPort->PortType() )
1792               << " , SALOME_ModuleCatalog." << anOutPort->Dependency() << " )" << endl ;
1793             long aNumberOfValues ;
1794             aNumberOfValues = ((GraphBase::OutDataStreamPort * ) anOutPort)->NumberOfValues() ;
1795             f << "    " << "O" << EndName << anOutPort->PortName() << ".SetNumberOfValues( " << aNumberOfValues << " )"
1796               << endl ;
1797           }
1798         }
1799       }
1800       cdebug << "ComputingNode::SavePY Node " << Name() << " EndName " << EndName
1801              << endl ;
1802 // PAL8507
1803 //JR 24.02.2005 Debug !!!... : I should not delete myself : what a stupid thing !
1804 //      delete [] EndName ;
1805     }
1806   }
1807
1808   if ( IsEndLoopNode() || IsEndSwitchNode() ) {
1809 // It is done with LoopNode or SwitchNode with CoupledNode()
1810   }
1811   else {
1812     f << "    " << Name() << ".SetName( '" << Name() << "' )" << endl ;
1813     f << "    " << Name() << ".SetAuthor( '" << Author() << "' )" << endl ;
1814     if ( IsFactoryNode() ) {
1815       f << "    " << Name() << ".SetContainer( '" << Computer << "' )" << endl ;
1816     }
1817     f << "    " << Name() << ".SetComment( '" << Comment() << "' )" << endl ;
1818     f << "    " << Name() << ".Coords( " << XCoordinate << " , " << YCoordinate << " )" << endl ;
1819
1820     if ( IsComputingNode() || IsFactoryNode() ) {
1821       int i ;
1822       for ( i = 0 ; i < GetNodeInPortsSize() ; i++ ) {
1823         const GraphBase::InPort * anInPort = GetNodeInPort(i) ;
1824         if ( !anInPort->IsDataStream() ) {
1825           cdebug << "Node " << Name() << " InPort " << anInPort->PortName()
1826                  << " " << anInPort->Kind() << endl ;
1827           f << "    " << "I" << Name() << anInPort->PortName() << " = "
1828             << Name() << ".GetInPort( '" << anInPort->PortName() << "' )" << endl ;
1829         }
1830       }
1831       for ( i = 0 ; i < GetNodeOutPortsSize() ; i++ ) {
1832         const GraphBase::OutPort * anOutPort = GetNodeOutPort(i) ;
1833         if ( !anOutPort->IsDataStream() ) {
1834           cdebug << "Node " << Name() << " OutPort " << anOutPort->PortName()
1835                  << " " << anOutPort->Kind() << endl ;
1836           f << "    " << "O" << Name() << anOutPort->PortName() << " = "
1837             << Name() << ".GetOutPort( '" << anOutPort->PortName() << "' )" << endl ;
1838         }
1839       }
1840     }
1841     else if ( IsOneOfInLineNodes() && !IsLoopNode() ) {
1842       int i ;
1843       for ( i = 0 ; i < GetNodeInPortsSize() ; i++ ) {
1844         const GraphBase::InPort * anInPort = GetNodeInPort(i) ;
1845         cdebug << "ComputingNode::SavePY Node " << Name() << " InPort " << anInPort->PortName()
1846                << " " << anInPort->Kind() << endl ;
1847 //        if ( anInPort->IsGate() || ( anInPort->IsInLine() && IsMacroNode() ) ) {
1848         if ( anInPort->IsGate() || IsMacroNode() ) {
1849           f << "    " << "I" << Name() << anInPort->PortName() << " = "
1850             << Name() << ".GetInPort( '" << anInPort->PortName()  << "' )" << endl ;
1851         }
1852         else if ( anInPort->IsInLine() || anInPort->IsEndSwitch() ) {
1853           f << "    " << "I" << Name() << anInPort->PortName() << " = "
1854             << Name() << ".InPort( '" << anInPort->PortName() << "' , '"
1855             << anInPort->PortType() << "' )" << endl ;
1856         }
1857         else {
1858           cdebug << "Ignored " << Name() << " " << anInPort->PortName() << " " << anInPort->PortStatus() << endl ;
1859 //          f << "    " << "I" << Name() << anInPort->PortName() << " = "
1860 //            << Name() << ".GetInPort( '" << anInPort->PortName()  << "' )" << endl ;
1861         }
1862       }
1863       for ( i = 0 ; i < GetNodeOutPortsSize() ; i++ ) {
1864         const GraphBase::OutPort * anOutPort = GetNodeOutPort(i) ;
1865         cdebug << "ComputingNode::SavePY Node " << Name() << " OutPort " << anOutPort->PortName()
1866                << " " << anOutPort->Kind() << endl ;
1867 //        if ( anOutPort->IsGate() || ( anOutPort->IsInLine() && IsMacroNode() ) ) {
1868         if ( anOutPort->IsGate() || IsMacroNode() ) {
1869           f << "    " << "O" << Name() << anOutPort->PortName() << " = "
1870             << Name() << ".GetOutPort( '" << anOutPort->PortName() << "' )" << endl ;
1871         }
1872         else if ( anOutPort->IsInLine() || anOutPort->IsSwitch() ) {
1873           f << "    " << "O" << Name() << anOutPort->PortName() << " = "
1874             << Name() << ".OutPort( '" << anOutPort->PortName()
1875             << "' , '" << anOutPort->PortType() << "' )" << endl ;
1876         }
1877         else {
1878           cdebug << "Ignored " << Name() << " " << anOutPort->PortName() << " " << anOutPort->PortStatus() << endl ;
1879 //          f << "    " << "O" << Name() << anOutPort->PortName() << " = "
1880 //            << Name() << ".GetOutPort( '" << anOutPort->PortName() << "' )" << endl ;
1881         }
1882       }
1883     }
1884     if ( !IsDataFlowNode() && !IsDataStreamNode() ) {
1885       int i ;
1886       for ( i = 0 ; i < GetNodeInPortsSize() ; i++ ) {
1887         const GraphBase::InPort * anInPort = GetNodeInPort(i) ;
1888         cdebug << "Node " << Name() << " InPort " << anInPort->PortName()
1889                << " " << anInPort->Kind() << endl ;
1890         if ( anInPort->IsDataStream() ) {
1891           if ( IsOneOfInLineNodes() ) {
1892             f << "    " << "I" << Name() << anInPort->PortName() << " = "
1893               << Name() << ".InStreamPort( '" << anInPort->PortName() << "' , SALOME_ModuleCatalog."
1894               << StringToDataStreamType( anInPort->PortType() ) << " , SALOME_ModuleCatalog."
1895               << anInPort->Dependency() << " )" << endl ;
1896           }
1897           else {
1898             f << "    " << "I" << Name() << anInPort->PortName() << " = "
1899               << Name() << ".GetInStreamPort( '" << anInPort->PortName() << "' )" << endl ;
1900           }
1901           SUPERV::KindOfSchema        aKindOfSchema ;
1902           SUPERV::KindOfInterpolation aKindOfInterpolation ;
1903           SUPERV::KindOfExtrapolation aKindOfExtrapolation ;
1904           ((GraphBase::InDataStreamPort * ) anInPort)->Params( aKindOfSchema , aKindOfInterpolation , aKindOfExtrapolation ) ;
1905           f << "    " << "I" << Name() << anInPort->PortName() << ".SetParams( SUPERV." << aKindOfSchema << " , SUPERV."
1906             << aKindOfInterpolation << " , SUPERV." << aKindOfExtrapolation << " )" << endl ;
1907         }
1908       }
1909       for ( i = 0 ; i < GetNodeOutPortsSize() ; i++ ) {
1910         const GraphBase::OutPort * anOutPort = GetNodeOutPort(i) ;
1911         cdebug << "Node " << Name() << " OutPort " << anOutPort->PortName()
1912                << " " << anOutPort->Kind() << endl ;
1913         if ( anOutPort->IsDataStream() ) {
1914           if ( IsOneOfInLineNodes() ) {
1915             f << "    " << "O" << Name() << anOutPort->PortName() << " = "
1916               << Name() << ".OutStreamPort( '" << anOutPort->PortName() << "' , SALOME_ModuleCatalog."
1917               << StringToDataStreamType( anOutPort->PortType() ) << " , SALOME_ModuleCatalog."
1918               << anOutPort->Dependency() << " )" << endl ;
1919           }
1920           else {
1921             f << "    " << "O" << Name() << anOutPort->PortName() << " = "
1922               << Name() << ".GetOutStreamPort( '" << anOutPort->PortName() << "' )" << endl ;
1923           }
1924           long aNumberOfValues ;
1925           aNumberOfValues = ((GraphBase::OutDataStreamPort * ) anOutPort)->NumberOfValues() ;
1926           f << "    " << "O" << Name() << anOutPort->PortName() << ".SetNumberOfValues( " << aNumberOfValues << " )" << endl ;
1927         }
1928       }
1929     }
1930   }
1931
1932   cdebug_out << "ComputingNode::SavePY " ;
1933   NodeInfo( *_fdebug ) ;
1934   cdebug << endl ;
1935   return true ;
1936 }
1937
1938 void GraphBase::ComputingNode::NodeInfo(ostream & s) const {
1939   s << *this ;
1940   ListPorts( s , true ) ;
1941   s << ends ;
1942 }
1943
1944 ostream & operator<< (ostream & f,const GraphBase::ComputingNode & G) {
1945 //  f << "ComponentName    " << G.ComponentName() << endl ;
1946   if ( G.IsComputingNode() ) {
1947     f << "NodeName         " << G.Name() << endl ;
1948   }
1949   else {
1950     f << "DataFlowName     " << G.Name() << endl ;
1951   }
1952   f << "Kind             " << G.Kind() << endl ;
1953   f << "Service          " << *G.GetService() ;
1954   f << "FirstCreation    " << G.FirstCreation () << endl ;
1955   f << "LastModification " << G.LastModification() << endl ;
1956   f << "EditorRelease    " << G.EditorRelease() << endl ;
1957   f << "Author           " << G.Author() << endl ;
1958 //  f << "Computer         " << G.Computer() << endl ;
1959   f << "Comment          " << G.Comment() << endl ;
1960   f << endl ;
1961   
1962   return f;
1963 }
1964
1965 void GraphBase::ComputingNode::ListLinks(ostream &f ) const {
1966   int i ;
1967   for ( i = 0 ; i < GetNodeOutPortsSize() ; i++ ) {
1968     const GraphBase::OutPort* fromPort = GetNodeOutPort( i ) ;
1969     if ( fromPort->IsPortConnected() ) {
1970       int j ;
1971       for ( j = 0 ; j < fromPort->InPortsSize() ; j++ ) {
1972         if ( j == 0 ) {
1973           f << "FromNode " << Name() << endl ;
1974         }
1975         f << "         FromServiceParameterName "
1976           << fromPort->GetServicesParameter().Parametername ;
1977         const GraphBase::InPort* toPort = fromPort->InPorts( j ) ;
1978         f << " ToNode " << toPort->NodeName() ;
1979         f << " ToServiceParameterName "
1980           << toPort->GetServicesParameter().Parametername;
1981         f << " Value " ;
1982         fromPort->StringValue( f ) ;
1983         f << endl ;
1984       }
1985     }
1986   }
1987 }
1988
1989 ostream & operator<< (ostream &fOut,const SUPERV::SDate &D) {
1990 //  cdebug_in << "operator<< GraphEditor::Date" << endl;
1991
1992   fOut  << D.Day << "/" 
1993         << D.Month << "/" 
1994         << D.Year << " - " 
1995         << D.Hour << ":" 
1996         << D.Minute <<  ":"  
1997         << D.Second;
1998
1999 //  cdebug_out << "operator<< GraphEditor::Date" << endl;
2000   return fOut;
2001 }
2002