]> SALOME platform Git repositories - modules/superv.git/blob - src/GraphBase/DataFlowBase_InLineNode.cxx
Salome HOME
b6285e696ec4d93d3a9622ee8c7600f3b33fd396
[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 <strstream>
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                                    ostream * 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                                    ostream * 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   cdebug_in << "GraphBase::InLineNode::Node "  << this 
62             << "' _Name "
63             << (void *) Name() << " '" << Name() << " _Comment "
64             << (void *) Comment() << " "  << Comment() << " " 
65             << " KindOfNode " << Kind()
66             << " ServiceName " << ServiceName() << " In("
67             << ServiceInParameter().length()
68             << ") Out(" << ServiceOutParameter().length() << ")" << endl ;
69
70   cdebug_out << "GraphBase::InLineNode::Node" << endl;
71 }
72
73 GraphBase::InLineNode::InLineNode( CORBA::ORB_ptr ORB ,
74                                    SALOME_NamingService* ptrNamingService ,
75                                    const char * FuncName ,
76                                    const SUPERV::ListOfStrings & aPythonFunction ,
77                                    const char *NodeName ,
78                                    const SUPERV::KindOfNode akind ,
79                                    const SUPERV::SDate NodeFirstCreation ,
80                                    const SUPERV::SDate NodeLastModification  ,
81                                    const char * NodeEditorRelease ,
82                                    const char * NodeAuthor ,
83                                    const char * NodeComment ,
84                                    const bool   GeneratedName ,
85                                    const long   X ,
86                                    const long   Y ,
87                                    int * Graph_prof_debug ,
88                                    ostream * Graph_fdebug ) :
89   GraphBase::ComputingNode::ComputingNode( ORB , ptrNamingService ,
90                                            SALOME_ModuleCatalog::Service() ,
91                                            NodeName , akind , NodeFirstCreation ,
92                                            NodeLastModification  , NodeEditorRelease ,
93                                            NodeAuthor , NodeComment , GeneratedName ,
94                                            X , Y ,
95                                            Graph_prof_debug , Graph_fdebug ) {
96
97   cdebug_in << "GraphBase::InLineNode::Node "  << this 
98             << "' _Name "
99             << (void *) Name() << " '" << Name() << " _Comment "
100             << (void *) Comment() << " "  << Comment() << " " 
101             << " KindOfNode " << Kind() << " FuncName " << FuncName
102             << " ServiceName " << ServiceName() << " In("
103             << ServiceInParameter().length()
104             << ") Out(" << ServiceOutParameter().length() << ")" << endl ;
105
106   SetPythonFunction( FuncName , aPythonFunction ) ;
107   SALOME_ModuleCatalog::Service aNodeService ;
108   aNodeService.ServiceName = NodeName ;
109 // python -> service
110   SetService( aNodeService ) ;
111   cdebug_out << "GraphBase::InLineNode::Node" << endl;
112 }
113
114 GraphBase::InLineNode::~InLineNode() {
115   cdebug << "GraphBase::InLineNode::~Node "  << this 
116          << " _Name "
117          << (void *) Name() << " " << Name() << " _Comment "
118          << (void *) Comment() << " "  << Comment() << " "  << endl ;
119 //  if ( _ComponentName != NULLSTRING )
120 //    delete [] _ComponentName ;
121 //  delete [] _Name ;
122 //  delete [] _EditorRelease ;
123 //  if ( _Author != NULLSTRING )
124 //    delete [] _Author ;
125 //  if ( _Computer != FACTORYSERVER )
126 //    delete [] _Computer;
127 //  if ( _Comment != NULLSTRING )
128 //    delete [] _Comment;
129 }
130
131 void GraphBase::InLineNode::SetPythonFunction( const char * FuncName ,
132                                                const SUPERV::ListOfStrings & aPythonFunction ) {
133   int i ;
134   cdebug << "GraphBase::InLineNode::PythonFunction length " << aPythonFunction.length()
135          << endl ;
136   _FuncName = my_strdup( FuncName ) ;
137   if ( ( aPythonFunction.length() == 0 ) ||
138          ( aPythonFunction.length() == 1 && strlen( aPythonFunction[ 0 ] ) == 0 ) ) {
139     _PythonFunction.length( 0 ) ;
140   }
141   else {
142     _PythonFunction.length( aPythonFunction.length() ) ;
143     for ( i = 0 ; i < aPythonFunction.length() ; i++ ) {
144       cdebug << aPythonFunction[ i ] << endl ;
145       _PythonFunction[ i ] = CORBA::string_dup( aPythonFunction[ i ] ) ;
146     }
147   }
148 }
149
150 //bool GraphBase::InLineNode::SaveXML( ostream &f , char *Tabs ,
151 bool GraphBase::InLineNode::SaveXML( QDomDocument & Graph , QDomElement & info ,
152                                      int XCoordinate , int YCoordinate ) const {
153   GraphBase::ListOfFuncName aFuncNames ;
154   GraphBase::ListOfPythonFunctions aPythonFunction ;
155   if ( PyFuncName() ) {
156     aFuncNames.resize( 1 ) ;
157     aFuncNames[0] = CORBA::string_dup( PyFuncName() ) ;
158     aPythonFunction.resize( 1 ) ;
159     aPythonFunction[0] = PythonFunction() ;
160   }
161 //  return GraphBase::ComputingNode::SaveXML( f , Tabs , "" , "" , "" , "" ,
162   return GraphBase::ComputingNode::SaveXML( Graph , info , "" , "" , "" , "" ,
163                                             aFuncNames , aPythonFunction ,
164                                             XCoordinate , YCoordinate ) ;
165 }
166
167 bool GraphBase::InLineNode::SavePY(ostream &f , const char * aGraphName ,
168                                    int XCoordinate , int YCoordinate ) const {
169   GraphBase::ListOfFuncName aFuncNames ; 
170   GraphBase::ListOfPythonFunctions aPythonFunction ;
171   if ( PyFuncName() ) {
172     aFuncNames.resize( 1 ) ;
173     aFuncNames[0] = CORBA::string_dup( PyFuncName() ) ;
174     aPythonFunction.resize( 1 ) ;
175     aPythonFunction[0] = PythonFunction() ;
176   }
177   return GraphBase::ComputingNode::SavePY( f , aGraphName , "" , "" , "" , NULL ,
178                                            aFuncNames , aPythonFunction ,
179                                            XCoordinate , YCoordinate ) ;
180 }