1 // SUPERV GraphBase : contains fondamental classes for Services, Input Ports, Output Ports Links and Nodes.
3 // Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
22 // File : DataFlowBase_ComputingNode.hxx
23 // Author : Jean Rahuel, CEA
26 #ifndef _DATAFLOWBASE_COMPUTINGNODE_HXX
27 #define _DATAFLOWBASE_COMPUTINGNODE_HXX
29 #include "SALOME_NamingService.hxx"
31 #include "DataFlowBase_StreamNode.hxx"
43 class EndOfSwitchNode ;
45 class ComputingNode : public StreamNode {
50 SALOME_NamingService * _NamingService ;
51 //->StreamNode int * _Graph_prof_debug ;
52 //->StreamNode ofstream * _Graph_fdebug ;
53 SUPERV::CNode_var _Node_var ;
54 CNode_Impl * _Node_Impl ;
55 void * _InNode ; // From GraphExecutor:: or GraphEditor::
60 //->StreamNode char * _Name ;
61 //->StreamNode SUPERV::KindOfNode _Kind ;
62 SUPERV::SDate _FirstCreation ;
63 SUPERV::SDate _LastModification ;
64 char * _EditorRelease ;
68 //->StreamNode bool _HeadNode ;
69 //->StreamNode int _LevelNumber ;
70 //->StreamNode int _SubGraphNumber ;
73 //->StreamNode int _DataStreamInPortsNumber ;
74 //->StreamNode int _DataStreamOutPortsNumber ;
76 int _ConnectedInPortsNumber ;
77 int _DecrConnectedInPortsNumber ;
79 // For generated NodeNames with ServiceName : number of Nodes using
80 // the same ServiceName. It is not the same Service if it belongs to
81 // a different Interface and/or a different Component ...
82 //->StreamNode map< string , int > _MapOfServiceNames ;
84 // Nodes with LinkedInPortsNumber InPort(s) linked to Outport(s) of this node :
85 //->StreamNode map< string , int > _MapOfLinkedNodes ;
86 //->StreamNode int _LinkedNodesSize ;
87 //->StreamNode vector<ComputingNode * > _LinkedNodes ;
88 //->StreamNode vector<int > _LinkedInPortsNumber ;
98 ComputingNode( CORBA::ORB_ptr ORB ,
99 SALOME_NamingService* ptrNamingService ,
100 const char * DataFlowName ,
101 const SUPERV::KindOfNode DataFlowkind ,
102 int * Graph_prof_debug ,
103 ofstream * Graph_fdebug ) ;
104 ComputingNode( CORBA::ORB_ptr ORB ,
105 SALOME_NamingService* ptrNamingService ,
106 const SALOME_ModuleCatalog::Service& NodeService ,
107 const char *NodeName ,
108 const SUPERV::KindOfNode akind ,
109 const SUPERV::SDate NodeFirstCreation ,
110 const SUPERV::SDate NodeLastModification ,
111 const char * NodeEditorRelease ,
112 const char * NodeAuthor ,
113 const char * NodeComment ,
114 const bool GeneratedName ,
117 int * Graph_prof_debug = NULL ,
118 ofstream * Graph_fdebug = NULL ) ;
119 virtual ~ComputingNode() ;
121 SALOME_NamingService * NamingService() const {
122 return _NamingService ; } ;
124 SUPERV::CNode_var ObjRef() const {
125 // char * _NodeName ;
126 // cdebug << "ComputingNode::ObjRef() " << _Node << " " << Name()
128 // SUPERV::CNode_var _NodeObjRef = SUPERV::CNode::_narrow( _Node ) ;
129 // if ( CORBA::is_nil( _NodeObjRef ) ) {
130 // _NodeName = "NilRef" ;
134 // _NodeName = _NodeObjRef->Name() ;
137 // _NodeName = "Catch Error" ;
140 // cdebug << _NodeName << " " << Name() << endl ;
141 return _Node_var ; } ;
142 void SetObjRef( SUPERV::CNode_var aNode_var ) {
143 // char * _NodeName ;
144 // if ( CORBA::is_nil( _Node ) ) {
145 // _NodeName = "NilRef" ;
148 // _NodeName = _Node->Name() ;
150 // cdebug << "ComputingNode::SetObjRef( " << _Node << " "
151 // << _NodeName << " ) " << Name() << " --> " ;
152 _Node_var = aNode_var ;
153 // cdebug << _Node << " " << _Node->Name() << " ) " << Name() << endl ;
156 CNode_Impl * ObjImpl() const { return _Node_Impl ; } ;
157 void SetObjImpl( CNode_Impl * aNode_Impl ) {
158 _Node_Impl = aNode_Impl ; } ;
160 void InNode( void * anInNode ) {
161 // cdebug << "GraphBase::ComputingNode::InNode " << Name() << endl ;
162 _InNode = anInNode ; } ;
163 void * GetInNode() const {
166 void ObjInterface( bool k_interface ) { _ObjInterface = k_interface ; } ;
167 bool ObjInterface() { return _ObjInterface ; } ;
169 pthread_t ThreadNo() { return _ThreadNo ; } ;
170 void ThreadNo( pthread_t aThread ) { _ThreadNo = aThread ; } ;
172 //->StreamNode char * Name() const { return my_strdup( _Name ) ; } ;
173 //->StreamNode const char *const * NamePtr() const { return &_Name ; } ;
174 // const SALOME_ModuleCatalog::Service * Service() const ;
175 SUPERV::SDate FirstCreation() const ;
176 SUPERV::SDate LastModification() const ;
177 //JR 17.02.2005 Memory Leak char* Author() const { return my_strdup( _Author ) ; } ;
178 char* Author() const { return _Author ; } ;
179 //JR 17.02.2005 Memory Leak char* EditorRelease() const { return my_strdup( _EditorRelease ) ; } ;
180 char* EditorRelease() const { return _EditorRelease ; } ;
181 //JR 17.02.2005 Memory Leak char * Comment() const { return my_strdup( _Comment ) ; } ;
182 char * Comment() const { return _Comment ; } ;
183 int XCoordinate() const { return _X ; } ;
184 int YCoordinate() const { return _Y ; } ;
186 //->StreamNode bool Name( const char * aName ) ;
187 // void Service( const SALOME_ModuleCatalog::Service aService ) ;
188 void FirstCreation( const SUPERV::SDate aFirstCreation ) ;
189 void LastModification( const SUPERV::SDate aLastModification ) ;
190 bool Author( const char * anAuthor ) ;
191 bool EditorRelease( const char* anEditorRelease ) ;
192 bool Comment( const char *c ) ;
193 void Coordinates( const int X , const int Y ) {
194 _X = X ; _Y = Y ; } ;
196 void NodePort( const char * NodeName ,
197 const char * ServiceParameterName ,
198 char ** aNode , char ** aPort ) ;
200 bool IsLinked(const char * ToServiceParameterName, bool isInput ) ; // mkr : PAL8060
201 bool HasInput(const char * ToServiceParameterName ) ;
203 GraphBase::SNode * GetInfo() ;
205 // void HeadNode( bool aHeadNode ) { _HeadNode = aHeadNode ; } ;
206 // const bool IsHeadNode() const { return _HeadNode ; } ;
208 bool RemovePorts( const char* aNodeName ) ;
210 void SetMacroPorts( GraphBase::Graph * aGraph ) ;
211 void UpdateMacroPorts( GraphBase::Graph * aGraph ) ;
212 void SetMacroDatas( GraphBase::Graph * aGraph , GraphBase::Graph * aGraphOfMacroGraph ) ;
214 void DelInPort( const char * InputParameterName ) ;
215 void DelOutPort( const char * OutputParameterName ) ;
217 InPort * AddInPort( const char * InputParameterName ,
218 const char * InputParameterType ,
219 const SUPERV::KindOfPort aKindOfPort ,
221 OutPort * AddOutPort( const char * OutputParameterName ,
222 const char * OutputParameterType ,
223 const SUPERV::KindOfPort aKindOfPort ,
226 void DelInDataStreamPort( const char * InputParameterName ) ;
227 void DelOutDataStreamPort( const char * OutputParameterName ) ;
229 InDataStreamPort * AddInDataStreamPort( const char * InputParameterName ,
230 const char * InputParameterType ,
231 const SALOME_ModuleCatalog::DataStreamDependency aDependency ,
232 const SUPERV::KindOfPort aKindOfPort ,
234 OutDataStreamPort * AddOutDataStreamPort( const char * OutputParameterName ,
235 const char * OutputParameterType ,
236 const SALOME_ModuleCatalog::DataStreamDependency aDependency ,
237 const SUPERV::KindOfPort aKindOfPort ,
240 // ComputingNode * LinkedNodes( int i ) const { return (GraphBase::ComputingNode *) GraphBase::StreamNode::LinkedNodes( i ) ; } ;
242 void AddLinkedNode( GraphBase::ComputingNode * ToNode ) {
243 GraphBase::StreamNode::AddLinkedNode( ToNode ) ;
244 cdebug << Name() << "->GraphBase::ComputingNode::AddLinkedNode( " << ToNode->Name()
245 << ") ConnectedInPortsNumber " << ToNode->ConnectedInPortsNumber()
246 << " + 1 Service " << ServiceName() << endl ;
247 ToNode->IncrConnectedInPortsNumber() ; } ;
249 bool RemoveLinkedNode( GraphBase::ComputingNode * ToNode ,
250 bool DoLinkedFromNode = true ) {
251 bool RetVal = GraphBase::StreamNode::RemoveLinkedNode( ToNode , DoLinkedFromNode ) ;
253 cdebug << "ComputingNode::RemoveLinkedNode to " << ToNode->Name() << " from "
254 << Name() << " ConnectedInPortsNumber "
255 << ToNode->ConnectedInPortsNumber() - 1 << endl ;
256 ToNode->DecrConnectedInPortsNumber() ;
260 void ReNameLinkedNode( const char* OldNodeName ,
261 const char* NewNodeName ) {
262 GraphBase::StreamNode::ReNameLinkedNode( OldNodeName , NewNodeName ) ; } ;
264 void IncrConnectedInPortsNumber() {
265 cdebug << "ComputingNode::IncrConnectedInPortsNumber " << Name() << " -> "
266 << _ConnectedInPortsNumber+1 << endl ;
267 _ConnectedInPortsNumber++ ; } ;
268 void DecrConnectedInPortsNumber() {
269 cdebug << "ComputingNode::DecrConnectedInPortsNumber " << Name() << " -> "
270 << _ConnectedInPortsNumber-1 << endl ;
271 _ConnectedInPortsNumber-- ; } ;
272 int ConnectedInPortsNumber() const {
273 return _ConnectedInPortsNumber ; } ;
274 void ConnectedInPortsNumber( int c ) {
275 cdebug << "ConnectedInPortsNumber " << Name() << " -> " << c << endl ;
276 _ConnectedInPortsNumber = c ; } ;
278 void IncrDecrConnectedInPortsNumber(const int cnt ) {
279 _DecrConnectedInPortsNumber += cnt ; } ;
280 bool DecrIncrDecrConnectedInPortsNumber() {
281 if ( _DecrConnectedInPortsNumber ) {
282 _ConnectedInPortsNumber = _ConnectedInPortsNumber -
283 _DecrConnectedInPortsNumber ;
284 _DecrConnectedInPortsNumber = 0 ;
289 bool CheckLoop( GraphBase::LoopNode * aLoopNode ,
290 GraphBase::EndOfLoopNode * anEndLoopNode ,
291 string & anErrorMessage ) const ;
292 bool CheckEndLoop( GraphBase::LoopNode * aLoopNode ,
293 GraphBase::EndOfLoopNode * anEndLoopNode ,
294 string & anErrorMessage ) const ;
295 bool InitBranchOfSwitchDone( bool AllInit , GraphBase::EndOfSwitchNode * anEndSwitchNode ,
296 string & anErrorMessage ) ;
297 bool CheckSwitch( GraphBase::EndOfSwitchNode * anEndSwitchNode ,
298 string & anErrorMessage ) ;
300 // const GraphBase::ListOfParameters * GetListOfParameters() const ;
302 const long CpuUsed() ;
304 bool SaveXML( QDomDocument & Graph , QDomElement & info ,
305 int X , int Y ) const {
306 ListOfFuncName aFuncNames ;
307 GraphBase::ListOfPythonFunctions aVoidList ;
308 return SaveXML( Graph , info , "" , "" , "" , "" , aFuncNames , aVoidList ,
311 bool SavePY( ostream &f , const char * aGraphName ,
312 int X , int Y ) const {
313 ListOfFuncName aFuncNames ;
314 GraphBase::ListOfPythonFunctions aVoidList ;
315 return SavePY( f , aGraphName , "" , "" , "" , NULL , aFuncNames , aVoidList ,
317 // bool SaveXML(ostream &f , char *Tabs ,
318 bool SaveXML(QDomDocument & Graph , QDomElement & info ,
319 const char * ComponentName ,
320 const char * InterfaceName ,
321 const char * Computer ,
322 const char * CoupledNode ,
323 const ListOfFuncName FuncNames ,
324 const GraphBase::ListOfPythonFunctions PythonFunctions ,
325 int X , int Y ) const ;
327 bool SavePY(ostream &f , const char * aGraphName ,
328 const char * ComponentName ,
329 const char * InterfaceName ,
330 const char * Computer ,
331 const GraphBase::InLineNode * aCoupledNode ,
332 const ListOfFuncName FuncNames ,
333 const GraphBase::ListOfPythonFunctions PythonFunctions ,
334 int X , int Y ) const ;
336 void NodeInfo(ostream & s) const ;
338 void ListLinks(ostream &f ) const ;
344 ostream & operator<< (ostream &,const GraphBase::ComputingNode & N );
346 ostream & operator<< (ostream &,const SUPERV::SDate & D );