class wrapping (was: [omniORB] Date: Wed, 5 Jan 2000 18:46:39 +0300)

Duncan Grisby dgrisby@uk.research.att.com
Wed, 12 Jan 2000 15:07:01 +0000


On Thursday 6 January, "Alik Kurdjukov" wrote:

[...]

> Interface A is a wrapper for Class_A. All real implementation is in Class_A,
> but I need to have all methods of Class_A implemented in interface A throu
> calling to embedded object of Class_A.

[...]

> an so on. But there's no solution of getting CORBA_Impl_A from object A_ptr
> in CORBA_Impl_B::method because of virtual inheretance ;((
> 
> In this task I don't need any location independance of the embedding object
> like CORBA_Impl_...

If I understand you correctly, your existing application has classes A
and B. Pointers to instances of class A are passed to instances of
class B. You wish to wrap A and B in CORBA interfaces, wrap_A and
wrap_B, but still be able to access the C++ implementation of As which
are passed to B.

The first thing you have to ask yourself is, given that you don't need
location independence, and you do need to "unwrap" the wrapped CORBA
object with interface wrap_A, why do you want to use CORBA at all?
The benefits of CORBA lie in location independence and its uniform
object model, neither of which you want.

That said, if you really want to get at the implementation object
associated with an object reference, you will have to use
dynamic_cast, if your C++ compiler supports it. If you are using
omniORB 3, you must first call poa->reference_to_servant() on the
reference, and try to dynamic_cast the result; with omniORB 2, you
just dynamic_cast the reference itself.

HTH,

Duncan.

-- 
 -- Duncan Grisby  \  Research Engineer  --
  -- AT&T Laboratories Cambridge          --
   -- http://www.uk.research.att.com/~dpg1 --