Discussion:
[omniORB] Need to know the type of object reference using an object Id
Amit Kumar
2009-11-13 11:12:38 UTC
Permalink
Hello Friends,



If we have an object Id, we can use " Object id_to_reference(in ObjectId
oid) " method to get the Object. After that we need to _narrow() to the
specific type of object reference.

My problem: I have two interfaces A and B. My need is that before executing
the _narrow() operation, I should get the type of the object reference so
that I can narrow to the appropriate interface type. E.g.



CORBA::Object_var obj = poa->id_to_reference(oid);

if ( reference type == type A)

A:: _narrow(Obj.in());

else if ( reference type == type B)

B::_narrow (Obj.in());



This is the nature of my problem. Can anybody suggest to solve my problem of
knowing the object type at run time while having only object Id known?



Regards & Thanks,

Amit





-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.omniorb-support.com/pipermail/omniorb-list/attachments/20091113/793a977d/attachment.htm
Duncan Grisby
2009-11-15 04:18:21 UTC
Permalink
If we have an object Id, we can use ? Object id_to_reference(in
ObjectId oid) ? method to get the Object. After that we need to
_narrow() to the specific type of object reference.
Where did you get the object id from? Why do you not know what type of
object it corresponds to?
My problem: I have two interfaces A and B. My need is that before
executing the _narrow() operation, I should get the type of the object
reference so that I can narrow to the appropriate interface type.
E.g.
Just try to narrow it to one of the interfaces. If that returns nil, it
wasn't that interface, so try the other one.

Cheers,

Duncan.
--
-- Duncan Grisby --
-- ***@grisby.org --
-- http://www.grisby.org --
Loading...