[C++-sig] wrapping abstract classes question

Roman Yakovenko roman.yakovenko at gmail.com
Sun Dec 4 13:36:47 CET 2005


Hi. What is the right way to wrap next abstract classes?

struct base{
    virtual int do_smth() = 0;
};

struct derived : base{
    virtual int do_smth_else() = 0;
};

It is obvious to me that I should create wrapper classes for base and derived.
My question is what is definition of derived wrapper?

struct base_wrapper : base, boost::python::wrapper< base >
{
...
}

The are 2 approaches to create wrapper for derived class
1.

struct derived_wrapper : derived, boost::python::wrapper< derived >{

 virtual int do_smth(  ){
        boost::python::override do_smth = this->get_override( "do_smth" );
        return do_smth(  );
 }

 virtual int do_smth_else(  ){
        boost::python::override do_smth_else = this->get_override(
"do_smth_else" );
        return do_smth_else(  );
    }

}

2.

struct derived_wrapper : derived, base_wrapper,
boost::python::wrapper< derived >{

virtual int do_smth_else(  ){
        boost::python::override do_smth_else = this->get_override(
"do_smth_else" );
        return do_smth_else(  );
    }

}

It seems to me that both approaches will work, but I do not know which
one is better
( right ) and which one is not.

Thanks for help.

Roman Yakovenko



More information about the Cplusplus-sig mailing list