2013-07-23 30 views
2

如何在使用QuickFix的Python綁定時在Python中繼承MessageStoreFactory類?QuickFix Python API - 可以在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。 (我只用升壓過去 - 在Python是繼承C++類的,即使在痛飲可能嗎?)

更新 Python綁定是打包的Ubuntu 12.04的人。我相當肯定,當我換出的QuickFix的一個錯誤只發生在我創建一個SocketInitiator與下面的一個對象,我已經得到了正確的參數:通過放置

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

根據你的文檔有可能子類[從Python的C++類(http://www.swig.org/Doc2.0/SWIGDocumentation.html#Python_directors),I只是做這與Java和它的工作很好。在QuickFix頁面中,我只看到了Java和.Net綁定的鏈接,您是從哪裏得到它們的Python?而明顯的問題是,你是否用正確數量的參數調用該函數?你能發佈該代碼片段嗎? –

回答

1

得到了解決此問題調用基類的構造函數。

class TestStoreFactory(quickfix.MessageStoreFactory): 
    def __init__(self): 
     quickfix.MessageStoreFactory.__init__(self) 
     logging.info("TestStoreFactory()")