OnixS C++ B3 Binary UMDF Market Data Handler  1.4.2
API documentation
Handler.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 <unordered_set>
23 #include <vector>
24 
30 
31 namespace OnixS
32 {
33  namespace B3
34  {
35  namespace MarketData
36  {
37  namespace UMDF
38  {
39  namespace Implementation { struct PcapReplayHelper; }
40  class ErrorListener;
41  class FeedEngine;
42  class WarningListener;
43  class MessageListener;
44  class OrderBookListener;
45 
46  struct HandlerSettings;
47 
48  /// B3 Binary UMDF Market Data Handler class.
49  class ONIXS_B3_UMDF_MD_API Handler
50  {
51  public:
52  /// Performs instance initialization.
53  /// @param settings defines values for various options
54  /// which affect handler behavior like enabling logging
55  /// during execution of the handler.
56  explicit
57  Handler (const HandlerSettings& settings);
58 
59  /// Finalizes the Handler.
60  virtual ~Handler();
61 
62  /// Assigns listener for errors occurred while executing handler.
63  /// It's permissible to change the listener multiple times during
64  /// handler's life-time, but only when handler is in disconnected state.
65  /// @throw OperationException if handler not disconnected
66  void registerErrorListener (ErrorListener* listener);
67 
68  /// Assigns listener for warnings occurred while executing handler.
69  /// It's permissible to change the listener multiple times during
70  /// handler's life-time, but only when handler is in disconnected state.
71  /// @throw OperationException if handler not disconnected
72  void registerWarningListener (WarningListener* listener);
73 
74  /// Assigns listener for state change events occurred while executing handler.
75  /// It's permissible to change the listener multiple times during
76  /// handler's life-time, but only when handler is in disconnected state.
77  /// @throw OperationException if handler not disconnected.
78  void registerHandlerStateListener (HandlerStateListener* listener);
79 
80  /// Assigns listener to receive notifications when Optiq MDG messages are received while executing handler.
81  /// It's permissible to change the listener multiple times during
82  /// handler's life-time, but only when handler is in disconnected state.
83  /// @throw OperationException if handler not disconnected.
84  void registerMessageListener (MessageListener* listener);
85 
86  /// Assigns listener to receive notification about order book states while executing handler.
87  /// It's permissible to change the listener multiple times during
88  /// handler's life-time, but only when handler is in disconnected state.
89  /// @throw OperationException if handler not disconnected.
90  void registerOrderBookListener (OrderBookListener* listener);
91 
92  /// Start handler.
93  ///
94  /// @note This action is asynchronous.
95  /// @throw std::exception in case of unable to start.
96  void start ();
97 
98  /// Stop handler.
99  void stop (bool wait);
100 
101  /// Returns handler state.
102  HandlerState::Enum state () const;
103 
104  /// Logs the given user-level message to the handler log.
105  void log (LogLevel::Enum logLevel, const char* logMessage, size_t length);
106 
107  /// Logs the given user-level message to the handler log
108  void log (LogLevel::Enum logLevel, const char* logMessage);
109 
110  /// Logs the given user-level message to the handler log.
111  void log (LogLevel::Enum logLevel, const std::string& str);
112 
113  /// Returns the license expiration date.
114  std::string licenseExpirationDate () const;
115 
116  /// Returns Handler's version.
117  static const char* version ();
118 
119  /// Starts replaying previously logged data.
120  void replayLogs (const ReplayOptions& options);
121 
122  /// Replay pcap files.
123  void replayPcap (const ReplayOptions& options, const FilesList& instrument, const FilesList& snapshot);
124 
125  /// Adds security id to the security filter
126  Handler& subscribe(Messaging::SecurityID securityId);
127 
128  /// Adds a few security ids to the security filter
129  Handler& subscribe(std::initializer_list<Messaging::SecurityID> securityIds);
130 
131  /// Removes security id from the security filter
132  Handler& unsubscribe(Messaging::SecurityID securityId);
133 
134  /// Removes a few security ids from the security filter
135  Handler& unsubscribe(std::initializer_list<Messaging::SecurityID> securityIds);
136 
137  private:
138  Handler (const Handler&); //no implementation
139  Handler& operator = (const Handler&); //no implementation
140 
141  private:
142  friend struct Implementation::PcapReplayHelper;
143  struct Impl;
144  Impl* impl_;
145  };
146 
147 
148  /// Replay pcap files.
149  /// @note Only realtime feed is supported.
150  /// @note Recovery feeds must be disabled.
151  ONIXS_B3_UMDF_MD_API
152  void replayPcap (const std::vector<Handler*>& handlers, const ReplayOptions& options, const FilesList& instrument, const FilesList& snapshot);
153  }
154  }
155  }
156 }
B3 Binary UMDF Market Data Handler class.
Definition: Handler.h:49
Enum
Defines the state that the handler is in.
Definition: Handler.h:31
Defines an interface through which the Handler notifies subscribers about errors occurred while proce...
Definition: ErrorListener.h:51
ONIXS_B3_UMDF_MD_API void replayPcap(const std::vector< Handler * > &handlers, const ReplayOptions &options, const FilesList &instrument, const FilesList &snapshot)
Replay pcap files.
Defines params which affect replay.
Definition: Replay.h:87
std::vector< std::string > FilesList
Ordered list of files to be replayed.
Definition: Replay.h:74
Handler configuration settings.
UInt64 SecurityID
Security ID as defined by B3&#39;s Trading System.
Definition: Fields.h:168
The Feed Engine machinery.
Definition: FeedEngine.h:106