OnixS C++ CME Streamlined Market Data Handler  1.0.0.4
API documentation
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 
26 
28 
29 /// TCP recovery service configuration settings.
32 {
33 public:
34  /// Initializes parameters with default values.
36  : username_()
37  , password_()
38  , reconnectAttempts_(3)
39  , reconnectInterval_(500)
40  , servingTimeout_(10)
41  , acquisitionTimeout_(500)
42  {
43  }
44 
45  /// Cleans everything up.
47  {
48  }
49 
50  /// Username to identify a requester while
51  /// logging on to a TCP Recovery service.
52  const std::string& username() const
53  {
54  return username_;
55  }
56 
57  /// Assigns username to identify a requester
58  /// while logging on to a TCP Recovery service.
59  void
61  const std::string& username)
62  {
63  username_ = username;
64  }
65 
66  /// Password to identify a requester while
67  /// logging on to TCP Recovery service.
68  const std::string& password() const
69  {
70  return password_;
71  }
72 
73  /// Assigns password to identify a requester
74  /// while logging on to TCP Recovery service.
75  void
77  const std::string& password)
78  {
79  password_ = password;
80  }
81 
82  /// Number of attempts to receive missed
83  /// messages via the TCP recovery feed.
84  ///
85  /// @note Default value is '3'.
87  {
88  return reconnectAttempts_;
89  }
90 
91  /// Number of attempts to receive missed
92  /// messages via the TCP recovery feed.
93  void
95  UInt32 reconnectAttempts)
96  {
97  reconnectAttempts_ =
98  reconnectAttempts;
99  }
100 
101  /// Interval between the attempts to receive
102  /// missed packets via the TCP recovery feed if
103  /// previous attempt either failed or was rejected.
104  ///
105  /// Interval is measured in milliseconds.
106  ///
107  /// @note Default value is '500'.
109  {
110  return reconnectInterval_;
111  }
112 
113  /// Interval between the attempts to receive
114  /// missed packets via the TCP recovery feed if
115  /// previous attempt either failed or was rejected.
116  ///
117  /// Interval is measured in milliseconds.
118  void
120  UInt32 reconnectInterval)
121  {
122  reconnectInterval_ =
123  reconnectInterval;
124  }
125 
126  /// Amount of time allocated to process a
127  /// recovery request. TCP recovery service
128  /// interrupts request processing if it can't
129  /// be accomplished within given time frame.
130  ///
131  /// Interval is measured in seconds.
132  ///
133  /// @note Default value is '10'.
135  {
136  return servingTimeout_;
137  }
138 
139  /// Amount of time allocated to process a
140  /// recovery request. TCP recovery service
141  /// interrupts request processing if it can't
142  /// be accomplished within given time frame.
143  ///
144  /// Interval is measured in seconds.
145  void
147  UInt32 servingTimeout)
148  {
149  servingTimeout_ =
150  servingTimeout;
151  }
152 
153  /// Timeout on a TCP recovery service acquisition.
154  ///
155  /// TCP recovery service may process only
156  /// single request at a time. If TCP recovery
157  /// service can't be acquired within time defined
158  /// by given parameter, recovery request will be
159  /// rejected.
160  ///
161  /// Timeout is measured in milliseconds.
162  ///
163  /// @note Default value is '500'.
165  {
166  return acquisitionTimeout_;
167  }
168 
169  /// Timeout of request for shared TCP recovery service.
170  /// If shared TCP recovery service is used and another Handler
171  /// instance owned it for processing, this Handler instance
172  /// will wait for specified timeout and cancel TCP recovery request
173  /// if TCP Recovery service still not released.
174  ///
175  /// Timeout is measured in milliseconds.
176  void
178  UInt32 acquisitionTimeout)
179  {
180  acquisitionTimeout_ =
181  acquisitionTimeout;
182  }
183 
184 private:
185  std::string username_;
186  std::string password_;
187 
188  UInt32 reconnectAttempts_;
189  UInt32 reconnectInterval_;
190 
191  UInt32 servingTimeout_;
192  UInt32 acquisitionTimeout_;
193 };
194 
195 /// Serializes TCP recovery settings.
196 ONIXS_CMESTREAMLINEDMDH_EXPORTED
197 void
198 toStr(
199  std::string&,
200  const
202 
203 /// Serializes TCP recovery settings.
204 inline
205 std::string
207  const
208  TcpRecoverySettings& settings)
209 {
210  std::string str;
211 
212  toStr(str, settings);
213 
214  return str;
215 }
216 
218 (
219  TcpRecoverySession
220 );
221 
222 /// TCP Recovery Service.
225 {
226 public:
227  /// Initializes instance according to given settings.
229  const TcpRecoverySettings&);
230 
231  /// Finalizes instance and cleans everything up.
233 
234  /// Settings defining service behavior.
235  const
237  settings() const
238  {
239  return *settings_;
240  }
241 
242 private:
243  friend
245  (
246  TcpRecoverySession
247  );
248 
249  // Shared details.
250  void* resource_;
251 
252  // Settings of the service.
253  TcpRecoverySettings* settings_;
254 
255  // Copying is not assumed.
256 
258  const TcpRecoveryService&);
259 
261  operator =(
262  const TcpRecoveryService&);
263 };
264 
std::string toStr(const TcpRecoverySettings &settings)
Serializes TCP recovery settings.
Definition: TcpRecovery.h:206
void reconnectInterval(UInt32 reconnectInterval)
Definition: TcpRecovery.h:119
void acquisitionTimeout(UInt32 acquisitionTimeout)
Definition: TcpRecovery.h:177
const TcpRecoverySettings & settings() const
Settings defining service behavior.
Definition: TcpRecovery.h:237
#define ONIXS_CMESTREAMLINEDMDH_NAMESPACE_END
Definition: Bootstrap.h:172
#define ONIXS_CMESTREAMLINEDMDH_LTWT_CLASS
Definition: Bootstrap.h:110
#define ONIXS_CMESTREAMLINEDMDH_INTERNAL_CLASS_DECL(typeName)
Definition: Bootstrap.h:70
TCP recovery service configuration settings.
Definition: TcpRecovery.h:30
#define ONIXS_CMESTREAMLINEDMDH_EXPORTED_CLASS
Definition: Bootstrap.h:62
void reconnectAttempts(UInt32 reconnectAttempts)
Definition: TcpRecovery.h:94
void username(const std::string &username)
Definition: TcpRecovery.h:60
void password(const std::string &password)
Definition: TcpRecovery.h:76
TcpRecoverySettings()
Initializes parameters with default values.
Definition: TcpRecovery.h:35
UInt32 UInt32
uInt32.
Definition: Fields.h:183
#define ONIXS_CMESTREAMLINEDMDH_NAMESPACE_BEGIN
Definition: Bootstrap.h:168