Salome HOME
PAL8521
[modules/superv.git] / src / Supervision / LNode_Impl.cxx
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   : LNode_Impl.cxx
8 //  Author : Jean Rahuel
9 //  Module : SUPERV
10 //  $Header: 
11
12 using namespace std;
13 #include <stdio.h>
14 #include <fstream>
15 //#include <sstream>
16 #include <string>
17
18 //#include "utilities.h"
19
20 #include "LNode_Impl.hxx"
21
22 LNode_Impl::LNode_Impl() {
23 }
24
25 LNode_Impl::LNode_Impl( CORBA::ORB_ptr orb ,
26                         PortableServer::POA_ptr poa ,
27                         PortableServer::ObjectId * contId , 
28                         const char *instanceName ,
29                         const char *interfaceName ,
30                         GraphEditor::DataFlow * aDataFlowEditor ,
31                         GraphBase::ListOfFuncName FuncNameList ,
32                         GraphBase::ListOfPythonFunctions PythonFunctionList ,
33 //                        const char * InitName , 
34 //                        const SUPERV::ListOfStrings & anInitPythonFunction ,
35 //                        const char * MoreName , 
36 //                        const SUPERV::ListOfStrings & aMorePythonFunction ,
37 //                        const char * NextName , 
38 //                        const SUPERV::ListOfStrings & aNextPythonFunction ,
39                         const SUPERV::KindOfNode NodeKindOfNode ) :
40 //  Engines_Component_i(orb, poa, contId, instanceName, interfaceName, false, false) {
41 //  GNode_Impl( orb , poa , contId , instanceName , interfaceName , aDataFlowEditor , InitName , anInitPythonFunction , NodeKindOfNode ) {
42   GNode_Impl( orb , poa , contId , instanceName , interfaceName , aDataFlowEditor , FuncNameList , PythonFunctionList , NodeKindOfNode ) {
43 //  MESSAGE( NodeName << " " );
44   beginService( "LNode_Impl::LNode_Impl" );
45   _thisObj = this ;
46   _id = _poa->activate_object(_thisObj);
47   _Orb = CORBA::ORB::_duplicate(orb);
48   _Poa = poa ;
49   _ContId = contId ;
50 //  DataFlowNode()->SetPyMorePythonFunction( MoreName , aMorePythonFunction ) ;
51 //  DataFlowNode()->SetPyNextPythonFunction( NextName , aNextPythonFunction ) ;
52   endService( "LNode_Impl::LNode_Impl" );  
53 }
54
55 LNode_Impl::LNode_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 * aDataFlowEditor ,
61                       GraphEditor::InNode * aDataFlowNode ) :
62 //  Engines_Component_i(orb, poa, contId, instanceName, interfaceName, false, false) {
63   GNode_Impl( orb , poa , contId , instanceName , interfaceName , aDataFlowEditor , aDataFlowNode ) {
64   MESSAGE( DataFlowNode()->Name() << " " );
65   beginService( "LNode_Impl::LNode_Impl" );
66   _thisObj = this ;
67   _id = _poa->activate_object(_thisObj);
68   _Orb = CORBA::ORB::_duplicate(orb);
69   _Poa = poa ;
70   _ContId = contId ;
71   endService( "LNode_Impl::LNode_Impl" );  
72 }
73
74 LNode_Impl::~LNode_Impl() {
75   beginService( "LNode_Impl::~LNode_Impl" );
76   endService( "LNode_Impl::~LNode_Impl" );
77 }
78
79 void LNode_Impl::destroy() {
80   beginService( "LNode_Impl::Destroy" );
81   if ( DataFlowEditor()->IsEditing() ) {
82     SUPERV::GNode_ptr aCoupled = SUPERV::GNode::_narrow( Coupled() ) ;
83     if ( Delete() ) {
84       _poa->deactivate_object(*_id) ;
85       CORBA::release(_poa) ;
86       delete(_id) ;
87       _thisObj->_remove_ref();
88     }
89     else {
90       MESSAGE("LNode_Impl::destroy ERROR ") ;
91     }
92     if ( !CORBA::is_nil( aCoupled ) ) {
93 //      aCoupled->SetCoupled( "" ) ; : Used in GraphBase::Graph::RemoveNode( EndLoopNode ) :
94       aCoupled->destroy() ;
95     }
96 // Valid() only after deletion of the corresponding EndLoopNode :
97     DataFlowEditor()->UnValid() ;
98   }
99   endService( "LNode_Impl::Destroy" );
100 }
101
102 bool LNode_Impl::Delete() {
103   beginService( "LNode_Impl::Delete" );
104   bool RetVal = false ;  
105   if ( DataFlowEditor()->IsEditing() ) {
106     DeletePorts() ;
107     RetVal = DataFlowEditor()->RemoveNode( Name() ) ;
108 // Valid() only after deletion of the corresponding EndLoopNode :
109 //    if ( RetVal ) {
110 //      RetVal = DataFlowEditor()->IsValid() ;
111 //    }
112   }
113   endService( "LNode_Impl::Delete" );
114   return RetVal ;
115 }
116
117 void LNode_Impl::SetPyInit( const char * InitName ,
118                             const SUPERV::ListOfStrings & aPyInit ) {
119   beginService( "LNode_Impl::SetPyInit" );
120   SetPyFunction( InitName , aPyInit ) ;
121   endService( "LNode_Impl::SetPyInit" );
122   return ;
123 }
124
125 SUPERV::ListOfStrings * LNode_Impl::PyInit() {
126   SUPERV::ListOfStrings * aPythonFunction ;
127   beginService( "LNode_Impl::PyInit" );
128   aPythonFunction = PyFunction() ;
129   endService( "LNode_Impl::PyInit" );
130   return aPythonFunction ;
131 }
132
133 char * LNode_Impl::PyInitName() {
134   beginService( "LNode_Impl::PyInitName" );
135   char * RetVal = PyFuncName() ;
136   endService( "LNode_Impl::PyInitName" );
137   return CORBA::string_dup( RetVal ) ;
138 }
139
140 void LNode_Impl::SetPyMore( const char * MoreName ,
141                             const SUPERV::ListOfStrings & aPyMore ) {
142   beginService( "LNode_Impl::SetPyMore" );
143   DataFlowNode()->SetPyMorePythonFunction( MoreName , aPyMore ) ;
144   endService( "LNode_Impl::SetPyMore" );
145   return ;
146 }
147
148 SUPERV::ListOfStrings * LNode_Impl::PyMore() {
149   SUPERV::ListOfStrings * aPythonFunction ;
150   beginService( "LNode_Impl::PyMore" );
151   aPythonFunction = DataFlowNode()->PyMorePythonFunction() ;
152   endService( "LNode_Impl::PyMore" );
153   return aPythonFunction ;
154 }
155
156 char * LNode_Impl::PyMoreName() {
157   beginService( "LNode_Impl::PyMoreName" );
158   char * RetVal = DataFlowNode()->PyMoreName() ;
159   endService( "LNode_Impl::PyMoreName" );
160   return CORBA::string_dup( RetVal ) ;
161 }
162
163 void LNode_Impl::SetPyNext( const char * NextName ,
164                             const SUPERV::ListOfStrings & aPyNext ) {
165   beginService( "LNode_Impl::SetPyNext" );
166   DataFlowNode()->SetPyNextPythonFunction( NextName , aPyNext ) ;
167   endService( "LNode_Impl::SetPyNext" );
168   return ;
169 }
170
171 SUPERV::ListOfStrings * LNode_Impl::PyNext() {
172   SUPERV::ListOfStrings * aPythonFunction ;
173   beginService( "LNode_Impl::PyNext" );
174   aPythonFunction = DataFlowNode()->PyNextPythonFunction() ;
175   endService( "LNode_Impl::PyNext" );
176   return aPythonFunction ;
177 }
178
179 char * LNode_Impl::PyNextName() {
180   beginService( "LNode_Impl::PyNextName" );
181   char * RetVal = DataFlowNode()->PyNextName() ;
182   endService( "LNode_Impl::PyNextName" );
183   return CORBA::string_dup( RetVal );
184 }
185
186