OnixS BME SENAF Handler C++ library  2.2.1
API documentation
HandlerSettings.h
Go to the documentation of this file.
1 /*
2  * Copyright Onix Solutions Limited [OnixS]. All rights reserved.
3  *
4  * This software owned by Onix Solutions Limited [OnixS] and is protected by
5  * copyright law and international copyright treaties.
6  *
7  * Access to and use of the software is governed by the terms of the applicable
8  * ONIXS Software Services Agreement (the Agreement) and Customer end user
9  * license agreements granting a non-assignable, non-transferable and
10  * non-exclusive license to use the software for it's own data processing
11  * purposes under the terms defined in the Agreement.
12  *
13  * Except as otherwise granted within the terms of the Agreement, copying or
14  * reproduction of any part of this source code or associated reference material
15  * to any other location for further reproduction or redistribution, and any
16  * amendments to this copyright notice, are expressly prohibited.
17  *
18  * Any reproduction or redistribution for sale or hiring of the Software not in
19  * accordance with the terms of the Agreement is a violation of copyright law.
20  */
21 
22 #pragma once
23 
24 #include <OnixS/Senaf/MarketData/Export.h>
27 
28 #include <iosfwd>
29 #include <set>
30 #include <string>
31 #include <vector>
32 
33 namespace OnixS { namespace Senaf { namespace MarketData {
34 
35 /// Connection retries settings.
36 struct ONIXS_BME_SENAF_EXPORT ConnectionRetries
37 {
38  /// Default constructor.
40  : number(0)
41  , interval(0)
42  {
43  }
44 
45  /// Constructor.
46  ConnectionRetries(int inNumber, unsigned inInterval)
47  : number(inNumber)
48  , interval(inInterval)
49  {
50  }
51 
52  /// Number of attempts to restore the telecommunication link.
53  /// -1 - unlimited
54  /// 0 - never (default)
55  /// >0 - the number of attempts
56  int number;
57 
58  /// The time interval between the attempts to restore the telecommunication
59  /// link (in seconds).
60  ///
61  /// \note The default value is 0 (zero).
62  unsigned int interval;
63 
64  /// Returns the string representation.
65  std::string toString() const;
66 };
67 
68 ONIXS_BME_SENAF_EXPORT std::ostream& operator<<(std::ostream&, const ConnectionRetries&);
69 
70 /// Logical processors that a thread is allowed to run on (first logical CPU has
71 /// index 0).
72 typedef std::set<int> CpuIndexes;
73 
74 /// Ordered list of logs to be replayed.
75 typedef std::vector<std::string> LogList;
76 
77 /// Log replay input stream.
79 {
80 public:
81  /**
82  * Called when log player wants to read data from stream.
83  *
84  * \param data buffer to read data into
85  * \param size max size to read
86  *
87  * \returns \c 0 in case of EOF, actually read bytes count otherwise
88  *
89  * \note Implementation is free to throw any exceptions.
90  * Player would react differently depending on exception type.
91  *
92  * Particularly:
93  * - \c std::ios_base::failure -- serious problem on getting data means
94  * do not try any further reading from stream and terminate playing;
95  *
96  * Absolutely all exceptions are reported via error handler.
97  * Description string will be available for children of \c std::exception.
98  */
99  virtual size_t read(char* const data, size_t size) = 0;
100 
101 protected:
102  /// Deletion is not supposed through interface of this class.
104 };
105 
106 /// Defines set of settings which affect behavior of the Handler.
107 struct ONIXS_BME_SENAF_EXPORT HandlerSettings
108 {
109  /**
110  * Content of the license file as a string.
111  *
112  * \note Default value is empty string.
113  * \note The Handler checks this license first.
114  */
115  std::string licenseString;
116 
117  /**
118  * Path to the license directory.
119  *
120  * \note Default value is \e "./" (the current directory).
121  * \note A home directory also used to search a license.
122  */
123  std::string licenseDirectory;
124 
125  /**
126  * Log files are stored in this directory.
127  *
128  * \note Default value is \e "./" (the current directory).
129  */
130  std::string logDirectory;
131 
132  /**
133  * Template of log file name without extension.
134  *
135  * \note Default value is \e "SenafMarketDataHandlerCpp".
136  */
137  std::string logFileNamePrefix;
138 
139  /**
140  * Log verbosity.
141  *
142  * \note Default value is LogLevels::Info.
143  */
145 
146  /**
147  * Additional options to control which data is to be logged.
148  * Ignored if logging is disabled.
149  *
150  * \note The default value is \c AdvancedLogOptions::Default.
151  */
153 
154  /**
155  * Specifies one or more network interfaces to use while
156  * joining the multicast group; use semi-colon delimited
157  * list if more than one.
158  *
159  * \note On Linux the network interface is specified
160  * by its name, on Windows - by IP address.
161  *
162  * \note If the value is empty or absent then the
163  * default networking interface is used.
164  */
165  std::string networkInterface;
166 
167  /**
168  * Specifies maximal time interval in seconds between two
169  * network packets. If no data is received during specified
170  * time frame, warning is reported.
171  *
172  * \note The default value is \c 3.
173  */
175 
176  /**
177  * Defines set of CPUs by their indices (starting from zero)
178  * allowed for thread used by the Handler while
179  * processing market data to be executed on.
180  *
181  * \note By default set is empty thus allowing threads
182  * to be executed on any CPU available in the system.
183  */
185 
186  /**
187  * Application Name.
188  */
189  std::string applicationName;
190 
191  /**
192  * Application Password.
193  */
194  std::string applicationPassword;
195 
196  /**
197  * Application Version.
198  */
199  unsigned short applicationVersion;
200 
201  /**
202  * Connection retries configuration settings.
203  */
205 
206  /**
207  * CPU affinity of the receiving thread.
208  */
210 
211  /**
212  * CPU affinity of the receiving thread.
213  */
215 
216  /**
217  * List of logs to be replated.
218  *
219  * \attention Must be stored in 'oldest to recent' order.
220  */
221  LogList logs;
222 
223  /// User defined input stream for log replay logs will be ignored
225 
226  /**
227  * Log player speed multiplier.
228  *
229  * This is an \f$ m \f$ in the formula \f$ mT+k \f$ to calculate delays
230  * between packets, where \f$ T \f$ is original delay. Values less than \c 1
231  * means reduced speed, greater than \c 1 means increased speed. Default value
232  * is \c 1.0 which means a normal speed.
233  */
235 
236  /**
237  * Log player speed auxiliary delay.
238  *
239  * This is an \f$ k \f$ in the formula \f$ mT+k \f$ to calculate delays
240  * between packets, where \f$ T \f$ is original delay. Default value is \c 0.
241  */
243 
244  /// Audit Trail files are stored in this directory.
245  ///
246  /// \note The default value is empty string.
247  std::string auditTrailDirectory;
248 
249  /// Template of Audit Trail file name without extension.
250  ///
251  /// Creates Audit Trail file that contains all messages that Handler sent or
252  /// received (in the chronological order).
253  ///
254  /// \note The default value is empty string (means no audit trail files
255  /// required).
257 
258  /// CPU affinity of the audit-trail thread.
260 
261  /// Market Image (Debug) files will be stored in this directory.
262  ///
263  /// \note The default value is "dump".
264  std::string marketImageDirectory;
265 
266  /// Template of Market Image (Debug) file name without extension.
267  ///
268  /// Creates Market Image file. See 5.6. Debugging and Testing Support for more
269  /// details.
270  ///
271  /// \note The default value is "File".
273 
274  /// Initializes instance with default values for control parameters.
275  HandlerSettings();
276 
277  /// Returns string representation.
278  std::string toString() const;
279 };
280 
281 /// Make it printable to formatted C++ I/O streams.
282 ONIXS_BME_SENAF_EXPORT std::ostream& operator<<(std::ostream&, const HandlerSettings&);
283 
284 }}} // namespace OnixS::Senaf::MarketData
ConnectionRetries(int inNumber, unsigned inInterval)
Constructor.
std::vector< std::string > LogList
Ordered list of logs to be replayed.
virtual ~LogReplayInputStream()
Deletion is not supposed through interface of this class.
LogReplayInputStream * inputStream
User defined input stream for log replay logs will be ignored.
Defines set of settings which affect behavior of the Handler.
std::set< int > CpuIndexes
std::ostream & operator<<(std::ostream &, const Error &)
Make it printable to formatted C++ I/O streams.
CpuIndexes auditTrailThreadAffinity
CPU affinity of the audit-trail thread.
Represents set of CPU indices.
unsigned AdvancedLogOptionSet
Additional options to control log information.
Definition: LogSettings.h:90