[omniORB] Getting the IDL out or the IOR

Duncan Grisby duncan at grisby.org
Tue Sep 9 12:26:01 BST 2014


On Fri, 2014-09-05 at 11:53 +0200, Ramón Talavera wrote:

> I am trying to get the Interface out of the stringified IOR, is it
> possible?
> In other words, given a CORBA Object, is it possible to guess its
> corresponding Interface Definition?
> 
[...]
> CORBA::Object_ptr obj=...
> std::cout<<corbautil.getTypeStr(obj)<<std::endl
> 
> 
> Should result in:
> 
> "IDL:meow.com/Test/A:1.0"

I assume you mean you want to get its repository id, not the full
interface definition?  To get the full interface definition, you need an
Interface Repository, and omniORB does not have its own one.

If you just want to get the repository id, which is the string like
"IDL:meow.com/Test/A:1.0", there is no CORBA standard way to get it, but
you can access some omniORB-specific details:

const char* id = obj->_PR_getobj()->_mostDerivedRepoId();

Beware that _PR_getobj() returns an invalid pointer for nil object
references and pseudo-objects, so make sure it's a valid normal object
reference first.

Also beware that what that does is get the repository id out of the
object reference, but it is valid for an object reference to have an
empty repository id, or even in id that you think is unrelated to the
one you were expecting. The only way to be completely sure if an object
supports a particular interface is to attempt to _narrow it, or call the
_is_a() method that's used by _narrow.

Cheers,

Duncan.

-- 
 -- Duncan Grisby         --
  -- duncan at grisby.org     --
   -- http://www.grisby.org --





More information about the omniORB-list mailing list