Boost logo

Boost :

From: Sam Holden (sholden_at_[hidden])
Date: 2001-04-24 00:42:42

I'm planning on embedding python in a C++ project I'm starting. I have
done a little of this before, but I've never tried it with boost::python.

Say I have the following classes:

class Base_Result {
    virtual int value() = 0;
class Base {
    virtual Base_Result& result() = 0;
class Derived_Result : public Base_Result {
    int value() { return 1;} //not inline in reality
class Derived {
    Base_Result& result() { return res;} //not inline in reality
    Derived_Result res;

Basically an abstract interface and an implementation (more than one in
reality). In reality the abstract interface has some implementation but
also contains pure virtual member functions which return references to
classes with pure virtual member functions.

I wish to export these classes to python using boost::python.

The best I can get is the Derived class working but when I call d.result()
in python I end up getting a Base_Result object back which calls the
Base classes member function (which I had to implement...)

So does anyone have any experience in getting something similar to work,
and could point me in the right direction?

Also does boost::python work OK for embedding python as opposed to extending
python? Can I statically link in the extensions for example?

Sorry for the long message, I tried to be as brief as possible, but clearly

This was for Linux, but since we all know that "platform independent"
means "runs on both BSD and Linux", this should be ok. :-)
	-- Tom Christiansen in <37cf3d16_at_[hidden]>

Boost list run by bdawes at, gregod at, cpdaniel at, john at