-
Notifications
You must be signed in to change notification settings - Fork 163
/
Copy pathNewsQueryMsgShim.h
118 lines (100 loc) · 4.53 KB
/
NewsQueryMsgShim.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
/************************************************************************
* 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/29 translates IQFeedNewsQuery events to Win API Messages for cross thread consumption
#include "IQFeedNewsQuery.h"
namespace ou { // One Unified
namespace tf { // TradeFrame
template <typename T>
class CIQFeedNewsQueryMsgShim: public CIQFeedNewsQuery<CIQFeedNewsQueryMsgShim<T> > {
friend CIQFeedNewsQuery<CIQFeedNewsQueryMsgShim<T> >;
public:
typedef CIQFeedNewsQuery<CIQFeedNewsQueryMsgShim<T> > inherited_t;
// pre-initialized message ids for messages delivered to and accepted by external caller
struct structMessageDestinations {
T* owner;
UINT msgConnected;
UINT msgSendComplete;
UINT msgDisconnected;
UINT msgError; // not currently forwarded
UINT msgNewsConfigDone;
UINT msgNewsStoryLine;
UINT msgNewsStoryDone;
structMessageDestinations( void )
: owner( NULL ), msgConnected( 0 ), msgSendComplete( 0 ), msgDisconnected( 0 ), msgError( 0 ),
msgNewsConfigDone( 0 ),
msgNewsStoryLine( 0 ), msgNewsStoryDone( 0 )
{};
structMessageDestinations(
T* owner_,
UINT msgConnected_, UINT msgSendComplete_, UINT msgDisconnected_, UINT msgError_,
UINT msgNewsConfigDone_,
UINT msgNewsStoryLine_, UINT msgNewsStoryDone_
)
: owner( owner_ ),
msgConnected( msgConnected_ ), msgSendComplete( msgSendComplete_ ), msgDisconnected( msgDisconnected_ ), msgError( msgError_ ),
msgNewsConfigDone( msgNewsConfigDone_ ),
msgNewsStoryLine( msgNewsStoryLine_ ), msgNewsStoryDone( msgNewsStoryDone_ )
{
assert( NULL != owner_ );
};
};
CIQFeedNewsQueryMsgShim( const structMessageDestinations& MessageDestinations)
: m_structMessageDestinations( MessageDestinations ) {
assert( NULL != MessageDestinations.owner );
};
~CIQFeedNewsQueryMsgShim( void ) {};
protected:
// CRTP callbacks
void OnNewsQueryConnected( void ) {
if ( 0 != m_structMessageDestinations.msgConnected ) {
m_structMessageDestinations.owner->PostMessage( m_structMessageDestinations.msgConnected );
}
};
void OnNewsQueryDisconnected( void ) {
if ( 0 != m_structMessageDestinations.msgDisconnected ) {
m_structMessageDestinations.owner->PostMessage( m_structMessageDestinations.msgDisconnected );
}
};
void OnNewsQueryError( size_t e ) {
if ( 0 != m_structMessageDestinations.msgError ) {
m_structMessageDestinations.owner->PostMessage( m_structMessageDestinations.msgError, e );
}
};
void OnNewsQuerySendDone( void ) {
if ( 0 != m_structMessageDestinations.msgSendComplete ) {
m_structMessageDestinations.owner->PostMessage( m_structMessageDestinations.msgSendComplete );
}
};
void OnNewsQueryNewsConfigDone( void ) {
if ( 0 != m_structMessageDestinations.msgNewsConfigDone ) {
m_structMessageDestinations.owner->PostMessage( m_structMessageDestinations.msgNewsConfigDone );
}
};
void OnNewsQueryStoryLine( linebuffer_t* buf, LPARAM lParam ) {
if ( 0 != m_structMessageDestinations.msgNewsStoryLine ) {
m_structMessageDestinations.owner->PostMessage(
m_structMessageDestinations.msgNewsStoryLine, reinterpret_cast<WPARAM>( buf ), lParam );
}
};
void OnNewsQueryStoryDone( LPARAM lParam ) {
if ( 0 != m_structMessageDestinations.msgNewsStoryDone ) {
m_structMessageDestinations.owner->PostMessage( m_structMessageDestinations.msgNewsStoryDone, 0, lParam );
}
};
private:
structMessageDestinations m_structMessageDestinations;
};
} // namespace tf
} // namespace ou