OnixS C++ SGX Titan ITCH Market Data Handler  1.2.2
API documentation
ListenerHolder.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 #pragma once
20 
27 
28 #include <logging/LogFacility.h>
29 
30 #include <OnixS/HandlerCore/Compiler.h>
31 
32 #include "NamespaceHelper.h"
33 
34 namespace OnixS {
35 namespace HandlerCore {
36 namespace Common {
37 
38 class HandlerLogger;
39 
40 }}}
41 
42 ONIXS_HANDLER_NAMESPACE_BEGIN
43 
44 struct SecondsMsg;
45 struct OrderBookDirectoryMsg;
46 struct CombinationOrderBookLegMsg;
47 struct TickSizeTableEntryMsg;
48 struct SystemEventMsg;
49 struct OrderBookStateMsg;
50 struct AddOrderMsg;
51 struct OrderExecutedMsg;
52 struct OrderExecutedWithPriceMsg;
53 struct OrderReplaceMsg;
54 struct OrderDeleteMsg;
55 struct TradeMsg;
56 struct EquilibriumPriceUpdateMsg;
57 
58 class ErrorListener;
59 class WarningListener;
60 class HandlerStateListener;
61 class MessageListener;
62 class TimeListener;
63 class EventAndStateChangeListener;
64 class ReferenceDataListener;
65 class MarketByOrderListener;
66 class TradeListener;
67 class AuctionListener;
68 class OrderBookListener;
69 
70 class OrderBookInternal;
71 
72 class ListenerHolder : public Logging::LogFacility
73 {
74  typedef OnixS::Logging::LogFacility base;
75 
76 public:
77  explicit
78  ListenerHolder(const Logging::LogFacility* parent, HandlerCore::Common::HandlerLogger* logger = nullptr);
79 
80  void setLogger(HandlerCore::Common::HandlerLogger* handlerLogger);
81 
82  void set(ErrorListener* listener) { errorListener_ = listener; }
83  void set(WarningListener* listener) { warningListener_ = listener; }
84  void set(HandlerStateListener* listener) { handlerStateListener_ = listener; }
85  void set(MessageListener* listener) { messageListener_ = listener; }
86  void set(TimeListener* listener) { timeListener_ = listener; }
87  void set(ReferenceDataListener* listener) { referenceDataListener_ = listener; }
88  void set(EventAndStateChangeListener* listener) { systemEventListener_ = listener; }
89  void set(MarketByOrderListener* listener) { orderListener_ = listener; }
90  void set(TradeListener* listener) { tradeListener_ = listener; }
91  void set(AuctionListener* listener) { auctionListener_ = listener; }
92  void set(OrderBookListener* listener) { orderBookListener_ = listener; }
93 
94 
95  bool hasOrderBookListener() const ONIXS_NOEXCEPT { return orderBookListener_ != nullptr; }
96  bool hasErrorListener() const ONIXS_NOEXCEPT { return errorListener_ != nullptr; }
97  bool hasWarningListener() const ONIXS_NOEXCEPT { return warningListener_ != nullptr; }
98  bool hasHandlerStateListener() const ONIXS_NOEXCEPT { return handlerStateListener_ != nullptr; }
99  bool hasMessageListener() const ONIXS_NOEXCEPT { return messageListener_ != nullptr; }
100  bool hasTimeListener() const ONIXS_NOEXCEPT { return timeListener_ != nullptr; }
101  bool hasReferenceDataListener() const ONIXS_NOEXCEPT { return referenceDataListener_ != nullptr; }
102  bool hasSystemEventListener() const ONIXS_NOEXCEPT { return systemEventListener_ != nullptr; }
103  bool hasMarketByOrderListener() const ONIXS_NOEXCEPT { return orderListener_ != nullptr; }
104  bool hasTradeListener() const ONIXS_NOEXCEPT { return tradeListener_ != nullptr; }
105  bool hasAuctionListener() const ONIXS_NOEXCEPT { return auctionListener_ != nullptr; }
106 
107 
108  void invokeError(ErrorCode::Enum code, const std::string& description) ONIXS_NOEXCEPT;
109  void invokeWarning(const std::string& description) ONIXS_NOEXCEPT;
110  void invokeStateChanged(HandlerState::Enum newState) ONIXS_NOEXCEPT;
111 
112  void invokeGap(SequenceNumber expectedSeqNum, SequenceNumber receivedSeqNum) ONIXS_NOEXCEPT;
113  void invokeInactivity() ONIXS_NOEXCEPT;
114 
115  void invokeTime(const SecondsMsg* msg, const DataSource& dataSource) ONIXS_NOEXCEPT;
116 
117  void invokeOrderBookDirectory(const OrderBookDirectoryMsg* msg, const DataSource& dataSource) ONIXS_NOEXCEPT;
118  void invokeCombinationOrderBookLeg(const CombinationOrderBookLegMsg* msg, const DataSource& dataSource) ONIXS_NOEXCEPT;
119  void invokeTickSizeTableEntry(const TickSizeTableEntryMsg* msg, const DataSource& dataSource) ONIXS_NOEXCEPT;
120 
121  void invokeSystemEvent(const SystemEventMsg* msg, const DataSource& dataSource) ONIXS_NOEXCEPT;
122  void invokeOrderBookState(const OrderBookStateMsg* msg, const DataSource& dataSource) ONIXS_NOEXCEPT;
123 
124  void invokeAddOrder(const AddOrderMsg* msg, const DataSource& dataSource) ONIXS_NOEXCEPT;
125  void invokeOrderExecuted(const OrderExecutedMsg* msg, const DataSource& dataSource) ONIXS_NOEXCEPT;
126  void invokeOrderExecutedWithPrice(const OrderExecutedWithPriceMsg* msg, const DataSource& dataSource) ONIXS_NOEXCEPT;
127  void invokeOrderDelete(const OrderDeleteMsg* msg, const DataSource& dataSource) ONIXS_NOEXCEPT;
128  void invokeOrderReplace(const OrderReplaceMsg* msg, const DataSource& dataSource) ONIXS_NOEXCEPT;
129 
130  void invokeTrade(const TradeMsg* msg, const DataSource& dataSource) ONIXS_NOEXCEPT;
131  void invokeEquilibriumPriceUpdate(const EquilibriumPriceUpdateMsg* msg, const DataSource& dataSource) ONIXS_NOEXCEPT;
132 
133  void invokeOrderBookUpdated(const OrderBookInternal& book) ONIXS_NOEXCEPT;
134  void invokeOrderBookOutOfDate(const OrderBookInternal& book) ONIXS_NOEXCEPT;
135  void invokeEndOfSession() ONIXS_NOEXCEPT;
136 
137  void invokeSnapshotRecoveryStarted() ONIXS_NOEXCEPT;
138  void invokeSnapshotRecoveryFinished() ONIXS_NOEXCEPT;
139 
140 private:
141  void reportError(const std::string& description);
142 
143 private:
144  HandlerCore::Common::HandlerLogger* logger_;
145 
146  ErrorListener* errorListener_;
147  WarningListener* warningListener_;
148  HandlerStateListener* handlerStateListener_;
149  MessageListener* messageListener_;
150 
151  TimeListener* timeListener_;
152  ReferenceDataListener* referenceDataListener_;
153  EventAndStateChangeListener* systemEventListener_;
154  MarketByOrderListener* orderListener_;
155  TradeListener* tradeListener_;
156  AuctionListener* auctionListener_;
157 
158  OrderBookListener* orderBookListener_;
159 };
160 
161 ONIXS_HANDLER_NAMESPACE_END
UInt64 SequenceNumber
Alias for Sequence Number type.
Definition: Defines.h:37
Enum
Defines the state that the handler is in.
bool hasMarketByOrderListener() const ONIXS_NOEXCEPT
bool hasSystemEventListener() const ONIXS_NOEXCEPT
bool hasReferenceDataListener() const ONIXS_NOEXCEPT
bool hasHandlerStateListener() const ONIXS_NOEXCEPT
bool hasOrderBookListener() const ONIXS_NOEXCEPT
Enum
Known (selected) error codes.
Definition: ErrorListener.h:34