在使用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 - 在Python中是否可以在SWIG中对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)
答案 0 :(得分:1)
通过调用基类构造函数解决了这个问题。
class TestStoreFactory(quickfix.MessageStoreFactory):
def __init__(self):
quickfix.MessageStoreFactory.__init__(self)
logging.info("TestStoreFactory()")