Salome HOME
78c085c0d616be4a4b968591fc3bc162469d5b02
[modules/superv.git] / src / Supervision / CNode_Impl.hxx
1 //  SUPERV Supervision : contains the implementation of interfaces of SuperVision described in SUPERV.idl
2 //
3 //  Copyright (C) 2003  CEA/DEN, EDF R&D
4 //
5 //
6 //
7 //  File   : CNode_Impl.hxx
8 //  Author : Jean Rahuel
9 //  Module : SUPERV
10 //  $Header: 
11
12 #ifndef _CNODE_IMPL_HXX_
13 #define _CNODE_IMPL_HXX_
14
15 #include <iostream>
16
17 #include "CORBA.h"
18
19 #include <SALOMEconfig.h>
20 #include "SALOME_Component_i.hxx"
21 #include "SALOME_LifeCycleCORBA.hxx"
22
23 #include "DataFlowEditor_DataFlow.hxx"
24 #include "DataFlowExecutor_DataFlow.hxx"
25
26 class CNode_Impl : public POA_SUPERV::CNode ,
27                    public Engines_Component_i  {
28   private:
29
30     CORBA::ORB_ptr             _Orb ;
31     PortableServer::POA_ptr    _Poa ;
32     PortableServer::ObjectId * _ContId ;
33
34     GraphEditor::DataFlow   * _DataFlowEditor ;
35     GraphEditor::InNode     * _DataFlowNode ;
36     bool _IsNode ;
37
38   public:
39     CNode_Impl();
40     CNode_Impl( CORBA::ORB_ptr orb ,
41                 PortableServer::POA_ptr poa ,
42                 PortableServer::ObjectId * contId , 
43                 const char *instanceName ,
44                 const char *interfaceName ,
45                 const char *aDataFlowName ,
46                 const SUPERV::KindOfNode aKindOfNode ) ;
47     CNode_Impl( CORBA::ORB_ptr orb ,
48                 PortableServer::POA_ptr poa ,
49                 PortableServer::ObjectId * contId , 
50                 const char *instanceName ,
51                 const char *interfaceName ,
52                 GraphEditor::DataFlow * DataFlowEditor ,
53                 const SALOME_ModuleCatalog::Service &NodeService ,
54                 const char * NodeName = NULLSTRING ,
55                 const SUPERV::KindOfNode NodeKindOfNode = SUPERV::ComputingNode ,
56                 const char * aFuncName = NULLSTRING ,
57                 const SUPERV::ListOfStrings & aPythonFunction = SUPERV::ListOfStrings() ) ;
58     CNode_Impl( CORBA::ORB_ptr orb ,
59                 PortableServer::POA_ptr poa ,
60                 PortableServer::ObjectId * contId , 
61                 const char *instanceName ,
62                 const char *interfaceName ,
63                 GraphEditor::DataFlow * DataFlowEditor ,
64                 const SALOME_ModuleCatalog::Service &NodeService ,
65                 const char * NodeName = NULLSTRING ,
66                 const SUPERV::KindOfNode NodeKindOfNode = SUPERV::InLineNode ,
67                 const GraphBase::ListOfFuncName & aFuncName = GraphBase::ListOfFuncName() ,
68                 const GraphBase::ListOfPythonFunctions & aPythonFunction = GraphBase::ListOfPythonFunctions() ) ;
69     CNode_Impl( CORBA::ORB_ptr orb ,
70                 PortableServer::POA_ptr poa ,
71                 PortableServer::ObjectId * contId , 
72                 const char *instanceName ,
73                 const char *interfaceName ,
74                 GraphEditor::DataFlow * DataFlowEditor ,
75                 GraphEditor::InNode * DataFlowNode ) ;
76     virtual ~CNode_Impl() ;
77     virtual void destroy() ;
78     virtual bool Delete() ;
79
80     void DeletePorts() ;
81
82     virtual void DataFlowEditor( GraphEditor::DataFlow * DataFlowEditor ) {
83             _DataFlowEditor = DataFlowEditor ; } ;
84     virtual GraphEditor::DataFlow * DataFlowEditor() {
85             return _DataFlowEditor ; } ;
86
87     virtual GraphExecutor::DataFlow * DataFlowExecutor() {
88             return DataFlowEditor()->Executor(); } ;
89
90     virtual void DataFlowNode( GraphEditor::InNode * DataFlowNode ) {
91             _DataFlowNode = DataFlowNode ; } ;
92     virtual GraphEditor::InNode * DataFlowNode() {
93             return _DataFlowNode ; } ;
94
95     virtual char * Name() ;
96     virtual bool SetName( const char * aDataFlowName ) ;
97     virtual SALOME_ModuleCatalog::Service * Service() ;
98     virtual SUPERV::KindOfNode Kind() ;
99     virtual SUPERV::SDate CreationDate() ;
100     virtual SUPERV::SDate LastUpdateDate() ;
101     virtual char * Version() ;
102     virtual char * Author() ;
103     virtual bool SetAuthor( const char * aDataFlowAuthor ) ;
104     virtual char * Comment() ;
105     virtual bool SetComment( const char * aDataFlowComment ) ;
106
107     virtual GraphEditor::InNode * DataFlowNode() const {
108             return _DataFlowNode ; } ;
109     virtual GraphBase::ComputingNode * BaseNode() {
110             return DataFlowNode()->ComputingNode() ; } ;
111
112     virtual SUPERV::CNode_var ObjRef() {
113             SUPERV::CNode_var iobject = SUPERV::GNode::_nil() ;
114             if ( DataFlowNode() && _IsNode ) {
115               iobject = SUPERV::CNode::_narrow( DataFlowNode()->ObjRef() ) ;
116             }
117             else {
118               iobject = SUPERV::CNode::_narrow( DataFlowEditor()->Graph()->ObjRef() ) ;
119             }
120             return iobject ; } ;
121     virtual void SetObjRef(SUPERV::CNode_var aNode ) {
122             if ( DataFlowNode() && _IsNode ) {
123               DataFlowNode()->SetObjRef( aNode ) ;
124             }
125             else {
126               if ( DataFlowEditor() ) {
127                 DataFlowEditor()->Graph()->SetObjRef( SUPERV::Graph::_narrow( aNode ) ) ;
128               }
129               if ( DataFlowExecutor() ) {
130                 DataFlowExecutor()->Graph()->SetObjRef( SUPERV::Graph::_narrow( aNode ) ) ;
131               }
132
133             }
134           } ;
135
136     virtual CNode_Impl * ObjImpl() {
137             CNode_Impl * objimpl = NULL ;
138             if ( DataFlowNode() && _IsNode ) {
139               objimpl = DataFlowNode()->ObjImpl() ;
140             }
141             else {
142               objimpl = DataFlowEditor()->Graph()->ObjImpl() ;
143             }
144             return objimpl ; } ;
145     virtual void SetObjImpl( CNode_Impl * objimpl  ) {
146             if ( DataFlowNode() && _IsNode ) {
147               DataFlowNode()->SetObjImpl( objimpl ) ;
148             }
149             else {
150               if ( DataFlowEditor() ) {
151                 DataFlowEditor()->Graph()->SetObjImpl( objimpl ) ;
152               }
153               if ( DataFlowExecutor() ) {
154                 DataFlowExecutor()->Graph()->SetObjImpl( objimpl ) ;
155               }
156
157             }
158           } ;
159
160     virtual void Coords( const long X , const long Y ) ;
161     virtual long X() ;
162     virtual long Y() ;
163
164     virtual SUPERV::Port_ptr Port( const char * aParameterName ) ;
165
166 //    virtual bool BusPorts( const char * InputParameterName ,
167 //                           const char * InputParameterType ,
168 //                           const char * OutputParameterName ,
169 //                           const char * OutputParameterType ,
170 //                           SUPERV::Port_out InputPort ,
171 //                           SUPERV::Port_out OutputPort ) ;
172
173 //    virtual SUPERV::Link_ptr Link( const char * ToServiceParameterName ,
174 //                                    const SUPERV::Value_ptr aValue ) ;
175
176     virtual SUPERV::Port_ptr Input( const char * ToServiceParameterName ,
177                                     const SUPERV::Value_ptr aValue ) ;
178 //    virtual bool InputOfAny( const char * ToServiceParameterName ,
179 //                             const CORBA::Any & aValue ) ;
180
181     virtual SUPERV::Port_ptr GetInPort( const char * aParameterName ) ;
182     virtual SUPERV::Port_ptr GetOutPort( const char * aParameterName ) ;
183
184     virtual SUPERV::StreamPort_ptr GetInStreamPort( const char * aParameterName ) ;
185     virtual SUPERV::StreamPort_ptr GetOutStreamPort( const char * aParameterName ) ;
186
187     virtual SUPERV::ListOfPorts * Ports() ;
188     virtual SUPERV::ListOfStreamPorts * StreamPorts() ;
189
190     virtual bool HasStreamPort() ;
191
192     virtual SUPERV::ListOfLinks * Links() ;
193     virtual SUPERV::ListOfStreamLinks * StreamLinks() ;
194
195     virtual SUPERV::Link_ptr GetLink( const char * ToServiceParameterName ) ;
196     virtual SUPERV::StreamLink_ptr GetStreamLink( const char * ToServiceParameterName ) ;
197
198     virtual bool IsStreamGraph() ;
199     virtual bool IsGraph() ;
200     virtual bool IsMacro() ;
201     virtual bool IsFlowMacro() ;
202     virtual bool IsStreamMacro() ;
203     virtual bool IsHeadGraph() ;
204     virtual long GraphLevel() ;
205     virtual bool IsComputing() ;
206     virtual bool IsFactory() ;
207     virtual bool IsInLine() ;
208     virtual bool IsGOTO() ;
209     virtual bool IsLoop() ;
210     virtual bool IsEndLoop() ;
211     virtual bool IsSwitch() ;
212     virtual bool IsEndSwitch() ;
213
214     virtual long SubGraph() ;
215     virtual long SubStreamGraph() ;
216
217     virtual bool IsLinked(const char * ToServiceParameterName ) ;
218     virtual bool HasInput(const char * ToServiceParameterName ) ;
219
220 //    virtual SUPERV::Link_ptr GetLink(const char * ToServiceParameterName ) ;
221 //    virtual SUPERV::Value_ptr GetValue(const char * FromServiceParameterName ) ;
222
223     virtual bool IsReady() ;
224     virtual bool IsWaiting() ;
225     virtual bool IsRunning() ;
226     virtual bool IsDone() ;
227     virtual bool IsSuspended() ;
228
229     virtual SUPERV::GraphState State() ;
230     virtual SUPERV::ControlState Control() ;
231     virtual void ControlClear() ;
232
233     virtual long Thread() ;
234
235     GraphExecutor::AutomatonState AutoState() ;
236
237     virtual bool ReadyW() ;
238     virtual bool RunningW() ;
239     virtual bool DoneW() ;
240     virtual bool SuspendedW() ;
241
242     virtual void ping() ;
243     virtual bool ContainerKill() ;
244
245     virtual bool Kill() ;
246     virtual bool KillDone() ;
247     virtual bool Stop() ;
248     virtual bool Suspend() ;
249     virtual bool SuspendDone() ;
250     virtual bool Resume() ;
251
252     virtual long CpuUsed() ;
253
254     virtual bool IsExecuting();
255
256 } ;
257
258 #endif