OnixS C++ CME MDP Premium Market Data Handler 5.9.0
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>
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:
44
46 enum { DefaultMaxRequests = 15 };
47
49 : username_()
50 , password_()
51 , acquisitionTimeout_(DefaultAcquisitionTimeout)
52 , maxRequests_(DefaultMaxRequests)
53 , watch_(&UtcWatch::service())
54 {
55 }
56
57 TcpRecoverySettings(const std::string& username, const std::string& password)
58 : username_(username)
59 , password_(password)
60 , acquisitionTimeout_(DefaultAcquisitionTimeout)
61 , maxRequests_(DefaultMaxRequests)
62 , watch_(&UtcWatch::service())
63 {
64 }
65
67
70 const std::string& username() const
71 {
72 return username_;
73 }
74
78 {
79 username_ = username;
80
81 return *this;
82 }
83
86 const std::string& password() const
87 {
88 return password_;
89 }
90
93 {
94 password_ = password;
95
96 return *this;
97 }
98
105 {
106 return acquisitionTimeout_;
107 }
108
113 {
114 acquisitionTimeout_ = acquisitionTimeout;
115
116 return *this;
117 }
118
125 {
126 return maxRequests_;
127 }
128
133 {
134 if (0 < maxRequests)
135 {
136 maxRequests_ = maxRequests;
137 }
138 else
139 {
141 }
142
143 return *this;
144 }
145
153 {
154 return *watch_;
155 }
156
161 {
162 watch_ = &watch;
163
164 return *this;
165 }
166
167 private:
168 std::string username_;
169 std::string password_;
170
171 UInt32 acquisitionTimeout_;
172
173 UInt32 maxRequests_;
174
175 WatchService* watch_;
176};
177
180void toStr(std::string&, const TcpRecoverySettings&);
181
183inline std::string toStr(const TcpRecoverySettings& settings)
184{
185 std::string str;
186
187 toStr(str, settings);
188
189 return str;
190}
191
192// A bit of declarations.
194
197{
198public:
201
204
206 virtual void brief(std::string&);
207
212 virtual bool tryAcquire(const Handler&, StrRef&, StrRef&);
213
215 virtual void release(const Handler&);
216
217protected:
220 {};
221
224
225private:
226 class Details;
227
228 // Shared details.
229 Details* details_;
230
231 // Copying is not assumed.
232
234
235 TcpRecoveryService& operator=(const TcpRecoveryService&);
236};
237
#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
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 &)
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)
const std::string & username() const
Definition TcpRecovery.h:70
TcpRecoverySettings & password(const std::string &password)
Assigns password to identify a requester while logging on to TCP Recovery service.
Definition TcpRecovery.h:92
TcpRecoverySettings & username(const std::string &username)
Definition TcpRecovery.h:77
TcpRecoverySettings(const std::string &username, const std::string &password)
Definition TcpRecovery.h:57
TcpRecoverySettings & acquisitionTimeout(UInt32 acquisitionTimeout)
TcpRecoverySettings & maxRequests(UInt32 maxRequests)
const std::string & password() const
Definition TcpRecovery.h:86
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