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"
27 class ComputingNode : public StreamNode {
32 SALOME_NamingService * _NamingService ;
33 //->StreamNode int * _Graph_prof_debug ;
34 //->StreamNode ofstream * _Graph_fdebug ;
35 SUPERV::CNode_var _Node_var ;
36 CNode_Impl * _Node_Impl ;
37 void * _InNode ; // From GraphExecutor:: or GraphEditor::
42 //->StreamNode char * _Name ;
43 //->StreamNode SUPERV::KindOfNode _Kind ;
44 SUPERV::SDate _FirstCreation ;
45 SUPERV::SDate _LastModification ;
46 char * _EditorRelease ;
50 //->StreamNode bool _HeadNode ;
51 //->StreamNode int _LevelNumber ;
52 //->StreamNode int _SubGraphNumber ;
55 //->StreamNode int _DataStreamInPortsNumber ;
56 //->StreamNode int _DataStreamOutPortsNumber ;
58 int _ConnectedInPortsNumber ;
59 int _DecrConnectedInPortsNumber ;
61 // For generated NodeNames with ServiceName : number of Nodes using
62 // the same ServiceName. It is not the same Service if it belongs to
63 // a different Interface and/or a different Component ...
64 //->StreamNode map< string , int > _MapOfServiceNames ;
66 // Nodes with LinkedInPortsNumber InPort(s) linked to Outport(s) of this node :
67 //->StreamNode map< string , int > _MapOfLinkedNodes ;
68 //->StreamNode int _LinkedNodesSize ;
69 //->StreamNode vector<ComputingNode * > _LinkedNodes ;
70 //->StreamNode vector<int > _LinkedInPortsNumber ;
80 ComputingNode( CORBA::ORB_ptr ORB ,
81 SALOME_NamingService* ptrNamingService ,
82 const char * DataFlowName ,
83 const SUPERV::KindOfNode DataFlowkind ,
84 int * Graph_prof_debug ,
85 ofstream * Graph_fdebug ) ;
86 ComputingNode( CORBA::ORB_ptr ORB ,
87 SALOME_NamingService* ptrNamingService ,
88 const SALOME_ModuleCatalog::Service& NodeService ,
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 * NodeComment ,
96 const bool GeneratedName ,
99 int * Graph_prof_debug = NULL ,
100 ofstream * Graph_fdebug = NULL ) ;
101 virtual ~ComputingNode() ;
103 SALOME_NamingService * NamingService() const {
104 return _NamingService ; } ;
106 SUPERV::CNode_var ObjRef() const {
107 // char * _NodeName ;
108 // cdebug << "ComputingNode::ObjRef() " << _Node << " " << Name()
110 // SUPERV::CNode_var _NodeObjRef = SUPERV::CNode::_narrow( _Node ) ;
111 // if ( CORBA::is_nil( _NodeObjRef ) ) {
112 // _NodeName = "NilRef" ;
116 // _NodeName = _NodeObjRef->Name() ;
119 // _NodeName = "Catch Error" ;
122 // cdebug << _NodeName << " " << Name() << endl ;
123 return _Node_var ; } ;
124 void SetObjRef( SUPERV::CNode_var aNode_var ) {
125 // char * _NodeName ;
126 // if ( CORBA::is_nil( _Node ) ) {
127 // _NodeName = "NilRef" ;
130 // _NodeName = _Node->Name() ;
132 // cdebug << "ComputingNode::SetObjRef( " << _Node << " "
133 // << _NodeName << " ) " << Name() << " --> " ;
134 _Node_var = aNode_var ;
135 // cdebug << _Node << " " << _Node->Name() << " ) " << Name() << endl ;
138 CNode_Impl * ObjImpl() const { return _Node_Impl ; } ;
139 void SetObjImpl( CNode_Impl * aNode_Impl ) {
140 _Node_Impl = aNode_Impl ; } ;
142 void InNode( void * anInNode ) {
143 // cdebug << "GraphBase::ComputingNode::InNode " << Name() << endl ;
144 _InNode = anInNode ; } ;
145 void * GetInNode() const {
148 void ObjInterface( bool k_interface ) { _ObjInterface = k_interface ; } ;
149 bool ObjInterface() { return _ObjInterface ; } ;
151 pthread_t ThreadNo() { return _ThreadNo ; } ;
152 void ThreadNo( pthread_t aThread ) { _ThreadNo = aThread ; } ;
154 //->StreamNode char * Name() const { return my_strdup( _Name ) ; } ;
155 //->StreamNode const char *const * NamePtr() const { return &_Name ; } ;
156 // const SALOME_ModuleCatalog::Service * Service() const ;
157 SUPERV::SDate FirstCreation() const ;
158 SUPERV::SDate LastModification() const ;
159 char* Author() const { return my_strdup( _Author ) ; } ;
160 char* EditorRelease() const { return my_strdup( _EditorRelease ) ; } ;
161 char * Comment() const { return my_strdup( _Comment ) ; } ;
162 int XCoordinate() const { return _X ; } ;
163 int YCoordinate() const { return _Y ; } ;
165 //->StreamNode bool Name( const char * aName ) ;
166 // void Service( const SALOME_ModuleCatalog::Service aService ) ;
167 void FirstCreation( const SUPERV::SDate aFirstCreation ) ;
168 void LastModification( const SUPERV::SDate aLastModification ) ;
169 bool Author( const char * anAuthor ) ;
170 bool EditorRelease( const char* anEditorRelease ) ;
171 bool Comment( const char *c ) ;
172 void Coordinates( const int X , const int Y ) {
173 _X = X ; _Y = Y ; } ;
175 void NodePort( const char * NodeName ,
176 const char * ServiceParameterName ,
177 char ** aNode , char ** aPort ) ;
179 bool IsLinked(const char * ToServiceParameterName ) ;
180 bool HasInput(const char * ToServiceParameterName ) ;
182 GraphBase::SNode * GetInfo() ;
184 // void HeadNode( bool aHeadNode ) { _HeadNode = aHeadNode ; } ;
185 // const bool IsHeadNode() const { return _HeadNode ; } ;
187 bool RemovePorts( const char* aNodeName ) ;
189 void SetMacroPorts( GraphBase::Graph * aGraph ) ;
190 void UpdateMacroPorts( GraphBase::Graph * aGraph ) ;
191 void SetMacroDatas( GraphBase::Graph * aGraph , GraphBase::Graph * aGraphOfMacroGraph ) ;
193 void DelInPort( const char * InputParameterName ) ;
194 void DelOutPort( const char * OutputParameterName ) ;
196 InPort * AddInPort( const char * InputParameterName ,
197 const char * InputParameterType ,
198 const SUPERV::KindOfPort aKindOfPort ,
200 OutPort * AddOutPort( const char * OutputParameterName ,
201 const char * OutputParameterType ,
202 const SUPERV::KindOfPort aKindOfPort ,
205 void DelInDataStreamPort( const char * InputParameterName ) ;
206 void DelOutDataStreamPort( const char * OutputParameterName ) ;
208 InDataStreamPort * AddInDataStreamPort( const char * InputParameterName ,
209 const SALOME_ModuleCatalog::DataStreamType InputParameterType ,
210 const SALOME_ModuleCatalog::DataStreamDependency aDependency ,
211 const SUPERV::KindOfPort aKindOfPort ,
213 OutDataStreamPort * AddOutDataStreamPort( const char * OutputParameterName ,
214 const SALOME_ModuleCatalog::DataStreamType OutputParameterType ,
215 const SALOME_ModuleCatalog::DataStreamDependency aDependency ,
216 const SUPERV::KindOfPort aKindOfPort ,
219 // ComputingNode * LinkedNodes( int i ) const { return (GraphBase::ComputingNode *) GraphBase::StreamNode::LinkedNodes( i ) ; } ;
221 void AddLinkedNode( GraphBase::ComputingNode * ToNode ) {
222 GraphBase::StreamNode::AddLinkedNode( ToNode ) ;
223 cdebug << Name() << "->GraphBase::ComputingNode::AddLinkedNode( " << ToNode->Name()
224 << ") ConnectedInPortsNumber " << ToNode->ConnectedInPortsNumber()
225 << " + 1 Service " << ServiceName() << endl ;
226 ToNode->IncrConnectedInPortsNumber() ; } ;
228 bool RemoveLinkedNode( GraphBase::ComputingNode * ToNode ) {
229 bool RetVal = GraphBase::StreamNode::RemoveLinkedNode( ToNode ) ;
231 cdebug << "GraphBase::StreamNode::RemoveLinkedNode to " << ToNode->Name() << " from "
232 << Name() << " ConnectedInPortsNumber "
233 << ToNode->ConnectedInPortsNumber() - 1 << endl ;
234 ToNode->DecrConnectedInPortsNumber() ;
238 void ReNameLinkedNode( const char* OldNodeName ,
239 const char* NewNodeName ) {
240 GraphBase::StreamNode::ReNameLinkedNode( OldNodeName , NewNodeName ) ; } ;
242 void IncrConnectedInPortsNumber() {
243 cdebug << "IncrConnectedInPortsNumber " << Name() << " -> "
244 << _ConnectedInPortsNumber+1 << endl ;
245 _ConnectedInPortsNumber++ ; } ;
246 void DecrConnectedInPortsNumber() {
247 _ConnectedInPortsNumber-- ; } ;
248 int ConnectedInPortsNumber() const {
249 return _ConnectedInPortsNumber ; } ;
250 void ConnectedInPortsNumber( int c ) {
251 cdebug << "ConnectedInPortsNumber " << Name() << " -> " << c << endl ;
252 _ConnectedInPortsNumber = c ; } ;
254 void IncrDecrConnectedInPortsNumber(const int cnt ) {
255 _DecrConnectedInPortsNumber += cnt ; } ;
256 bool DecrIncrDecrConnectedInPortsNumber() {
257 if ( _DecrConnectedInPortsNumber ) {
258 _ConnectedInPortsNumber = _ConnectedInPortsNumber -
259 _DecrConnectedInPortsNumber ;
260 _DecrConnectedInPortsNumber = 0 ;
265 // const GraphBase::ListOfParameters * GetListOfParameters() const ;
267 const long CpuUsed() ;
269 bool SaveXML( QDomDocument & Graph , QDomElement & info ,
270 int X , int Y ) const {
271 ListOfFuncName aFuncNames ;
272 GraphBase::ListOfPythonFunctions aVoidList ;
273 return SaveXML( Graph , info , "" , "" , "" , "" , aFuncNames , aVoidList ,
276 bool SavePY( ostream &f , const char * aGraphName ,
277 int X , int Y ) const {
278 ListOfFuncName aFuncNames ;
279 GraphBase::ListOfPythonFunctions aVoidList ;
280 return SavePY( f , aGraphName , "" , "" , "" , NULL , aFuncNames , aVoidList ,
282 // bool SaveXML(ostream &f , char *Tabs ,
283 bool SaveXML(QDomDocument & Graph , QDomElement & info ,
284 const char * ComponentName ,
285 const char * InterfaceName ,
286 const char * Computer ,
287 const char * CoupledNode ,
288 const ListOfFuncName FuncNames ,
289 const GraphBase::ListOfPythonFunctions PythonFunctions ,
290 int X , int Y ) const ;
292 bool SavePY(ostream &f , const char * aGraphName ,
293 const char * ComponentName ,
294 const char * InterfaceName ,
295 const char * Computer ,
296 const GraphBase::InLineNode * aCoupledNode ,
297 const ListOfFuncName FuncNames ,
298 const GraphBase::ListOfPythonFunctions PythonFunctions ,
299 int X , int Y ) const ;
301 void NodeInfo(ostream & s) const ;
303 void ListLinks(ostream &f ) const ;
309 ostream & operator<< (ostream &,const GraphBase::ComputingNode & N );
311 ostream & operator<< (ostream &,const SUPERV::SDate & D );