Cython包装C ++虚函数

时间:2014-11-19 04:12:54

标签: python c++ cython

在C ++头声明中:

class MdSpi
{ 
    public:
        virtual void OnFrontConnected(){};
        virtual void OnFrontDisconnected(int nReason){};
        virtual void OnHeartBeatWarning(int nTimeLapse){};
}

class MdApi
{
public:

    static MdApi *CreateMdApi(const char *FlowPath = "");

    virtual void Release() = 0;

    virtual void Init() = 0;

    virtual int Join() = 0;

    virtual const char *GetTradingDay() = 0;

    virtual void RegisterFront(char *pszFrontAddress) = 0;

    virtual void RegisterSpi(MdSpi *pSpi) = 0;
protected:
    ~MdApi(){};
}

Cython文档没有提供有关C ++虚拟或纯虚函数的任何介绍。

我知道如何定义从虚拟类继承的c ++标头。

class WrapMdSpi  : public MdSpi
{
public:
    WrapMdSpi();
    ~ WrapMdSpi();

    virtual void OnFrontConnected();
    virtual void OnFrontDisconnected(int nReason);
    virtual void OnHeartBeatWarning(int nTimeLapse);
};

在main.cpp中:

#include “MdSpi.h”

MdSpi g_MdSpi;
MdApi *g_MdApi = NULL;

int main(int argc, char* argv[])
{

  g_MdApi = CKSGMdApi::CreateMdApi();
  g_MdApi->RegisterSpi(&g_MdSpi);
  g_MdApi->Init();
  g_MdApi->Release();

  return 0;
}

如何在pxd中定义虚拟功能,或者如何定义pyx文件?

0 个答案:

没有答案