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