OmniOrb Snippets
Assume that the implementation of a class named A is named AImp.
A is-a Corba Object
As soon as we encapsulate AImpl into an A_ptr in code such as (pseudocode):
AImpl *aimp=new AImpl(orb); PortableServer::POA_var poa = PortableServer::POA::_narrow(root_poa); poa->activate_object(aimpl); CORBA::Object_var o; o = poa->servant_to_reference(aimpl);
It seems as we have lost the implementation of A!
Of course we have it present in the variable aimp, but as soon as we leave that method all we will be able to get is the remote interface of A as declared in its IDL.
What if we have public methods in the declaration of A (AImpl.hh) that we want to keep public when locally to the object an private when remotely to it?
There should be a way to recover the implementation when we are in the same process than it by using a dynamic_cast.
Here it is (pseudocode):
AImpl* aimp; corba::A_ptr ac= ... //obtain the corba reference here ; PortableServer::Servant srvnt = getPOA()->reference_to_servant(ac); aimp=dynamic_cast(srvnt);
Returning NULL (NIL) references in Omniorb:
No, you cannot return NULL in Omniorb. To do so, _nil() method of the corresponding POA should be used:
::my::corba::CTestObject_ptr CorbaTest::methodThatReturnsNIL()
{
return ::my::corba::CTestObject::_nil();
}
To check if the returned value corresponds to NIL, use the _isNil() method.
--------------------------------------------------------------------------------------------------------------------------
Comments
Post a Comment