2 //=============================================================================
3 // File : INode_Impl.cxx
5 // Author : Jean Rahuel
9 //=============================================================================
16 #include "utilities.h"
18 #include "LNode_Impl.hxx"
20 INode_Impl::INode_Impl( CORBA::ORB_ptr orb ,
21 PortableServer::POA_ptr poa ,
22 PortableServer::ObjectId * contId ,
23 const char *instanceName ,
24 const char *interfaceName ,
25 const char *aDataFlowName ) :
26 // Engines_Component_i(orb, poa, contId, instanceName, interfaceName, false, false) {
27 CNode_Impl( orb , poa , contId , instanceName , interfaceName , aDataFlowName ) {
28 // MESSAGE("INode_Impl::INode_Impl activate object instanceName("
29 // << instanceName << ") interfaceName(" << interfaceName << ") --> "
30 // << hex << (void *) this << dec )
32 // _id = _poa->activate_object(_thisObj);
33 MESSAGE( "INode_Impl::INode_Impl " << aDataFlowName );
34 beginService( "INode_Impl::INode_Impl" );
35 _Orb = CORBA::ORB::_duplicate(orb);
38 endService( "INode_Impl::INode_Impl" );
41 INode_Impl::INode_Impl() {
44 INode_Impl::INode_Impl( CORBA::ORB_ptr orb ,
45 PortableServer::POA_ptr poa ,
46 PortableServer::ObjectId * contId ,
47 const char *instanceName ,
48 const char *interfaceName ,
49 GraphEditor::DataFlow * aDataFlowEditor ,
50 const char * FuncName ,
51 const SUPERV::ListOfStrings & aPythonFunction ,
52 const SUPERV::KindOfNode NodeKindOfNode ) :
53 // Engines_Component_i(orb, poa, contId, instanceName, interfaceName, false, false) {
54 CNode_Impl( orb , poa , contId , instanceName , interfaceName , aDataFlowEditor , SALOME_ModuleCatalog::Service() , FuncName , NodeKindOfNode , FuncName , aPythonFunction ) {
55 beginService( "INode_Impl::INode_Impl" );
57 cout << "INode_Impl::CNode_Impl " << (void *) FuncName << " " << FuncName
58 << " " << strlen( FuncName ) << endl ;
60 if ( NodeKindOfNode == SUPERV::InLineNode ) {
61 MESSAGE( "INode_Impl::INode_Impl " << FuncName << " _poa->activate_object" );
63 _id = _poa->activate_object(_thisObj);
65 MESSAGE("INode_Impl::INode_Impl " << FuncName << " " << strlen( FuncName ) ) ;
66 _Orb = CORBA::ORB::_duplicate(orb);
69 // DataFlowNode()->SetPythonFunction( FuncName , aPythonFunction ) ;
70 endService( "INode_Impl::INode_Impl" );
73 INode_Impl::INode_Impl( CORBA::ORB_ptr orb ,
74 PortableServer::POA_ptr poa ,
75 PortableServer::ObjectId * contId ,
76 const char *instanceName ,
77 const char *interfaceName ,
78 GraphEditor::DataFlow * aDataFlowEditor ,
79 const GraphBase::ListOfFuncName FuncName ,
80 const GraphBase::ListOfPythonFunctions aPythonFunction ,
81 const SUPERV::KindOfNode NodeKindOfNode ) :
82 // Engines_Component_i(orb, poa, contId, instanceName, interfaceName, false, false) {
83 CNode_Impl( orb , poa , contId , instanceName , interfaceName , aDataFlowEditor , SALOME_ModuleCatalog::Service() , FuncName[0].c_str() , NodeKindOfNode , FuncName , aPythonFunction ) {
84 beginService( "INode_Impl::INode_Impl" );
85 if ( NodeKindOfNode == SUPERV::InLineNode ) {
86 MESSAGE( "INode_Impl::INode_Impl " << FuncName[0] << " _poa->activate_object" );
88 _id = _poa->activate_object(_thisObj);
90 MESSAGE("INode_Impl::INode_Impl " << FuncName[0].c_str() << " " << strlen( FuncName[0].c_str() ) ) ;
91 _Orb = CORBA::ORB::_duplicate(orb);
94 // DataFlowNode()->SetPythonFunction( FuncName , aPythonFunction ) ;
95 endService( "INode_Impl::INode_Impl" );
98 INode_Impl::INode_Impl( CORBA::ORB_ptr orb ,
99 PortableServer::POA_ptr poa ,
100 PortableServer::ObjectId * contId ,
101 const char *instanceName ,
102 const char *interfaceName ,
103 GraphEditor::DataFlow * aDataFlowEditor ,
104 GraphEditor::InNode * aDataFlowNode ) :
105 // Engines_Component_i(orb, poa, contId, instanceName, interfaceName, false, false) {
106 CNode_Impl( orb , poa , contId , instanceName , interfaceName , aDataFlowEditor , aDataFlowNode ) {
107 MESSAGE( DataFlowNode()->Name() << " " );
108 beginService( "INode_Impl::INode_Impl" );
109 if ( DataFlowNode()->IsInLineNode() ) {
110 MESSAGE( "INode_Impl::INode_Impl " << DataFlowNode()->PyFuncName()
111 << " _poa->activate_object" );
113 _id = _poa->activate_object(_thisObj);
115 _Orb = CORBA::ORB::_duplicate(orb);
118 endService( "INode_Impl::INode_Impl" );
121 INode_Impl::~INode_Impl() {
122 beginService( "INode_Impl::~INode_Impl" );
123 endService( "INode_Impl::~INode_Impl" );
126 void INode_Impl::destroy() {
127 beginService( "INode_Impl::Destroy" );
128 if ( DataFlowEditor()->IsEditing() ) {
130 _poa->deactivate_object(*_id) ;
131 CORBA::release(_poa) ;
133 _thisObj->_remove_ref();
136 endService( "INode_Impl::Destroy" );
139 bool INode_Impl::Delete() {
140 // beginService( "INode_Impl::Delete" );
141 bool RetVal = false ;
142 if ( DataFlowEditor()->IsEditing() ) {
143 RetVal = DataFlowEditor()->RemoveNode( Name() ) ;
145 RetVal = DataFlowEditor()->IsValid() ;
147 // endService( "INode_Impl::Delete" );
151 void INode_Impl::SetPyFunction( const char * FuncName ,
152 const SUPERV::ListOfStrings & aPyFunction ) {
153 beginService( "INode_Impl::SetPyFunction" );
154 if ( DataFlowEditor()->IsEditing() ) {
155 DataFlowNode()->SetPythonFunction( FuncName , aPyFunction ) ;
157 endService( "INode_Impl::SetPyFunction" );
161 SUPERV::ListOfStrings * INode_Impl::PyFunction() {
162 beginService( "INode_Impl::PyFunction" );
163 SUPERV::ListOfStrings * aPyFunc = NULL ;
164 if ( DataFlowEditor()->IsEditing() ) {
165 aPyFunc = new SUPERV::ListOfStrings( *DataFlowNode()->PythonFunction() ) ;
168 aPyFunc = new SUPERV::ListOfStrings() ;
170 endService( "INode_Impl::PyFunction" );
174 char * INode_Impl::PyFuncName() {
175 return CORBA::string_dup( DataFlowNode()->PyFuncName() ) ;
178 SUPERV::Port_ptr INode_Impl::InPort( const char *aParameterName ,
179 const char *aParameterType ) {
180 SUPERV::Port_ptr Inobject = SUPERV::Port::_nil() ;
181 SUPERV::Port_ptr Outobject = SUPERV::Port::_nil() ;
182 SUPERV::Port_ptr InEndobject = SUPERV::Port::_nil() ;
183 Port_Impl * myInPort = NULL ;
184 bool InPortCreated = false ;
185 GraphBase::InPort * anInPort = DataFlowNode()->GetChangeInPort( aParameterName ) ;
186 if ( anInPort == NULL && DataFlowNode()->IsOneOfInLineNodes() ) {
187 anInPort = DataFlowNode()->AddInPort( aParameterName , aParameterType ) ;
188 InPortCreated = true ;
191 Inobject = anInPort->ObjRef() ;
192 if ( CORBA::is_nil( Inobject ) ) {
193 myInPort = new Port_Impl( _Orb , _Poa , _ContId ,
194 instanceName() , interfaceName() ,
197 (GraphBase::Port * ) anInPort ,
200 PortableServer::ObjectId * id = myInPort->getId() ;
201 CORBA::Object_var obj = _poa->id_to_reference(*id) ;
202 Inobject = SUPERV::Port::_narrow(obj) ;
207 if ( !CORBA::is_nil( Inobject ) && InPortCreated &&
208 ( DataFlowNode()->IsLoopNode() || DataFlowNode()->IsEndLoopNode() ||
209 DataFlowNode()->IsEndSwitchNode() ) ) {
210 Outobject = OutPort( aParameterName , aParameterType ) ;
211 if ( DataFlowNode()->IsLoopNode() ) {
212 LNode_Impl * myLoopNode = (LNode_Impl * ) this ;
213 InEndobject = myLoopNode->Coupled()->InPort( aParameterName , aParameterType ) ;
214 DataFlowEditor()->AddLink( Outobject->Node()->Name() , Outobject->Name() ,
215 InEndobject->Node()->Name() , InEndobject->Name() ) ;
218 DataFlowEditor()->UnValid() ;
219 return SUPERV::Port::_duplicate( Inobject ) ;
222 SUPERV::Port_ptr INode_Impl::OutPort( const char *aParameterName ,
223 const char *aParameterType ) {
224 Port_Impl * myOutPort = NULL ;
225 SUPERV::Port_ptr Outobject = SUPERV::Port::_nil() ;
226 GraphBase::OutPort * anOutPort = DataFlowNode()->GetChangeOutPort( aParameterName ) ;
227 if ( anOutPort == NULL && DataFlowNode()->IsOneOfInLineNodes() ) {
228 anOutPort = DataFlowNode()->AddOutPort( aParameterName , aParameterType ) ;
231 Outobject = anOutPort->ObjRef() ;
232 if ( CORBA::is_nil( Outobject ) ) {
233 const CORBA::Any * anAny = anOutPort->Value() ;
234 myOutPort = new Port_Impl( _Orb , _Poa , _ContId ,
235 instanceName() , interfaceName() ,
238 (GraphBase::Port * ) anOutPort ,
242 PortableServer::ObjectId * id = myOutPort->getId() ;
243 CORBA::Object_var obj = _poa->id_to_reference(*id) ;
244 Outobject = SUPERV::Port::_narrow(obj) ;
248 DataFlowEditor()->UnValid() ;
249 return SUPERV::Port::_duplicate( Outobject );
253 bool INode_Impl::BusPort( const char * InOutParameterName ,
254 const char * InOutParameterType ,
255 SUPERV::Port_out InputPort ,
256 SUPERV::Port_out OutputPort ) {
257 return BusPorts( InOutParameterName , InOutParameterType ,
258 InOutParameterName , InOutParameterType ,
259 InputPort , OutputPort ) ;
262 bool INode_Impl::BusPorts( const char * InputParameterName ,
263 const char * InputParameterType ,
264 const char * OutputParameterName ,
265 const char * OutputParameterType ,
266 SUPERV::Port_out InputPort ,
267 SUPERV::Port_out OutputPort ) {
268 beginService( "INode_Impl::BusPorts" );
269 bool RetVal = false ;
270 Port_Impl * myInPort = NULL ;
271 Port_Impl * myOutPort = NULL ;
272 SUPERV::Port_var Inobject = SUPERV::Port::_nil() ;
273 SUPERV::Port_var Outobject = SUPERV::Port::_nil() ;
274 // if ( DataFlowNode()->GetInPort( InputParameterName ) ||
275 // DataFlowNode()->GetOutPort( OutputParameterName ) ) {
278 GraphBase::InPort * anInPort = DataFlowNode()->AddInPort( InputParameterName ,
279 InputParameterType ) ;
281 myInPort = new Port_Impl( _Orb , _Poa , _ContId ,
282 instanceName() , interfaceName() ,
285 // InputParameterName ) ;
286 (GraphBase::Port * ) anInPort ,
288 GraphBase::OutPort * anOutPort = DataFlowNode()->AddOutPort( OutputParameterName ,
289 OutputParameterType ) ;
291 const CORBA::Any * anAny = anOutPort->Value() ;
292 myOutPort = new Port_Impl( _Orb , _Poa , _ContId ,
293 instanceName() , interfaceName() ,
296 // OutputParameterName ,
297 (GraphBase::Port * ) anOutPort ,
300 DataFlowNode()->InOutPort( anInPort , anOutPort ) ;
305 if ( RetVal && myInPort && myOutPort ) {
306 if ( DataFlowNode()->CoupledNode() ) {
307 GraphBase::InPort * anInPort ;
308 anInPort = DataFlowNode()->CoupledNode()->AddInPort( OutputParameterName ,
309 OutputParameterType ) ;
310 GraphBase::OutPort * anOutPort ;
311 anOutPort = DataFlowNode()->CoupledNode()->AddOutPort( InputParameterName ,
312 InputParameterType ) ;
313 DataFlowNode()->CoupledNode()->InOutPort( anInPort , anOutPort ) ;
315 PortableServer::ObjectId * id = myInPort->getId() ;
316 CORBA::Object_var obj = _poa->id_to_reference(*id) ;
317 Inobject = SUPERV::Port::_narrow(obj) ;
318 InputPort = SUPERV::Port::_duplicate( Inobject ) ;
319 id = myOutPort->getId() ;
320 obj = _poa->id_to_reference(*id);
321 Outobject = SUPERV::Port::_narrow(obj) ;
322 OutputPort = SUPERV::Port::_duplicate( Outobject ) ;
324 endService( "INode_Impl::BusPorts" );