]> SALOME platform Git repositories - modules/superv.git/blob - src/GraphBase/DataFlowBase_InLineNode.cxx
Salome HOME
Join modifications from BR_Dev_For_4_0 tag V4_1_1.
[modules/superv.git] / src / GraphBase / DataFlowBase_InLineNode.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_InLineNode.cxx
23 //  Author : Jean Rahuel, CEA
24 //  Module : SUPERV
25
26 using namespace std;
27 //#include <sstream>
28 //#include <iostream>
29
30 #include "DataFlowBase_InLineNode.hxx"
31
32 GraphBase::InLineNode::InLineNode() :
33   GraphBase::ComputingNode::ComputingNode() {
34   _FuncName = NULL ;
35   _PythonFunction = SUPERV::ListOfStrings() ;
36   _MyPyRunMethod = NULL ;
37 }
38
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 ) {
47   _FuncName = NULL ;
48   _PythonFunction = SUPERV::ListOfStrings() ;
49   _MyPyRunMethod = NULL ;
50   cdebug << "GraphBase::InLineNode::Node "  << this 
51          << "' _Name "
52          << (void *) Name() << " '" << Name() << " _Comment "
53          << (void *) Comment() << " "  << Comment() << endl ;
54 }
55
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 ,
67                                    const long   X ,
68                                    const long   Y ,
69                                    int * Graph_prof_debug ,
70                                    ofstream * Graph_fdebug ) :
71   GraphBase::ComputingNode::ComputingNode( ORB , ptrNamingService ,
72                                            NodeService ,
73                                            NodeName , akind , NodeFirstCreation ,
74                                            NodeLastModification  ,
75                                            NodeEditorRelease ,
76                                            NodeAuthor , NodeComment , GeneratedName ,
77                                            X , Y ,
78                                            Graph_prof_debug , Graph_fdebug ) {
79   _FuncName = NULL ;
80   _PythonFunction = SUPERV::ListOfStrings() ;
81   _MyPyRunMethod = NULL ;
82   cdebug_in << "GraphBase::InLineNode::Node "  << this 
83             << "' _Name "
84             << (void *) Name() << " '" << Name() << " _Comment "
85             << (void *) Comment() << " "  << Comment() << " " 
86             << " KindOfNode " << Kind()
87             << " ServiceName " << ServiceName() << " In("
88             << ServiceInParameter().length()
89             << ") Out(" << ServiceOutParameter().length() << ")" << endl ;
90
91   cdebug_out << "GraphBase::InLineNode::Node" << endl;
92 }
93
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 ,
106                                    const long   X ,
107                                    const long   Y ,
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 ,
115                                            X , Y ,
116                                            Graph_prof_debug , Graph_fdebug ) {
117
118   cdebug_in << "GraphBase::InLineNode::Node "  << this 
119             << "' _Name "
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 ;
126
127   _FuncName = NULL ;
128   SetPythonFunction( FuncName , aPythonFunction ) ;
129   _MyPyRunMethod = NULL ;
130   SALOME_ModuleCatalog::Service aNodeService ;
131   aNodeService.ServiceName = NodeName ;
132 // python -> service
133   SetService( aNodeService ) ;
134   cdebug_out << "GraphBase::InLineNode::Node" << endl;
135 }
136
137 GraphBase::InLineNode::~InLineNode() {
138   cdebug << "GraphBase::InLineNode::~Node "  << this 
139          << " _Name "
140          << (void *) Name() << " " << Name() << " _Comment "
141          << (void *) Comment() << " "  << Comment() << " "  << endl ;
142 //  if ( _ComponentName != NULLSTRING )
143 //    delete [] _ComponentName ;
144 //  delete [] _Name ;
145 //  delete [] _EditorRelease ;
146 //  if ( _Author != NULLSTRING )
147 //    delete [] _Author ;
148 //  if ( _Computer != FACTORYSERVER )
149 //    delete [] _Computer;
150 //  if ( _Comment != NULLSTRING )
151 //    delete [] _Comment;
152 }
153
154 void GraphBase::InLineNode::SetPythonFunction( const char * FuncName ,
155                                                const SUPERV::ListOfStrings & aPythonFunction ) {
156   int i ;
157   cdebug << "GraphBase::InLineNode::PythonFunction length " << aPythonFunction.length() ;
158   if ( aPythonFunction.length() == 1 ) {
159     cdebug << " aPythonFunction[ 0 ] '" << aPythonFunction[ 0 ] << "'" ;
160   }
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 ) ;
168   }
169   else {
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 ] ) ;
174     }
175   }
176 }
177
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() ;
189   }
190 //  return GraphBase::ComputingNode::SaveXML( f , Tabs , "" , "" , "" , "" ,
191   return GraphBase::ComputingNode::SaveXML( Graph , info , "" , "" , "" , "" ,
192                                             aFuncNames , aPythonFunction ,
193                                             XCoordinate , YCoordinate ) ;
194 }
195
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() ;
206   }
207   return GraphBase::ComputingNode::SavePY( f , aGraphName , "" , "" , "" , NULL ,
208                                            aFuncNames , aPythonFunction ,
209                                            XCoordinate , YCoordinate ) ;
210 }