Salome HOME
DCQ:prepare 2.0.0
[modules/superv.git] / src / Supervision / GNode_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   : GNode_Impl.hxx
8 //  Author : Jean Rahuel
9 //  Module : SUPERV
10 //  $Header: 
11
12 #ifndef _GNODE_IMPL_HXX_
13 #define _GNODE_IMPL_HXX_
14
15 //#include <iostream.h>
16
17 #include "CORBA.h"
18
19 #include <SALOMEconfig.h>
20 #include "SALOME_Component_i.hxx"
21 #include "SALOME_LifeCycleCORBA.hxx"
22
23 #include "INode_Impl.hxx"
24 #include "Port_Impl.hxx"
25
26 #include "DataFlowEditor_DataFlow.hxx"
27 #include "DataFlowExecutor_DataFlow.hxx"
28
29 class GNode_Impl : public INode_Impl ,
30                    public POA_SUPERV::GNode {
31   private:
32
33     CORBA::ORB_ptr             _Orb ;
34     PortableServer::POA_ptr    _Poa ;
35     PortableServer::ObjectId * _ContId ;
36
37   public:
38     GNode_Impl();
39     GNode_Impl( CORBA::ORB_ptr orb ,
40                 PortableServer::POA_ptr poa ,
41                 PortableServer::ObjectId * contId , 
42                 const char *instanceName ,
43                 const char *interfaceName ,
44                 const char *aDataFlowName ,
45                 const SUPERV::KindOfNode aKindOfNode ) ;
46     GNode_Impl( CORBA::ORB_ptr orb ,
47                 PortableServer::POA_ptr poa ,
48                 PortableServer::ObjectId * contId , 
49                 const char *instanceName ,
50                 const char *interfaceName ,
51                 GraphEditor::DataFlow * DataFlowEditor ,
52                 const char * FuncName , 
53                 const SUPERV::ListOfStrings & PythonFunction ,
54                 const SUPERV::KindOfNode NodeKindOfNode = SUPERV::GOTONode ) ;
55     GNode_Impl( CORBA::ORB_ptr orb ,
56                 PortableServer::POA_ptr poa ,
57                 PortableServer::ObjectId * contId , 
58                 const char *instanceName ,
59                 const char *interfaceName ,
60                 GraphEditor::DataFlow * DataFlowEditor ,
61                 GraphBase::ListOfFuncName FuncNameList , 
62                 GraphBase::ListOfPythonFunctions PythonFunctionList ,
63                 const SUPERV::KindOfNode NodeKindOfNode = SUPERV::GOTONode ) ;
64     GNode_Impl( CORBA::ORB_ptr orb ,
65                 PortableServer::POA_ptr poa ,
66                 PortableServer::ObjectId * contId , 
67                 const char *instanceName ,
68                 const char *interfaceName ,
69                 GraphEditor::DataFlow * DataFlowEditor ,
70                 GraphEditor::InNode * DataFlowNode ) ;
71     GNode_Impl( CORBA::ORB_ptr orb ,
72                 PortableServer::POA_ptr poa ,
73                 PortableServer::ObjectId * contId , 
74                 const char *instanceName ,
75                 const char *interfaceName ,
76                 GraphExecutor::DataFlow * DataFlowExecutor ,
77                 GraphExecutor::InNode * DataFlowExecutorNode ) ;
78     virtual ~GNode_Impl() ;
79     virtual void destroy() ;
80     virtual bool Delete() ;
81
82     virtual bool SetCoupled( const char * anInLineNode ) {
83             GraphBase::InLineNode * CoupledINode = (GraphBase::InLineNode * ) DataFlowEditor()->Graph()->GetGraphNode( anInLineNode ) ;
84 //            cout << Name() << ".SetCoupled " << anInLineNode << endl ;
85 //            if ( CoupledINode && ( IsGOTO() &&
86             if ( ( IsGOTO() &&
87                    ( CoupledINode->IsInLineNode() || CoupledINode->IsLoopNode() ||
88                      CoupledINode->IsSwitchNode() ) ) ||
89                  ( !IsGOTO() && ( IsLoop() || IsSwitch() ||
90                                   IsEndLoop() || IsEndSwitch() ) ) ) {
91               DataFlowNode()->CoupledNode( CoupledINode ) ;
92               if ( CoupledINode && IsSwitch() ) {
93                 DataFlowEditor()->AddLink( Name() , "Default" ,
94                                            CoupledINode->Name() , "Default" ) ;
95               }
96               else if ( CoupledINode && ( IsLoop() || IsEndLoop() ) ) {
97                 DataFlowEditor()->AddLink( Name() , "DoLoop" ,
98                                            CoupledINode->Name() , "DoLoop" ) ;
99               }
100               else if ( CoupledINode && IsGOTO() ) {
101                 DataFlowEditor()->AddLink( Name() , "OutGate" ,
102                                            CoupledINode->Name() , "InGate" ) ;
103               }
104 //              cout << "SetCoupled " << CoupledINode->Name() << endl ;
105               return  true ;
106             }
107 //            cout << Name() << ".SetCoupled ERROR " << anInLineNode << " " << CoupledINode
108 //                 << " of " << Kind() ;
109 //            if ( CoupledINode ) {
110 //              cout << " kinfOkCoupled " << CoupledINode->Kind() ;
111 //          }
112 //            cout << endl ;
113             return false ; } ;
114     virtual SUPERV::INode_ptr Coupled() ;
115
116     virtual GraphBase::GOTONode * BaseNode() {
117             return DataFlowNode()->GOTONode() ; } ;
118
119 } ;
120
121 #endif