[omniORB] IDL interface insufficient

Martin Trappel 0xCDCDCDCD at gmx.at
Fri Apr 18 13:44:43 BST 2008


Michael wrote:
> Hi David,
> 
> seems like you're using the default poa. What you could do is the following:
> 
> Assuming you a method that accepts a ref reference:
> 
> void MyObject::MyMethod(RemoteProxy_ptr p)
> {
>   try
>   {
>     PortableServer::Servant servant = poa_->reference_to_servant(p)
>     if (RemoteProxy_i* rp = dynamic_cast<RemoteProxy_i*>(servant))
>     {
>       WrappedObject* o = rp->getWrapedObject();
>     }
>   }
>   catch(...)
>   {
>     // there are different (meaningful) exceptions emitted, check the standard
>   }
> }
> (this assumes, you stored the poa used somewhere - if it's the default poa you could also
> get it through resolve_initial_reference)
> 
> This is also nice, because you can verify that the servant is really out of this oa (and
> not a remote object).
> 

I though I might throw in what I used for this, maybe it's useful to 
someone else ...

br,
Martin

[CODE]
//////////////////////////////////////////////////////////////////////
template<class ITF_IMPL_T, class POA_T, class ITF_PTR_T>
inline PortableServer::Servant_var<ITF_IMPL_T>
get_implemenation(POA_T poa, ITF_PTR_T itf_ptr_obj)
{
	if(CORBA::is_nil(itf_ptr_obj))
		return NULL;
	else
		return dynamic_cast<ITF_IMPL_T*>( 
poa->reference_to_servant(itf_ptr_obj) );
}

//////////////////////////////////////////////////////////////////////
#define IMPL_OBJ(t, v) 
get_implemenation<t>(PortableServer::POA_var(_default_POA()), v)

// Usage:
MyServant_i* p = IMPL_OBJ(ACI_MyServant_i, interface_ptr);
if(p) { ... }

[/CODE]



More information about the omniORB-list mailing list