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"
30 class ComputingNode : public StreamNode {
35 SALOME_NamingService * _NamingService ;
36 //->StreamNode int * _Graph_prof_debug ;
37 //->StreamNode ofstream * _Graph_fdebug ;
38 SUPERV::CNode_var _Node_var ;
39 CNode_Impl * _Node_Impl ;
40 void * _InNode ; // From GraphExecutor:: or GraphEditor::
45 //->StreamNode char * _Name ;
46 //->StreamNode SUPERV::KindOfNode _Kind ;
47 SUPERV::SDate _FirstCreation ;
48 SUPERV::SDate _LastModification ;
49 char * _EditorRelease ;
53 //->StreamNode bool _HeadNode ;
54 //->StreamNode int _LevelNumber ;
55 //->StreamNode int _SubGraphNumber ;
58 //->StreamNode int _DataStreamInPortsNumber ;
59 //->StreamNode int _DataStreamOutPortsNumber ;
61 int _ConnectedInPortsNumber ;
62 int _DecrConnectedInPortsNumber ;
64 // For generated NodeNames with ServiceName : number of Nodes using
65 // the same ServiceName. It is not the same Service if it belongs to
66 // a different Interface and/or a different Component ...
67 //->StreamNode map< string , int > _MapOfServiceNames ;
69 // Nodes with LinkedInPortsNumber InPort(s) linked to Outport(s) of this node :
70 //->StreamNode map< string , int > _MapOfLinkedNodes ;
71 //->StreamNode int _LinkedNodesSize ;
72 //->StreamNode vector<ComputingNode * > _LinkedNodes ;
73 //->StreamNode vector<int > _LinkedInPortsNumber ;
83 ComputingNode( CORBA::ORB_ptr ORB ,
84 SALOME_NamingService* ptrNamingService ,
85 const char * DataFlowName ,
86 const SUPERV::KindOfNode DataFlowkind ,
87 int * Graph_prof_debug ,
88 ofstream * Graph_fdebug ) ;
89 ComputingNode( CORBA::ORB_ptr ORB ,
90 SALOME_NamingService* ptrNamingService ,
91 const SALOME_ModuleCatalog::Service& NodeService ,
92 const char *NodeName ,
93 const SUPERV::KindOfNode akind ,
94 const SUPERV::SDate NodeFirstCreation ,
95 const SUPERV::SDate NodeLastModification ,
96 const char * NodeEditorRelease ,
97 const char * NodeAuthor ,
98 const char * NodeComment ,
99 const bool GeneratedName ,
102 int * Graph_prof_debug = NULL ,
103 ofstream * Graph_fdebug = NULL ) ;
104 virtual ~ComputingNode() ;
106 SALOME_NamingService * NamingService() const {
107 return _NamingService ; } ;
109 SUPERV::CNode_var ObjRef() const {
110 // char * _NodeName ;
111 // cdebug << "ComputingNode::ObjRef() " << _Node << " " << Name()
113 // SUPERV::CNode_var _NodeObjRef = SUPERV::CNode::_narrow( _Node ) ;
114 // if ( CORBA::is_nil( _NodeObjRef ) ) {
115 // _NodeName = "NilRef" ;
119 // _NodeName = _NodeObjRef->Name() ;
122 // _NodeName = "Catch Error" ;
125 // cdebug << _NodeName << " " << Name() << endl ;
126 return _Node_var ; } ;
127 void SetObjRef( SUPERV::CNode_var aNode_var ) {
128 // char * _NodeName ;
129 // if ( CORBA::is_nil( _Node ) ) {
130 // _NodeName = "NilRef" ;
133 // _NodeName = _Node->Name() ;
135 // cdebug << "ComputingNode::SetObjRef( " << _Node << " "
136 // << _NodeName << " ) " << Name() << " --> " ;
137 _Node_var = aNode_var ;
138 // cdebug << _Node << " " << _Node->Name() << " ) " << Name() << endl ;
141 CNode_Impl * ObjImpl() const { return _Node_Impl ; } ;
142 void SetObjImpl( CNode_Impl * aNode_Impl ) {
143 _Node_Impl = aNode_Impl ; } ;
145 void InNode( void * anInNode ) {
146 // cdebug << "GraphBase::ComputingNode::InNode " << Name() << endl ;
147 _InNode = anInNode ; } ;
148 void * GetInNode() const {
151 void ObjInterface( bool k_interface ) { _ObjInterface = k_interface ; } ;
152 bool ObjInterface() { return _ObjInterface ; } ;
154 pthread_t ThreadNo() { return _ThreadNo ; } ;
155 void ThreadNo( pthread_t aThread ) { _ThreadNo = aThread ; } ;
157 //->StreamNode char * Name() const { return my_strdup( _Name ) ; } ;
158 //->StreamNode const char *const * NamePtr() const { return &_Name ; } ;
159 // const SALOME_ModuleCatalog::Service * Service() const ;
160 SUPERV::SDate FirstCreation() const ;
161 SUPERV::SDate LastModification() const ;
162 char* Author() const { return my_strdup( _Author ) ; } ;
163 char* EditorRelease() const { return my_strdup( _EditorRelease ) ; } ;
164 char * Comment() const { return my_strdup( _Comment ) ; } ;
165 int XCoordinate() const { return _X ; } ;
166 int YCoordinate() const { return _Y ; } ;
168 //->StreamNode bool Name( const char * aName ) ;
169 // void Service( const SALOME_ModuleCatalog::Service aService ) ;
170 void FirstCreation( const SUPERV::SDate aFirstCreation ) ;
171 void LastModification( const SUPERV::SDate aLastModification ) ;
172 bool Author( const char * anAuthor ) ;
173 bool EditorRelease( const char* anEditorRelease ) ;
174 bool Comment( const char *c ) ;
175 void Coordinates( const int X , const int Y ) {
176 _X = X ; _Y = Y ; } ;
178 void NodePort( const char * NodeName ,
179 const char * ServiceParameterName ,
180 char ** aNode , char ** aPort ) ;
182 bool IsLinked(const char * ToServiceParameterName ) ;
183 bool HasInput(const char * ToServiceParameterName ) ;
185 GraphBase::SNode * GetInfo() ;
187 // void HeadNode( bool aHeadNode ) { _HeadNode = aHeadNode ; } ;
188 // const bool IsHeadNode() const { return _HeadNode ; } ;
190 bool RemovePorts( const char* aNodeName ) ;
192 void SetMacroPorts( GraphBase::Graph * aGraph ) ;
193 void UpdateMacroPorts( GraphBase::Graph * aGraph ) ;
194 void SetMacroDatas( GraphBase::Graph * aGraph , GraphBase::Graph * aGraphOfMacroGraph ) ;
196 void DelInPort( const char * InputParameterName ) ;
197 void DelOutPort( const char * OutputParameterName ) ;
199 InPort * AddInPort( const char * InputParameterName ,
200 const char * InputParameterType ,
201 const SUPERV::KindOfPort aKindOfPort ,
203 OutPort * AddOutPort( const char * OutputParameterName ,
204 const char * OutputParameterType ,
205 const SUPERV::KindOfPort aKindOfPort ,
208 void DelInDataStreamPort( const char * InputParameterName ) ;
209 void DelOutDataStreamPort( const char * OutputParameterName ) ;
211 InDataStreamPort * AddInDataStreamPort( const char * InputParameterName ,
212 const SALOME_ModuleCatalog::DataStreamType InputParameterType ,
213 const SALOME_ModuleCatalog::DataStreamDependency aDependency ,
214 const SUPERV::KindOfPort aKindOfPort ,
216 OutDataStreamPort * AddOutDataStreamPort( const char * OutputParameterName ,
217 const SALOME_ModuleCatalog::DataStreamType OutputParameterType ,
218 const SALOME_ModuleCatalog::DataStreamDependency aDependency ,
219 const SUPERV::KindOfPort aKindOfPort ,
222 // ComputingNode * LinkedNodes( int i ) const { return (GraphBase::ComputingNode *) GraphBase::StreamNode::LinkedNodes( i ) ; } ;
224 void AddLinkedNode( GraphBase::ComputingNode * ToNode ) {
225 GraphBase::StreamNode::AddLinkedNode( ToNode ) ;
226 cdebug << Name() << "->GraphBase::ComputingNode::AddLinkedNode( " << ToNode->Name()
227 << ") ConnectedInPortsNumber " << ToNode->ConnectedInPortsNumber()
228 << " + 1 Service " << ServiceName() << endl ;
229 ToNode->IncrConnectedInPortsNumber() ; } ;
231 bool RemoveLinkedNode( GraphBase::ComputingNode * ToNode ,
232 bool DoLinkedFromNode = true ) {
233 bool RetVal = GraphBase::StreamNode::RemoveLinkedNode( ToNode , DoLinkedFromNode ) ;
235 cdebug << "ComputingNode::RemoveLinkedNode to " << ToNode->Name() << " from "
236 << Name() << " ConnectedInPortsNumber "
237 << ToNode->ConnectedInPortsNumber() - 1 << endl ;
238 ToNode->DecrConnectedInPortsNumber() ;
242 void ReNameLinkedNode( const char* OldNodeName ,
243 const char* NewNodeName ) {
244 GraphBase::StreamNode::ReNameLinkedNode( OldNodeName , NewNodeName ) ; } ;
246 void IncrConnectedInPortsNumber() {
247 cdebug << "ComputingNode::IncrConnectedInPortsNumber " << Name() << " -> "
248 << _ConnectedInPortsNumber+1 << endl ;
249 _ConnectedInPortsNumber++ ; } ;
250 void DecrConnectedInPortsNumber() {
251 _ConnectedInPortsNumber-- ; } ;
252 int ConnectedInPortsNumber() const {
253 return _ConnectedInPortsNumber ; } ;
254 void ConnectedInPortsNumber( int c ) {
255 cdebug << "ConnectedInPortsNumber " << Name() << " -> " << c << endl ;
256 _ConnectedInPortsNumber = c ; } ;
258 void IncrDecrConnectedInPortsNumber(const int cnt ) {
259 _DecrConnectedInPortsNumber += cnt ; } ;
260 bool DecrIncrDecrConnectedInPortsNumber() {
261 if ( _DecrConnectedInPortsNumber ) {
262 _ConnectedInPortsNumber = _ConnectedInPortsNumber -
263 _DecrConnectedInPortsNumber ;
264 _DecrConnectedInPortsNumber = 0 ;
269 bool CheckLoop(GraphBase::LoopNode * aLoopNode ,
270 GraphBase::EndOfLoopNode * anEndLoopNode ) const ;
271 bool CheckEndLoop(GraphBase::LoopNode * aLoopNode ,
272 GraphBase::EndOfLoopNode * anEndLoopNode ) const ;
274 // const GraphBase::ListOfParameters * GetListOfParameters() const ;
276 const long CpuUsed() ;
278 bool SaveXML( QDomDocument & Graph , QDomElement & info ,
279 int X , int Y ) const {
280 ListOfFuncName aFuncNames ;
281 GraphBase::ListOfPythonFunctions aVoidList ;
282 return SaveXML( Graph , info , "" , "" , "" , "" , aFuncNames , aVoidList ,
285 bool SavePY( ostream &f , const char * aGraphName ,
286 int X , int Y ) const {
287 ListOfFuncName aFuncNames ;
288 GraphBase::ListOfPythonFunctions aVoidList ;
289 return SavePY( f , aGraphName , "" , "" , "" , NULL , aFuncNames , aVoidList ,
291 // bool SaveXML(ostream &f , char *Tabs ,
292 bool SaveXML(QDomDocument & Graph , QDomElement & info ,
293 const char * ComponentName ,
294 const char * InterfaceName ,
295 const char * Computer ,
296 const char * CoupledNode ,
297 const ListOfFuncName FuncNames ,
298 const GraphBase::ListOfPythonFunctions PythonFunctions ,
299 int X , int Y ) const ;
301 bool SavePY(ostream &f , const char * aGraphName ,
302 const char * ComponentName ,
303 const char * InterfaceName ,
304 const char * Computer ,
305 const GraphBase::InLineNode * aCoupledNode ,
306 const ListOfFuncName FuncNames ,
307 const GraphBase::ListOfPythonFunctions PythonFunctions ,
308 int X , int Y ) const ;
310 void NodeInfo(ostream & s) const ;
312 void ListLinks(ostream &f ) const ;
318 ostream & operator<< (ostream &,const GraphBase::ComputingNode & N );
320 ostream & operator<< (ostream &,const SUPERV::SDate & D );