-
Notifications
You must be signed in to change notification settings - Fork 163
/
Copy pathHistoryQueryMsgShim.h
136 lines (111 loc) · 5.03 KB
/
HistoryQueryMsgShim.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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
/************************************************************************
* Copyright(c) 2010, One Unified. All rights reserved. *
* email: [email protected] *
* *
* This file is provided as is WITHOUT ANY WARRANTY *
* without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
* *
* This software may not be used nor distributed without proper license *
* agreement. *
* *
* See the file LICENSE.txt for redistribution information. *
************************************************************************/
#pragma once
// 2010/05/30 translates IQFeedHistoryQuery events to Win API Messages for cross thread consumption
#include "HistoryQuery.h"
namespace ou { // One Unified
namespace tf { // TradeFrame
namespace iqfeed { // IQFeed
template <typename T>
class HistoryQueryMsgShim: public HistoryQuery<HistoryQueryMsgShim<T> > {
friend HistoryQuery<HistoryQueryMsgShim<T> >;
public:
typedef typename HistoryQuery<HistoryQueryMsgShim<T> > inherited_t;
struct structMessageDestinations {
T* owner;
UINT msgConnected;
UINT msgSendComplete;
UINT msgDisconnected;
UINT msgError; // not currently forwarded
UINT msgHistoryTickDataPoint;
UINT msgHistoryIntervalData;
UINT msgHistorySummaryData;
UINT msgHistoryRequestDone;
structMessageDestinations( void )
: owner( NULL ), msgConnected( 0 ), msgSendComplete( 0 ), msgDisconnected( 0 ), msgError( 0 ),
msgHistoryTickDataPoint( 0 ), msgHistoryIntervalData( 0 ), msgHistorySummaryData( 0 ),
msgHistoryRequestDone( 0 )
{};
structMessageDestinations(
T* owner_,
UINT msgConnected_, UINT msgSendComplete_, UINT msgDisconnected_, UINT msgError_,
UINT msgHistoryTickDataPoint_, UINT msgHistoryIntervalData_, UINT msgHistorySummaryData_,
UINT msgHistoryRequestDone_
)
: owner( owner_ ),
msgConnected( msgConnected_ ), msgSendComplete( msgSendComplete_ ), msgDisconnected( msgDisconnected_ ), msgError( msgError_ ),
msgHistoryTickDataPoint( msgHistoryTickDataPoint_ ),
msgHistoryIntervalData( msgHistoryIntervalData_ ), msgHistorySummaryData( msgHistorySummaryData_ ),
msgHistoryRequestDone( msgHistoryRequestDone_ )
{
assert( NULL != owner_ );
};
};
HistoryQueryMsgShim( const structMessageDestinations& MessageDestinations)
: m_structMessageDestinations( MessageDestinations ) {
assert( NULL != MessageDestinations.owner );
};
~HistoryQueryMsgShim( void ) {};
protected:
// CRTP callbacks
void OnHistoryConnected( void ) {
if ( 0 != m_structMessageDestinations.msgConnected ) {
m_structMessageDestinations.owner->PostMessage( m_structMessageDestinations.msgConnected );
}
}
void OnHistoryDisconnected( void ) {
if ( 0 != m_structMessageDestinations.msgDisconnected ) {
m_structMessageDestinations.owner->PostMessage( m_structMessageDestinations.msgDisconnected );
}
}
void OnHistoryError( size_t e ) {
if ( 0 != m_structMessageDestinations.msgError ) {
m_structMessageDestinations.owner->PostMessage( m_structMessageDestinations.msgError, e );
}
}
void OnHistorySendDone( void ) {
if ( 0 != m_structMessageDestinations.msgSendComplete ) {
m_structMessageDestinations.owner->PostMessage( m_structMessageDestinations.msgSendComplete );
}
}
void OnHistoryTickDataPoint( structTickDataPoint* pDP ) {
if ( 0 != m_structMessageDestinations.msgHistoryTickDataPoint ) {
m_structMessageDestinations.owner->PostMessage(
m_structMessageDestinations.msgHistoryTickDataPoint, reinterpret_cast<WPARAM>( pDP ) );
}
}
void OnHistoryIntervalData( structInterval* pDP ) {
if ( 0 != m_structMessageDestinations.msgHistoryIntervalData ) {
m_structMessageDestinations.owner->PostMessage(
m_structMessageDestinations.msgHistoryIntervalData, reinterpret_cast<WPARAM>( pDP ) );
}
}
void OnHistorySummaryData( structSummary* pDP ) {
if ( 0 != m_structMessageDestinations.msgHistorySummaryData ) {
m_structMessageDestinations.owner->PostMessage(
m_structMessageDestinations.msgHistorySummaryData, reinterpret_cast<WPARAM>( pDP ) );
}
}
void OnHistoryRequestDone( void ) {
if ( 0 != m_structMessageDestinations.msgHistoryRequestDone ) {
m_structMessageDestinations.owner->PostMessage(
m_structMessageDestinations.msgHistoryRequestDone, 0 );
}
}
private:
structMessageDestinations m_structMessageDestinations;
};
} // namespace iqfeed
} // namespace tf
} // namespace ou