[omniORB] Ambiguous inheritance error

Randy Shoup rshoup@tumbleweed.com
Tue, 23 Feb 1999 11:18:54 -0800


"Gary D. Duzan" wrote:
> 
>    I don't believe that will work. Unless I'm mistaken, you'll end up
> with multiple instances of omniObject and CORBA::Object from
> Test::_sk_A (via A_i), Test::_sk_B (via B_i), and Test::_sk_C.  It
> might actually compile, but it won't register properly with the BOA.

omniObject and CORBA::Object are inherited virtually, so you won't have
this multiple-instances problem.  Almost without exception, the
generated omni base classes, proxies, skeletons, etc., are inherited
virtually, for (I assume) exactly this reason.

The solution I give below does work in practice.  It is what we have
been doing for months :-).

I can tell you that we went through quite a bit of thinking a while back
(and all the fun delegation hacks you and David suggested) before
arriving at this simple approach.  Virtual inheritance is ugly, but the
dominance rule at least makes it palatable.

> 
>                                         Gary Duzan
>                                         GTE Laboratories
> 
> p.s. There seems to be considerable lag in the list today. My earlier
> suggested hack which was practically identical to David's was actually
> sent before I received that message. Just didn't want everyone to
> think I wasn't paying attention. :-)
> 
> In Message <36D2F066.DF53C0D1@tumbleweed.com> ,
>    rshoup@tumbleweed.com (Randy Shoup) wrote:
> 
> =>Ah, the fun of virtual inheritance.  You don't want C_i to inherit
> =>virtually from A_i, B_i.  Something having to do with the "dominance
> =>rule", I suspect, though at this point it's probably just enough to say
> =>that this works:
> =>
> =>      class A_i : public virtual Test::_sk_A {
> =>      public:
> =>         void A_foo_1 ();
> =>         void A_foo_2 ();
> =>      };
> =>
> =>      class B_i : public virtual Test::_sk_B {
> =>      public:
> =>         void B_foo_1 ();
> =>         void B_foo_2 ();
> =>      };
> =>
> =>      class C_i : public virtual Test::_sk_C,
> =>                  public A_i,
> =>                  public B_i {
> =>      public:
> =>         void C_foo_1 ();
> =>         void C_foo_2 ();
> =>      };
> =>
> =>Thus you should be able to inherit both interface and implementation.
> =>This is how we handle implementation classes of base interfaces in our
> =>omniORB application.


-- Randy
_________________________________________________________________  
Randy Shoup                                     (650)569-3682  
Software Architect                              rshoup@tumbleweed.com  
Tumbleweed Software Corporation