Salome HOME
SMH: 3.0.0 preparation = merged version (POLYWORK + RTVDEBUG01) + adopation for new GUI
[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  CEA/DEN, EDF R&D
4 //
5 //
6 //
7 //  File   : DataFlowBase_InLineNode.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
18 GraphBase::InLineNode::InLineNode() :
19   GraphBase::ComputingNode::ComputingNode() {
20   _FuncName = NULL ;
21   _PythonFunction = SUPERV::ListOfStrings() ;
22   _MyPyRunMethod = NULL ;
23 }
24
25 GraphBase::InLineNode::InLineNode( CORBA::ORB_ptr ORB ,
26                                    SALOME_NamingService* ptrNamingService ,
27                                    const char * aDataFlowName ,
28                                    const SUPERV::KindOfNode DataFlowkind ,
29                                    int * Graph_prof_debug ,
30                                    ofstream * Graph_fdebug ) :
31   GraphBase::ComputingNode::ComputingNode( ORB , ptrNamingService , aDataFlowName , DataFlowkind ,
32                                            Graph_prof_debug , Graph_fdebug ) {
33   _FuncName = NULL ;
34   _PythonFunction = SUPERV::ListOfStrings() ;
35   _MyPyRunMethod = NULL ;
36   cdebug << "GraphBase::InLineNode::Node "  << this 
37          << "' _Name "
38          << (void *) Name() << " '" << Name() << " _Comment "
39          << (void *) Comment() << " "  << Comment() << endl ;
40 }
41
42 GraphBase::InLineNode::InLineNode( CORBA::ORB_ptr ORB ,
43                                    SALOME_NamingService* ptrNamingService ,
44                                    const SALOME_ModuleCatalog::Service& NodeService ,
45                                    const char *NodeName ,
46                                    const SUPERV::KindOfNode akind ,
47                                    const SUPERV::SDate NodeFirstCreation ,
48                                    const SUPERV::SDate NodeLastModification  ,
49                                    const char * NodeEditorRelease ,
50                                    const char * NodeAuthor ,
51                                    const char * NodeComment ,
52                                    const bool   GeneratedName ,
53                                    const long   X ,
54                                    const long   Y ,
55                                    int * Graph_prof_debug ,
56                                    ofstream * Graph_fdebug ) :
57   GraphBase::ComputingNode::ComputingNode( ORB , ptrNamingService ,
58                                            NodeService ,
59                                            NodeName , akind , NodeFirstCreation ,
60                                            NodeLastModification  ,
61                                            NodeEditorRelease ,
62                                            NodeAuthor , NodeComment , GeneratedName ,
63                                            X , Y ,
64                                            Graph_prof_debug , Graph_fdebug ) {
65   _FuncName = NULL ;
66   _PythonFunction = SUPERV::ListOfStrings() ;
67   _MyPyRunMethod = NULL ;
68   cdebug_in << "GraphBase::InLineNode::Node "  << this 
69             << "' _Name "
70             << (void *) Name() << " '" << Name() << " _Comment "
71             << (void *) Comment() << " "  << Comment() << " " 
72             << " KindOfNode " << Kind()
73             << " ServiceName " << ServiceName() << " In("
74             << ServiceInParameter().length()
75             << ") Out(" << ServiceOutParameter().length() << ")" << endl ;
76
77   cdebug_out << "GraphBase::InLineNode::Node" << endl;
78 }
79
80 GraphBase::InLineNode::InLineNode( CORBA::ORB_ptr ORB ,
81                                    SALOME_NamingService* ptrNamingService ,
82                                    const char * FuncName ,
83                                    const SUPERV::ListOfStrings & aPythonFunction ,
84                                    const char *NodeName ,
85                                    const SUPERV::KindOfNode akind ,
86                                    const SUPERV::SDate NodeFirstCreation ,
87                                    const SUPERV::SDate NodeLastModification  ,
88                                    const char * NodeEditorRelease ,
89                                    const char * NodeAuthor ,
90                                    const char * NodeComment ,
91                                    const bool   GeneratedName ,
92                                    const long   X ,
93                                    const long   Y ,
94                                    int * Graph_prof_debug ,
95                                    ofstream * Graph_fdebug ) :
96   GraphBase::ComputingNode::ComputingNode( ORB , ptrNamingService ,
97                                            SALOME_ModuleCatalog::Service() ,
98                                            NodeName , akind , NodeFirstCreation ,
99                                            NodeLastModification  , NodeEditorRelease ,
100                                            NodeAuthor , NodeComment , GeneratedName ,
101                                            X , Y ,
102                                            Graph_prof_debug , Graph_fdebug ) {
103
104   cdebug_in << "GraphBase::InLineNode::Node "  << this 
105             << "' _Name "
106             << (void *) Name() << " '" << Name() << " _Comment "
107             << (void *) Comment() << " "  << Comment() << " " 
108             << " KindOfNode " << Kind() << " FuncName " << FuncName
109             << " ServiceName " << ServiceName() << " In("
110             << ServiceInParameter().length()
111             << ") Out(" << ServiceOutParameter().length() << ")" << endl ;
112
113   _FuncName = NULL ;
114   SetPythonFunction( FuncName , aPythonFunction ) ;
115   _MyPyRunMethod = NULL ;
116   SALOME_ModuleCatalog::Service aNodeService ;
117   aNodeService.ServiceName = NodeName ;
118 // python -> service
119   SetService( aNodeService ) ;
120   cdebug_out << "GraphBase::InLineNode::Node" << endl;
121 }
122
123 GraphBase::InLineNode::~InLineNode() {
124   cdebug << "GraphBase::InLineNode::~Node "  << this 
125          << " _Name "
126          << (void *) Name() << " " << Name() << " _Comment "
127          << (void *) Comment() << " "  << Comment() << " "  << endl ;
128 //  if ( _ComponentName != NULLSTRING )
129 //    delete [] _ComponentName ;
130 //  delete [] _Name ;
131 //  delete [] _EditorRelease ;
132 //  if ( _Author != NULLSTRING )
133 //    delete [] _Author ;
134 //  if ( _Computer != FACTORYSERVER )
135 //    delete [] _Computer;
136 //  if ( _Comment != NULLSTRING )
137 //    delete [] _Comment;
138 }
139
140 void GraphBase::InLineNode::SetPythonFunction( const char * FuncName ,
141                                                const SUPERV::ListOfStrings & aPythonFunction ) {
142   int i ;
143   cdebug << "GraphBase::InLineNode::PythonFunction length " << aPythonFunction.length() ;
144   if ( aPythonFunction.length() == 1 ) {
145     cdebug << " aPythonFunction[ 0 ] '" << aPythonFunction[ 0 ] << "'" ;
146   }
147   cdebug << " FuncName " << FuncName << endl ;
148   _FuncName = my_strblkdup( FuncName ) ;
149   cdebug << "GraphBase::InLineNode::SetPythonFunction FuncName '" << FuncName << "' --> '"
150          << _FuncName << "'" << endl ;
151   if ( ( aPythonFunction.length() == 0 ) ||
152          ( aPythonFunction.length() == 1 && strlen( aPythonFunction[ 0 ] ) == 0 ) ) {
153     _PythonFunction.length( 0 ) ;
154   }
155   else {
156     _PythonFunction.length( aPythonFunction.length() ) ;
157     for ( i = 0 ; i < (int ) aPythonFunction.length() ; i++ ) {
158       cdebug << aPythonFunction[ i ] << endl ;
159       _PythonFunction[ i ] = CORBA::string_dup( aPythonFunction[ i ] ) ;
160     }
161   }
162 }
163
164 //bool GraphBase::InLineNode::SaveXML( ostream &f , char *Tabs ,
165 bool GraphBase::InLineNode::SaveXML( QDomDocument & Graph , QDomElement & info ,
166                                      int XCoordinate , int YCoordinate ) const {
167   GraphBase::ListOfFuncName aFuncNames ;
168   GraphBase::ListOfPythonFunctions aPythonFunction ;
169   if ( PyFuncName() ) {
170     aFuncNames.resize( 1 ) ;
171 //JR 24.02.2005 Memory Leak    aFuncNames[0] = CORBA::string_dup( PyFuncName() ) ;
172     aFuncNames[0] = string( PyFuncName() ) ;
173     aPythonFunction.resize( 1 ) ;
174     aPythonFunction[0] = PythonFunction() ;
175   }
176 //  return GraphBase::ComputingNode::SaveXML( f , Tabs , "" , "" , "" , "" ,
177   return GraphBase::ComputingNode::SaveXML( Graph , info , "" , "" , "" , "" ,
178                                             aFuncNames , aPythonFunction ,
179                                             XCoordinate , YCoordinate ) ;
180 }
181
182 bool GraphBase::InLineNode::SavePY(ostream &f , const char * aGraphName ,
183                                    int XCoordinate , int YCoordinate ) const {
184   GraphBase::ListOfFuncName aFuncNames ; 
185   GraphBase::ListOfPythonFunctions aPythonFunction ;
186   if ( PyFuncName() ) {
187     aFuncNames.resize( 1 ) ;
188 //JR 24.02.2005 Memory Leak    aFuncNames[0] = CORBA::string_dup( PyFuncName() ) ;
189     aFuncNames[0] = string( PyFuncName() ) ;
190     aPythonFunction.resize( 1 ) ;
191     aPythonFunction[0] = PythonFunction() ;
192   }
193   return GraphBase::ComputingNode::SavePY( f , aGraphName , "" , "" , "" , NULL ,
194                                            aFuncNames , aPythonFunction ,
195                                            XCoordinate , YCoordinate ) ;
196 }