OnixS C++ Cboe CFE Multicast PITCH Market Data Handler  1.12.1
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 #pragma once
19 
21 
22 #include <vector>
23 #include <string>
24 
25 namespace OnixS
26 {
27  namespace CboeCFE
28  {
29  namespace MarketData
30  {
31  namespace Pitch
32  {
33  /// @typedef FilesList
34  /// Ordered list of files to be replayed.
35  typedef std::vector<std::string> FilesList;
36 
37  /// Listening interface for log replay-related events.
38  class ONIXS_CBOECFE_PITCH_API ReplayListener
39  {
40  public:
41  /// Is called once error occurs while replaying.
42  virtual void onReplayError (const std::string& errorDescription) = 0;
43 
44  /// Is called once the replay is finished
45  virtual void onReplayFinished() = 0;
46 
47  protected:
48  /// Deletion is not supposed
49  /// through interface of this class.
50  virtual ~ReplayListener();
51  };
52 
53  /// Logging options.
54  struct ONIXS_CBOECFE_PITCH_API ReplayMode
55  {
56  enum Enum
57  {
58  /// The packets are replayed with constant delay, defined by ReplayOptions::packetReplayDelay
59  /// Timestamps from the replayed file are ignored
60  /// ReplayOptions::playSpeedMultiplier is ignored
61  ConstantPacketReplayDelay = 1,
62 
63  /// The packets are replayed with delays as it come from the replayed file.
64  /// FinalDelay = LogFileDelay * ReplayOptions::playSpeedMultiplier + ReplayOptions::packetReplayDelay
65  NaturalPacketReplayDelay = 2
66  };
67  };
68 
69  /// Gathers files which are stored in a given folder.
70  void ONIXS_CBOECFE_PITCH_API gatherFiles(FilesList* gatheredFiles, const std::string& root, const std::string& extension);
71 
72  /// Gathers log files which are stored in a given folder.
73  inline
74  void gatherLogs(FilesList* gatheredLogs, const std::string& root)
75  {
76  gatherFiles(gatheredLogs, root, ".log");
77  }
78 
79  /// Defines params which affect replay.
81  {
82  /// List of files to be replayed.
83  /// Must be stored in 'oldest to recent' order.
84  FilesList logs;
85 
86  /// Instance to notify about replay events.
88 
89  /// Specifies the time delay (milliseconds) between replayed packets.
90  ///
91  /// @note Ability to control replay rate. The default value is 0 milliseconds.
92  unsigned int packetReplayDelay;
93 
94  /// Replay multiplier. Used only in ReplayMode::NaturalPacketReplayDelay
95  /// The default value is 1
97 
98  /// Replay mode. The default value is ReplayMode::ConstantPacketReplayDelay
100 
101  /// Initializes instance with default values.
103  : listener(defaultReplayListener())
104  , packetReplayDelay(0)
105  , playSpeedMultiplier(1)
106  , replayMode(ReplayMode::ConstantPacketReplayDelay)
107  {
108  }
109 
110  /// Initializes with all the files which are available and stored in a given folder.
111  explicit
112  ReplayOptions (const std::string& filesRoot, const std::string& filesExtention = ".log")
113  : listener(defaultReplayListener())
114  , packetReplayDelay(0)
115  , playSpeedMultiplier(1)
116  , replayMode(ReplayMode::ConstantPacketReplayDelay)
117  {
118  gatherFiles(&logs, filesRoot, filesExtention);
119  }
120 
121  private:
122  ONIXS_CBOECFE_PITCH_API static ReplayListener* defaultReplayListener();
123  };
124  }
125  }
126  }
127 }
128 
129 
130 
131 
std::vector< std::string > FilesList
Definition: Replay.h:35
ReplayOptions()
Initializes instance with default values.
Definition: Replay.h:102
ReplayMode::Enum replayMode
Replay mode. The default value is ReplayMode::ConstantPacketReplayDelay.
Definition: Replay.h:99
ReplayListener * listener
Instance to notify about replay events.
Definition: Replay.h:87
ReplayOptions(const std::string &filesRoot, const std::string &filesExtention=".log")
Initializes with all the files which are available and stored in a given folder.
Definition: Replay.h:112
void gatherLogs(FilesList *gatheredLogs, const std::string &root)
Gathers log files which are stored in a given folder.
Definition: Replay.h:74
Listening interface for log replay-related events.
Definition: Replay.h:38
Defines params which affect replay.
Definition: Replay.h:80
void ONIXS_CBOECFE_PITCH_API gatherFiles(FilesList *gatheredFiles, const std::string &root, const std::string &extension)
Gathers files which are stored in a given folder.