OnixS C++ CME MDP Premium Market Data Handler 5.10.3
Users' manual and 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>
30
31#include <OnixS/CME/MDH/Auxiliary/DeprecatedHeaderWarnings.Disable.h>
34#include <OnixS/CME/MDH/Auxiliary/DeprecatedHeaderWarnings.Restore.h>
35
37
40{
41 throw std::runtime_error("Maximal number of TCP Recovery requests per second must be greater than zero.");
42}
43
46{
47public:
50
52 enum { DefaultMaxRequests = 15 };
53
55 : username_()
56 , password_()
57 , acquisitionTimeout_(DefaultAcquisitionTimeout)
58 , maxRequests_(DefaultMaxRequests)
59 , watch_(&UtcWatch::service())
60 {
61 }
62
63 TcpRecoverySettings(const std::string& username, const std::string& password)
64 : username_(username)
65 , password_(password)
66 , acquisitionTimeout_(DefaultAcquisitionTimeout)
67 , maxRequests_(DefaultMaxRequests)
68 , watch_(&UtcWatch::service())
69 {
70 }
71
73
76 const std::string& username() const
77 {
78 return username_;
79 }
80
84 {
85 username_ = username;
86
87 return *this;
88 }
89
92 const std::string& password() const
93 {
94 return password_;
95 }
96
99 {
100 password_ = password;
101
102 return *this;
103 }
104
111 {
112 return acquisitionTimeout_;
113 }
114
119 {
120 acquisitionTimeout_ = acquisitionTimeout;
121
122 return *this;
123 }
124
131 {
132 return maxRequests_;
133 }
134
139 {
140 if (0 < maxRequests)
141 {
142 maxRequests_ = maxRequests;
143 }
144 else
145 {
147 }
148
149 return *this;
150 }
151
159 {
160 return *watch_;
161 }
162
167 {
168 watch_ = &watch;
169
170 return *this;
171 }
172
173 private:
174 std::string username_;
175 std::string password_;
176
177 Messaging::UInt32 acquisitionTimeout_;
178
179 Messaging::UInt32 maxRequests_;
180
181 WatchService* watch_;
182};
183
186void toStr(std::string&, const TcpRecoverySettings&);
187
189inline std::string toStr(const TcpRecoverySettings& settings)
190{
191 std::string str;
192
193 toStr(str, settings);
194
195 return str;
196}
197
198// A bit of declarations.
200
203{
204public:
207
210
212 virtual void brief(std::string&);
213
219
221 virtual void release(const Handler&);
222
223protected:
226 {};
227
230
231private:
232 class Details;
233
234 // Shared details.
235 Details* details_;
236
237 // Copying is not assumed.
238
240
241 TcpRecoveryService& operator=(const TcpRecoveryService&);
242};
243
#define ONIXS_CMEMDH_NAMESPACE_BEGIN
Definition Bootstrap.h:54
#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:55
#define ONIXS_CMEMDH_EXPORTED
Definition Compiler.h:148
virtual ~TcpRecoveryService()
Finalizes instance and cleans everything up.
TcpRecoveryService(const NoDetails &)
Initializes without synchronization resource.
virtual bool tryAcquire(const Handler &, Messaging::StrRef &, Messaging::StrRef &)
TcpRecoveryService(const TcpRecoverySettings &)
Initializes instance according to given settings.
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)
Messaging::UInt32 acquisitionTimeout() const
const std::string & username() const
Definition TcpRecovery.h:76
TcpRecoverySettings & acquisitionTimeout(Messaging::UInt32 acquisitionTimeout)
TcpRecoverySettings & password(const std::string &password)
Assigns password to identify a requester while logging on to TCP Recovery service.
Definition TcpRecovery.h:98
TcpRecoverySettings & username(const std::string &username)
Definition TcpRecovery.h:83
Messaging::UInt32 maxRequests() const
TcpRecoverySettings & maxRequests(Messaging::UInt32 maxRequests)
TcpRecoverySettings(const std::string &username, const std::string &password)
Definition TcpRecovery.h:63
const std::string & password() const
Definition TcpRecovery.h:92
std::uint32_t UInt32
uInt32.
Definition Integral.h:35
std::basic_string_view< Char > StrRef
Definition StrRef.h:46
void throwZeroTcpRecoveryRequestLimit()
Throws error on zero TCP recovery request limit value.
Definition TcpRecovery.h:39
void toStr(std::string &, BookState::Enum)
Serializes book state value into a string.
Services as a marker for special construction.
Abstract watch service.
Definition Watch.h:35