在下面的Python代码中,findFactory
返回FactoryBase
,而不是FactoryBaseWrapper
。
我认为这可能是问题的原因。
你知道如何告诉python FactoryBaseWrapper是从FactoryBase继承的吗?
我在课堂上试过“基地”这样:
class_<FactoryBaseWrapper, bases<FactoryBase> boost::noncopyable>( "FactoryBase", no_init )
但它不能编译。似乎我也需要从FactoryBase制作接口。但我不能,我需要FactoryBaseWrapper,因为Factorybase中有一个纯虚函数。在
谢谢
Python代码:
^{pr2}$BoostPython模块:
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函数和类:
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;
...
}
我得到这个错误:
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*)
目前没有回答
相关问题 更多 >
编程相关推荐