]> SALOME platform Git repositories - modules/superv.git/blob - src/GraphBase/DataFlowBase_GOTONode.cxx
Salome HOME
Join modifications from BR_Dev_For_4_0 tag V4_1_1.
[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  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 //  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS 
5 // 
6 //  This library is free software; you can redistribute it and/or 
7 //  modify it under the terms of the GNU Lesser General Public 
8 //  License as published by the Free Software Foundation; either 
9 //  version 2.1 of the License. 
10 // 
11 //  This library is distributed in the hope that it will be useful, 
12 //  but WITHOUT ANY WARRANTY; without even the implied warranty of 
13 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU 
14 //  Lesser General Public License for more details. 
15 // 
16 //  You should have received a copy of the GNU Lesser General Public 
17 //  License along with this library; if not, write to the Free Software 
18 //  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA 
19 // 
20 //  See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 //
22 //  File   : DataFlowBase_GOTONode.cxx
23 //  Author : Jean Rahuel, CEA
24 //  Module : SUPERV
25
26 using namespace std;
27 //#include <sstream>
28 //#include <iostream>
29
30 #include "DataFlowBase_GOTONode.hxx"
31
32 GraphBase::GOTONode::GOTONode() :
33   GraphBase::InLineNode::InLineNode() {
34
35   CoupledNode( NULL ) ;
36   _CoupledNodeName = NULL ;
37   cdebug << "GraphBase::GOTONode::GOTONode "  << this 
38          << " _Name " << (void *) Name() << " " << Name() << " _Comment "
39          << (void *) Comment() << " "  << Comment() << " "  << endl ;
40
41 }
42
43 GraphBase::GOTONode::GOTONode( CORBA::ORB_ptr ORB ,
44                                SALOME_NamingService* ptrNamingService ,
45                                const char *DataFlowName ,
46                                const SUPERV::KindOfNode DataFlowkind ,
47                                int * Graph_prof_debug ,
48                                ofstream * Graph_fdebug ) :
49   GraphBase::InLineNode::InLineNode( ORB , ptrNamingService , DataFlowName , DataFlowkind , Graph_prof_debug , Graph_fdebug ) {
50
51   CoupledNode( NULL ) ;
52   _CoupledNodeName = NULL ;
53   cdebug << "GraphBase::GOTONode::GOTONode "  << this 
54          << " _Name " << (void *) Name() << " " << Name() << " _Comment "
55          << (void *) Comment() << " "  << Comment() << " "  << endl ;
56
57 }
58
59 GraphBase::GOTONode::GOTONode( CORBA::ORB_ptr ORB ,
60                                SALOME_NamingService* ptrNamingService ,
61                                const char *FuncName ,
62                                const SUPERV::ListOfStrings & aPythonFunction ,
63                                const char *NodeName ,
64                                const SUPERV::KindOfNode akind ,
65                                const SUPERV::SDate NodeFirstCreation ,
66                                const SUPERV::SDate NodeLastModification  ,
67                                const char * NodeEditorRelease ,
68                                const char * NodeAuthor ,
69                                const char * NodeComment ,
70                                const bool   GeneratedName ,
71                                const long   X ,
72                                const long   Y ,
73                                int * Graph_prof_debug ,
74                                ofstream * Graph_fdebug ) :
75   GraphBase::InLineNode::InLineNode( ORB , ptrNamingService , FuncName , aPythonFunction ,
76                                      NodeName , akind , NodeFirstCreation ,
77                                      NodeLastModification  , NodeEditorRelease ,
78                                      NodeAuthor , NodeComment , GeneratedName ,
79                                      X , Y , Graph_prof_debug , Graph_fdebug ) {
80
81   CoupledNode( NULL ) ;
82   _CoupledNodeName = NULL ;
83   cdebug_in << "GraphBase::GOTONode::GOTONode "  << this 
84             << "' _Name " << (void *) Name() << " '" << Name() << " _Comment "
85             << (void *) Comment() << " "  << Comment() << " " 
86             << " KindOfNode " << Kind() << " FuncName " << FuncName
87             << " ServiceName " << ServiceName() << " In("
88             << ServiceInParameter().length()
89             << ") Out(" << ServiceOutParameter().length() << ")" << endl ;
90
91   cdebug_out << "GraphBase::GOTONode::GOTONode" << endl;
92 }
93
94 GraphBase::GOTONode::~GOTONode() {
95   cdebug << "GraphBase::GOTONode::~GOTONode "  << this 
96          << " _Name " << (void *) Name() << " " << Name() << " _Comment "
97          << (void *) Comment() << " "  << Comment() << " "  << endl ;
98 //  if ( _ComponentName != NULLSTRING )
99 //    delete [] _ComponentName ;
100 //  delete [] _Name ;
101 //  delete [] _EditorRelease ;
102 //  if ( _Author != NULLSTRING )
103 //    delete [] _Author ;
104 //  if ( _Computer != FACTORYSERVER )
105 //    delete [] _Computer;
106 //  if ( _Comment != NULLSTRING )
107 //    delete [] _Comment;
108 }
109
110 #define CoupledNodeTrace 0
111 void GraphBase::GOTONode::CoupledNode( GraphBase::InLineNode * aCoupledNode ) {
112 #if CoupledNodeTrace
113   cdebug << this << " " << Name() << " GraphBase::GOTONode::CoupledNode( " ;
114 #endif
115   if ( aCoupledNode ) {
116     CoupledNodeName( aCoupledNode->Name() ) ;
117 #if CoupledNodeTrace
118     cdebug << aCoupledNode->Name() ;
119 #endif
120   }
121   else {
122 #if CoupledNodeTrace
123     cdebug << "NULL" ;
124 #endif
125   }
126 #if CoupledNodeTrace
127   cdebug << " )" << endl ;
128 #endif
129   _CoupledNode = aCoupledNode ;
130 }
131
132 const GraphBase::InLineNode * GraphBase::GOTONode::CoupledNode() const {
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 GraphBase::InLineNode * GraphBase::GOTONode::CoupledNode() {
147 #if CoupledNodeTrace
148   cdebug << this << " " << Name() << " GraphBase::GOTONode::CoupledNode() --> " ;
149   if ( _CoupledNode ) {
150     cdebug << _CoupledNode->Name() ;
151   }
152   else {
153     cdebug << "NULL" ;
154   }
155   cdebug << endl ;
156 #endif
157   return _CoupledNode ;
158 }
159
160 void GraphBase::GOTONode::CoupledNodeName( const char * aCoupledNodeName ) {
161   if ( _CoupledNodeName ) {
162     delete [] _CoupledNodeName ;
163   }
164   _CoupledNodeName = new char [ strlen( aCoupledNodeName ) + 1 ] ;
165   strcpy( _CoupledNodeName , aCoupledNodeName ) ;
166 #if CoupledNodeTrace
167   cdebug << this << " " << Name() << " GraphBase::GOTONode::CoupledNodeName() --> "
168          << (void * ) _CoupledNodeName << " = " << _CoupledNodeName << endl ;
169 #endif
170 }
171 char * GraphBase::GOTONode::CoupledNodeName() const {
172 #if CoupledNodeTrace
173   cdebug << this << " " << Name() << " GraphBase::GOTONode::CoupledNodeName() --> " ;
174   if ( _CoupledNodeName ) {
175     cdebug << (void * ) _CoupledNodeName << " = " << _CoupledNodeName << endl ;
176   }
177   else {
178     cdebug << "NULL" << endl ;
179   }
180 #endif
181 //JR 17.02.2005 Memory Leak  return my_strdup( _CoupledNodeName ) ;
182   return _CoupledNodeName ;
183 }
184
185 //bool GraphBase::GOTONode::SaveXML( ostream &f , char *Tabs ,
186 bool GraphBase::GOTONode::SaveXML( QDomDocument & Graph , QDomElement & info ,
187                                    int XCoordinate , int YCoordinate ) const {
188   GraphBase::ListOfFuncName aFuncNames ; 
189   GraphBase::ListOfPythonFunctions aPythonFunction ;
190   if ( PyFuncName() ) {
191     aFuncNames.resize( 1 ) ;
192 //JR 24.02.2005 Memory Leak    aFuncNames[0] = CORBA::string_dup( PyFuncName() ) ;
193     aFuncNames[0] = string( PyFuncName() ) ;
194     aPythonFunction.resize( 1 ) ;
195     aPythonFunction[0] = PythonFunction() ;
196   }
197   char * CoupledName = "" ;
198   if ( CoupledNode() ) {
199     CoupledName = CoupledNode()->Name() ;
200   }
201 //  return GraphBase::ComputingNode::SaveXML( f , Tabs , "" , "" , "" ,
202   return GraphBase::ComputingNode::SaveXML( Graph , info , "" , "" , "" ,
203                                             CoupledName ,
204                                             aFuncNames , aPythonFunction ,
205                                             XCoordinate , YCoordinate ) ;
206 }
207
208 bool GraphBase::GOTONode::SavePY( ostream &f , const char * aGraphName ,
209                                   int XCoordinate , int YCoordinate ) const {
210   GraphBase::ListOfFuncName aFuncNames ; 
211   GraphBase::ListOfPythonFunctions aPythonFunction ;
212   if ( PyFuncName() ) {
213     aFuncNames.resize( 1 ) ;
214 //JR 24.02.2005 Memory Leak    aFuncNames[0] = CORBA::string_dup( PyFuncName() ) ;
215     aFuncNames[0] = string( PyFuncName() ) ;
216     aPythonFunction.resize( 1 ) ;
217     aPythonFunction[0] = PythonFunction() ;
218   }
219   return GraphBase::ComputingNode::SavePY( f , aGraphName , "" , "" , "" ,
220                                            CoupledNode() ,
221                                            aFuncNames , aPythonFunction ,
222                                            XCoordinate , YCoordinate ) ;
223 }
224