1 // SUPERV GraphBase : contains fondamental classes for Services, Input Ports, Output Ports Links and Nodes.
3 // Copyright (C) 2003 CEA/DEN, EDF R&D
7 // File : DataFlowBase_ComputingNode.hxx
8 // Author : Jean Rahuel, CEA
12 #ifndef _DATAFLOWBASE_COMPUTINGNODE_HXX
13 #define _DATAFLOWBASE_COMPUTINGNODE_HXX
15 #include "SALOME_NamingService.hxx"
17 #include "DataFlowBase_StreamNode.hxx"
29 class EndOfSwitchNode ;
31 class ComputingNode : public StreamNode {
36 SALOME_NamingService * _NamingService ;
37 //->StreamNode int * _Graph_prof_debug ;
38 //->StreamNode ofstream * _Graph_fdebug ;
39 SUPERV::CNode_var _Node_var ;
40 CNode_Impl * _Node_Impl ;
41 void * _InNode ; // From GraphExecutor:: or GraphEditor::
46 //->StreamNode char * _Name ;
47 //->StreamNode SUPERV::KindOfNode _Kind ;
48 SUPERV::SDate _FirstCreation ;
49 SUPERV::SDate _LastModification ;
50 char * _EditorRelease ;
54 //->StreamNode bool _HeadNode ;
55 //->StreamNode int _LevelNumber ;
56 //->StreamNode int _SubGraphNumber ;
59 //->StreamNode int _DataStreamInPortsNumber ;
60 //->StreamNode int _DataStreamOutPortsNumber ;
62 int _ConnectedInPortsNumber ;
63 int _DecrConnectedInPortsNumber ;
65 // For generated NodeNames with ServiceName : number of Nodes using
66 // the same ServiceName. It is not the same Service if it belongs to
67 // a different Interface and/or a different Component ...
68 //->StreamNode map< string , int > _MapOfServiceNames ;
70 // Nodes with LinkedInPortsNumber InPort(s) linked to Outport(s) of this node :
71 //->StreamNode map< string , int > _MapOfLinkedNodes ;
72 //->StreamNode int _LinkedNodesSize ;
73 //->StreamNode vector<ComputingNode * > _LinkedNodes ;
74 //->StreamNode vector<int > _LinkedInPortsNumber ;
84 ComputingNode( CORBA::ORB_ptr ORB ,
85 SALOME_NamingService* ptrNamingService ,
86 const char * DataFlowName ,
87 const SUPERV::KindOfNode DataFlowkind ,
88 int * Graph_prof_debug ,
89 ofstream * Graph_fdebug ) ;
90 ComputingNode( CORBA::ORB_ptr ORB ,
91 SALOME_NamingService* ptrNamingService ,
92 const SALOME_ModuleCatalog::Service& NodeService ,
93 const char *NodeName ,
94 const SUPERV::KindOfNode akind ,
95 const SUPERV::SDate NodeFirstCreation ,
96 const SUPERV::SDate NodeLastModification ,
97 const char * NodeEditorRelease ,
98 const char * NodeAuthor ,
99 const char * NodeComment ,
100 const bool GeneratedName ,
103 int * Graph_prof_debug = NULL ,
104 ofstream * Graph_fdebug = NULL ) ;
105 virtual ~ComputingNode() ;
107 SALOME_NamingService * NamingService() const {
108 return _NamingService ; } ;
110 SUPERV::CNode_var ObjRef() const {
111 // char * _NodeName ;
112 // cdebug << "ComputingNode::ObjRef() " << _Node << " " << Name()
114 // SUPERV::CNode_var _NodeObjRef = SUPERV::CNode::_narrow( _Node ) ;
115 // if ( CORBA::is_nil( _NodeObjRef ) ) {
116 // _NodeName = "NilRef" ;
120 // _NodeName = _NodeObjRef->Name() ;
123 // _NodeName = "Catch Error" ;
126 // cdebug << _NodeName << " " << Name() << endl ;
127 return _Node_var ; } ;
128 void SetObjRef( SUPERV::CNode_var aNode_var ) {
129 // char * _NodeName ;
130 // if ( CORBA::is_nil( _Node ) ) {
131 // _NodeName = "NilRef" ;
134 // _NodeName = _Node->Name() ;
136 // cdebug << "ComputingNode::SetObjRef( " << _Node << " "
137 // << _NodeName << " ) " << Name() << " --> " ;
138 _Node_var = aNode_var ;
139 // cdebug << _Node << " " << _Node->Name() << " ) " << Name() << endl ;
142 CNode_Impl * ObjImpl() const { return _Node_Impl ; } ;
143 void SetObjImpl( CNode_Impl * aNode_Impl ) {
144 _Node_Impl = aNode_Impl ; } ;
146 void InNode( void * anInNode ) {
147 // cdebug << "GraphBase::ComputingNode::InNode " << Name() << endl ;
148 _InNode = anInNode ; } ;
149 void * GetInNode() const {
152 void ObjInterface( bool k_interface ) { _ObjInterface = k_interface ; } ;
153 bool ObjInterface() { return _ObjInterface ; } ;
155 pthread_t ThreadNo() { return _ThreadNo ; } ;
156 void ThreadNo( pthread_t aThread ) { _ThreadNo = aThread ; } ;
158 //->StreamNode char * Name() const { return my_strdup( _Name ) ; } ;
159 //->StreamNode const char *const * NamePtr() const { return &_Name ; } ;
160 // const SALOME_ModuleCatalog::Service * Service() const ;
161 SUPERV::SDate FirstCreation() const ;
162 SUPERV::SDate LastModification() const ;
163 //JR 17.02.2005 Memory Leak char* Author() const { return my_strdup( _Author ) ; } ;
164 char* Author() const { return _Author ; } ;
165 //JR 17.02.2005 Memory Leak char* EditorRelease() const { return my_strdup( _EditorRelease ) ; } ;
166 char* EditorRelease() const { return _EditorRelease ; } ;
167 //JR 17.02.2005 Memory Leak char * Comment() const { return my_strdup( _Comment ) ; } ;
168 char * Comment() const { return _Comment ; } ;
169 int XCoordinate() const { return _X ; } ;
170 int YCoordinate() const { return _Y ; } ;
172 //->StreamNode bool Name( const char * aName ) ;
173 // void Service( const SALOME_ModuleCatalog::Service aService ) ;
174 void FirstCreation( const SUPERV::SDate aFirstCreation ) ;
175 void LastModification( const SUPERV::SDate aLastModification ) ;
176 bool Author( const char * anAuthor ) ;
177 bool EditorRelease( const char* anEditorRelease ) ;
178 bool Comment( const char *c ) ;
179 void Coordinates( const int X , const int Y ) {
180 _X = X ; _Y = Y ; } ;
182 void NodePort( const char * NodeName ,
183 const char * ServiceParameterName ,
184 char ** aNode , char ** aPort ) ;
186 bool IsLinked(const char * ToServiceParameterName, bool isInput ) ; // mkr : PAL8060
187 bool HasInput(const char * ToServiceParameterName ) ;
189 GraphBase::SNode * GetInfo() ;
191 // void HeadNode( bool aHeadNode ) { _HeadNode = aHeadNode ; } ;
192 // const bool IsHeadNode() const { return _HeadNode ; } ;
194 bool RemovePorts( const char* aNodeName ) ;
196 void SetMacroPorts( GraphBase::Graph * aGraph ) ;
197 void UpdateMacroPorts( GraphBase::Graph * aGraph ) ;
198 void SetMacroDatas( GraphBase::Graph * aGraph , GraphBase::Graph * aGraphOfMacroGraph ) ;
200 void DelInPort( const char * InputParameterName ) ;
201 void DelOutPort( const char * OutputParameterName ) ;
203 InPort * AddInPort( const char * InputParameterName ,
204 const char * InputParameterType ,
205 const SUPERV::KindOfPort aKindOfPort ,
207 OutPort * AddOutPort( const char * OutputParameterName ,
208 const char * OutputParameterType ,
209 const SUPERV::KindOfPort aKindOfPort ,
212 void DelInDataStreamPort( const char * InputParameterName ) ;
213 void DelOutDataStreamPort( const char * OutputParameterName ) ;
215 InDataStreamPort * AddInDataStreamPort( const char * InputParameterName ,
216 const SALOME_ModuleCatalog::DataStreamType InputParameterType ,
217 const SALOME_ModuleCatalog::DataStreamDependency aDependency ,
218 const SUPERV::KindOfPort aKindOfPort ,
220 OutDataStreamPort * AddOutDataStreamPort( const char * OutputParameterName ,
221 const SALOME_ModuleCatalog::DataStreamType OutputParameterType ,
222 const SALOME_ModuleCatalog::DataStreamDependency aDependency ,
223 const SUPERV::KindOfPort aKindOfPort ,
226 // ComputingNode * LinkedNodes( int i ) const { return (GraphBase::ComputingNode *) GraphBase::StreamNode::LinkedNodes( i ) ; } ;
228 void AddLinkedNode( GraphBase::ComputingNode * ToNode ) {
229 GraphBase::StreamNode::AddLinkedNode( ToNode ) ;
230 cdebug << Name() << "->GraphBase::ComputingNode::AddLinkedNode( " << ToNode->Name()
231 << ") ConnectedInPortsNumber " << ToNode->ConnectedInPortsNumber()
232 << " + 1 Service " << ServiceName() << endl ;
233 ToNode->IncrConnectedInPortsNumber() ; } ;
235 bool RemoveLinkedNode( GraphBase::ComputingNode * ToNode ,
236 bool DoLinkedFromNode = true ) {
237 bool RetVal = GraphBase::StreamNode::RemoveLinkedNode( ToNode , DoLinkedFromNode ) ;
239 cdebug << "ComputingNode::RemoveLinkedNode to " << ToNode->Name() << " from "
240 << Name() << " ConnectedInPortsNumber "
241 << ToNode->ConnectedInPortsNumber() - 1 << endl ;
242 ToNode->DecrConnectedInPortsNumber() ;
246 void ReNameLinkedNode( const char* OldNodeName ,
247 const char* NewNodeName ) {
248 GraphBase::StreamNode::ReNameLinkedNode( OldNodeName , NewNodeName ) ; } ;
250 void IncrConnectedInPortsNumber() {
251 cdebug << "ComputingNode::IncrConnectedInPortsNumber " << Name() << " -> "
252 << _ConnectedInPortsNumber+1 << endl ;
253 _ConnectedInPortsNumber++ ; } ;
254 void DecrConnectedInPortsNumber() {
255 cdebug << "ComputingNode::DecrConnectedInPortsNumber " << Name() << " -> "
256 << _ConnectedInPortsNumber-1 << endl ;
257 _ConnectedInPortsNumber-- ; } ;
258 int ConnectedInPortsNumber() const {
259 return _ConnectedInPortsNumber ; } ;
260 void ConnectedInPortsNumber( int c ) {
261 cdebug << "ConnectedInPortsNumber " << Name() << " -> " << c << endl ;
262 _ConnectedInPortsNumber = c ; } ;
264 void IncrDecrConnectedInPortsNumber(const int cnt ) {
265 _DecrConnectedInPortsNumber += cnt ; } ;
266 bool DecrIncrDecrConnectedInPortsNumber() {
267 if ( _DecrConnectedInPortsNumber ) {
268 _ConnectedInPortsNumber = _ConnectedInPortsNumber -
269 _DecrConnectedInPortsNumber ;
270 _DecrConnectedInPortsNumber = 0 ;
275 bool CheckLoop( GraphBase::LoopNode * aLoopNode ,
276 GraphBase::EndOfLoopNode * anEndLoopNode ,
277 string & anErrorMessage ) const ;
278 bool CheckEndLoop( GraphBase::LoopNode * aLoopNode ,
279 GraphBase::EndOfLoopNode * anEndLoopNode ,
280 string & anErrorMessage ) const ;
281 bool InitBranchOfSwitchDone( bool AllInit , GraphBase::EndOfSwitchNode * anEndSwitchNode ,
282 string & anErrorMessage ) ;
283 bool CheckSwitch( GraphBase::EndOfSwitchNode * anEndSwitchNode ,
284 string & anErrorMessage ) ;
286 // const GraphBase::ListOfParameters * GetListOfParameters() const ;
288 const long CpuUsed() ;
290 bool SaveXML( QDomDocument & Graph , QDomElement & info ,
291 int X , int Y ) const {
292 ListOfFuncName aFuncNames ;
293 GraphBase::ListOfPythonFunctions aVoidList ;
294 return SaveXML( Graph , info , "" , "" , "" , "" , aFuncNames , aVoidList ,
297 bool SavePY( ostream &f , const char * aGraphName ,
298 int X , int Y ) const {
299 ListOfFuncName aFuncNames ;
300 GraphBase::ListOfPythonFunctions aVoidList ;
301 return SavePY( f , aGraphName , "" , "" , "" , NULL , aFuncNames , aVoidList ,
303 // bool SaveXML(ostream &f , char *Tabs ,
304 bool SaveXML(QDomDocument & Graph , QDomElement & info ,
305 const char * ComponentName ,
306 const char * InterfaceName ,
307 const char * Computer ,
308 const char * CoupledNode ,
309 const ListOfFuncName FuncNames ,
310 const GraphBase::ListOfPythonFunctions PythonFunctions ,
311 int X , int Y ) const ;
313 bool SavePY(ostream &f , const char * aGraphName ,
314 const char * ComponentName ,
315 const char * InterfaceName ,
316 const char * Computer ,
317 const GraphBase::InLineNode * aCoupledNode ,
318 const ListOfFuncName FuncNames ,
319 const GraphBase::ListOfPythonFunctions PythonFunctions ,
320 int X , int Y ) const ;
322 void NodeInfo(ostream & s) const ;
324 void ListLinks(ostream &f ) const ;
330 ostream & operator<< (ostream &,const GraphBase::ComputingNode & N );
332 ostream & operator<< (ostream &,const SUPERV::SDate & D );