OnixS BME SENAF Handler C++ library  2.0.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 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  * Path to the license directory.
99  *
100  * \note Default value is \e "./" (the current directory).
101  * \note A home directory also used to search a license.
102  */
103  std::string licenseDirectory;
104 
105  /**
106  * Log files are stored in this directory.
107  *
108  * \note Default value is \e "./" (the current directory).
109  */
110  std::string logDirectory;
111 
112  /**
113  * Template of log file name without extension.
114  *
115  * \note Default value is \e "SenafMarketDataHandlerCpp".
116  */
117  std::string logFileNamePrefix;
118 
119  /**
120  * Log verbosity.
121  *
122  * \note Default value is LogLevels::Info.
123  */
125 
126  /**
127  * Additional options to control which data is to be logged.
128  * Ignored if logging is disabled.
129  *
130  * \note The default value is \c AdvancedLogOptions::Default.
131  */
133 
134  /**
135  * Specifies one or more network interfaces to use while
136  * joining the multicast group; use semi-colon delimited
137  * list if more than one.
138  *
139  * \note On Linux the network interface is specifed
140  * by its name, on Windows - by IP address.
141  *
142  * \note If the value is empty or absent then the
143  * default networking interface is used.
144  */
145  std::string networkInterface;
146 
147  /**
148  * Specifies maximal time interval in seconds between two
149  * network packets. If no data is received during specified
150  * time frame, warning is reported.
151  *
152  * \note The default value is \c 3.
153  */
155 
156  /**
157  * Defines set of CPUs by their indices (starting from zero)
158  * allowed for thread used by the Handler while
159  * processing market data to be executed on.
160  *
161  * \note By default set is empty thus allowing threads
162  * to be executed on any CPU available in the system.
163  */
165 
166  /**
167  * Application Name.
168  */
169  std::string applicationName;
170 
171  /**
172  * Application Password.
173  */
174  std::string applicationPassword;
175 
176  /**
177  * Application Version.
178  */
179  unsigned short applicationVersion;
180 
181  /**
182  * Connection retries configuration settings.
183  */
185 
186  /**
187  * CPU affinity of the receiving thread.
188  */
190 
191  /**
192  * CPU affinity of the receiving thread.
193  */
195 
196  /**
197  * List of logs to be replated.
198  *
199  * \attention Must be stored in 'oldest to recent' order.
200  */
201  LogList logs;
202 
203  /// User defined input stream for log replay logs will be ignored
205 
206  /**
207  * Log player speed multiplier.
208  *
209  * This is an \f$ m \f$ in the formula \f$ mT+k \f$ to calculate delays between packets,
210  * where \f$ T \f$ is original delay. Values less than \c 1 means reduced speed, greather
211  * than \c 1 means increased speed. Default value is \c 1.0 which means a normal speed.
212  */
214 
215  /**
216  * Log player speed auxilary delay.
217  *
218  * This is an \f$ k \f$ in the formula \f$ mT+k \f$ to calculate delays between packets,
219  * where \f$ T \f$ is original delay. Default value is \c 0.
220  */
222 
223  /// Audit Trail files are stored in this directory.
224  ///
225  /// @note The default value is empty string.
226  std::string auditTrailDirectory;
227 
228  /// Template of Audit Trail file name without extension.
229  ///
230  /// Creates Audit Trail file that contains all messages that Handler sent or received (in the chronological order).
231  ///
232  /// \note The default value is empty string (means no audit trail files required).
234 
235  /// CPU affinity of the audit-trail thread.
237 
238  /// Market Image (Debug) files will be stored in this directory.
239  ///
240  /// @note The default value is "dump".
241  std::string marketImageDirectory;
242 
243  /// Template of Market Image (Debug) file name without extension.
244  ///
245  /// Creates Market Image file. See 5.6. Debugging and Testing Support for more details.
246  ///
247  /// \note The default value is "File".
249 
250  /// Initializes instance with default values for control parameters.
251  HandlerSettings();
252 
253  /// Returns string representation.
254  std::string toString() const;
255 };
256 
257 /// Make it printable to formatted C++ I/O streams.
258 ONIXS_BME_SENAF_EXPORT std::ostream& operator<<(std::ostream&, const HandlerSettings&);
259 
260 }}} // 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