OnixS C++ Eurex T7 Market and Reference Data Interface (EMDI, RDI, EOBI) Handlers  7.4.2
API documentation
Replay.h
Go to the documentation of this file.
1 // Copyright 2005-2012 Onix Solutions Limited [OnixS]. All rights reserved.
2 //
3 // This software owned by Onix Solutions Limited [OnixS] and is protected by copyright law
4 // and international copyright treaties.
5 //
6 // Access to and use of the software is governed by the terms of the applicable ONIXS Software
7 // Services Agreement (the Agreement) and Customer end user license agreements granting
8 // a non-assignable, non-transferable and non-exclusive license to use the software
9 // for it's own data processing purposes under the terms defined in the Agreement.
10 //
11 // Except as otherwise granted within the terms of the Agreement, copying or reproduction of any part
12 // of this source code or associated reference material to any other location for further reproduction
13 // or redistribution, and any amendments to this copyright notice, are expressly prohibited.
14 //
15 // Any reproduction or redistribution for sale or hiring of the Software not in accordance with
16 // the terms of the Agreement is a violation of copyright law.
17 //
18 
19 #pragma once
20 
21 #include <string>
22 #include <vector>
23 
25 #include <OnixS/Eurex/MarketData/Compiler.h>
26 
27 namespace OnixS
28 {
29  namespace Eurex
30  {
31  namespace MarketData
32  {
33  /// @typedef HandlerLogs
34  /// Ordered list of logs to be replayed.
35  typedef std::vector<std::string> HandlerLogs;
36 
37  /// @typedef HandlerLogsEntry
38  /// Read-write iterator over ordered list of logs to be replayed.
39  typedef std::vector<std::string>::iterator HandlerLogsEntry;
40 
41  /// Listening interface for log replay-related events.
42  class ONIXS_EUREX_EMDI_API ReplayListener
43  {
44  public:
45  /// Is called once error occurs while replaying logs.
46  virtual void onReplayError (const std::string& errorDescription) = 0;
47 
48  /// Is called once all the logs are replayed.
49  virtual void onReplayFinished() = 0;
50 
51  protected:
52  /// Deletion is not supposed
53  /// through interface of this class.
54  virtual ~ReplayListener();
55  };
56 
57  /// Logging options.
58  struct ONIXS_EUREX_EMDI_API ReplayMode
59  {
60  enum Enum
61  {
62  /// The packets are replayed with constant delay, defined by ReplayOptions::packetReplayDelay
63  /// Timestamps from the log file are ignored
64  /// ReplayOptions::playSpeedMultiplier is ignored
65  ConstantPacketReplayDelay = 1,
66 
67  /// The packets are replayed with delays as it come from the logs.
68  /// FinalDelay = LogFileDelay * ReplayOptions::playSpeedMultiplier + ReplayOptions::packetReplayDelay
69  NaturalPacketReplayDelay = 2
70  };
71  };
72 
73  /// Gathers log files logs which are stored in a given folder.
74  void ONIXS_EUREX_EMDI_API gatherLogs(HandlerLogs* gatheredLogs, const std::string& root);
75 
76  /// Defines params which affect logs replay.
78  {
79  /// List of instruments logs to be replayed.
80  /// Must be stored in 'oldest to recent' order.
81  HandlerLogs logs;
82 
83  /// Instance to notify about replay events.
85 
86  /// Specifies the time delay (milliseconds) between replayed packets.
87  ///
88  /// @note Ability to control log replay rate. The default value is 0 milliseconds.
89  unsigned int packetReplayDelay;
90 
91  /// Replay multiplier. Used only in ReplayMode::NaturalPacketReplayDelay
92  /// The default value is 1
94 
95  /// Replay mode. The default value is ReplayMode::ConstantPacketReplayDelay
97 
98  /// Initializes instance with default values.
100  : listener(ONIXS_EUREX_EMDI_NULLPTR)
101  , packetReplayDelay(0)
102  , playSpeedMultiplier(1)
103  , replayMode(ReplayMode::ConstantPacketReplayDelay)
104  {
105  }
106 
107  /// Initializes with all the logs which are available
108  /// and are stored in a given folder.
109  explicit
110  ReplayOptions (const std::string& logsRoot)
111  : listener(ONIXS_EUREX_EMDI_NULLPTR)
112  , packetReplayDelay(0)
113  , playSpeedMultiplier(1)
114  , replayMode(ReplayMode::ConstantPacketReplayDelay)
115  {
116  gatherLogs(&logs, logsRoot);
117  }
118  };
119  }
120  }
121 }
122 
ReplayOptions(const std::string &logsRoot)
Definition: Replay.h:110
std::vector< std::string >::iterator HandlerLogsEntry
Definition: Replay.h:39
Definition: Defines.h:30
ReplayMode::Enum replayMode
Replay mode. The default value is ReplayMode::ConstantPacketReplayDelay.
Definition: Replay.h:96
Defines params which affect logs replay.
Definition: Replay.h:77
ReplayOptions()
Initializes instance with default values.
Definition: Replay.h:99
void ONIXS_EUREX_EMDI_API gatherLogs(HandlerLogs *gatheredLogs, const std::string &root)
Gathers log files logs which are stored in a given folder.
Definition: Replay.cpp:37
std::vector< std::string > HandlerLogs
Definition: Replay.h:35
ReplayListener * listener
Instance to notify about replay events.
Definition: Replay.h:84
Listening interface for log replay-related events.
Definition: Replay.h:42