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