c++ - Boost python: Argument Error lvalue between Wrapped and Base class -
in python code below, findfactory
returns factorybase
instead of factorybasewrapper
.
, think may cause of problem.
know how tell python factorybasewrapper inherit factorybase? tried "bases" in class_ this:
class_<factorybasewrapper, bases<factorybase> boost::noncopyable>( "factorybase", no_init )
but doesn't compile. seems need make interface factorybase too. can't, need factorybasewrapper because of pure virtual function in factorybase.
thanks
python code:
_sourcefactory = _myfactorymgr.findfactory(name) foo = _sourcefactory.getorcreatebase(myobj) # problem here
boostpython module:
class_<factorymgr, boost::noncopyable>("factorymgr",no_init) .def("findfactory",&factorymgr::findfactory, return_value_policy<reference_existing_object>()); class_<factorybasewrapper, boost::noncopyable>( "factorybase", no_init ) .def( "getorcreateindicator", &factorybasewrapper::getorcreateindicator, return_value_policy<reference_existing_object>())
cpp functions & classes :
class factorymgr { factorybase* factorymgr::findfactory( const std::string& name ); } class factorybasewrapper :public factorybase, public wrapper<factorybase> { base* factorybase::getorcreatebase ( const customobject* myobj); base* createbase( string str ) { return this->get_override( "createbase" )(); } } class factorybase { virtual base* createbase( string str )=0; ... }
i error:
traceback (most recent call last): file "xxx", line 149, in yyyy _sourcefactory.getorcreatebase(myobj) boost.python.argumenterror: python argument types in factorybase.getorcreatebase(factorybase, customobject) did not match c++ signature: getorcreatebase(factorybasewrapper {lvalue}, interface::customobject const*)
Comments
Post a Comment