[omniORB] _narrow problems with VAC++ 5.0 on AIX

Sai-Lai Lo S.Lo@uk.research.att.com
01 Aug 2000 17:39:07 +0100


Have you considered using tie implementation instead? Seems to me the
implementation class hierarchy is a lot easier to understand.

class B_i { .. } // Not inherit from _sk_B but contains methods with the same
           // signature as in _sk_B for all the operations defined in the
           // interface.

class E_i : public B_i { .. } 
  // Again not inherit from _sk_E.
  // E_i contains implementations of all the operations in C,D,E
  //              implementations of A and B is provided by B_i.

Then instantiate the CORBA object:

B_i* Bimpl = new B_i();
_tie_B<B_i,1>* Bobj = new _tie_B<B_i,1>(Bimpl);
Bobj->_obj_is_ready(boa);

E_i* Eimpl = new E_i();
_tie_E<E_i,1>* Eobj = new _tie_E<E_i,1>(Eimpl);
Eobj->_obj_is_ready(boa);
                     
Sai-Lai

>>>>> Peter Ledbrook writes:

> OK, I've now solved the problem but I am not too sure why it didn't work :-)
> Imagine this scenario:

> Interface A
> Interface B : A
> Interface C : B
> Interface D : C,B
> Interface E : D

> Nice and simple :-) Now consider two implementation classes:

> class B_i : public virtual _sk_B {}

> class E_i : public virtual _sk_E, public virtual B_i {}

> This second declaration is the one causing the problems. An object created of
> type E_i will not work with _narrow correctly. So, if you try to narrow a
> CORBA::Object of type E_i to the correct object reference,
> _widenFromTheMostDerivedIntf will be called as if the object is type A rather
> than type E. To fix this problem, the virtual keywords need to be removed from
> the declaration for E:

> class E_i : public _sk_E, public B_i {}

> I really don't know whether this is a problem with the compiler or not. I am
> still trying to replicate the problem on a small scale, perhaps for a bug
> report.







-- 
Sai-Lai Lo                                   S.Lo@uk.research.att.com
AT&T Laboratories Cambridge           WWW:   http://www.uk.research.att.com 
24a Trumpington Street                Tel:   +44 1223 343000
Cambridge CB2 1QA                     Fax:   +44 1223 313542
ENGLAND