Salome HOME
Fix for bug IPAL9558 : Maintainance Mandrake porting: black rectangle in table view.
[modules/superv.git] / src / GraphBase / DataFlowBase_GOTONode.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_GOTONode.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_GOTONode.hxx"
17
18 GraphBase::GOTONode::GOTONode() :
19   GraphBase::InLineNode::InLineNode() {
20
21   CoupledNode( NULL ) ;
22   _CoupledNodeName = NULL ;
23   cdebug << "GraphBase::GOTONode::GOTONode "  << this 
24          << " _Name " << (void *) Name() << " " << Name() << " _Comment "
25          << (void *) Comment() << " "  << Comment() << " "  << endl ;
26
27 }
28
29 GraphBase::GOTONode::GOTONode( CORBA::ORB_ptr ORB ,
30                                SALOME_NamingService* ptrNamingService ,
31                                const char *DataFlowName ,
32                                const SUPERV::KindOfNode DataFlowkind ,
33                                int * Graph_prof_debug ,
34                                ofstream * Graph_fdebug ) :
35   GraphBase::InLineNode::InLineNode( ORB , ptrNamingService , DataFlowName , DataFlowkind , Graph_prof_debug , Graph_fdebug ) {
36
37   CoupledNode( NULL ) ;
38   _CoupledNodeName = NULL ;
39   cdebug << "GraphBase::GOTONode::GOTONode "  << this 
40          << " _Name " << (void *) Name() << " " << Name() << " _Comment "
41          << (void *) Comment() << " "  << Comment() << " "  << endl ;
42
43 }
44
45 GraphBase::GOTONode::GOTONode( CORBA::ORB_ptr ORB ,
46                                SALOME_NamingService* ptrNamingService ,
47                                const char *FuncName ,
48                                const SUPERV::ListOfStrings & aPythonFunction ,
49                                const char *NodeName ,
50                                const SUPERV::KindOfNode akind ,
51                                const SUPERV::SDate NodeFirstCreation ,
52                                const SUPERV::SDate NodeLastModification  ,
53                                const char * NodeEditorRelease ,
54                                const char * NodeAuthor ,
55                                const char * NodeComment ,
56                                const bool   GeneratedName ,
57                                const long   X ,
58                                const long   Y ,
59                                int * Graph_prof_debug ,
60                                ofstream * Graph_fdebug ) :
61   GraphBase::InLineNode::InLineNode( ORB , ptrNamingService , FuncName , aPythonFunction ,
62                                      NodeName , akind , NodeFirstCreation ,
63                                      NodeLastModification  , NodeEditorRelease ,
64                                      NodeAuthor , NodeComment , GeneratedName ,
65                                      X , Y , Graph_prof_debug , Graph_fdebug ) {
66
67   CoupledNode( NULL ) ;
68   _CoupledNodeName = NULL ;
69   cdebug_in << "GraphBase::GOTONode::GOTONode "  << this 
70             << "' _Name " << (void *) Name() << " '" << Name() << " _Comment "
71             << (void *) Comment() << " "  << Comment() << " " 
72             << " KindOfNode " << Kind() << " FuncName " << FuncName
73             << " ServiceName " << ServiceName() << " In("
74             << ServiceInParameter().length()
75             << ") Out(" << ServiceOutParameter().length() << ")" << endl ;
76
77   cdebug_out << "GraphBase::GOTONode::GOTONode" << endl;
78 }
79
80 GraphBase::GOTONode::~GOTONode() {
81   cdebug << "GraphBase::GOTONode::~GOTONode "  << this 
82          << " _Name " << (void *) Name() << " " << Name() << " _Comment "
83          << (void *) Comment() << " "  << Comment() << " "  << endl ;
84 //  if ( _ComponentName != NULLSTRING )
85 //    delete [] _ComponentName ;
86 //  delete [] _Name ;
87 //  delete [] _EditorRelease ;
88 //  if ( _Author != NULLSTRING )
89 //    delete [] _Author ;
90 //  if ( _Computer != FACTORYSERVER )
91 //    delete [] _Computer;
92 //  if ( _Comment != NULLSTRING )
93 //    delete [] _Comment;
94 }
95
96 #define CoupledNodeTrace 0
97 void GraphBase::GOTONode::CoupledNode( GraphBase::InLineNode * aCoupledNode ) {
98 #if CoupledNodeTrace
99   cdebug << this << " " << Name() << " GraphBase::GOTONode::CoupledNode( " ;
100 #endif
101   if ( aCoupledNode ) {
102     CoupledNodeName( aCoupledNode->Name() ) ;
103 #if CoupledNodeTrace
104     cdebug << aCoupledNode->Name() ;
105 #endif
106   }
107   else {
108 #if CoupledNodeTrace
109     cdebug << "NULL" ;
110 #endif
111   }
112 #if CoupledNodeTrace
113   cdebug << " )" << endl ;
114 #endif
115   _CoupledNode = aCoupledNode ;
116 }
117
118 const GraphBase::InLineNode * GraphBase::GOTONode::CoupledNode() const {
119 #if CoupledNodeTrace
120   cdebug << this << " " << Name() << " GraphBase::GOTONode::CoupledNode() --> " ;
121   if ( _CoupledNode ) {
122     cdebug << _CoupledNode->Name() ;
123   }
124   else {
125     cdebug << "NULL" ;
126   }
127   cdebug << endl ;
128 #endif
129   return _CoupledNode ;
130 }
131
132 GraphBase::InLineNode * GraphBase::GOTONode::CoupledNode() {
133 #if CoupledNodeTrace
134   cdebug << this << " " << Name() << " GraphBase::GOTONode::CoupledNode() --> " ;
135   if ( _CoupledNode ) {
136     cdebug << _CoupledNode->Name() ;
137   }
138   else {
139     cdebug << "NULL" ;
140   }
141   cdebug << endl ;
142 #endif
143   return _CoupledNode ;
144 }
145
146 void GraphBase::GOTONode::CoupledNodeName( const char * aCoupledNodeName ) {
147   if ( _CoupledNodeName ) {
148     delete [] _CoupledNodeName ;
149   }
150   _CoupledNodeName = new char [ strlen( aCoupledNodeName ) + 1 ] ;
151   strcpy( _CoupledNodeName , aCoupledNodeName ) ;
152 #if CoupledNodeTrace
153   cdebug << this << " " << Name() << " GraphBase::GOTONode::CoupledNodeName() --> "
154          << (void * ) _CoupledNodeName << " = " << _CoupledNodeName << endl ;
155 #endif
156 }
157 char * GraphBase::GOTONode::CoupledNodeName() const {
158 #if CoupledNodeTrace
159   cdebug << this << " " << Name() << " GraphBase::GOTONode::CoupledNodeName() --> " ;
160   if ( _CoupledNodeName ) {
161     cdebug << (void * ) _CoupledNodeName << " = " << _CoupledNodeName << endl ;
162   }
163   else {
164     cdebug << "NULL" << endl ;
165   }
166 #endif
167 //JR 17.02.2005 Memory Leak  return my_strdup( _CoupledNodeName ) ;
168   return _CoupledNodeName ;
169 }
170
171 //bool GraphBase::GOTONode::SaveXML( ostream &f , char *Tabs ,
172 bool GraphBase::GOTONode::SaveXML( QDomDocument & Graph , QDomElement & info ,
173                                    int XCoordinate , int YCoordinate ) const {
174   GraphBase::ListOfFuncName aFuncNames ; 
175   GraphBase::ListOfPythonFunctions aPythonFunction ;
176   if ( PyFuncName() ) {
177     aFuncNames.resize( 1 ) ;
178 //JR 24.02.2005 Memory Leak    aFuncNames[0] = CORBA::string_dup( PyFuncName() ) ;
179     aFuncNames[0] = string( PyFuncName() ) ;
180     aPythonFunction.resize( 1 ) ;
181     aPythonFunction[0] = PythonFunction() ;
182   }
183   char * CoupledName = "" ;
184   if ( CoupledNode() ) {
185     CoupledName = CoupledNode()->Name() ;
186   }
187 //  return GraphBase::ComputingNode::SaveXML( f , Tabs , "" , "" , "" ,
188   return GraphBase::ComputingNode::SaveXML( Graph , info , "" , "" , "" ,
189                                             CoupledName ,
190                                             aFuncNames , aPythonFunction ,
191                                             XCoordinate , YCoordinate ) ;
192 }
193
194 bool GraphBase::GOTONode::SavePY( ostream &f , const char * aGraphName ,
195                                   int XCoordinate , int YCoordinate ) const {
196   GraphBase::ListOfFuncName aFuncNames ; 
197   GraphBase::ListOfPythonFunctions aPythonFunction ;
198   if ( PyFuncName() ) {
199     aFuncNames.resize( 1 ) ;
200 //JR 24.02.2005 Memory Leak    aFuncNames[0] = CORBA::string_dup( PyFuncName() ) ;
201     aFuncNames[0] = string( PyFuncName() ) ;
202     aPythonFunction.resize( 1 ) ;
203     aPythonFunction[0] = PythonFunction() ;
204   }
205   return GraphBase::ComputingNode::SavePY( f , aGraphName , "" , "" , "" ,
206                                            CoupledNode() ,
207                                            aFuncNames , aPythonFunction ,
208                                            XCoordinate , YCoordinate ) ;
209 }
210