Salome HOME
4e689ef3ea061248d36e7ea1b20120c90f07a635
[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_Node.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_InLineNode.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::DataFlowNode ;
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
68   InitFields( _Kind ,
69               _FirstCreation ,
70               _LastModification ,
71               _EditorRelease ,
72               _Author ,
73               _Comment ,
74               _HeadNode ,
75               _GeneratedName ,
76               _DataStreamInPortsNumber ,
77               _DataStreamOutPortsNumber ,
78               _ConnectedInPortsNumber ,
79               _DecrConnectedInPortsNumber ,
80               _LinkedNodesSize ,
81               _SubGraphNumber ) ;
82   _NamingService = NULL ;
83   _Node = SUPERV::CNode::_nil() ;
84   _InNode = NULL ;
85   _ThreadNo = pthread_self() ;
86   _Name = NULL ;
87   cdebug << "GraphBase::Node::Node "  << this << " "  << endl ;
88
89 }
90
91 GraphBase::ComputingNode::ComputingNode( CORBA::ORB_ptr ORB ,
92                                          SALOME_NamingService* ptrNamingService ,
93                                          const char * aDataFlowName ,
94                                          int * Graph_prof_debug ,
95                                          ofstream * Graph_fdebug ) :
96   GraphBase::PortsOfNode::PortsOfNode( aDataFlowName ) {
97
98   MESSAGE( "GraphBase::ComputingNode::ComputingNode( " << aDataFlowName << " Graph_fdebug " << Graph_fdebug ) ;
99   InitFields( _Kind ,
100               _FirstCreation ,
101               _LastModification ,
102               _EditorRelease ,
103               _Author ,
104               _Comment ,
105               _HeadNode ,
106               _GeneratedName ,
107               _DataStreamInPortsNumber ,
108               _DataStreamOutPortsNumber ,
109               _ConnectedInPortsNumber ,
110               _DecrConnectedInPortsNumber ,
111               _LinkedNodesSize ,
112               _SubGraphNumber ) ;
113
114   _ORB = CORBA::ORB::_duplicate( ORB ) ;
115   _NamingService = ptrNamingService ;
116   _Node = SUPERV::CNode::_nil() ;
117   _InNode = NULL ;
118   _ThreadNo = pthread_self() ;
119
120   if ( aDataFlowName != NULLSTRING && strlen( aDataFlowName ) ) {
121     _Name = new char[ strlen( aDataFlowName )+1 ] ;
122     strcpy( _Name , aDataFlowName ) ;
123   }
124   else {
125     _Name = NULLSTRING ;
126   }
127   if ( Graph_prof_debug ) {
128 //    MESSAGE( "GraphBase::ComputingNode::ComputingNode --> SetDebug" ) ;
129 //    cout << "GraphBase::ComputingNode::ComputingNode --> SetDebug" << endl ;
130     _Graph_prof_debug = Graph_prof_debug ;
131     _Graph_fdebug = Graph_fdebug ;
132     SetDebug( ORB , Graph_prof_debug , Graph_fdebug ) ;
133   }
134 //  else {
135 //    cout << "GraphBase::ComputingNode::ComputingNode NO SetDebug" << endl ;
136 //  }
137   cdebug << "GraphBase::ComputingNode::ComputingNode "  << this 
138          << "' _Name "
139          << (void *) _Name << " '" << _Name << " "  << _FirstCreation
140          << " "  << _LastModification << endl ;
141 }
142
143 GraphBase::ComputingNode::ComputingNode( CORBA::ORB_ptr ORB ,
144                                          SALOME_NamingService* ptrNamingService ,
145                                          const SALOME_ModuleCatalog::Service& aService ,
146                                          const char *NodeName ,
147                                          const SUPERV::KindOfNode akind ,
148                                          const SUPERV::SDate NodeFirstCreation ,
149                                          const SUPERV::SDate NodeLastModification  ,
150                                          const char * NodeEditorRelease ,
151                                          const char * NodeAuthor ,
152                                          const char * NodeComment ,
153                                          const bool   GeneratedName ,
154                                          const long   X ,
155                                          const long   Y ,
156                                          int * Graph_prof_debug ,
157                                          ofstream * Graph_fdebug ) :
158   GraphBase::PortsOfNode::PortsOfNode() {
159
160   _ORB = CORBA::ORB::_duplicate( ORB ) ;
161   _NamingService = ptrNamingService ;
162   _Node = SUPERV::CNode::_nil() ;
163   _InNode = NULL ;
164   _ThreadNo = pthread_self() ;
165
166   _Kind = akind ;
167
168   time_t T = time(NULL);
169   struct tm * Tm = localtime(&T);
170
171   _FirstCreation.Second = _LastModification.Second = Tm->tm_sec;
172   _FirstCreation.Minute = _LastModification.Minute = Tm->tm_min;
173   _FirstCreation.Hour   = _LastModification.Hour   = Tm->tm_hour;
174   _FirstCreation.Day    = _LastModification.Day    = Tm->tm_mday;
175   _FirstCreation.Month  = _LastModification.Month  = Tm->tm_mon + 1;
176   _FirstCreation.Year   = _LastModification.Year   = Tm->tm_year + 1900; 
177
178   if ( NodeEditorRelease != NULLSTRING ) {
179     _EditorRelease = new char[ strlen( NodeEditorRelease ) + 1 ] ;
180     strcpy( _EditorRelease , NodeEditorRelease ) ;
181   }
182   else {
183     _EditorRelease = new char[ strlen( SuperVision_Version ) + 1 ] ;
184     strcpy( _EditorRelease , SuperVision_Version ) ;
185   }
186
187   if ( NodeAuthor != NULLSTRING ) {
188     _Author = new char[ strlen( NodeAuthor ) + 1 ] ;
189     strcpy( _Author  , NodeAuthor ) ;
190   }
191   else {
192     _Author = NULLSTRING ;
193   }
194
195   if ( NodeComment != NULLSTRING ) {
196     _Comment = new char[ strlen( NodeComment ) + 1 ] ;
197     strcpy( _Comment  , NodeComment ) ;
198   }
199   else {
200     _Comment = NULLSTRING ;
201   }
202
203   _SubGraphNumber = 0 ;
204   _HeadNode = false ;
205   _GeneratedName = GeneratedName ;
206
207   const char *aNodeName = NodeName ;
208   _Name = new char[strlen(aNodeName)+1];
209   strcpy(_Name , aNodeName);
210
211   _DataStreamInPortsNumber = 0 ;
212   _DataStreamOutPortsNumber = 0 ;
213
214   _ConnectedInPortsNumber = 0 ;
215   _DecrConnectedInPortsNumber = 0 ;
216   _LinkedNodesSize = 0 ;
217
218   _X = X ;
219   _Y = Y ;
220
221 //  MESSAGE( "GraphBase::ComputingNode::ComputingNode --> SetDebug " << Graph_prof_debug << " Graph_fdebug "
222 //           << Graph_fdebug ) ;
223 //  cout << "GraphBase::ComputingNode::ComputingNode --> SetDebug " << Graph_prof_debug << " Graph_fdebug "
224 //       << Graph_fdebug << endl ;
225   _Graph_prof_debug = Graph_prof_debug ;
226   _Graph_fdebug = Graph_fdebug ;
227   SetDebug( ORB , Graph_prof_debug , Graph_fdebug ) ;
228 //  MESSAGE( "GraphBase::ComputingNode::ComputingNode SetDebug Done " << Graph_prof_debug << " Graph_fdebug "
229 //           << Graph_fdebug << " aService.ServiceName " << aService.ServiceName ) ;
230 //  cout << "GraphBase::ComputingNode::ComputingNode SetDebug Done " << Graph_prof_debug << " Graph_fdebug "
231 //       << Graph_fdebug << endl ;
232 //  cout << "GraphBase::ComputingNode::ComputingNode(" << aService.ServiceName << "," << aNodeName << ","
233 //       << akind << ")" << endl;
234   cdebug_in << "GraphBase::ComputingNode::ComputingNode(" << aService.ServiceName << "," << aNodeName << ","
235             << akind << ")" << endl;
236   
237
238   DefPortsOfNode( ORB , aService , NamePtr() , Kind() , Graph_prof_debug , Graph_fdebug ) ;
239
240   cdebug << "GraphBase::ComputingNode::ComputingNode "  << this 
241          << " _Name " << (void *) _Name << " '" << _Name
242          << " KindOfNode " << _Kind
243          << " ServiceName " << ServiceName() << " In(" << ServiceInParameter().length()
244          << ") Out(" << ServiceOutParameter().length() << ")" << endl ;
245
246   cdebug_out << "GraphBase::ComputingNode::ComputingNode" << endl;
247 }
248
249 GraphBase::ComputingNode::~ComputingNode() {
250   cdebug << "GraphBase::ComputingNode::~ComputingNode "  << this 
251          << " _Name "
252          << (void *) _Name << " " << _Name << " _Comment "
253          << (void *) _Comment << " "  << _Comment << " "  << endl ;
254 //  if ( _ComponentName != NULLSTRING )
255 //    delete [] _ComponentName ;
256 //  delete [] _Name ;
257 //  delete [] _EditorRelease ;
258 //  if ( _Author != NULLSTRING )
259 //    delete [] _Author ;
260 //  if ( _Computer != FACTORYSERVER )
261 //    delete [] _Computer;
262 //  if ( _Comment != NULLSTRING )
263 //    delete [] _Comment;
264 }
265
266 bool GraphBase::ComputingNode::Name( const char * aName) {
267   cdebug_in << "GraphBase::ComputingNode::Name " << _Name << endl;
268   if ( _Name ) {
269     cdebug << "GraphBase::ComputingNode::ReName "  << _Name << " --> " << aName << endl ;
270     delete [] _Name ;
271   }
272   _Name = new char[strlen(aName)+1] ;
273   strcpy( _Name , aName ) ;
274   cdebug_out << "GraphBase::ComputingNode::Name " << _Name << endl;
275   return true ;
276 }
277
278 SUPERV::SDate GraphBase::ComputingNode::FirstCreation () const {
279 //  cdebug << "GraphBase::ComputingNode::FirstCreation "
280 //         << "' _Name " << _Name << " "  << _FirstCreation << " "  
281 //         << _LastModification << endl ;
282   return _FirstCreation;
283 }
284
285 SUPERV::SDate GraphBase::ComputingNode::LastModification () const {
286   return _LastModification ;
287 }
288
289 bool GraphBase::ComputingNode::Kind(const SUPERV::KindOfNode aKind) {
290   _Kind = aKind ;
291   return true ;
292 }
293
294 void GraphBase::ComputingNode::FirstCreation(const SUPERV::SDate aDate ) {
295   _FirstCreation = aDate ;
296 }
297
298 void GraphBase::ComputingNode::LastModification(const SUPERV::SDate aDate ) {
299   _LastModification = aDate ;
300 }
301
302 bool GraphBase::ComputingNode::EditorRelease(const char * c){
303   if ( _EditorRelease && _EditorRelease != NULLSTRING )
304     delete _EditorRelease;
305   _EditorRelease = my_strdup(c);
306   return true ;
307 }
308
309 bool GraphBase::ComputingNode::Author(const char * a) {
310   cdebug_in << "GraphBase::ComputingNode::Author " << _Author << endl;
311   if ( _Author && _Author != NULLSTRING )
312     delete _Author;
313   _Author = my_strdup(a);
314   cdebug_out << "GraphBase::ComputingNode::Author " << _Author << endl;
315   return true ;
316 }
317
318 bool GraphBase::ComputingNode::Comment(const char *c) {
319   cdebug_in << "GraphBase::ComputingNode::Comment " << _Comment << endl;
320   if ( _Comment != NULLSTRING )
321     delete [] _Comment;
322   _Comment = my_strdup(c);
323   cdebug_out << "GraphBase::ComputingNode::Comment " << _Comment << endl;
324   return true ;
325 }
326
327 void GraphBase::ComputingNode::NodePort( const char * NodeName ,
328                                 const char * ServiceParameterName ,
329                                 char ** aNode , char ** aPort ) {
330   if ( strcmp( NodeName , Name() ) ) {
331     *aNode = my_strdup( NodeName ) ;
332     *aPort = my_strdup( ServiceParameterName ) ;
333   }
334   else {
335     char * BPort = strchr( ServiceParameterName , '\\' ) ;
336     if ( BPort ) {
337       int len = BPort - ServiceParameterName ;
338       *aNode = new char [ len + 1 ] ;
339       strncpy( *aNode , ServiceParameterName , len ) ;
340       (*aNode)[ len ] = '\0' ;
341       *aPort = my_strdup( &BPort[ 1 ] ) ;
342     }
343     else {
344       *aNode = my_strdup( NULLSTRING ) ;
345       *aPort = my_strdup( NULLSTRING ) ;
346     }
347   }
348 }
349
350 bool GraphBase::ComputingNode::IsLinked(const char * ToServiceParameterName ) {
351   bool RetVal = false ;
352   const GraphBase::InPort * thePort = GetInPort( ToServiceParameterName ) ;
353   if ( thePort ) {
354     RetVal = thePort->IsConnected() ;
355   }
356   else {
357     const GraphBase::OutPort * thePort = GetOutPort( ToServiceParameterName ) ;
358     if ( thePort ) {
359       RetVal = thePort->IsConnected() ;
360     }
361   }
362   return RetVal ;
363 }
364
365 bool GraphBase::ComputingNode::HasInput(const char * ToServiceParameterName ) {
366   bool RetVal = false ;
367   const GraphBase::InPort * thePort = GetInPort( ToServiceParameterName ) ;
368   if ( IsDataFlowNode() && thePort ) {
369     RetVal = true ;
370   }
371   else if ( thePort ) {
372 //    cout << "GraphBase::ComputingNode::HasInput theInPort " << thePort << " " << thePort->PortName() << " of "
373 //         << thePort->NodeName() << " IsDataConnected " << thePort->IsDataConnected() << " OutPort "
374 //         << thePort->GetOutPort() << endl ;
375     RetVal = thePort->IsDataConnected() ;
376   }
377   else {
378     const GraphBase::OutPort * thePort = GetOutPort( ToServiceParameterName ) ;
379     if ( thePort ) {
380       RetVal = thePort->IsDataConnected() ;
381     }
382   }
383   return RetVal ;
384 }
385
386 GraphBase::SNode * GraphBase::ComputingNode::GetInfo() {
387   cdebug_in << "GraphBase::ComputingNode::GetInfo" << endl;
388   GraphBase::SNode * Info = new GraphBase::SNode ;
389 //  Info->theComponentName = ComponentName() ;
390 //  Info->theInterfaceName = InterfaceName() ;
391   Info->theName = Name() ;
392   Info->theKind = Kind() ;
393   Info->theService = *GetService() ;
394 //  Info->theListOfParameters = *GetListOfParameters() ;
395   Info->theFirstCreation = FirstCreation() ;
396   Info->theLastModification = LastModification() ;
397   Info->theEditorRelease = EditorRelease() ;
398   Info->theAuthor = Author() ;
399 //  Info->theContainer = Computer() ;
400   Info->theComment = Comment() ;
401   Info->theCoords.theX = GraphBase::ComputingNode::XCoordinate() ;
402   Info->theCoords.theY = GraphBase::ComputingNode::YCoordinate() ;
403   cdebug_out << "GraphBase::ComputingNode::GetInfo" << endl;
404   return Info ;
405 }
406
407 void GraphBase::ComputingNode::DelInPort( const char * InputParameterName ) {
408   if ( GetChangeInPort( InputParameterName )->IsDataStream() ) {
409     _DataStreamInPortsNumber-- ;
410   }
411   GraphBase::PortsOfNode::DelInPort( InputParameterName ) ;
412 }
413 void GraphBase::ComputingNode::DelOutPort( const char * OutputParameterName ) {
414   if ( GetChangeOutPort( OutputParameterName )->IsDataStream() ) {
415     _DataStreamOutPortsNumber-- ;
416   }
417   GraphBase::PortsOfNode::DelOutPort( OutputParameterName ) ;
418 }
419
420 GraphBase::InPort * GraphBase::ComputingNode::AddInPort( const char * InputParameterName ,
421                                                 const char * InputParameterType ) {
422   return GraphBase::PortsOfNode::AddInPort( _ORB , NamePtr() ,
423                                             Kind() ,
424                                             InputParameterName ,
425                                             InputParameterType ,
426                                             _Graph_prof_debug , _Graph_fdebug ) ;
427 }
428 GraphBase::OutPort * GraphBase::ComputingNode::AddOutPort( const char * OutputParameterName ,
429                                                   const char * OutputParameterType ) {
430   return GraphBase::PortsOfNode::AddOutPort( _ORB , NamePtr() ,
431                                              Kind() ,
432                                              OutputParameterName ,
433                                              OutputParameterType ,
434                                              _Graph_prof_debug , _Graph_fdebug ) ;
435 }
436
437 void GraphBase::ComputingNode::AddLink( GraphBase::ComputingNode * ToNode ) {
438   int index = GetLinkedNodeIndex( ToNode->Name() ) ;
439   if ( index < 0 ) {
440     cdebug << Name() << "->GraphBase::ComputingNode::AddLinkedNode( " << ToNode->Name()
441            << " ) new LinkedNode " << endl ;
442     _LinkedNodes.resize( _LinkedNodesSize+1 ) ;
443     _LinkedInPortsNumber.resize( _LinkedNodesSize+1 ) ;
444     _LinkedNodes[ _LinkedNodesSize ] = ToNode ;
445     _LinkedInPortsNumber[ _LinkedNodesSize ] = 1 ;
446     SetLinkedNodeIndex( ToNode->Name() , _LinkedNodesSize ) ;
447     index = _LinkedNodesSize ;
448     _LinkedNodesSize++ ;
449   }
450   else {
451     cdebug << Name() << "->GraphBase::ComputingNode::AddLinkedNode( " << ToNode->Name()
452            << " ) old LinkedNode " << _LinkedNodes[index ]->Name() << endl ;
453     _LinkedInPortsNumber[ index ] += 1 ;
454   }
455   cdebug << Name() << "->GraphBase::ComputingNode::AddLinkedNode( " << ToNode->Name()
456          << " ) LinkedNodesSize " << _LinkedNodesSize << " [ " << index
457          << " ] _LinkedInPortsNumber " << _LinkedInPortsNumber[ index ]
458          << " ConnectedInPortsNumber " << ToNode->ConnectedInPortsNumber()
459          << " + 1 Service " << ServiceName() << endl ;
460   ToNode->IncrConnectedInPortsNumber() ;
461 }
462
463 void GraphBase::ComputingNode::RemoveLink( GraphBase::ComputingNode * ToNode ) {
464   int index = GetLinkedNodeIndex( ToNode->Name() ) ;
465   if ( index >= 0 ) {
466     cdebug << "GraphBase::ComputingNode::RemoveLink( to " << ToNode->Name() << " from "
467            << Name() << " index : " << index << " ConnectedInPortsNumber "
468            << ToNode->ConnectedInPortsNumber() - 1 << " LinkedInPortsNumber "
469            << _LinkedInPortsNumber[ index ] << " - 1" << endl ;
470     ToNode->DecrConnectedInPortsNumber() ;
471     _LinkedInPortsNumber[ index ] -= 1 ;
472     if ( _LinkedInPortsNumber[ index ] == 0 ) {
473       _LinkedNodesSize-- ;
474       cdebug << "GraphBase::ComputingNode::RemoveLink new LinkedNodesSize "
475              << _LinkedNodesSize << " " << ToNode->Name() << " removed from "
476              << " linkednodes of " << Name() << endl ;
477       int i ;
478       for ( i = index ; i < _LinkedNodesSize ; i++ ) {
479         _LinkedNodes[ i ] = _LinkedNodes[ i+1 ] ;
480         _LinkedInPortsNumber[ i ] =  _LinkedInPortsNumber[ i+1 ] ;
481         SetLinkedNodeIndex( _LinkedNodes[ i ]->Name() , i ) ;
482       }
483       DelLinkedNodeIndex( ToNode->Name() ) ;
484       _LinkedNodes.resize( _LinkedNodesSize+1 ) ;
485       _LinkedInPortsNumber.resize( _LinkedNodesSize+1 ) ;
486     }
487   }
488   else {
489     cdebug << " Error index " << index << endl ;
490   }
491 }
492
493 void GraphBase::ComputingNode::ReNameLink( const char* OldNodeName ,
494                                   const char* NewNodeName ) {
495   cdebug_in << "GraphBase::ComputingNode::ReNameLink (" << OldNodeName << " , "
496             << NewNodeName << ")" << endl;
497   int index = GetLinkedNodeIndex( OldNodeName ) ;
498   if ( index >= 0 ) {
499     _MapOfLinkedNodes.erase( OldNodeName ) ;
500     SetLinkedNodeIndex( NewNodeName , index ) ;
501   }
502   cdebug_out << "GraphBase::ComputingNode::ReNameLink" << endl ;
503 }
504
505 #include <sys/time.h>
506 #include <sys/resource.h>
507 #include <unistd.h>
508
509 const long GraphBase::ComputingNode::CpuUsed() {
510   struct rusage usage ;
511   if ( getrusage( RUSAGE_SELF , &usage ) == -1 ) {
512     perror("GraphBase::CpuUsed") ;
513     return 0 ;
514   }
515 //  return usage.ru_utime.__time_t tv_sec ;
516   cdebug << "CpuUsed " << usage.ru_utime.tv_sec << " " << usage.ru_utime.tv_usec << " "
517          << usage.ru_stime.tv_sec << " " << usage.ru_stime.tv_usec << endl ;
518   return usage.ru_utime.tv_sec ;
519 }
520
521 #if 0
522 const GraphBase::ListOfParameters * GraphBase::ComputingNode::GetListOfParameters() const {
523   GraphBase::ListOfParameters * aListOfParameters = new GraphBase::ListOfParameters ;
524   if ( IsInLineNode() || IsGOTONode() ) {
525     unsigned int i;
526     for ( i = 0 ; i < GetNodeInPortsSize() ; i++ ) {
527       const InPort * anInPort = GetNodeInPort( i ) ;
528       if ( anInPort->IsBus() ) {
529         int size = aListOfParameters->size() ;
530         aListOfParameters->resize( size + 1 ) ;
531         (*aListOfParameters)[size].theInParameter.Parametername = anInPort->PortName() ;
532         (*aListOfParameters)[size].theInParameter.Parametertype = anInPort->PortType() ;
533         const OutPort * anOutPort = GetNodeOutPort( anInPort->PortIndex() ) ;
534         (*aListOfParameters)[size].theOutParameter.Parametername = anOutPort->PortName() ;
535         (*aListOfParameters)[size].theOutParameter.Parametertype = anOutPort->PortType() ;
536       }
537     }
538   }
539   return aListOfParameters ;
540 }
541 #endif
542
543 bool GraphBase::ComputingNode::SaveXML( QDomDocument & Graph , QDomElement & info ,
544                                         const char * ComponentName ,
545                                         const char * InterfaceName ,
546                                         const char * Computer ,
547                                         const char * CoupledNode ,
548                                         const ListOfFuncName FuncNames ,
549                                         const ListOfPythonFunctions PythonFunctions ,
550                                         int XCoordinate , int YCoordinate ) const {
551   cdebug_in << "SaveXML Node " << Name() << endl ;
552   QDomElement node = Graph.createElement( "node" ) ;
553   info.appendChild( node ) ;
554   QDomElement componentname = Graph.createElement( "component-name" ) ;
555   QDomText aField ;
556   if ( strlen( ComponentName ) ) {
557 //    f << Tabs << "<component-name>" << ComponentName << "</component-name>"
558 //      << endl ;
559 //    componentname.setNodeValue( ComponentName ) ;
560     aField = Graph.createTextNode( ComponentName ) ;
561   }
562   else {
563 //    f << Tabs << "<component-name>?</component-name>" << endl ;
564 //    componentname.setNodeValue( "?" ) ;
565     aField = Graph.createTextNode( "?" ) ;
566   }
567   node.appendChild( componentname ) ;
568   componentname.appendChild( aField ) ;
569
570   QDomElement interfacename = Graph.createElement("interface-name") ;
571   if ( strlen( InterfaceName ) ) {
572 //    f << Tabs << "<interface-name>" << InterfaceName << "</interface-name>"
573 //      << endl ;
574 //    interfacename.setAttribute("name" , InterfaceName ) ;
575     aField = Graph.createTextNode( InterfaceName ) ;
576   }
577   else {
578 //    f << Tabs << "<interface-name>?</interface-name>" << endl ;
579 //    interfacename.setAttribute("name" , "?" ) ;
580     aField = Graph.createTextNode( "?" ) ;
581   }
582   node.appendChild(interfacename) ;
583   interfacename.appendChild( aField ) ;
584
585 //  f << Tabs << "<node-name>" << Name() << "</node-name>" << endl ;
586   QDomElement nodename = Graph.createElement("node-name") ;
587   aField = Graph.createTextNode( Name() ) ;
588   node.appendChild( nodename ) ;
589   nodename.appendChild( aField ) ;
590
591 //  f << Tabs << "<kind>" << (int ) Kind() << "</kind>" << endl ;
592   QDomElement kind = Graph.createElement( "kind" ) ;
593   QString aKind ;
594   aKind = aKind.setNum( Kind() ) ;
595   aField = Graph.createTextNode( aKind ) ;
596   node.appendChild( kind ) ;
597   kind.appendChild( aField ) ;
598
599   QDomElement couplednode = Graph.createElement("coupled-node") ;
600   if ( IsGOTONode() || IsLoopNode() || IsEndLoopNode() ||
601        IsSwitchNode() || IsEndSwitchNode() ) {
602 //    f << Tabs << "<coupled-node>" << CoupledNode << "</coupled-node>"
603 //      << endl ;
604     aField = Graph.createTextNode( CoupledNode ) ;
605   }
606   else {
607 //    f << Tabs << "<coupled-node>?</coupled-node>" << endl ;
608     aField = Graph.createTextNode( "?" ) ;
609   }
610   node.appendChild(couplednode) ;
611   couplednode.appendChild( aField ) ;
612
613 //  f << Tabs << "<service>" << endl ;
614   QDomElement service = Graph.createElement("service") ;
615   node.appendChild(service) ;
616   QDomElement servicename = Graph.createElement("service-name") ;
617   if ( strlen( ServiceName() ) ) {
618 //    f << Tabs << "    <service-name>" << ServiceName() << "</service-name>" << endl ;
619     aField = Graph.createTextNode( ServiceName() ) ;
620   }
621   else {
622 //    f << Tabs << "    <service-name>?</service-name>" << endl ;
623     aField = Graph.createTextNode( "?" ) ;
624   }
625   service.appendChild(servicename) ;
626   servicename.appendChild( aField ) ;
627
628   QDomElement inParameterlist = Graph.createElement("inParameter-list") ;
629   service.appendChild(inParameterlist) ;
630   unsigned int i;
631   GraphBase::ComputingNode * aNode = (GraphBase::ComputingNode * ) this ;
632   for ( i = 0 ; i < ServiceInParameter().length() ; i++ ) {
633     const GraphBase::InPort * anInPort ;
634     anInPort = aNode->GetInPort( ServiceInParameter()[i].Parametername ) ;
635     if ( !anInPort->IsDataStream() ) {
636       cdebug << "SaveXML " << i << ". " << ServiceInParameter()[i].Parametername
637              << " InParameterPort " << anInPort->Kind() << endl ;
638       QDomElement inParameter = Graph.createElement("inParameter") ;
639       inParameterlist.appendChild(inParameter) ;
640       QDomElement inParametertype = Graph.createElement("inParameter-type") ;
641       if ( strlen( ServiceInParameter()[i].Parametertype ) ) {
642         aField = Graph.createTextNode( strdup( ServiceInParameter()[i].Parametertype ) ) ;
643       }
644       else {
645         aField = Graph.createTextNode( "?" ) ;
646       }
647       inParameter.appendChild(inParametertype) ;
648       inParametertype.appendChild( aField ) ;
649       QDomElement inParametername = Graph.createElement("inParameter-name") ;
650       if ( strlen( ServiceInParameter()[i].Parametername ) ) {
651         aField = Graph.createTextNode( strdup(ServiceInParameter()[i].Parametername) ) ;
652       }
653       else {
654         aField = Graph.createTextNode( "?" ) ;
655       }
656       inParameter.appendChild(inParametername) ;
657       inParametername.appendChild( aField ) ;
658     }
659   }
660   QDomElement outParameterlist = Graph.createElement("outParameter-list") ;
661   service.appendChild(outParameterlist) ;
662   for ( i = 0 ; i < ServiceOutParameter().length() ; i++ ) {
663     const GraphBase::OutPort * anOutPort ;
664     anOutPort = aNode->GetOutPort( ServiceOutParameter()[i].Parametername ) ;
665     if ( !anOutPort->IsDataStream() ) {
666       cdebug << "SaveXML " << i << ". " << ServiceOutParameter()[i].Parametername
667              << " OutParameterPort " << anOutPort->Kind() << endl ;
668       QDomElement outParameter = Graph.createElement("outParameter") ;
669       outParameterlist.appendChild(outParameter) ;
670       QDomElement outParametertype = Graph.createElement("outParameter-type") ;
671       if ( strlen( ServiceOutParameter()[i].Parametertype ) ) {
672         aField = Graph.createTextNode( strdup(ServiceOutParameter()[i].Parametertype) ) ;
673       }
674       else {
675         aField = Graph.createTextNode( "?" ) ;
676       }
677       outParameter.appendChild(outParametertype) ;
678       outParametertype.appendChild( aField ) ;
679       QDomElement outParametername = Graph.createElement("outParameter-name") ;
680       if ( strlen( ServiceOutParameter()[i].Parametername ) ) {
681         aField = Graph.createTextNode( strdup(ServiceOutParameter()[i].Parametername) ) ;
682       }
683       else {
684         aField = Graph.createTextNode( "?" ) ;
685       }
686       outParameter.appendChild(outParametername) ;
687       outParametername.appendChild( aField ) ;
688     }
689   }
690
691   QDomElement DataStreamlist = Graph.createElement("DataStream-list") ;
692   node.appendChild( DataStreamlist ) ;
693   for ( i = 0 ; i < ServiceInParameter().length() ; i++ ) {
694     const GraphBase::InPort * anInPort ;
695     anInPort = aNode->GetInPort( ServiceInParameter()[i].Parametername ) ;
696     if ( anInPort->IsDataStream() ) {
697       cdebug << "SaveXML " << ServiceInParameter()[i].Parametername
698              << " InDataStreamPort " << anInPort->Kind() << endl ;
699       QDomElement inParameter = Graph.createElement("inParameter") ;
700       DataStreamlist.appendChild(inParameter) ;
701       QDomElement inParametertype = Graph.createElement("inParameter-type") ;
702       if ( strlen( ServiceInParameter()[i].Parametertype ) ) {
703         aField = Graph.createTextNode( strdup( ServiceInParameter()[i].Parametertype ) ) ;
704       }
705       else {
706         aField = Graph.createTextNode( "?" ) ;
707       }
708       inParameter.appendChild(inParametertype) ;
709       inParametertype.appendChild( aField ) ;
710       QDomElement inParametername = Graph.createElement("inParameter-name") ;
711       if ( strlen( ServiceInParameter()[i].Parametername ) ) {
712         aField = Graph.createTextNode( strdup(ServiceInParameter()[i].Parametername) ) ;
713       }
714       else {
715         aField = Graph.createTextNode( "?" ) ;
716       }
717       inParameter.appendChild(inParametername) ;
718       inParametername.appendChild( aField ) ;
719     }
720   }
721   for ( i = 0 ; i < ServiceOutParameter().length() ; i++ ) {
722     const GraphBase::OutPort * anOutPort ;
723     anOutPort = aNode->GetOutPort( ServiceOutParameter()[i].Parametername ) ;
724     if ( anOutPort->IsDataStream() ) {
725       cdebug << "SaveXML " << ServiceOutParameter()[i].Parametername
726              << " OutDataStreamPort " << anOutPort->Kind() << endl ;
727       QDomElement outParameter = Graph.createElement("outParameter") ;
728       DataStreamlist.appendChild(outParameter) ;
729       QDomElement outParametertype = Graph.createElement("outParameter-type") ;
730       if ( strlen( ServiceOutParameter()[i].Parametertype ) ) {
731         aField = Graph.createTextNode( strdup(ServiceOutParameter()[i].Parametertype) ) ;
732       }
733       else {
734         aField = Graph.createTextNode( "?" ) ;
735       }
736       outParameter.appendChild(outParametertype) ;
737       outParametertype.appendChild( aField ) ;
738       QDomElement outParametername = Graph.createElement("outParameter-name") ;
739       if ( strlen( ServiceOutParameter()[i].Parametername ) ) {
740         aField = Graph.createTextNode( strdup(ServiceOutParameter()[i].Parametername) ) ;
741       }
742       else {
743         aField = Graph.createTextNode( "?" ) ;
744       }
745       outParameter.appendChild(outParametername) ;
746       outParametername.appendChild( aField ) ;
747     }
748   }
749 //  f << Tabs << "</Parameter-list>" << endl ;    
750
751 //  f << Tabs << "<PyFunction-list>" << endl ;
752   QDomElement PyFunctionlist = Graph.createElement("PyFunction-list") ;
753   node.appendChild( PyFunctionlist ) ;
754   for ( i = 0 ; i < PythonFunctions.size() ; i++ ) {
755 //    f << Tabs << "    <PyFunction>" << endl ;
756     QDomElement PyFunction = Graph.createElement("PyFunction") ;
757     PyFunctionlist.appendChild( PyFunction ) ;
758     int j ;
759     QDomElement FuncName = Graph.createElement("FuncName") ;
760     if ( strlen( FuncNames[i].c_str() ) ) {
761       aField = Graph.createTextNode( FuncNames[i].c_str() ) ;
762     }
763     else {
764       aField = Graph.createTextNode( "?" ) ;
765     }
766     PyFunction.appendChild( FuncName ) ;
767     FuncName.appendChild( aField ) ;
768     if ( (*PythonFunctions[i]).length() ) {
769       for ( j = 0 ; j < (int ) (*PythonFunctions[i]).length() ; j++ ) {
770         QDomElement PyFunc = Graph.createElement("PyFunc") ;
771         QDomCDATASection aCDATA ;
772       // mpv: Linux 8.0 compiler compatibility
773         char * aCDATAChar = strdup ((*PythonFunctions[i])[j]) ;
774         int i ;
775         for ( i = 0 ; i < (int ) strlen( aCDATAChar ) ; i++ ) {
776           if ( aCDATAChar[ i ] != ' ' ) {
777             break ;
778           }
779         }
780         if ( i == (int ) strlen( aCDATAChar ) ) {
781           aCDATA = Graph.createCDATASection( "?" ) ;
782         }
783         else {
784           aCDATA = Graph.createCDATASection( aCDATAChar ) ;
785         }
786         PyFunction.appendChild( PyFunc ) ;
787         PyFunc.appendChild( aCDATA ) ;
788       }
789     }
790     else {
791       QDomElement PyFunc = Graph.createElement("PyFunc") ;
792       QDomCDATASection aCDATA = Graph.createCDATASection( "?" ) ;
793       PyFunction.appendChild( PyFunc ) ;
794       PyFunc.appendChild( aCDATA ) ;
795     }
796   }
797
798 //  f << Tabs << "<creation-date>" << FirstCreation() << "</creation-date>"
799 //    << endl ;
800   QDomElement creationdate = Graph.createElement("creation-date") ;
801   char fdate[30] ;
802   sprintf( fdate , "%d/%d/%d - %d:%d:%d" ,  FirstCreation().Day , FirstCreation().Month , FirstCreation().Year , FirstCreation().Hour , FirstCreation().Minute , FirstCreation().Second ) ;
803   aField = Graph.createTextNode( fdate ) ;
804   node.appendChild( creationdate ) ;
805   creationdate.appendChild( aField ) ;
806 //  f << Tabs << "<lastmodification-date>" << LastModification()
807 //    << "</lastmodification-date>" << endl ;
808   QDomElement lastmodificationdate = Graph.createElement("lastmodification-date") ;
809   char ldate[30] ;
810   sprintf( ldate , "%d/%d/%d - %d:%d:%d" , LastModification().Day , LastModification().Month , LastModification().Year , LastModification().Hour , LastModification().Minute , LastModification().Second ) ;
811   aField = Graph.createTextNode( ldate ) ;
812   node.appendChild( lastmodificationdate ) ;
813   lastmodificationdate.appendChild( aField ) ;
814 //  f << Tabs << "<editor-release>" << EditorRelease() << "</editor-release>"
815 //    << endl ;
816   QDomElement editorrelease = Graph.createElement("editor-release") ;
817   aField = Graph.createTextNode( EditorRelease() ) ;
818   node.appendChild( editorrelease ) ;
819   editorrelease.appendChild( aField ) ;
820   QDomElement author = Graph.createElement("author") ;
821   if ( strlen( Author() ) ) {
822 //    f << Tabs << "<author>" << Author() << "</author>" << endl ;
823     aField = Graph.createTextNode( Author() ) ;
824   }
825   else {
826 //    f << Tabs << "<author>?</author>" << endl ;
827     aField = Graph.createTextNode( "?" ) ;
828   }
829   node.appendChild( author ) ;
830   author.appendChild( aField ) ;
831   QDomElement container = Graph.createElement("container") ;
832   if ( IsFactoryNode() && strlen( Computer) ) {
833 //    f << Tabs << "<container>" << Computer << "</container>" << endl ;
834     aField = Graph.createTextNode( Computer ) ;
835   }
836   else {
837 //    f << Tabs << "<container>?</container>" << endl ;
838     aField = Graph.createTextNode( "?" ) ;
839   }
840   node.appendChild( container ) ;
841   container.appendChild( aField ) ;
842   QDomElement comment = Graph.createElement("comment") ;
843   if ( strlen( Comment() ) ) {
844 //    f << Tabs << "<comment>" << Comment() << "</comment>" << endl ;
845     aField = Graph.createTextNode( Comment() ) ;
846   }
847   else {
848 //    f << Tabs << "<comment>?</comment>" << endl ;
849     aField = Graph.createTextNode( "?" ) ;
850   }
851   node.appendChild( comment ) ;
852   comment.appendChild( aField ) ;
853 //  f << Tabs << "<x-position>" << XCoordinate << "</x-position>" << endl ;
854   QDomElement xposition = Graph.createElement("x-position") ;
855   QString aXCoordinate ;
856   aXCoordinate = aKind.setNum( XCoordinate ) ;
857   aField = Graph.createTextNode( aXCoordinate ) ;
858   node.appendChild( xposition ) ;
859   xposition.appendChild( aField ) ;
860 //  f << Tabs << "<y-position>" << YCoordinate << "</y-position>" << endl ;
861   QDomElement yposition = Graph.createElement("y-position") ;
862   QString aYCoordinate ;
863   aYCoordinate = aKind.setNum( YCoordinate ) ;
864   aField = Graph.createTextNode( aYCoordinate ) ;
865   node.appendChild( yposition ) ;
866   yposition.appendChild( aField ) ;
867   cdebug_out << "SaveXML Node " << Name() << endl ;
868   return true ;
869 }
870
871 bool GraphBase::ComputingNode::SavePY( ostream &f , const char * aGraphName ,
872                                        const char * ComponentName ,
873                                        const char * InterfaceName ,
874                                        const char * Computer ,
875                                        const GraphBase::InLineNode * aCoupledNode ,
876                                        const ListOfFuncName FuncNames ,
877                                        const ListOfPythonFunctions PythonFunctions ,
878                                        int XCoordinate , int YCoordinate ) const {
879   if ( IsDataFlowNode() ) {
880     f << Name() << " = Graph( '" << Name() << "' )" << endl ;
881   }
882   else if ( IsComputingNode() ) {
883     int i ;
884     f << Name() << "_ServiceinParameter = []" << endl ;
885     for ( i = 0 ; i < (int ) ServiceInParameter().length() ; i++ ) {
886       f << Name() << "_ServiceinParameter.append( SALOME_ModuleCatalog.ServicesParameter( '"
887         << ServiceInParameter()[i].Parametertype << "' , '"
888         << ServiceInParameter()[i].Parametername << "' ) )" << endl ;
889     }
890     f << Name() << "_ServiceoutParameter = []" << endl ;
891     for ( i = 0 ; i < (int ) ServiceOutParameter().length() ; i++ ) {
892       f << Name() << "_ServiceoutParameter.append( SALOME_ModuleCatalog.ServicesParameter( '"
893         << ServiceOutParameter()[i].Parametertype << "' , '"
894         << ServiceOutParameter()[i].Parametername << "' ) )" << endl ;
895     }
896     f << Name() << "_Service = SALOME_ModuleCatalog.Service( '" << ServiceName()
897       << "' , " << Name() << "_ServiceinParameter" << " , "
898       << Name() << "_ServiceoutParameter" << " , 0 )" << endl ;
899     f << Name() << " = " << aGraphName << ".CNode( " << Name() << "_Service" << " )"
900       << endl ;
901   }
902   else if ( IsFactoryNode() ) {
903     f << Name() << " = " << aGraphName << ".FNode( '" << ComponentName
904       << "' , '" << InterfaceName << "' , '" << ServiceName() << "' )"
905       << endl ;
906   }
907   else {
908     f << "Py" << Name() << " = []" << endl ;
909     int i ;
910     SUPERV::ListOfStrings aPyFunc ;
911     if ( PythonFunctions.size() ) {
912       aPyFunc = *PythonFunctions[0] ;
913       for ( i = 0 ; i < (int ) aPyFunc.length() ; i++ ) {
914         f << "Py" << Name() << ".append( '" << aPyFunc[i] << "' )" << endl ;
915       }
916     }
917     if ( IsInLineNode() ) {
918       f << Name() << " = " << aGraphName << ".INode( '" << FuncNames[0].c_str() << "' , Py"
919         << Name() << " )" << endl ;
920     }
921     else if ( IsGOTONode() ) {
922       if ( aCoupledNode ) {
923         f << Name() << " = " << aGraphName << ".GNode( '" << FuncNames[0].c_str() << "' , Py"
924           << Name() << " , '" << aCoupledNode->Name() << "' )" << endl ;
925       }
926       else {
927         f << Name() << " = " << aGraphName << ".GNode( '" << FuncNames[0].c_str() << "' , Py"
928           << Name() << " , '' )" << endl ;
929       }
930     }
931     else {
932 //      char * EndName = NULL ;
933 //      EndName = new char[ 3 + strlen( Name() ) + 1 ] ;
934 //      strcpy( EndName , "End" ) ;
935 //      strcat( EndName , Name() ) ;
936       char * EndName = aCoupledNode->Name() ;
937       if ( IsLoopNode() ) {
938         SUPERV::ListOfStrings aPyMore = *PythonFunctions[1] ;
939         SUPERV::ListOfStrings aPyNext = *PythonFunctions[2] ;
940         f << "PyMore" << Name() << " = []" << endl ;
941         for ( i = 0 ; i < (int ) aPyMore.length() ; i++ ) {
942           f << "PyMore" << Name() << ".append( '" << aPyMore[i] << "' )" << endl ;
943         }
944         f << "PyNext" << Name() << " = []" << endl ;
945         for ( i = 0 ; i < (int ) aPyNext.length() ; i++ ) {
946           f << "PyNext" << Name() << ".append( '" << aPyNext[i] << "' )" << endl ;
947         }
948         f << Name() << "," << EndName << " = " << aGraphName << ".LNode( '"
949           << FuncNames[0].c_str() << "' , Py" << Name() << " , '"
950           << FuncNames[1].c_str() << "' , PyMore" << Name()
951           << " , '" << FuncNames[2].c_str() << "' , PyNext"
952           << Name() << " )" << endl ;
953         f << EndName << ".SetName( '" << aCoupledNode->Name() << "' )" << endl ;
954         f << EndName << ".SetAuthor( '" << aCoupledNode->Author() << "' )" << endl ;
955         f << EndName << ".SetComment( '" << aCoupledNode->Comment() << "' )" << endl ;
956         f << EndName << ".Coords( " << aCoupledNode->XCoordinate() << " , "
957           << aCoupledNode->YCoordinate() << " )" << endl ;
958         SUPERV::ListOfStrings aPyFunc = *aCoupledNode->PythonFunction() ;
959         f << "Py" << aCoupledNode->Name() << " = []" << endl ;
960         for ( i = 0 ; i < (int ) aPyFunc.length() ; i++ ) {
961           f << "Py" << aCoupledNode->Name() << ".append( '" << aPyFunc[i] << "' )"
962             << endl ;
963         }
964         f << EndName << ".SetPyFunction( 'End" << FuncNames[0].c_str() << "' , Py" << aCoupledNode->Name() << " )" << endl ;
965       }
966       else if ( IsSwitchNode() ) {
967         f << Name() << "," << EndName << " = " << aGraphName << ".SNode( '"
968           << FuncNames[0].c_str() << "' , Py" << Name() << " )" << endl ;
969         f << EndName << ".SetName( '" << aCoupledNode->Name() << "' )" << endl ;
970         f << EndName << ".SetAuthor( '" << aCoupledNode->Author() << "' )" << endl ;
971         f << EndName << ".SetComment( '" << aCoupledNode->Comment() << "' )" << endl ;
972         f << EndName << ".Coords( " << aCoupledNode->XCoordinate() << " , "
973           << aCoupledNode->YCoordinate() << " )" << endl ;
974         SUPERV::ListOfStrings aPyFunc = *aCoupledNode->PythonFunction() ;
975         f << "Py" << aCoupledNode->Name() << " = []" << endl ;
976         for ( i = 0 ; i < (int ) aPyFunc.length() ; i++ ) {
977           f << "Py" << aCoupledNode->Name() << ".append( '" << aPyFunc[i] << "' )"
978             << endl ;
979         }
980         f << EndName << ".SetPyFunction( 'End" << FuncNames[0].c_str() << "' , Py" << aCoupledNode->Name() << " )" << endl ;
981         for ( i = 0 ; i < aCoupledNode->GetNodeInPortsSize() ; i++ ) {
982           const GraphBase::InPort * anInPort = aCoupledNode->GetNodeInPort(i) ;
983           if ( anInPort->IsInLine() || anInPort->IsEndSwitch() ) {
984             f << EndName << ".InPort( '" << anInPort->PortName()
985               << "' , '" << anInPort->PortType() << "' )" << endl ;
986           }
987         }
988         for ( i = 0 ; i < aCoupledNode->GetNodeOutPortsSize() ; i++ ) {
989           const GraphBase::OutPort * anOutPort = aCoupledNode->GetNodeOutPort(i) ;
990           if ( anOutPort->IsInLine() ) {
991             f << EndName << ".OutPort( '" << anOutPort->PortName()
992               << "' , '" << anOutPort->PortType() << "' )" << endl ;
993           }
994         }
995       }
996       delete [] EndName ;
997     }
998   }
999
1000   f << Name() << ".SetName( '" << Name() << "' )" << endl ;
1001   f << Name() << ".SetAuthor( '" << Author() << "' )" << endl ;
1002   if ( IsFactoryNode() ) {
1003     f << Name() << ".SetContainer( '" << Computer << "' )" << endl ;
1004   }
1005   f << Name() << ".SetComment( '" << Comment() << "' )" << endl ;
1006   f << Name() << ".Coords( " << XCoordinate << " , " << YCoordinate << " )" << endl ;
1007
1008   if ( IsOneOfInLineNodes() ) {
1009     int i ;
1010     for ( i = 0 ; i < GetNodeInPortsSize() ; i++ ) {
1011       const GraphBase::InPort * anInPort = GetNodeInPort(i) ;
1012       if ( anInPort->IsInLine() ) {
1013         f << Name() << ".InPort( '" << anInPort->PortName() << "' , '"
1014           << anInPort->PortType() << "' )" << endl ;
1015       }
1016     }
1017 //    for ( i = 0 ; i < GetNodeOutPortsSize() ; i++ ) {
1018 //      const GraphBase::OutPort * anOutPort = GetNodeOutPort(i) ;
1019 //      if ( anOutPort->IsInLine() || anOutPort->IsSwitch() ) {
1020 //        f << Name() << ".OutPort( '" << anOutPort->PortName()
1021 //          << "' , '" << anOutPort->PortType() << "' )" << endl ;
1022 //      }
1023 //    }
1024   }
1025   if ( !IsDataFlowNode() ) {
1026     int i ;
1027     for ( i = 0 ; i < GetNodeInPortsSize() ; i++ ) {
1028       const GraphBase::InPort * anInPort = GetNodeInPort(i) ;
1029       if ( anInPort->IsDataStream() ) {
1030         f << Name() << ".InDataStreamPort( '" << anInPort->PortName() << "' , '"
1031           << anInPort->PortType() << "' )" << endl ;
1032       }
1033     }
1034     for ( i = 0 ; i < GetNodeOutPortsSize() ; i++ ) {
1035       const GraphBase::OutPort * anOutPort = GetNodeOutPort(i) ;
1036       if ( anOutPort->IsDataStream() ) {
1037         f << Name() << ".OutDataStreamPort( '" << anOutPort->PortName()
1038           << "' , '" << anOutPort->PortType() << "' )" << endl ;
1039       }
1040     }
1041   }
1042
1043 #if 0
1044   if ( IsLoopNode() || IsSwitchNode() ) {
1045     f << EndName << ".SetName( '" << CoupledNode
1046       << "' )" << endl ;
1047     f << EndName << ".SetAuthor( '" << CoupledNode->Author()
1048       << "' )" << endl ;
1049     f << EndName << ".SetComment( '" << CoupledNode->Comment()
1050       << "' )" << endl ;
1051     f << EndName << ".Coords( " << CoupledNode->XCoordinate() << " , "
1052       << CoupledNode->YCoordinate() << " )" << endl ;
1053     unsigned int i;
1054     for ( i = 0 ; i < GetNodeInPortsSize() ; i++ ) {
1055       const InPort * anInPort = GetNodeInPort( i ) ;
1056       if ( anInPort->IsBus() ) {
1057         const OutPort * anOutPort = GetNodeOutPort( anInPort->PortIndex() ) ;
1058         f << Name() << ".BusPorts( '" << anInPort->PortName() << "' , '"
1059           << anInPort->PortType() << "' , '" << anOutPort->PortName()
1060           << "' , '" << anOutPort->PortType() << "' )" << endl ;
1061       }
1062     }
1063   }
1064 #endif
1065   return true ;
1066 }
1067
1068 void GraphBase::ComputingNode::NodeInfo(ostream & s) const {
1069   s << *this ;
1070   ListPorts( s , true ) ;
1071   s << ends ;
1072 }
1073
1074 ostream & operator<< (ostream & f,const GraphBase::ComputingNode & G) {
1075 //  f << "ComponentName    " << G.ComponentName() << endl ;
1076   if ( G.IsComputingNode() )
1077     f << "NodeName         " << G.Name() << endl ;
1078   else
1079     f << "DataFlowName     " << G.Name() << endl ;
1080   f << "Kind             " << G.Kind() << endl ;
1081   f << "Service          " << *G.GetService() ;
1082   f << "FirstCreation    " << G.FirstCreation () << endl ;
1083   f << "LastModification " << G.LastModification() << endl ;
1084   f << "EditorRelease    " << G.EditorRelease() << endl ;
1085   f << "Author           " << G.Author() << endl ;
1086 //  f << "Computer         " << G.Computer() << endl ;
1087   f << "Comment          " << G.Comment() << endl ;
1088   f << endl ;
1089   
1090   return f;
1091 }
1092
1093 void GraphBase::ComputingNode::ListLinks(ostream &f ) const {
1094   int i ;
1095   for ( i = 0 ; i < GetNodeOutPortsSize() ; i++ ) {
1096     const GraphBase::OutPort* fromPort = GetNodeOutPort( i ) ;
1097     if ( fromPort->IsPortConnected() ) {
1098       int j ;
1099       for ( j = 0 ; j < fromPort->InPortsSize() ; j++ ) {
1100         if ( j == 0 )
1101           f << "FromNode " << Name() << endl ;
1102         f << "         FromServiceParameterName "
1103           << fromPort->GetServicesParameter().Parametername ;
1104         const GraphBase::InPort* toPort = fromPort->InPorts( j ) ;
1105         f << " ToNode " << toPort->NodeName() ;
1106         f << " ToServiceParameterName "
1107           << toPort->GetServicesParameter().Parametername;
1108         f << " Value " ;
1109         fromPort->StringValue( f ) ;
1110         f << endl ;
1111       }
1112     }
1113   }
1114 }
1115
1116 ostream & operator<< (ostream &fOut,const SUPERV::SDate &D) {
1117 //  cdebug_in << "operator<< GraphEditor::Date" << endl;
1118
1119   fOut  << D.Day << "/" 
1120         << D.Month << "/" 
1121         << D.Year << " - " 
1122         << D.Hour << ":" 
1123         << D.Minute <<  ":"  
1124         << D.Second;
1125
1126 //  cdebug_out << "operator<< GraphEditor::Date" << endl;
1127   return fOut;
1128 }
1129