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