-
Notifications
You must be signed in to change notification settings - Fork 21
/
Copy pathquoter.h
73 lines (66 loc) · 3.53 KB
/
quoter.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
/////////////////////////////////////////////////////////////////////////
//// Ftdc C++ => C Adapter
//// Author : [email protected]
/////////////////////////////////////////////////////////////////////////
#pragma once
#include "api/ThostFtdcMdApi.h"
#include "enums.h"
class Quoter : public CThostFtdcMdSpi
{
public:
CThostFtdcMdApi* RawApi{ nullptr };
CbOnFrontEvent mOnFrontEvent{ nullptr };
CbOnRspEvent mOnRspEvent{ nullptr };
CbOnRtnEvent mOnRtnEvent{ nullptr };
void* pObject;
Quoter(const char* pszFlowPath, const bool bIsUsingUdp, const bool bIsMulticast) {
RawApi = CThostFtdcMdApi::CreateFtdcMdApi(pszFlowPath, bIsUsingUdp, bIsMulticast);
RawApi->RegisterSpi(this);
pObject = this;
}
virtual ~Quoter() {
if (RawApi) {
RawApi->RegisterSpi(nullptr);
RawApi->Release();
RawApi = nullptr;
}
};
void OnFrontConnected() override {
mOnFrontEvent(pObject, EnumOnFrontEvent::OnFrontConnected, 0);
};
void OnFrontDisconnected(int nReason) override {
mOnFrontEvent(pObject, EnumOnFrontEvent::OnFrontDisconnected, nReason);
};
void OnHeartBeatWarning(int nTimeLapse) override {
};
void OnRspUserLogin(CThostFtdcRspUserLoginField* pRspUserLogin, CThostFtdcRspInfoField* pRspInfo, int nRequestID, bool bIsLast) override {
mOnRspEvent(pObject, EnumOnRspEvent::OnRspUserLogin, pRspUserLogin, pRspInfo, nRequestID, bIsLast);
};
void OnRspUserLogout(CThostFtdcUserLogoutField* pUserLogout, CThostFtdcRspInfoField* pRspInfo, int nRequestID, bool bIsLast) override {
mOnRspEvent(pObject, EnumOnRspEvent::OnRspUserLogout, pUserLogout, pRspInfo, nRequestID, bIsLast);
};
void OnRspQryMulticastInstrument(CThostFtdcMulticastInstrumentField* pMulticastInstrument, CThostFtdcRspInfoField* pRspInfo, int nRequestID, bool bIsLast) override {
mOnRspEvent(pObject, EnumOnRspEvent::OnRspQryMulticastInstrument, pMulticastInstrument, pRspInfo, nRequestID, bIsLast);
};
void OnRspError(CThostFtdcRspInfoField* pRspInfo, int nRequestID, bool bIsLast) override {
mOnRspEvent(pObject, EnumOnRspEvent::OnRspError, nullptr, pRspInfo, nRequestID, bIsLast);
};
void OnRspSubMarketData(CThostFtdcSpecificInstrumentField* pSpecificInstrument, CThostFtdcRspInfoField* pRspInfo, int nRequestID, bool bIsLast) override {
mOnRspEvent(pObject, EnumOnRspEvent::OnRspSubMarketData, pSpecificInstrument, pRspInfo, nRequestID, bIsLast);
};
void OnRspUnSubMarketData(CThostFtdcSpecificInstrumentField* pSpecificInstrument, CThostFtdcRspInfoField* pRspInfo, int nRequestID, bool bIsLast) override {
mOnRspEvent(pObject, EnumOnRspEvent::OnRspUnSubMarketData, pSpecificInstrument, pRspInfo, nRequestID, bIsLast);
};
void OnRspSubForQuoteRsp(CThostFtdcSpecificInstrumentField* pSpecificInstrument, CThostFtdcRspInfoField* pRspInfo, int nRequestID, bool bIsLast) override {
mOnRspEvent(pObject, EnumOnRspEvent::OnRspSubForQuoteRsp, pSpecificInstrument, pRspInfo, nRequestID, bIsLast);
};
void OnRspUnSubForQuoteRsp(CThostFtdcSpecificInstrumentField* pSpecificInstrument, CThostFtdcRspInfoField* pRspInfo, int nRequestID, bool bIsLast) override {
mOnRspEvent(pObject, EnumOnRspEvent::OnRspUnSubForQuoteRsp, pSpecificInstrument, pRspInfo, nRequestID, bIsLast);
};
void OnRtnDepthMarketData(CThostFtdcDepthMarketDataField* pDepthMarketData) override {
mOnRtnEvent(pObject, EnumOnRtnEvent::OnRtnDepthMarketData, pDepthMarketData);
};
void OnRtnForQuoteRsp(CThostFtdcForQuoteRspField* pForQuoteRsp) override {
mOnRtnEvent(pObject, EnumOnRtnEvent::OnRtnForQuoteRsp, pForQuoteRsp);
};
}; // end of class