[omniORB] Interface inheritance or Code inheritance?
Lars von Wedel
vonWedel@lfpt.rwth-aachen.de
Wed Sep 4 13:47:00 2002
Try to use virtual inheritance, it should work out then.
Lars
Michael Mountrakis wrote:
>
> Hallo all
>
> I am quite new at omniORB and currently I use
> omniORB_304_x86_linux_2.0_glibc2.
> The problem I have is that I want one class to inherit methods from its
> parent, without having to re write the method implementation for the derived
> class. Is it possible with omniORB ? For that reason, I wrote the classic
> idl:
>
> test.idl
> --------
> interface Base{
> double op1();
> };
>
> interface Derived : Base{
> double op2();
> };
>
> I've compile it using the example code generation flag:
> $ omniidl -bcxx -Wbexample -Wbuse_quotes test.idl
>
> The omniidl generated the following test_i.cc :
>
> class Base_i: public POA_Base,
> public PortableServer::RefCountServantBase {
> private:
> // Make sure all instances are built on the heap by making the
> // destructor non-public
> //virtual ~Base_i();
> public:
> // standard constructor
> Base_i();
> virtual ~Base_i();
>
> // methods corresponding to defined IDL attributes and operations
> CORBA::Double op1();
> };
>
> //
> // Example implementational code for IDL interface Base
> //
> Base_i::Base_i(){
> // add extra constructor code here
> }
> Base_i::~Base_i(){
> // add extra destructor code here
> }
> // Methods corresponding to IDL attributes and operations
> CORBA::Double Base_i::op1(){
> // MY CODE FOR op1() HERE
> return 1000;
> }
>
> // End of example implementational code
>
> //
> // Example class implementing IDL interface Derived
> //
> class Derived_i: public POA_Derived,
> public PortableServer::RefCountServantBase {
> private:
> // Make sure all instances are built on the heap by making the
> // destructor non-public
> //virtual ~Derived_i();
> public:
> // standard constructor
> Derived_i();
> virtual ~Derived_i();
>
> // methods corresponding to defined IDL attributes and operations
> CORBA::Double op2();
> CORBA::Double op1(); <------SHADOWS PARENT'S INHERITED METHOD
>
> };
>
> //
> // Example implementational code for IDL interface Derived
> //
> Derived_i::Derived_i(){
> // add extra constructor code here
> }
> Derived_i::~Derived_i(){
> // add extra destructor code here
> }
> // Methods corresponding to IDL attributes and operations
> CORBA::Double Derived_i::op2(){
> // MY CODE HERE
> return 2000;
> }
>
> CORBA::Double Derived_i::op1(){
> // DO I HAVE TO REWRITE THE METHOD AGAIN ?
> }
>
> I also tryed out the following class Derived_i definition:
>
> class Derived_i: public POA_Derived,public Base_i,
> public PortableServer::RefCountServantBase {
> ..............
> };
>
> But it did not compiled. Can you please suggest anything ?
>
> Mike Mountrakis
> Neurosoft Technologies
> Athens Greece
> www.neurosoft.gr
> mike@neurosoft.gr
>
> _______________________________________________
> omniORB-list mailing list
> omniORB-list@omniorb-support.com
> http://www.omniorb-support.com/mailman/listinfo/omniorb-list