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"
23 class ComputingNode : public StreamNode {
28 SALOME_NamingService * _NamingService ;
29 //->StreamNode int * _Graph_prof_debug ;
30 //->StreamNode ofstream * _Graph_fdebug ;
31 SUPERV::CNode_var _Node ;
32 void * _InNode ; // From GraphExecutor:: or GraphEditor::
37 //->StreamNode char * _Name ;
38 //->StreamNode SUPERV::KindOfNode _Kind ;
39 SUPERV::SDate _FirstCreation ;
40 SUPERV::SDate _LastModification ;
41 char * _EditorRelease ;
45 //->StreamNode bool _HeadNode ;
46 //->StreamNode int _LevelNumber ;
47 //->StreamNode int _SubGraphNumber ;
50 //->StreamNode int _DataStreamInPortsNumber ;
51 //->StreamNode int _DataStreamOutPortsNumber ;
53 int _ConnectedInPortsNumber ;
54 int _DecrConnectedInPortsNumber ;
56 // For generated NodeNames with ServiceName : number of Nodes using
57 // the same ServiceName. It is not the same Service if it belongs to
58 // a different Interface and/or a different Component ...
59 //->StreamNode map< string , int > _MapOfServiceNames ;
61 // Nodes with LinkedInPortsNumber InPort(s) linked to Outport(s) of this node :
62 //->StreamNode map< string , int > _MapOfLinkedNodes ;
63 //->StreamNode int _LinkedNodesSize ;
64 //->StreamNode vector<ComputingNode * > _LinkedNodes ;
65 //->StreamNode vector<int > _LinkedInPortsNumber ;
75 ComputingNode( CORBA::ORB_ptr ORB ,
76 SALOME_NamingService* ptrNamingService ,
77 const char * DataFlowName ,
78 int * Graph_prof_debug = NULL ,
79 ofstream * Graph_fdebug = NULL ) ;
80 ComputingNode( CORBA::ORB_ptr ORB ,
81 SALOME_NamingService* ptrNamingService ,
82 const SALOME_ModuleCatalog::Service& NodeService ,
83 const char *NodeName ,
84 const SUPERV::KindOfNode akind ,
85 const SUPERV::SDate NodeFirstCreation ,
86 const SUPERV::SDate NodeLastModification ,
87 const char * NodeEditorRelease ,
88 const char * NodeAuthor ,
89 const char * NodeComment ,
90 const bool GeneratedName ,
93 int * Graph_prof_debug = NULL ,
94 ofstream * Graph_fdebug = NULL ) ;
95 virtual ~ComputingNode() ;
97 SALOME_NamingService * NamingService() const {
98 return _NamingService ; } ;
100 SUPERV::CNode_var ObjRef() const {
101 // char * _NodeName ;
102 // cdebug << "ComputingNode::ObjRef() " << _Node << " " << Name()
104 // SUPERV::CNode_var _NodeObjRef = SUPERV::CNode::_narrow( _Node ) ;
105 // if ( CORBA::is_nil( _NodeObjRef ) ) {
106 // _NodeName = "NilRef" ;
110 // _NodeName = _NodeObjRef->Name() ;
113 // _NodeName = "Catch Error" ;
116 // cdebug << _NodeName << " " << Name() << endl ;
118 void SetObjRef(SUPERV::CNode_var aNode) {
119 // char * _NodeName ;
120 // if ( CORBA::is_nil( _Node ) ) {
121 // _NodeName = "NilRef" ;
124 // _NodeName = _Node->Name() ;
126 // cdebug << "ComputingNode::SetObjRef( " << _Node << " "
127 // << _NodeName << " ) " << Name() << " --> " ;
129 // cdebug << _Node << " " << _Node->Name() << " ) " << Name() << endl ;
131 void InNode( void * anInNode ) {
132 // cdebug << "GraphBase::ComputingNode::InNode " << Name() << endl ;
133 _InNode = anInNode ; } ;
134 void * GetInNode() const {
137 void ObjInterface( bool k_interface ) { _ObjInterface = k_interface ; } ;
138 bool ObjInterface() { return _ObjInterface ; } ;
140 pthread_t ThreadNo() { return _ThreadNo ; } ;
141 void ThreadNo( pthread_t aThread ) { _ThreadNo = aThread ; } ;
143 //->StreamNode char * Name() const { return my_strdup( _Name ) ; } ;
144 //->StreamNode const char *const * NamePtr() const { return &_Name ; } ;
145 // const SALOME_ModuleCatalog::Service * Service() const ;
146 SUPERV::SDate FirstCreation() const ;
147 SUPERV::SDate LastModification() const ;
148 char* Author() const { return my_strdup( _Author ) ; } ;
149 char* EditorRelease() const { return my_strdup( _EditorRelease ) ; } ;
150 char * Comment() const { return my_strdup( _Comment ) ; } ;
151 int XCoordinate() const { return _X ; } ;
152 int YCoordinate() const { return _Y ; } ;
154 //->StreamNode bool Name( const char * aName ) ;
155 // void Service( const SALOME_ModuleCatalog::Service aService ) ;
156 void FirstCreation( const SUPERV::SDate aFirstCreation ) ;
157 void LastModification( const SUPERV::SDate aLastModification ) ;
158 bool Author( const char * anAuthor ) ;
159 bool EditorRelease( const char* anEditorRelease ) ;
160 bool Comment( const char *c ) ;
161 void Coordinates( const int X , const int Y ) {
162 _X = X ; _Y = Y ; } ;
164 void NodePort( const char * NodeName ,
165 const char * ServiceParameterName ,
166 char ** aNode , char ** aPort ) ;
168 bool IsLinked(const char * ToServiceParameterName ) ;
169 bool HasInput(const char * ToServiceParameterName ) ;
171 GraphBase::SNode * GetInfo() ;
173 // void HeadNode( bool aHeadNode ) { _HeadNode = aHeadNode ; } ;
174 // const bool IsHeadNode() const { return _HeadNode ; } ;
176 bool RemovePorts( const char* aNodeName ) ;
178 void DelInPort( const char * InputParameterName ) ;
179 void DelOutPort( const char * OutputParameterName ) ;
181 InPort * AddInPort( const char * InputParameterName ,
182 const char * InputParameterType ,
183 const SUPERV::KindOfPort aKindOfPort ) ;
184 OutPort * AddOutPort( const char * OutputParameterName ,
185 const char * OutputParameterType ,
186 const SUPERV::KindOfPort aKindOfPort ) ;
188 void DelInDataStreamPort( const char * InputParameterName ) ;
189 void DelOutDataStreamPort( const char * OutputParameterName ) ;
191 InDataStreamPort * AddInDataStreamPort( const char * InputParameterName ,
192 const SALOME_ModuleCatalog::DataStreamType InputParameterType ,
193 const SALOME_ModuleCatalog::DataStreamDependency aDependency ,
194 const SUPERV::KindOfPort aKindOfPort ) ;
195 OutDataStreamPort * AddOutDataStreamPort( const char * OutputParameterName ,
196 const SALOME_ModuleCatalog::DataStreamType OutputParameterType ,
197 const SALOME_ModuleCatalog::DataStreamDependency aDependency ,
198 const SUPERV::KindOfPort aKindOfPort ) ;
200 // ComputingNode * LinkedNodes( int i ) const { return (GraphBase::ComputingNode *) GraphBase::StreamNode::LinkedNodes( i ) ; } ;
202 void AddLink( GraphBase::ComputingNode * ToNode ) {
203 GraphBase::StreamNode::AddLink( ToNode ) ;
204 cdebug << Name() << "->GraphBase::ComputingNode::AddLinkedNode( " << ToNode->Name()
205 << ") ConnectedInPortsNumber " << ToNode->ConnectedInPortsNumber()
206 << " + 1 Service " << ServiceName() << endl ;
207 ToNode->IncrConnectedInPortsNumber() ; } ;
209 void RemoveLink( GraphBase::ComputingNode * ToNode ) {
210 if ( GraphBase::StreamNode::RemoveLink( ToNode ) ) {
211 cdebug << "GraphBase::StreamNode::RemoveLink to " << ToNode->Name() << " from "
212 << Name() << " ConnectedInPortsNumber "
213 << ToNode->ConnectedInPortsNumber() - 1 << endl ;
214 ToNode->DecrConnectedInPortsNumber() ; } } ;
216 void ReNameLink( const char* OldNodeName ,
217 const char* NewNodeName ) {
218 GraphBase::StreamNode::ReNameLink( OldNodeName , NewNodeName ) ; } ;
220 void IncrConnectedInPortsNumber() {
221 cdebug << "IncrConnectedInPortsNumber " << Name() << " -> "
222 << _ConnectedInPortsNumber+1 << endl ;
223 _ConnectedInPortsNumber++ ; } ;
224 void DecrConnectedInPortsNumber() {
225 _ConnectedInPortsNumber-- ; } ;
226 int ConnectedInPortsNumber() const {
227 return _ConnectedInPortsNumber ; } ;
228 void ConnectedInPortsNumber( int c ) {
229 cdebug << "ConnectedInPortsNumber " << Name() << " -> " << c << endl ;
230 _ConnectedInPortsNumber = c ; } ;
232 void IncrDecrConnectedInPortsNumber(const int cnt ) {
233 _DecrConnectedInPortsNumber += cnt ; } ;
234 bool DecrIncrDecrConnectedInPortsNumber() {
235 if ( _DecrConnectedInPortsNumber ) {
236 _ConnectedInPortsNumber = _ConnectedInPortsNumber -
237 _DecrConnectedInPortsNumber ;
238 _DecrConnectedInPortsNumber = 0 ;
243 // const GraphBase::ListOfParameters * GetListOfParameters() const ;
245 const long CpuUsed() ;
247 bool SaveXML( QDomDocument & Graph , QDomElement & info ,
248 int X , int Y ) const {
249 ListOfFuncName aFuncNames ;
250 GraphBase::ListOfPythonFunctions aVoidList ;
251 return SaveXML( Graph , info , "" , "" , "" , "" , aFuncNames , aVoidList ,
254 bool SavePY( ostream &f , const char * aGraphName ,
255 int X , int Y ) const {
256 ListOfFuncName aFuncNames ;
257 GraphBase::ListOfPythonFunctions aVoidList ;
258 return SavePY( f , aGraphName , "" , "" , "" , NULL , aFuncNames , aVoidList ,
260 // bool SaveXML(ostream &f , char *Tabs ,
261 bool SaveXML(QDomDocument & Graph , QDomElement & info ,
262 const char * ComponentName ,
263 const char * InterfaceName ,
264 const char * Computer ,
265 const char * CoupledNode ,
266 const ListOfFuncName FuncNames ,
267 const GraphBase::ListOfPythonFunctions PythonFunctions ,
268 int X , int Y ) const ;
270 bool SavePY(ostream &f , const char * aGraphName ,
271 const char * ComponentName ,
272 const char * InterfaceName ,
273 const char * Computer ,
274 const GraphBase::InLineNode * aCoupledNode ,
275 const ListOfFuncName FuncNames ,
276 const GraphBase::ListOfPythonFunctions PythonFunctions ,
277 int X , int Y ) const ;
279 void NodeInfo(ostream & s) const ;
281 void ListLinks(ostream &f ) const ;
287 ostream & operator<< (ostream &,const GraphBase::ComputingNode & N );
289 ostream & operator<< (ostream &,const SUPERV::SDate & D );