OnixS C++ CME Market Data Handler  5.4.0
API documentation
HandlerListener.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 <string>
24 
26 
28 
29 /// Collection of statuses of recovery completion.
31 {
32  enum Enum
33  {
34  /// Recovery accomplished successfully.
36 
37  /// Recovery failed and no further
38  /// attempts to recover will be made.
40 
41  /// Identifies incomplete recovery.
42  /// Used to identify restart of recovery,
43  /// when new loop of recovery data is detected
44  /// and thus recovery must be done from scratch.
45  Incomplete
46  };
47 };
48 
49 /// Gathers information about the recovery completion.
51 {
52 public:
53  /// Initializes as blank instance.
55  {
56  }
57 
58  /// Initializes with given details.
61  const std::string& message = std::string())
62  : status_(status), message_(message)
63  {
64  }
65 
66  /// Indicates completion status of the recovery.
68  {
69  return status_;
70  }
71 
72  /// Assigns completion status of the recovery.
73  void
76  {
77  status_ = status;
78  }
79 
80  /// Human readable description of recovery completion.
81  /// In case of failure may include failure reason.
82  const std::string& details() const
83  {
84  return message_;
85  }
86 
87  /// Associates human readable message
88  /// with recover completion event.
89  void
91  const std::string& message)
92  {
93  message_ = message;
94  }
95 
96 private:
98  std::string message_;
99 };
100 
101 /// Collection of issues Handler may
102 /// report during market data processing.
104 Issue
105 {
106  enum Enum
107  {
108  /// Identifies network connection failure.
110 
111  /// Source reported this issue will
112  /// function in reduced capacity.
113  ///
114  /// For example, if feed engine fails to
115  /// configure feed to use socket buffer as
116  /// specified by Handler settings, feed will
117  /// continue functioning but in reduced capacity.
119 
120  /// Indicates data reception failure.
122 
123  /// Indicates data receive timeout.
125 
126  /// Indicates data processing failure.
128 
129  /// Indicates internal queue overflow.
131 
132  /// Indicates error in data sequence.
134 
135  /// Operation performed by the Handler failed.
137 
138  /// Operation performed by the Handler did not
139  /// accomplish within the time allocated for it.
141 
142  /// Market data replay failed.
143  ReplayFailure
144  };
145 };
146 
147 /// Gathers information about the issue Handler
148 /// may experience while processing market data.
150 IssueArgs
151 {
152  Issue::Enum id_;
153  const std::string& source_;
154  const std::string& description_;
155 
156  IssueArgs(const IssueArgs&);
157  IssueArgs& operator =(const IssueArgs&);
158 
159 public:
160  /// Initializes issue with provided attributes.
162  Issue::Enum id,
163  const std::string& source,
164  const std::string& description)
165  : id_(id)
166  , source_(source)
167  , description_(description)
168  {
169  }
170 
171  /// Issue identifier.
172  Issue::Enum id() const
173  {
174  return id_;
175  }
176 
177  /// Source of the issue.
178  const std::string& source() const
179  {
180  return source_;
181  }
182 
183  /// Human readable description of the issue.
184  const std::string& description() const
185  {
186  return description_;
187  }
188 };
189 
190 /// Warning arguments.
191 typedef
192 IssueArgs
194 
195 /// Error arguments.
196 typedef
197 IssueArgs
199 
201 
202 /// Events raised by Handler while processing market data.
205 {
206  /// Handler is has started to process market data.
207  virtual
208  void
210  {
211  }
212 
213  /// Invoked when Handler has stopped market data processing.
214  virtual
215  void
217  {
218  }
219 
220  /// Download or replay of Security Definition(d) messages is started.
221  virtual
222  void
224  {
225  }
226 
227  /// Download or replay of Security Definition(d) messages is finished.
228  virtual
229  void
231  Handler&,
232  const RecoveryCompletionArgs&)
233  {
234  }
235 
236  /// Handler started recovering order books from snapshots.
237  ///
238  /// Handler switches to this state when it joins the market and the
239  /// initial books state is built from MarketDataSnapshotFullRefresh
240  /// (MsgType=W) messages or when the TCP Recovery is not used and the
241  /// message sequence number gap is detected, so the book state should
242  /// be re-built from MarketDataSnapshotFullRefresh (MsgType=W) messages
243  /// again.
244  ///
245  /// It should be assumed at this point that all books maintained
246  /// in the Handler may no longer have the correct, latest state
247  /// maintained by CME, so they are cleared.
248  virtual
249  void
251  {
252  }
253 
254  /// Handler accomplished recovering order books from snapshots.
255  ///
256  /// Handler switches to this state when the latest books state is
257  /// restored from MarketDataSnapshotFullRefresh (MsgType=W) messages
258  /// (all snapshot data is retrieved).
259  ///
260  /// It should be assumed at this point that all books maintained in
261  /// the Handler have the correct, latest state maintained by CME.
262  virtual
263  void
265  Handler&,
266  const RecoveryCompletionArgs&)
267  {
268  }
269 
270  /// Handler spawned recovery of lost packets over TCP feed.
271  virtual
272  void
274  {
275  }
276 
277  /// Handler accomplished recovery of lost packets over TCP feed.
278  virtual
279  void
281  Handler&,
282  const RecoveryCompletionArgs&)
283  {
284  }
285 
286  /// Handler resumed real-time processing of
287  /// market data received over incremental feeds.
288  virtual
289  void
291  {
292  }
293 
294  /// Handler suspended real-time processing of
295  /// market data received over incremental feeds.
296  virtual
297  void
299  {
300  }
301 
302  /// Non-critical issue occurred while Handler is
303  /// processing market data. Handler will handle
304  /// an issue by itself, thus no special handling
305  /// is required for the case. Supplied parameters
306  /// exposes details information on the issue.
307  virtual
308  void
310  Handler&,
311  const WarningArgs&)
312  {
313  }
314 
315  /// Error occurred while Handler is processing market
316  /// data. In contrast to warnings, given issue indicates
317  /// the fact Handler fell into a conditions which are not
318  /// supposed to take place (for example, book update failed
319  /// due to corrupted data). Handler will handle an issue by
320  /// itself, thus no special handling is required for the case.
321  virtual
322  void
324  Handler&,
325  const ErrorArgs&)
326  {
327  }
328 };
329 
Indicates data processing failure.
#define ONIXS_CMEMDH_LTWT_CLASS
Definition: Bootstrap.h:94
Indicates data receive timeout.
void status(RecoveryCompletionStatus::Enum status)
Assigns completion status of the recovery.
RecoveryCompletionStatus::Enum status() const
Indicates completion status of the recovery.
RecoveryCompletionArgs()
Initializes as blank instance.
Recovery accomplished successfully.
void details(const std::string &message)
Issue::Enum id() const
Issue identifier.
virtual void onEndOfMarketRecovery(Handler &, const RecoveryCompletionArgs &)
virtual void onInstrumentRecovery(Handler &)
Download or replay of Security Definition(d) messages is started.
IssueArgs(Issue::Enum id, const std::string &source, const std::string &description)
Initializes issue with provided attributes.
Identifies network connection failure.
Indicates data reception failure.
virtual void onWarning(Handler &, const WarningArgs &)
virtual void onRealtimeProcessing(Handler &)
#define ONIXS_CMEMDH_EXPORTED_CLASS_DECL(typeName)
Definition: Bootstrap.h:46
virtual void onStopped(Handler &)
Invoked when Handler has stopped market data processing.
IssueArgs WarningArgs
Warning arguments.
Indicates internal queue overflow.
Indicates error in data sequence.
#define ONIXS_CMEMDH_LTWT_STRUCT
Definition: Bootstrap.h:98
Collection of statuses of recovery completion.
virtual void onMarketRecovery(Handler &)
#define ONIXS_CMEMDH_NAMESPACE_BEGIN
Definition: Bootstrap.h:152
Gathers information about the recovery completion.
virtual void onEndOfRealtimeProcessing(Handler &)
virtual void onError(Handler &, const ErrorArgs &)
RecoveryCompletionArgs(RecoveryCompletionStatus::Enum status, const std::string &message=std::string())
Initializes with given details.
Operation performed by the Handler failed.
virtual void onTcpRecovery(Handler &)
Handler spawned recovery of lost packets over TCP feed.
virtual void onEndOfInstrumentRecovery(Handler &, const RecoveryCompletionArgs &)
Download or replay of Security Definition(d) messages is finished.
const std::string & details() const
virtual void onEndOfTcpRecovery(Handler &, const RecoveryCompletionArgs &)
Handler accomplished recovery of lost packets over TCP feed.
Events raised by Handler while processing market data.
virtual void onStarted(Handler &)
Handler is has started to process market data.
const std::string & source() const
Source of the issue.
#define ONIXS_CMEMDH_EXPORTED_STRUCT
Definition: Bootstrap.h:58
const std::string & description() const
Human readable description of the issue.
IssueArgs ErrorArgs
Error arguments.
#define ONIXS_CMEMDH_NAMESPACE_END
Definition: Bootstrap.h:156