]> SALOME platform Git repositories - modules/superv.git/blob - src/GraphBase/DataFlowBase_FactoryNode.cxx
Salome HOME
NRI : Merge from 1.2c.
[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                        int * Graph_prof_debug ,
48                        ofstream * 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                        ofstream * 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 != NULLSTRING) {
104     _Computer = new char[ strlen( NodeComputer ) + 1 ] ;
105     strcpy( _Computer  , NodeComputer ) ;
106   }
107   else {
108     _Computer = FACTORYSERVER ;
109   }
110
111   cdebug_in << "GraphBase::FactoryNode::FactoryNode( '" << aService.ServiceName << "','"
112             << _ComponentName << "','" << Name() << "'," << akind << ",'" << _Computer << "'" << 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_in << "GraphBase::FactoryNode::Computer('" << _Computer << "')" << endl;
170   cdebug_out << "GraphBase::FactoryNode::Computer" << endl;
171   return true ;
172 }
173
174 //bool GraphBase::FactoryNode::SaveXML( ostream &f , char *Tabs ,
175 bool GraphBase::FactoryNode::SaveXML( QDomDocument & Graph , QDomElement & info ,
176                                       int XCoordinate , int YCoordinate ) const {
177   GraphBase::ListOfFuncName aFuncNames ; 
178   GraphBase::ListOfPythonFunctions aVoidList ;
179 //  return GraphBase::ComputingNode::SaveXML( f , Tabs , ComponentName() ,
180   return GraphBase::ComputingNode::SaveXML( Graph , info , ComponentName() ,
181                                             InterfaceName() , Computer() , "" ,
182                                             aFuncNames , aVoidList ,
183                                             XCoordinate , YCoordinate ) ;
184 }
185
186 bool GraphBase::FactoryNode::SavePY(ostream &f , const char * aGraphName ,
187                                     int XCoordinate , int YCoordinate ) const {
188   GraphBase::ListOfFuncName aFuncNames ; 
189   GraphBase::ListOfPythonFunctions aVoidList ;
190   return GraphBase::ComputingNode::SavePY( f , aGraphName , ComponentName() ,
191                                            InterfaceName() , Computer() , NULL ,
192                                            aFuncNames  , aVoidList ,
193                                            XCoordinate , YCoordinate ) ;
194 }
195