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