]> SALOME platform Git repositories - modules/superv.git/blob - src/GraphBase/DataFlowBase_FactoryNode.cxx
Salome HOME
NRI : First integration.
[modules/superv.git] / src / GraphBase / DataFlowBase_FactoryNode.cxx
1 using namespace std;
2 //=============================================================================
3 // File      : DataFlowBase_FactoryNode.cxx
4 // Created   : 2003
5 // Author    : Jean Rahuel, CEA
6 // Project   : SALOME
7 // $Header:
8 //=============================================================================
9
10 #include <strstream>
11 #include <iostream>
12
13 #include "DataFlowBase_FactoryNode.hxx"
14
15 static void InitFields( char *              &_ComponentName ,
16                         char *              &_InterfaceName ,
17                         char *              &_Computer ) {
18   time_t T = time(NULL);
19   struct tm * Tm = localtime(&T);
20
21   _ComponentName = NULLSTRING ;
22   _InterfaceName = NULLSTRING ;
23
24   _Computer = FACTORYSERVER ;
25 }
26
27 GraphBase::FactoryNode::FactoryNode() :
28   GraphBase::ComputingNode::ComputingNode() {
29
30   InitFields( _ComponentName ,
31               _InterfaceName ,
32               _Computer ) ;
33   _Container = Engines::Container::_nil() ;
34   _ObjComponent = Engines::Component::_nil() ;
35   cdebug << "GraphBase::FactoryNode::FactoryNode "  << this 
36        << " _ComponentName " 
37        << (void *) _ComponentName << " " << _ComponentName << " _Name "
38        << (void *) Name() << " " << Name() << " _Computer "
39        << (void *) _Computer << " "  << _Computer << " _Comment "
40        << (void *) Comment() << " "  << Comment() << " "  << endl ;
41
42 }
43
44 GraphBase::FactoryNode::FactoryNode( CORBA::ORB_ptr ORB ,
45                        SALOME_NamingService* ptrNamingService ,
46                        const char * aDataFlowName ,
47                        int * Graph_prof_debug ,
48                        ostream * Graph_fdebug ) :
49   GraphBase::ComputingNode::ComputingNode( ORB , ptrNamingService , aDataFlowName ,
50                                            Graph_prof_debug , Graph_fdebug ) {
51
52   InitFields( _ComponentName ,
53               _InterfaceName ,
54               _Computer ) ;
55
56   _Container = Engines::Container::_nil() ;
57   _ObjComponent = Engines::Component::_nil() ;
58
59   cdebug << "GraphBase::FactoryNode::FactoryNode "  << this 
60        << " _ComponentName " 
61        << (void *) _ComponentName << " '" << _ComponentName
62        << "' _InterfaceName "
63        << (void *) _InterfaceName << " '" << _InterfaceName << "' _Name "
64        << (void *) Name() << " '" << Name() << "' _Computer "
65        << (void *) _Computer << " "  << _Computer << " _Comment "
66        << (void *) Comment() << " "  << Comment() << " "  << endl ;
67 }
68
69 GraphBase::FactoryNode::FactoryNode( CORBA::ORB_ptr ORB ,
70                        SALOME_NamingService* ptrNamingService ,
71                        const SALOME_ModuleCatalog::Service& aService ,
72                        const char *ComponentName ,
73                        const char* InterfaceName ,
74                        const char *NodeName ,
75                        const SUPERV::KindOfNode akind ,
76                        const SUPERV::SDate NodeFirstCreation ,
77                        const SUPERV::SDate NodeLastModification  ,
78                        const char * NodeEditorRelease ,
79                        const char * NodeAuthor ,
80                        const char * NodeComputer ,
81                        const char * NodeComment ,
82                        const bool   GeneratedName ,
83                        const long   X ,
84                        const long   Y ,
85                        int * Graph_prof_debug ,
86                        ostream * Graph_fdebug ) :
87   GraphBase::ComputingNode::ComputingNode( ORB , ptrNamingService , aService ,
88                                            NodeName , akind ,
89                                            NodeFirstCreation , NodeLastModification  ,
90                                            NodeEditorRelease , NodeAuthor , NodeComment ,
91                                            GeneratedName , X , Y ,
92                                            Graph_prof_debug , Graph_fdebug ) {
93
94   _Container = Engines::Container::_nil() ;
95   _ObjComponent = Engines::Component::_nil() ;
96
97   _ComponentName = new char[strlen(ComponentName)+1];
98   strcpy(_ComponentName , ComponentName ) ;
99
100   _InterfaceName = new char[strlen(InterfaceName)+1];
101   strcpy(_InterfaceName , InterfaceName ) ;
102
103   if ( NodeComputer ) {
104     _Computer = new char[ strlen( NodeComputer ) + 1 ] ;
105     strcpy( _Computer  , NodeComputer ) ;
106   }
107   else
108     _Computer = FACTORYSERVER ;
109
110   cdebug_in << "GraphBase::FactoryNode::FactoryNode(" << aService.ServiceName << ","
111             << ComponentName << "," << Name() << "," << akind
112             << "," << NodeComputer << "," << Comment() << ")" << endl;
113   
114   cdebug << "GraphBase::FactoryNode::FactoryNode "  << this 
115        << " _ComponentName " 
116        << (void *) _ComponentName << " '" << _ComponentName
117        << "' _InterfaceName "
118        << (void *) _InterfaceName << " '" << _InterfaceName << "' _Name "
119        << (void *) Name() << " '" << Name() << "' _Computer "
120        << (void *) _Computer << " "  << _Computer << " _Comment "
121        << (void *) Comment() << " "  << Comment() << " " 
122        << " KindOfNode " << Kind()
123        << " ServiceName " << ServiceName() << " In(" << ServiceInParameter().length()
124        << ") Out(" << ServiceOutParameter().length() << ")" << endl ;
125
126   cdebug_out << "GraphBase::FactoryNode::FactoryNode" << endl;
127 }
128
129 GraphBase::FactoryNode::~FactoryNode() {
130   cdebug << "GraphBase::Node::~Node "  << this 
131        << "_ComponentName " 
132        << (void *) _ComponentName << " " << _ComponentName << " _Name "
133        << (void *) Name() << " " << Name() << " _Computer "
134        << (void *) _Computer << " "  << _Computer << " _Comment "
135        << (void *) Comment() << " "  << Comment() << " "  << endl ;
136 //  if ( _ComponentName != NULLSTRING )
137 //    delete [] _ComponentName ;
138 //  delete [] _Name ;
139 //  delete [] _EditorRelease ;
140 //  if ( _Author != NULLSTRING )
141 //    delete [] _Author ;
142 //  if ( _Computer != FACTORYSERVER )
143 //    delete [] _Computer;
144 //  if ( _Comment != NULLSTRING )
145 //    delete [] _Comment;
146 }
147
148 bool GraphBase::FactoryNode::ComponentName(const char * aComponentName) {
149   if ( _ComponentName && _ComponentName != NULLSTRING )
150     delete [] _ComponentName ;
151   _ComponentName = new char[strlen(aComponentName)+1] ;
152   strcpy( _ComponentName , aComponentName ) ;
153   return true ;
154 }
155
156 bool GraphBase::FactoryNode::InterfaceName(const char * anInterfaceName) {
157   if ( _InterfaceName && _InterfaceName != NULLSTRING )
158     delete [] _InterfaceName ;
159   _InterfaceName = new char[strlen(anInterfaceName)+1] ;
160   strcpy( _InterfaceName , anInterfaceName ) ;
161   return true ;
162 }
163
164 bool GraphBase::FactoryNode::Computer(const char *c) {
165   cdebug_in << "GraphBase::FactoryNode::Computer" << endl;
166   if ( _Computer != FACTORYSERVER )
167     delete [] _Computer ;
168   _Computer = my_strdup(c);
169   cdebug_out << "GraphBase::FactoryNode::Computer" << endl;
170   return true ;
171 }
172
173 //bool GraphBase::FactoryNode::SaveXML( ostream &f , char *Tabs ,
174 bool GraphBase::FactoryNode::SaveXML( QDomDocument & Graph , QDomElement & info ,
175                                       int XCoordinate , int YCoordinate ) const {
176   GraphBase::ListOfFuncName aFuncNames ; 
177   GraphBase::ListOfPythonFunctions aVoidList ;
178 //  return GraphBase::ComputingNode::SaveXML( f , Tabs , ComponentName() ,
179   return GraphBase::ComputingNode::SaveXML( Graph , info , ComponentName() ,
180                                             InterfaceName() , Computer() , "" ,
181                                             aFuncNames , aVoidList ,
182                                             XCoordinate , YCoordinate ) ;
183 }
184
185 bool GraphBase::FactoryNode::SavePY(ostream &f , const char * aGraphName ,
186                                     int XCoordinate , int YCoordinate ) const {
187   GraphBase::ListOfFuncName aFuncNames ; 
188   GraphBase::ListOfPythonFunctions aVoidList ;
189   return GraphBase::ComputingNode::SavePY( f , aGraphName , ComponentName() ,
190                                            InterfaceName() , Computer() , NULL ,
191                                            aFuncNames  , aVoidList ,
192                                            XCoordinate , YCoordinate ) ;
193 }
194