1 //=============================================================================
2 // File : DataFlowBase_ComputingNode.hxx
4 // Author : Jean Rahuel, CEA
7 //=============================================================================
9 #ifndef _DATAFLOWBASE_NODE_HXX
10 #define _DATAFLOWBASE_NODE_HXX
12 #include "DataFlowBase_PortsOfNode.hxx"
18 class ComputingNode : public PortsOfNode {
23 SALOME_NamingService * _NamingService ;
24 int * _Graph_prof_debug ;
25 ostream * _Graph_fdebug ;
26 SUPERV::CNode_var _Node ;
27 void * _InNode ; // From GraphExecutor:: or GraphEditor::
33 SUPERV::KindOfNode _Kind ;
34 SUPERV::SDate _FirstCreation ;
35 SUPERV::SDate _LastModification ;
36 char * _EditorRelease ;
45 int _ConnectedInPortsNumber ;
46 int _DecrConnectedInPortsNumber ;
48 // For generated NodeNames with ServiceName : number of Nodes using
49 // the same ServiceName. It is not the same Service if it belongs to
50 // a different Interface and/or a different Component ...
51 map< string , int > _MapOfServiceNames ;
53 // Nodes with LinkedInPortsNumber InPort(s) linked to Outport(s) of this node :
54 map< string , int > _MapOfLinkedNodes ;
55 int _LinkedNodesSize ;
56 vector<ComputingNode * > _LinkedNodes ;
57 vector<int > _LinkedInPortsNumber ;
67 ComputingNode( CORBA::ORB_ptr ORB ,
68 SALOME_NamingService* ptrNamingService ,
69 const char * DataFlowName ,
70 int * Graph_prof_debug = NULL ,
71 ostream * Graph_fdebug = NULL ) ;
72 ComputingNode( CORBA::ORB_ptr ORB ,
73 SALOME_NamingService* ptrNamingService ,
74 const SALOME_ModuleCatalog::Service& NodeService ,
75 const char *NodeName ,
76 const SUPERV::KindOfNode akind ,
77 const SUPERV::SDate NodeFirstCreation ,
78 const SUPERV::SDate NodeLastModification ,
79 const char * NodeEditorRelease ,
80 const char * NodeAuthor ,
81 const char * NodeComment ,
82 const bool GeneratedName ,
85 int * Graph_prof_debug = NULL ,
86 ostream * Graph_fdebug = NULL ) ;
87 virtual ~ComputingNode() ;
89 SALOME_NamingService * NamingService() const {
90 return _NamingService ; } ;
92 SUPERV::CNode_var ObjRef() const { return _Node ; } ;
93 void SetObjRef(SUPERV::CNode_var aNode) {
95 void InNode( void * anInNode ) {
96 // cdebug << "GraphBase::ComputingNode::InNode " << Name() << endl ;
97 _InNode = anInNode ; } ;
98 void * GetInNode() const {
101 void ObjInterface( bool k_interface ) { _ObjInterface = k_interface ; } ;
102 bool ObjInterface() { return _ObjInterface ; } ;
104 pthread_t ThreadNo() { return _ThreadNo ; } ;
105 void ThreadNo( pthread_t aThread ) { _ThreadNo = aThread ; } ;
107 char * Name() const { return my_strdup( _Name ) ; } ;
108 const char *const * NamePtr() const { return &_Name ; } ;
109 SUPERV::KindOfNode Kind() const {
111 // const SALOME_ModuleCatalog::Service * Service() const ;
112 SUPERV::SDate FirstCreation() const ;
113 SUPERV::SDate LastModification() const ;
114 char* Author() const { return my_strdup( _Author ) ; } ;
115 char* EditorRelease() const { return my_strdup( _EditorRelease ) ; } ;
116 char * Comment() const { return my_strdup( _Comment ) ; } ;
117 int XCoordinate() const { return _X ; } ;
118 int YCoordinate() const { return _Y ; } ;
120 bool Name( const char * aName ) ;
121 bool Kind( SUPERV::KindOfNode aKind) ;
122 // void Service( const SALOME_ModuleCatalog::Service aService ) ;
123 void FirstCreation( const SUPERV::SDate aFirstCreation ) ;
124 void LastModification( const SUPERV::SDate aLastModification ) ;
125 bool Author( const char * anAuthor ) ;
126 bool EditorRelease( const char* anEditorRelease ) ;
127 bool Comment( const char *c ) ;
128 void Coordinates( const int X , const int Y ) {
129 _X = X ; _Y = Y ; } ;
131 void NodePort( const char * NodeName ,
132 const char * ServiceParameterName ,
133 char ** aNode , char ** aPort ) ;
135 bool IsLinked(const char * ToServiceParameterName ) ;
136 bool HasInput(const char * ToServiceParameterName ) ;
138 GraphBase::SNode * GetInfo() ;
140 const bool IsComputingNode() const {
141 return (_Kind == SUPERV::ComputingNode ) ; } ;
142 const bool IsFactoryNode() const {
143 return (_Kind == SUPERV::FactoryNode ) ; } ;
144 const bool IsOneOfGOTONodes() const {
145 return (_Kind == SUPERV::LoopNode ||
146 _Kind == SUPERV::EndLoopNode ||
147 _Kind == SUPERV::SwitchNode ||
148 _Kind == SUPERV::EndSwitchNode ||
149 _Kind == SUPERV::GOTONode ) ; } ;
150 const bool IsOneOfInLineNodes() const {
151 return (_Kind == SUPERV::InLineNode || IsOneOfGOTONodes() ) ; } ;
152 const bool IsInLineNode() const {
153 return (_Kind == SUPERV::InLineNode ) ; } ;
154 const bool IsDataFlowNode() const {
155 return (_Kind == SUPERV::DataFlowNode ) ; } ;
156 const bool IsLoopNode() const {
157 return (_Kind == SUPERV::LoopNode ) ; } ;
158 const bool IsEndLoopNode() const {
159 return (_Kind == SUPERV::EndLoopNode ) ; } ;
160 const bool IsSwitchNode() const {
161 return (_Kind == SUPERV::SwitchNode ) ; } ;
162 const bool IsEndSwitchNode() const {
163 return (_Kind == SUPERV::EndSwitchNode ) ; } ;
164 const bool IsGOTONode() const {
165 return (_Kind == SUPERV::GOTONode ) ; } ;
166 void HeadNode( bool aHeadNode ) { _HeadNode = aHeadNode ; } ;
167 const bool IsHeadNode() const { return _HeadNode ; } ;
169 bool RemovePorts( const char* aNodeName ) ;
171 InPort * AddInPort( const char * InputParameterName ,
172 const char * InputParameterType ) ;
173 OutPort * AddOutPort( const char * OutputParameterName ,
174 const char * OutputParameterType ) ;
176 void AddLink( ComputingNode * aNode ) ;
177 void RemoveLink( ComputingNode * aNode ) ;
178 void ReNameLink( const char* OldNodeName ,
179 const char* NewNodeName ) ;
181 int GetServiceNameNumber( const char * name ) {
182 int num = _MapOfServiceNames[ name ] ;
184 _MapOfServiceNames[ name ] = 1 ;
187 _MapOfServiceNames[ name ] = num + 1 ;
189 return _MapOfServiceNames[ name ] ; } ;
191 void IncrConnectedInPortsNumber() {
192 cdebug << "IncrConnectedInPortsNumber " << Name() << " -> "
193 << _ConnectedInPortsNumber+1 << endl ;
194 _ConnectedInPortsNumber++ ; } ;
195 void DecrConnectedInPortsNumber() {
196 _ConnectedInPortsNumber-- ; } ;
197 int ConnectedInPortsNumber() const {
198 return _ConnectedInPortsNumber ; } ;
199 void ConnectedInPortsNumber( int c ) {
200 cdebug << "ConnectedInPortsNumber " << Name() << " -> " << c << endl ;
201 _ConnectedInPortsNumber = c ; } ;
203 void IncrDecrConnectedInPortsNumber(const int cnt ) {
204 _DecrConnectedInPortsNumber += cnt ; } ;
205 bool DecrIncrDecrConnectedInPortsNumber() {
206 if ( _DecrConnectedInPortsNumber ) {
207 _ConnectedInPortsNumber = _ConnectedInPortsNumber -
208 _DecrConnectedInPortsNumber ;
209 _DecrConnectedInPortsNumber = 0 ;
214 int GetLinkedNodeIndex( const char * name ) {
215 int index = _MapOfLinkedNodes[ name ] -1 ;
217 cdebug << "GetLinkedNodeIndex of " << name
218 << " in _MapOfLinkedNodes : "
219 << index << " Node " << hex << (void *) _LinkedNodes[ index ]
220 << dec << " '" << _LinkedNodes[ index ]->Name() << "'"
224 void SetLinkedNodeIndex( const char * name , const int index ) {
225 _MapOfLinkedNodes[ name ] = index +1 ;
226 cdebug << "SetLinkedNodeIndex of " << name << " in _MapOfLinkedNodes : "
227 << index << " Node " << hex << (void *) _LinkedNodes[ index ]
228 << dec << " '" << _LinkedNodes[ index ]->Name() << "'"
229 << " _MapOfLinkedNodes " << _MapOfLinkedNodes[ name ] - 1
232 void DelLinkedNodeIndex( const char * name ) {
233 _MapOfLinkedNodes.erase( name ) ; } ;
234 int LinkedNodesSize() const { return _LinkedNodesSize ; } ;
235 ComputingNode * LinkedNodes( int i ) const { return _LinkedNodes[ i ] ; } ;
236 const int LinkedInPortsNumber( int i ) const { return _LinkedInPortsNumber[ i ] ; } ;
238 int Level() { return _LevelNumber ; } ;
239 void Level( int LevelNumber ) {
240 _LevelNumber = LevelNumber ; } ;
241 int SubGraph() { return _SubGraphNumber ; } ;
242 void SubGraph( int SubGraphNumber ) {
243 _SubGraphNumber = SubGraphNumber ; } ;
245 // const GraphBase::ListOfParameters * GetListOfParameters() const ;
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(ostrstream & s) const ;
281 void ListLinks(ostream &f ) const ;
287 ostream & operator<< (ostream &,const GraphBase::ComputingNode & N );
289 ostream & operator<< (ostream &,const SUPERV::SDate & D );