OnixS C++ B3 Binary UMDF Market Data Handler  1.6.3
API documentation
LogPlayer.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 <limits>
24 #include <string>
25 
28 
30 
31 /// Identifies channel.
32 typedef UInt32 ChannelId;
33 
34 struct FeedType {
35  enum Enum
36  {
38 
42  };
43 };
44 
45 /// LogPlayer's configuration settings.
47 {
48 public:
49  /// Initializes parameters with default values.
51  {
52  }
53 
54  /// Cleans everything up.
56 
57  /// Path to the log file.
58  const std::string& logFile() const
59  {
60  return logFile_;
61  }
62 
63  /// Path to the log file.
64  LogPlayerSettings& logFile(const std::string& file)
65  {
66  logFile_ = file;
67 
68  return *this;
69  }
70 
71  /// Identifies CME market data channel.
73  {
74  return channel_;
75  }
76 
77  /// Identifies CME market data channel.
79  {
80  channel_ = value;
81  return *this;
82  }
83 
84  /// Path to the connectivity configuration file.
85  const std::string& connectivityConfigurationFile() const
86  {
87  return configurationFile_;
88  }
89 
90  /// Path to the connectivity configuration file from which
91  /// to load feed connection settings.
92  LogPlayerSettings& connectivityConfigurationFile(const std::string& configurationFile)
93  {
94  configurationFile_ = configurationFile;
95 
96  return *this;
97  }
98 
99  /// Pause before sending data to the same source as it was sent before (in microseconds).
100  unsigned sendDelay() const
101  {
102  return sendDelay_;
103  }
104 
105  /// Pause before sending data to the same source as it was sent before (in microseconds).
106  LogPlayerSettings& sendDelay(unsigned delay)
107  {
108  sendDelay_ = delay;
109 
110  return *this;
111  }
112 
113  /// Use delays from the log file. If true, sendDelay will be ignored.
114  bool useNaturalSendDelays() const
115  {
116  return useNaturalSendDelays_;
117  }
118 
119  /// Use delays from the log file. If true, sendDelay will be ignored.
121  {
122  useNaturalSendDelays_ = value;
123 
124  return *this;
125  }
126 
127  /// Update the SendingTime field in the Binary Packet Header
128  bool updateSendingTime() const
129  {
130  return updateSendingTime_;
131  }
132 
133  /// Update the SendingTime field in the Binary Packet Header
135  {
136  updateSendingTime_ = value;
137 
138  return *this;
139  }
140 
141  /// Pause before sending data to the source which differs from the source data was sent before (in microseconds).
142  unsigned sourceSwitchDelay() const
143  {
144  return sourceSwitchDelay_;
145  }
146 
147  /// Pause before sending data to the source which differs from the source data was sent before (in microseconds).
149  {
150  sourceSwitchDelay_ = delay;
151 
152  return *this;
153  }
154 
155  /// Defines primary feed for the feed group.
156  const std::string& primaryFeed() const
157  {
158  return primaryFeed_;
159  }
160 
161  /// Defines primary feed for the feed group.
162  LogPlayerSettings& primaryFeed(const std::string& feed)
163  {
164  primaryFeed_ = feed;
165 
166  return *this;
167  }
168 
169  /// Simulates arbitrage on realtime feeds. By default, data is sent through primary feed only.
170  bool simulateArbitrage() const
171  {
172  return simulateArbitrage_;
173  }
174 
175  /// Simulates arbitrage on realtime feeds. By default, data is sent through primary feed only.
177  {
178  simulateArbitrage_ = value;
179 
180  return *this;
181  }
182 
183  /// Interface through which application must send data belonging to primary feed. If not specified, default network interface is used.
184  const std::string& ifaceA() const
185  {
186  return ifaceA_;
187  }
188 
189  /// Interface through which application must send data belonging to primary feed. If not specified, default network interface is used.
190  LogPlayerSettings& ifaceA(const std::string& iface)
191  {
192  ifaceA_ = iface;
193 
194  return *this;
195  }
196 
197  /// Interface through which application must send data belonging to secondary feed. If not specified, default network
198  /// interface is used.
199  const std::string& ifaceB() const
200  {
201  return ifaceA_;
202  }
203 
204  /// Interface through which application must send data belonging to secondary feed. If not specified, default network
205  /// interface is used.
206  LogPlayerSettings& ifaceB(const std::string& iface)
207  {
208  ifaceA_ = iface;
209 
210  return *this;
211  }
212 
213  /// The number of incremental packets to replay
214  unsigned long packetsCount() const
215  {
216  return packetsCount_;
217  }
218 
219  /// The number of incremental packets to replay
220  LogPlayerSettings& packetsCount(unsigned long value)
221  {
222  packetsCount_ = value;
223 
224  return *this;
225  }
226 
227 private:
228  std::string logFile_;
229  ChannelId channel_ = 80;
230  std::string configurationFile_;
231  unsigned sendDelay_ = 100;
232  bool useNaturalSendDelays_ = false;
233  bool updateSendingTime_ = false;
234  unsigned sourceSwitchDelay_ = 100000;
235  std::string primaryFeed_ = "A";
236  bool simulateArbitrage_ = false;
237  std::string ifaceA_;
238  std::string ifaceB_;
239  unsigned long packetsCount_ = 0xffffffff;
240 
241 };
242 
244 {
245  /// Returns the Interrupter instance state.
246  virtual bool activated() const = 0;
247 };
248 
250 {
251  /// Returns the Interrupter instance state.
252  virtual void onPacketProcessed(FeedType::Enum) const = 0;
253 };
254 
255 
257 {
258  size_t incrementalCounter_ = 0;
259  size_t snapshotCounter_ = 0;
260  size_t instrumentCounter_ = 0;
261 
262  size_t counter(FeedType::Enum type) const;
263 
264 public:
266  {}
267 
268  void reset();
269 
270  void update(FeedType::Enum type);
271 
272  void dump(std::ostream& out) const;
273 };
274 
275 inline std::ostream& operator<<(std::ostream& out, const LogPlayerStatistics& statistics)
276 {
277  statistics.dump(out);
278 
279  return out;
280 }
281 
282 /// Multicast Log Player.
284 {
285 public:
286  /// Initializes the instance according to the given settings.
288 
290  {
291  return statistics_;
292  }
293 
294  /// Starts playing of the log, until the interrupter is activated or the log is played totally.
295  void
296  run(const LogPlayerSettings& settings, const Interrupter* interrupter = nullptr, const PacketNotifier* packetNotifier = nullptr);
297 
298 private:
299  LogPlayerStatistics statistics_;
300 };
301 
const LogPlayerStatistics & statistics() const
Definition: LogPlayer.h:289
LogPlayerSettings & sendDelay(unsigned delay)
Pause before sending data to the same source as it was sent before (in microseconds).
Definition: LogPlayer.h:106
const std::string & connectivityConfigurationFile() const
Path to the connectivity configuration file.
Definition: LogPlayer.h:85
const std::string & ifaceA() const
Interface through which application must send data belonging to primary feed. If not specified...
Definition: LogPlayer.h:184
LogPlayerSettings & ifaceB(const std::string &iface)
Interface through which application must send data belonging to secondary feed.
Definition: LogPlayer.h:206
LogPlayerSettings & updateSendingTime(bool value)
Update the SendingTime field in the Binary Packet Header.
Definition: LogPlayer.h:134
bool updateSendingTime() const
Update the SendingTime field in the Binary Packet Header.
Definition: LogPlayer.h:128
LogPlayerSettings & channel(ChannelId value)
Identifies CME market data channel.
Definition: LogPlayer.h:78
#define ONIXS_B3_UMDF_MD_EXPORTED
Definition: ABI.h:37
Messaging::UInt32 UInt32
Definition: Integral.h:37
LogPlayerSettings & primaryFeed(const std::string &feed)
Defines primary feed for the feed group.
Definition: LogPlayer.h:162
LogPlayerSettings & useNaturalSendDelays(bool value)
Use delays from the log file. If true, sendDelay will be ignored.
Definition: LogPlayer.h:120
ChannelId channel() const
Identifies CME market data channel.
Definition: LogPlayer.h:72
const std::string & primaryFeed() const
Defines primary feed for the feed group.
Definition: LogPlayer.h:156
LogPlayerSettings & simulateArbitrage(bool value)
Simulates arbitrage on realtime feeds. By default, data is sent through primary feed only...
Definition: LogPlayer.h:176
UInt32 ChannelId
Identifies channel.
Definition: LogPlayer.h:32
LogPlayer&#39;s configuration settings.
Definition: LogPlayer.h:46
LogPlayerSettings & connectivityConfigurationFile(const std::string &configurationFile)
Path to the connectivity configuration file from which to load feed connection settings.
Definition: LogPlayer.h:92
LogPlayerSettings & packetsCount(unsigned long value)
The number of incremental packets to replay.
Definition: LogPlayer.h:220
unsigned long packetsCount() const
The number of incremental packets to replay.
Definition: LogPlayer.h:214
LogPlayerSettings & ifaceA(const std::string &iface)
Interface through which application must send data belonging to primary feed. If not specified...
Definition: LogPlayer.h:190
bool useNaturalSendDelays() const
Use delays from the log file. If true, sendDelay will be ignored.
Definition: LogPlayer.h:114
LogPlayerSettings & sourceSwitchDelay(unsigned delay)
Pause before sending data to the source which differs from the source data was sent before (in micros...
Definition: LogPlayer.h:148
LogPlayerSettings()
Initializes parameters with default values.
Definition: LogPlayer.h:50
bool simulateArbitrage() const
Simulates arbitrage on realtime feeds. By default, data is sent through primary feed only...
Definition: LogPlayer.h:170
unsigned sendDelay() const
Pause before sending data to the same source as it was sent before (in microseconds).
Definition: LogPlayer.h:100
#define ONIXS_B3_UMDF_MD_TESTING_NAMESPACE_BEGIN
Definition: ABI.h:146
#define ONIXS_B3_UMDF_MD_LTWT_CLASS
Definition: ABI.h:90
#define ONIXS_B3_UMDF_MD_TESTING_NAMESPACE_END
Definition: ABI.h:151
const std::string & logFile() const
Path to the log file.
Definition: LogPlayer.h:58
unsigned sourceSwitchDelay() const
Pause before sending data to the source which differs from the source data was sent before (in micros...
Definition: LogPlayer.h:142
LogPlayerSettings & logFile(const std::string &file)
Path to the log file.
Definition: LogPlayer.h:64
const std::string & ifaceB() const
Interface through which application must send data belonging to secondary feed.
Definition: LogPlayer.h:199
LogPlayer()
Initializes the instance according to the given settings.
Definition: LogPlayer.h:287
std::ostream & operator<<(std::ostream &out, const LogPlayerStatistics &statistics)
Definition: LogPlayer.h:275