【发布时间】:2013-07-23 12:27:40
【问题描述】:
在为 QuickFix 使用 Python 绑定时,如何在 Python 中子类化 MessageStoreFactory 类?
当我尝试这样做时,该对象没有“被视为”为 MessageStoreFactory:
NotImplementedError: Wrong number of arguments for overloaded function 'new_SocketInitiatorBase'.
Possible C/C++ prototypes are:
FIX::SocketInitiator(FIX::Application &,FIX::MessageStoreFactory &,FIX::SessionSettings const &)
FIX::SocketInitiator(FIX::Application &,FIX::MessageStoreFactory &,FIX::SessionSettings const &,FIX::LogFactory &)
当类型错误时,SWIG 似乎会返回此错误。 (我过去只使用过 Boost - 在 SWIG 中甚至可以在 Python 中对 C++ 类进行子类化吗?)
更新 Python 绑定是为 Ubuntu 12.04 打包的。我很确定我的参数是正确的,因为只有在创建 SocketInitiator 时将其中一个 QuickFix 对象换成下面的对象时才会发生错误:
class TestStoreFactory(quickfix.MessageStoreFactory):
def __init__(self):
logging.info("TestStoreFactory()")
def create(self, sessionId):
logging.info("Create %s"%sessionId)
def destroy(self, messageStore):
logging.info("Destroy %s" % messageStore)
【问题讨论】:
-
根据您的文档,可以将C++ class from Python 子类化,我只使用 Java 完成了此操作,并且效果很好。在 QuickFix 页面中,我只看到了 Java 和 .Net 绑定的链接,您从哪里获得 Python 的链接?显而易见的问题是,您是否使用正确数量的参数调用函数?您可以发布该代码 sn-p 吗?