[C++-sig] Re : [boost] Re : Using an element of a class A in a constructor of a class B (reflection with boost::python)
christophe jean-joseph
jjchristophe at yahoo.fr
Thu Mar 15 14:22:00 CET 2012
Hello
The situation is as follow.
I have a C++ code that I haven't written and that I barely can modified. I am supposed to reflect this code in Python with boost.
In the code, I have something looking like this:
Class A_Base {
A_Base(){};
~A_Base(){};
Whatever virtual and pure virtual functions;
}
Class A_Derived{
A_Derived(Type1 arg1,...){whatever instructions;}
~A_Derived(){};
Whatever functions;
}
Class B {
B(A_Base& aBase, double& x){};
~B(){};
Whatever functions;
}
In the C++ main, at some point aDerived A_Derived is set, and then B(aDerived, x).
I need to reflect that under python.
Until now, I have been able, with a simple example, to reflect a function f,
which is not a ctor, from a class B using A_Base& as argument type,
but I can't figure out how to deal with it for a constructor.
Based on:
http://wiki.python.org/moin/boost.python/ExportingClasses
I am declaring f under both its class B and A_Base as follow:
class_A_Base <A, boost::noncopyable>("A_Base", no_init) //this line can be modified
.def("f", &B::f);
class_B <B, boost::noncopyable>("B", init< >()) //this line can be modified
.def("f", &B::f);
But when I try this for a constructor as f, it refuse to compile.
Anyone got a clue?
Thank you very much in advance for any further help.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/cplusplus-sig/attachments/20120315/4f31eb87/attachment.html>
More information about the Cplusplus-sig
mailing list