1 // SUPERV Supervision : contains the implementation of interfaces of SuperVision described in SUPERV.idl
3 // Copyright (C) 2003 CEA/DEN, EDF R&D
7 // File : INode_Impl.cxx
8 // Author : Jean Rahuel
18 //#include "utilities.h"
20 #include "LNode_Impl.hxx"
22 INode_Impl::INode_Impl( CORBA::ORB_ptr orb ,
23 PortableServer::POA_ptr poa ,
24 PortableServer::ObjectId * contId ,
25 const char *instanceName ,
26 const char *interfaceName ,
27 const char *aDataFlowName ) :
28 // Engines_Component_i(orb, poa, contId, instanceName, interfaceName, false, false) {
29 CNode_Impl( orb , poa , contId , instanceName , interfaceName , aDataFlowName ) {
30 // MESSAGE("INode_Impl::INode_Impl activate object instanceName("
31 // << instanceName << ") interfaceName(" << interfaceName << ") --> "
32 // << hex << (void *) this << dec )
34 // _id = _poa->activate_object(_thisObj);
35 MESSAGE( "INode_Impl::INode_Impl " << aDataFlowName );
36 beginService( "INode_Impl::INode_Impl" );
37 _Orb = CORBA::ORB::_duplicate(orb);
40 endService( "INode_Impl::INode_Impl" );
43 INode_Impl::INode_Impl() {
46 INode_Impl::INode_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 * aDataFlowEditor ,
52 const char * FuncName ,
53 const SUPERV::ListOfStrings & aPythonFunction ,
54 const SUPERV::KindOfNode NodeKindOfNode ) :
55 // Engines_Component_i(orb, poa, contId, instanceName, interfaceName, false, false) {
56 CNode_Impl( orb , poa , contId , instanceName , interfaceName , aDataFlowEditor , SALOME_ModuleCatalog::Service() , FuncName , NodeKindOfNode , FuncName , aPythonFunction ) {
57 beginService( "INode_Impl::INode_Impl" );
59 // cout << "INode_Impl::CNode_Impl " << (void *) FuncName << " " << FuncName
60 // << " " << strlen( FuncName ) << endl ;
62 if ( NodeKindOfNode == SUPERV::InLineNode ) {
63 MESSAGE( "INode_Impl::INode_Impl " << FuncName << " _poa->activate_object" );
65 _id = _poa->activate_object(_thisObj);
67 MESSAGE("INode_Impl::INode_Impl " << FuncName << " " << strlen( FuncName ) ) ;
68 _Orb = CORBA::ORB::_duplicate(orb);
71 // DataFlowNode()->SetPythonFunction( FuncName , aPythonFunction ) ;
72 endService( "INode_Impl::INode_Impl" );
75 INode_Impl::INode_Impl( CORBA::ORB_ptr orb ,
76 PortableServer::POA_ptr poa ,
77 PortableServer::ObjectId * contId ,
78 const char *instanceName ,
79 const char *interfaceName ,
80 GraphEditor::DataFlow * aDataFlowEditor ,
81 const GraphBase::ListOfFuncName FuncName ,
82 const GraphBase::ListOfPythonFunctions aPythonFunction ,
83 const SUPERV::KindOfNode NodeKindOfNode ) :
84 // Engines_Component_i(orb, poa, contId, instanceName, interfaceName, false, false) {
85 CNode_Impl( orb , poa , contId , instanceName , interfaceName , aDataFlowEditor , SALOME_ModuleCatalog::Service() , FuncName[0].c_str() , NodeKindOfNode , FuncName , aPythonFunction ) {
86 beginService( "INode_Impl::INode_Impl" );
87 if ( NodeKindOfNode == SUPERV::InLineNode ) {
88 MESSAGE( "INode_Impl::INode_Impl " << FuncName[0] << " _poa->activate_object" );
90 _id = _poa->activate_object(_thisObj);
92 MESSAGE("INode_Impl::INode_Impl " << FuncName[0].c_str() << " " << strlen( FuncName[0].c_str() ) ) ;
93 _Orb = CORBA::ORB::_duplicate(orb);
96 // DataFlowNode()->SetPythonFunction( FuncName , aPythonFunction ) ;
97 endService( "INode_Impl::INode_Impl" );
100 INode_Impl::INode_Impl( CORBA::ORB_ptr orb ,
101 PortableServer::POA_ptr poa ,
102 PortableServer::ObjectId * contId ,
103 const char *instanceName ,
104 const char *interfaceName ,
105 GraphEditor::DataFlow * aDataFlowEditor ,
106 GraphEditor::InNode * aDataFlowNode ) :
107 // Engines_Component_i(orb, poa, contId, instanceName, interfaceName, false, false) {
108 CNode_Impl( orb , poa , contId , instanceName , interfaceName , aDataFlowEditor , aDataFlowNode ) {
109 MESSAGE( DataFlowNode()->Name() << " " );
110 beginService( "INode_Impl::INode_Impl" );
111 if ( DataFlowNode()->IsInLineNode() ) {
112 MESSAGE( "INode_Impl::INode_Impl " << DataFlowNode()->PyFuncName()
113 << " _poa->activate_object" );
115 _id = _poa->activate_object(_thisObj);
117 _Orb = CORBA::ORB::_duplicate(orb);
120 endService( "INode_Impl::INode_Impl" );
123 INode_Impl::~INode_Impl() {
124 beginService( "INode_Impl::~INode_Impl" );
125 endService( "INode_Impl::~INode_Impl" );
128 void INode_Impl::destroy() {
129 beginService( "INode_Impl::Destroy" );
130 if ( DataFlowEditor()->IsEditing() ) {
132 _poa->deactivate_object(*_id) ;
133 CORBA::release(_poa) ;
135 _thisObj->_remove_ref();
138 endService( "INode_Impl::Destroy" );
141 bool INode_Impl::Delete() {
142 // beginService( "INode_Impl::Delete" );
143 bool RetVal = false ;
144 if ( DataFlowEditor()->IsEditing() ) {
145 RetVal = DataFlowEditor()->RemoveNode( Name() ) ;
147 RetVal = DataFlowEditor()->IsValid() ;
149 // endService( "INode_Impl::Delete" );
153 void INode_Impl::SetPyFunction( const char * FuncName ,
154 const SUPERV::ListOfStrings & aPyFunction ) {
155 beginService( "INode_Impl::SetPyFunction" );
156 if ( DataFlowEditor()->IsEditing() ) {
157 DataFlowNode()->SetPythonFunction( FuncName , aPyFunction ) ;
159 endService( "INode_Impl::SetPyFunction" );
163 SUPERV::ListOfStrings * INode_Impl::PyFunction() {
164 beginService( "INode_Impl::PyFunction" );
165 SUPERV::ListOfStrings * aPyFunc = NULL ;
166 if ( DataFlowEditor()->IsEditing() ) {
167 aPyFunc = new SUPERV::ListOfStrings( *DataFlowNode()->PythonFunction() ) ;
170 aPyFunc = new SUPERV::ListOfStrings() ;
172 endService( "INode_Impl::PyFunction" );
176 char * INode_Impl::PyFuncName() {
177 return CORBA::string_dup( DataFlowNode()->PyFuncName() ) ;
181 bool INode_Impl::BusPort( const char * InOutParameterName ,
182 const char * InOutParameterType ,
183 SUPERV::Port_out InputPort ,
184 SUPERV::Port_out OutputPort ) {
185 return BusPorts( InOutParameterName , InOutParameterType ,
186 InOutParameterName , InOutParameterType ,
187 InputPort , OutputPort ) ;
190 bool INode_Impl::BusPorts( const char * InputParameterName ,
191 const char * InputParameterType ,
192 const char * OutputParameterName ,
193 const char * OutputParameterType ,
194 SUPERV::Port_out InputPort ,
195 SUPERV::Port_out OutputPort ) {
196 beginService( "INode_Impl::BusPorts" );
197 bool RetVal = false ;
198 Port_Impl * myInPort = NULL ;
199 Port_Impl * myOutPort = NULL ;
200 SUPERV::Port_var Inobject = SUPERV::Port::_nil() ;
201 SUPERV::Port_var Outobject = SUPERV::Port::_nil() ;
202 // if ( DataFlowNode()->GetInPort( InputParameterName ) ||
203 // DataFlowNode()->GetOutPort( OutputParameterName ) ) {
206 GraphBase::InPort * anInPort = DataFlowNode()->AddInPort( InputParameterName ,
207 InputParameterType ) ;
209 myInPort = new Port_Impl( _Orb , _Poa , _ContId ,
210 instanceName() , interfaceName() ,
213 // InputParameterName ) ;
214 (GraphBase::Port * ) anInPort ,
216 GraphBase::OutPort * anOutPort = DataFlowNode()->AddOutPort( OutputParameterName ,
217 OutputParameterType ) ;
219 const CORBA::Any * anAny = anOutPort->Value() ;
220 myOutPort = new Port_Impl( _Orb , _Poa , _ContId ,
221 instanceName() , interfaceName() ,
224 // OutputParameterName ,
225 (GraphBase::Port * ) anOutPort ,
228 DataFlowNode()->InOutPort( anInPort , anOutPort ) ;
233 if ( RetVal && myInPort && myOutPort ) {
234 if ( DataFlowNode()->CoupledNode() ) {
235 GraphBase::InPort * anInPort ;
236 anInPort = DataFlowNode()->CoupledNode()->AddInPort( OutputParameterName ,
237 OutputParameterType ) ;
238 GraphBase::OutPort * anOutPort ;
239 anOutPort = DataFlowNode()->CoupledNode()->AddOutPort( InputParameterName ,
240 InputParameterType ) ;
241 DataFlowNode()->CoupledNode()->InOutPort( anInPort , anOutPort ) ;
243 PortableServer::ObjectId * id = myInPort->getId() ;
244 CORBA::Object_var obj = _poa->id_to_reference(*id) ;
245 Inobject = SUPERV::Port::_narrow(obj) ;
246 InputPort = SUPERV::Port::_duplicate( Inobject ) ;
247 id = myOutPort->getId() ;
248 obj = _poa->id_to_reference(*id);
249 Outobject = SUPERV::Port::_narrow(obj) ;
250 OutputPort = SUPERV::Port::_duplicate( Outobject ) ;
252 endService( "INode_Impl::BusPorts" );