OnixS C++ CME MDP Premium Market Data Handler 5.9.0
API Documentation
Loading...
Searching...
No Matches
TcpRecovery.h
Go to the documentation of this file.
1// Copyright Onix Solutions Limited [OnixS]. All rights reserved.
2//
3// This software owned by Onix Solutions Limited [OnixS] and is
4// protected by copyright law and international copyright treaties.
5//
6// Access to and use of the software is governed by the terms of the applicable
7// OnixS Software Services Agreement (the Agreement) and Customer end user license
8// agreements granting a non-assignable, non-transferable and non-exclusive license
9// to use the software for it's own data processing purposes under the terms defined
10// in the Agreement.
11//
12// Except as otherwise granted within the terms of the Agreement, copying or
13// reproduction of any part of this source code or associated reference material
14// to any other location for further reproduction or redistribution, and any
15// amendments to this copyright notice, are expressly prohibited.
16//
17// Any reproduction or redistribution for sale or hiring of the Software not in
18// accordance with the terms of the Agreement is a violation of copyright law.
19//
20
21#pragma once
22
23#include <string>
24#include <stdexcept>
25
26#include <OnixS/CME/MDH/Watch.h>
29
31
34{
35 throw std::runtime_error("Maximal number of TCP Recovery requests per second must be greater than zero.");
36}
37
40{
41public:
46
50 enum { DefaultMaxRequests = 15 };
51
53 : username_()
54 , password_()
55 , acquisitionTimeout_(DefaultAcquisitionTimeout)
56 , maxRequests_(DefaultMaxRequests)
57 , watch_(&UtcWatch::service())
58 {
59 }
60
61 TcpRecoverySettings(const std::string& username, const std::string& password)
62 : username_(username)
63 , password_(password)
64 , acquisitionTimeout_(DefaultAcquisitionTimeout)
65 , maxRequests_(DefaultMaxRequests)
66 , watch_(&UtcWatch::service())
67 {
68 }
69
71
74 const std::string& username() const
75 {
76 return username_;
77 }
78
82 {
83 username_ = username;
84
85 return *this;
86 }
87
90 const std::string& password() const
91 {
92 return password_;
93 }
94
97 {
98 password_ = password;
99
100 return *this;
101 }
102
109 {
110 return acquisitionTimeout_;
111 }
112
117 {
118 acquisitionTimeout_ = acquisitionTimeout;
119
120 return *this;
121 }
122
129 {
130 return maxRequests_;
131 }
132
137 {
138 if (0 < maxRequests)
139 {
140 maxRequests_ = maxRequests;
141 }
142 else
143 {
145 }
146
147 return *this;
148 }
149
157 {
158 return *watch_;
159 }
160
165 {
166 watch_ = &watch;
167
168 return *this;
169 }
170
171 private:
172 std::string username_;
173 std::string password_;
174
175 UInt32 acquisitionTimeout_;
176
177 UInt32 maxRequests_;
178
179 WatchService* watch_;
180};
181
184void toStr(std::string&, const TcpRecoverySettings&);
185
187inline std::string toStr(const TcpRecoverySettings& settings)
188{
189 std::string str;
190
191 toStr(str, settings);
192
193 return str;
194}
195
196// A bit of declarations.
198
201{
202public:
205
208
210 virtual void brief(std::string&);
211
216 virtual bool tryAcquire(const Handler&, StrRef&, StrRef&);
217
219 virtual void release(const Handler&);
220
221protected:
224 {};
225
228
229private:
230 class Details;
231
232 // Shared details.
233 Details* details_;
234
235 // Copying is not assumed.
236
238
239 TcpRecoveryService& operator=(const TcpRecoveryService&);
240};
241
#define ONIXS_CMEMDH_NAMESPACE_BEGIN
Definition Bootstrap.h:67
#define ONIXS_CMEMDH_LTWT
Definition Bootstrap.h:46
#define ONIXS_CMEMDH_EXPORTED_CLASS_DECL(typeName)
Definition Bootstrap.h:35
#define ONIXS_CMEMDH_NAMESPACE_END
Definition Bootstrap.h:68
#define ONIXS_CMEMDH_EXPORTED
Definition Compiler.h:171
Encapsulates all the machinery related with market data processing from CME Market Data Platform.
Definition Handler.h:56
Provides efficient way of accessing text-based values without copying content of the text being refer...
Definition String.h:42
virtual ~TcpRecoveryService()
Finalizes instance and cleans everything up.
TcpRecoveryService(const NoDetails &)
Initializes without synchronization resource.
TcpRecoveryService(const TcpRecoverySettings &)
Initializes instance according to given settings.
virtual bool tryAcquire(const Handler &, StrRef &, StrRef &)
Gains access to the service.
virtual void brief(std::string &)
Basic information on the service.
virtual void release(const Handler &)
Releases previously acquired lock on the service.
TcpRecoverySettings & watch(WatchService &watch)
Watch service to be used by the service.
const std::string & username() const
Username to identify a requester while logging on to a TCP Recovery service.
Definition TcpRecovery.h:74
UInt32 maxRequests() const
Returns the maximum number of requests per second.
TcpRecoverySettings & password(const std::string &password)
Assigns password to identify a requester while logging on to TCP Recovery service.
Definition TcpRecovery.h:96
TcpRecoverySettings & username(const std::string &username)
Assigns username to identify a requester while logging on to a TCP Recovery service.
Definition TcpRecovery.h:81
UInt32 acquisitionTimeout() const
Returns the timeout (in milliseconds) on a TCP Recovery service acquisition.
TcpRecoverySettings(const std::string &username, const std::string &password)
Definition TcpRecovery.h:61
TcpRecoverySettings & acquisitionTimeout(UInt32 acquisitionTimeout)
Sets the timeout (in milliseconds) on a TCP Recovery service acquisition.
WatchService & watch() const
Watch service to be used by the service.
TcpRecoverySettings & maxRequests(UInt32 maxRequests)
Sets the maximum number of requests per second.
const std::string & password() const
Password to identify a requester while logging on to TCP Recovery service.
Definition TcpRecovery.h:90
void throwZeroTcpRecoveryRequestLimit()
Throws error on zero TCP recovery request limit value.
Definition TcpRecovery.h:33
void toStr(std::string &, BookState::Enum)
Serializes book state value into a string.
UInt32 UInt32
uInt32.
Definition Fields.h:202
Services as a marker for special construction.
Abstract watch service.
Definition Watch.h:30