Salome HOME
72eed81da83e0ec3f3140671c857ce5dbd456e90
[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                 GraphEditor::DataFlow * DataFlowEditor ,
45                 const char * FuncName , 
46                 const SUPERV::ListOfStrings & PythonFunction ,
47                 const SUPERV::KindOfNode NodeKindOfNode = SUPERV::GOTONode ) ;
48     GNode_Impl( CORBA::ORB_ptr orb ,
49                 PortableServer::POA_ptr poa ,
50                 PortableServer::ObjectId * contId , 
51                 const char *instanceName ,
52                 const char *interfaceName ,
53                 GraphEditor::DataFlow * DataFlowEditor ,
54                 GraphBase::ListOfFuncName FuncNameList , 
55                 GraphBase::ListOfPythonFunctions PythonFunctionList ,
56                 const SUPERV::KindOfNode NodeKindOfNode = SUPERV::GOTONode ) ;
57     GNode_Impl( CORBA::ORB_ptr orb ,
58                 PortableServer::POA_ptr poa ,
59                 PortableServer::ObjectId * contId , 
60                 const char *instanceName ,
61                 const char *interfaceName ,
62                 GraphEditor::DataFlow * DataFlowEditor ,
63                 GraphEditor::InNode * DataFlowNode ) ;
64     virtual ~GNode_Impl() ;
65     virtual void destroy() ;
66     virtual bool Delete() ;
67
68     virtual bool SetCoupled( const char * anInLineNode ) {
69             GraphBase::InLineNode * CoupledINode = (GraphBase::InLineNode * ) DataFlowEditor()->GetGraphNode( anInLineNode ) ;
70 //            cout << Name() << ".SetCoupled " << anInLineNode << endl ;
71 //            if ( CoupledINode && ( IsGOTO() &&
72             if ( ( IsGOTO() &&
73                    ( CoupledINode->IsInLineNode() || CoupledINode->IsLoopNode() ||
74                      CoupledINode->IsSwitchNode() ) ) ||
75                  ( !IsGOTO() && ( IsLoop() || IsSwitch() ||
76                                   IsEndLoop() || IsEndSwitch() ) ) ) {
77               DataFlowNode()->CoupledNode( CoupledINode ) ;
78               if ( CoupledINode && IsSwitch() ) {
79                 DataFlowEditor()->AddLink( Name() , "Default" ,
80                                            CoupledINode->Name() , "Default" ) ;
81               }
82               else if ( CoupledINode && ( IsLoop() || IsEndLoop() ) ) {
83                 DataFlowEditor()->AddLink( Name() , "DoLoop" ,
84                                            CoupledINode->Name() , "DoLoop" ) ;
85               }
86               else if ( CoupledINode && IsGOTO() ) {
87                 DataFlowEditor()->AddLink( Name() , "OutGate" ,
88                                            CoupledINode->Name() , "InGate" ) ;
89               }
90 //              cout << "SetCoupled " << CoupledINode->Name() << endl ;
91               return  true ;
92             }
93 //            cout << Name() << ".SetCoupled ERROR " << anInLineNode << " " << CoupledINode
94 //                 << " of " << Kind() ;
95 //            if ( CoupledINode ) {
96 //              cout << " kinfOkCoupled " << CoupledINode->Kind() ;
97 //          }
98 //            cout << endl ;
99             return false ; } ;
100     virtual SUPERV::INode_ptr Coupled() ;
101
102     virtual GraphBase::GOTONode * BaseNode() {
103             return DataFlowNode()->GOTONode() ; } ;
104
105 } ;
106
107 #endif