|
Boost Users : |
Subject: [Boost-users] [boost::python] problems wrapping a base class
From: Andy Falanga (afalanga) (afalanga_at_[hidden])
Date: 2012-04-10 16:21:23
HI,
I'm working on exposing what should be a factory to create derived objects using the standard pattern for such a factory. In short, I have something like the following:
Class Base {
// some private member variables
Public:
Virtual void Func1() =0;
Virtual void Func2();
};
Class Derv1 : public Base {
// override Func1()
// override Func2()
};
Class BaseWrapper : public Base, boost::python::wrapper<Base> {
Void Func1() {
Get_override("Func1")();
}
Void Func2() {
If(boost::python::override func = get_override("Func2"))
{
Func();
Return;
}
Base::Func2();
}
};
Base* Factory(int selector) {
// return derived classes base on selector
}
BOOST_PYTHON_MODULE(myMod) {
Class_<Derv1, bases<Base> >("Derived")
.def("Func1", &Derived::Func1)
.def("Func2", &Derived::Func2)
;
Class_<BaseWrapper, boost::noncopyable>("BaseWrapper")
.def("Func1", pure_virtual(&Base::Func1))
.def("Func2", &Base::Func2, &BaseWrapper::Func2)
;
Def("Factory", Factory);
}
Everything compiles now but I'm getting the following error:
RuntimeError: extension class wrapper for base class class Base has not been created yet
This comes when I try to import this module into the python interpreter. What exactly am I missing? I'm following instructions from here:
http://www.boost.org/doc/libs/1_48_0/libs/python/doc/tutorial/doc/html/python/exposing.html
Some references I've found from Google thus far suggest that the problem is with linking order. However, how to specify linking order when that is determined dynamically during build? (I'm using Visual Studio 2010) Any help is greatly appreciated.
Thanks,
Andy
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net