1 // SUPERV GraphBase : contains fondamental classes for Services, Input Ports, Output Ports Links and Nodes.
3 // Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
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.
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.
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
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
22 // File : DataFlowBase_InLineNode.cxx
23 // Author : Jean Rahuel, CEA
30 #include "DataFlowBase_InLineNode.hxx"
32 GraphBase::InLineNode::InLineNode() :
33 GraphBase::ComputingNode::ComputingNode() {
35 _PythonFunction = SUPERV::ListOfStrings() ;
36 _MyPyRunMethod = NULL ;
39 GraphBase::InLineNode::InLineNode( CORBA::ORB_ptr ORB ,
40 SALOME_NamingService* ptrNamingService ,
41 const char * aDataFlowName ,
42 const SUPERV::KindOfNode DataFlowkind ,
43 int * Graph_prof_debug ,
44 ofstream * Graph_fdebug ) :
45 GraphBase::ComputingNode::ComputingNode( ORB , ptrNamingService , aDataFlowName , DataFlowkind ,
46 Graph_prof_debug , Graph_fdebug ) {
48 _PythonFunction = SUPERV::ListOfStrings() ;
49 _MyPyRunMethod = NULL ;
50 cdebug << "GraphBase::InLineNode::Node " << this
52 << (void *) Name() << " '" << Name() << " _Comment "
53 << (void *) Comment() << " " << Comment() << endl ;
56 GraphBase::InLineNode::InLineNode( CORBA::ORB_ptr ORB ,
57 SALOME_NamingService* ptrNamingService ,
58 const SALOME_ModuleCatalog::Service& NodeService ,
59 const char *NodeName ,
60 const SUPERV::KindOfNode akind ,
61 const SUPERV::SDate NodeFirstCreation ,
62 const SUPERV::SDate NodeLastModification ,
63 const char * NodeEditorRelease ,
64 const char * NodeAuthor ,
65 const char * NodeComment ,
66 const bool GeneratedName ,
69 int * Graph_prof_debug ,
70 ofstream * Graph_fdebug ) :
71 GraphBase::ComputingNode::ComputingNode( ORB , ptrNamingService ,
73 NodeName , akind , NodeFirstCreation ,
74 NodeLastModification ,
76 NodeAuthor , NodeComment , GeneratedName ,
78 Graph_prof_debug , Graph_fdebug ) {
80 _PythonFunction = SUPERV::ListOfStrings() ;
81 _MyPyRunMethod = NULL ;
82 cdebug_in << "GraphBase::InLineNode::Node " << this
84 << (void *) Name() << " '" << Name() << " _Comment "
85 << (void *) Comment() << " " << Comment() << " "
86 << " KindOfNode " << Kind()
87 << " ServiceName " << ServiceName() << " In("
88 << ServiceInParameter().length()
89 << ") Out(" << ServiceOutParameter().length() << ")" << endl ;
91 cdebug_out << "GraphBase::InLineNode::Node" << endl;
94 GraphBase::InLineNode::InLineNode( CORBA::ORB_ptr ORB ,
95 SALOME_NamingService* ptrNamingService ,
96 const char * FuncName ,
97 const SUPERV::ListOfStrings & aPythonFunction ,
98 const char *NodeName ,
99 const SUPERV::KindOfNode akind ,
100 const SUPERV::SDate NodeFirstCreation ,
101 const SUPERV::SDate NodeLastModification ,
102 const char * NodeEditorRelease ,
103 const char * NodeAuthor ,
104 const char * NodeComment ,
105 const bool GeneratedName ,
108 int * Graph_prof_debug ,
109 ofstream * Graph_fdebug ) :
110 GraphBase::ComputingNode::ComputingNode( ORB , ptrNamingService ,
111 SALOME_ModuleCatalog::Service() ,
112 NodeName , akind , NodeFirstCreation ,
113 NodeLastModification , NodeEditorRelease ,
114 NodeAuthor , NodeComment , GeneratedName ,
116 Graph_prof_debug , Graph_fdebug ) {
118 cdebug_in << "GraphBase::InLineNode::Node " << this
120 << (void *) Name() << " '" << Name() << " _Comment "
121 << (void *) Comment() << " " << Comment() << " "
122 << " KindOfNode " << Kind() << " FuncName " << FuncName
123 << " ServiceName " << ServiceName() << " In("
124 << ServiceInParameter().length()
125 << ") Out(" << ServiceOutParameter().length() << ")" << endl ;
128 SetPythonFunction( FuncName , aPythonFunction ) ;
129 _MyPyRunMethod = NULL ;
130 SALOME_ModuleCatalog::Service aNodeService ;
131 aNodeService.ServiceName = NodeName ;
133 SetService( aNodeService ) ;
134 cdebug_out << "GraphBase::InLineNode::Node" << endl;
137 GraphBase::InLineNode::~InLineNode() {
138 cdebug << "GraphBase::InLineNode::~Node " << this
140 << (void *) Name() << " " << Name() << " _Comment "
141 << (void *) Comment() << " " << Comment() << " " << endl ;
142 // if ( _ComponentName != NULLSTRING )
143 // delete [] _ComponentName ;
145 // delete [] _EditorRelease ;
146 // if ( _Author != NULLSTRING )
147 // delete [] _Author ;
148 // if ( _Computer != FACTORYSERVER )
149 // delete [] _Computer;
150 // if ( _Comment != NULLSTRING )
151 // delete [] _Comment;
154 void GraphBase::InLineNode::SetPythonFunction( const char * FuncName ,
155 const SUPERV::ListOfStrings & aPythonFunction ) {
157 cdebug << "GraphBase::InLineNode::PythonFunction length " << aPythonFunction.length() ;
158 if ( aPythonFunction.length() == 1 ) {
159 cdebug << " aPythonFunction[ 0 ] '" << aPythonFunction[ 0 ] << "'" ;
161 cdebug << " FuncName " << FuncName << endl ;
162 _FuncName = my_strblkdup( FuncName ) ;
163 cdebug << "GraphBase::InLineNode::SetPythonFunction FuncName '" << FuncName << "' --> '"
164 << _FuncName << "'" << endl ;
165 if ( ( aPythonFunction.length() == 0 ) ||
166 ( aPythonFunction.length() == 1 && strlen( aPythonFunction[ 0 ] ) == 0 ) ) {
167 _PythonFunction.length( 0 ) ;
170 _PythonFunction.length( aPythonFunction.length() ) ;
171 for ( i = 0 ; i < (int ) aPythonFunction.length() ; i++ ) {
172 cdebug << aPythonFunction[ i ] << endl ;
173 _PythonFunction[ i ] = CORBA::string_dup( aPythonFunction[ i ] ) ;
178 //bool GraphBase::InLineNode::SaveXML( ostream &f , char *Tabs ,
179 bool GraphBase::InLineNode::SaveXML( QDomDocument & Graph , QDomElement & info ,
180 int XCoordinate , int YCoordinate ) const {
181 GraphBase::ListOfFuncName aFuncNames ;
182 GraphBase::ListOfPythonFunctions aPythonFunction ;
183 if ( PyFuncName() ) {
184 aFuncNames.resize( 1 ) ;
185 //JR 24.02.2005 Memory Leak aFuncNames[0] = CORBA::string_dup( PyFuncName() ) ;
186 aFuncNames[0] = string( PyFuncName() ) ;
187 aPythonFunction.resize( 1 ) ;
188 aPythonFunction[0] = PythonFunction() ;
190 // return GraphBase::ComputingNode::SaveXML( f , Tabs , "" , "" , "" , "" ,
191 return GraphBase::ComputingNode::SaveXML( Graph , info , "" , "" , "" , "" ,
192 aFuncNames , aPythonFunction ,
193 XCoordinate , YCoordinate ) ;
196 bool GraphBase::InLineNode::SavePY(ostream &f , const char * aGraphName ,
197 int XCoordinate , int YCoordinate ) const {
198 GraphBase::ListOfFuncName aFuncNames ;
199 GraphBase::ListOfPythonFunctions aPythonFunction ;
200 if ( PyFuncName() ) {
201 aFuncNames.resize( 1 ) ;
202 //JR 24.02.2005 Memory Leak aFuncNames[0] = CORBA::string_dup( PyFuncName() ) ;
203 aFuncNames[0] = string( PyFuncName() ) ;
204 aPythonFunction.resize( 1 ) ;
205 aPythonFunction[0] = PythonFunction() ;
207 return GraphBase::ComputingNode::SavePY( f , aGraphName , "" , "" , "" , NULL ,
208 aFuncNames , aPythonFunction ,
209 XCoordinate , YCoordinate ) ;