OnixS ICE iMpact Multicast Price Feed Handler C++ library  8.15.1
API documentation
Handler.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) Onix Solutions Limited. All rights reserved.
3  *
4  * This software owned by Onix Solutions Limited 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 "Export.h"
26 #include "ErrorListener.h"
27 #include "ExchangeListener.h"
28 #include "FeedEngine.h"
29 #include "FeedListener.h"
30 #include "HandlerSettings.h"
32 #include "LogReplayListener.h"
33 #include "MarketSubscription.h"
34 #include "GroupSubscription.h"
35 #include "WarningListener.h"
36 #include "TcpSettings.h"
38 
39 #include <string>
40 
41 namespace OnixS { namespace ICE { namespace iMpact { namespace MarketData {
42 
43 /// Manipulates ICE iMpact Multicast Price Feeds. Provides flexible services to
44 /// subscribe to the multicast groups which are best suitable for certain needs.
45 class ONIXS_ICEMDH_EXPORT Handler
46 {
47 public:
48 
49  /// Performs instance initialization.
50  ///
51  /// \param handlerSettings defines values for various settings
52  /// which affect handler behavior like enabling logging
53  /// during execution of the handler.
54  Handler(const HandlerSettings& handlerSettings);
55 
56  /// Finalizes the Handler.
57  virtual ~Handler();
58 
59  /// Date when license for the Handler will expire.
60  std::string licenseExpirationDate() const;
61 
62  /// Get version of Handler.
63  static const std::string& version();
64 
65  /// Log a debug message.
66  void logDebug(const std::string& message);
67 
68  /// Log an error message.
69  void logError(const std::string& message);
70 
71  /// Log an information message.
72  void logMessage(const std::string& message);
73 
74  /// Log a warning message.
75  void logWarning(const std::string& message);
76 
77  /// Registers the order book change listener.
78  ///
79  /// Only single instance of listener can be associated with
80  /// the Handler. Registering new listener removes previous one.
81  ///
82  /// Listeners are to be associated before starting market data
83  /// processing.
84  ///
85  /// \throw exception in case of Handler is in active state.
86  void registerOrderBookChangeListener(OrderBookChangeListener* listener);
87 
88  /// Registers the order book update listener.
89  ///
90  /// Only single instance of listener can be associated with
91  /// the Handler. Registering new listener removes previous one.
92  ///
93  /// Listeners are to be associated before starting market data
94  /// processing.
95  ///
96  /// \throw exception in case of Handler is in active state.
97  void registerOrderBookUpdateListener(OrderBookUpdateListener* listener);
98 
99  /// Registers the order book bundle update listener.
100  ///
101  /// Only single instance of listener can be associated with
102  /// the Handler. Registering new listener removes previous one.
103  ///
104  /// Listeners are to be associated before starting market data
105  /// processing.
106  ///
107  /// \throw exception in case of Handler is in active state.
108  void registerOrderBookBundleUpdateListener(OrderBookBundleUpdateListener* listener);
109 
110  /// Registers the error listener.
111  ///
112  /// Only single instance of listener can be associated with
113  /// the Handler. Registering new listener removes previous one.
114  ///
115  /// Listeners are to be associated before starting market data
116  /// processing.
117  ///
118  /// \throw exception in case of Handler is in active state.
119  void registerErrorListener(ErrorListener* listener);
120 
121  /// Registers the warning listener.
122  ///
123  /// Only single instance of listener can be associated with
124  /// the Handler. Registering new listener removes previous one.
125  ///
126  /// Listeners are to be associated before starting market data
127  /// processing.
128  ///
129  /// \throw exception in case of Handler is in active state.
130  void registerWarningListener(WarningListener* listener);
131 
132  /// Registers the Exchange listener.
133  ///
134  /// Only single instance of listener can be associated with
135  /// the Handler. Registering new listener removes previous one.
136  ///
137  /// Listeners are to be associated before starting market data
138  /// processing.
139  ///
140  /// \throw exception in case of Handler is in active state.
141  void registerExchangeListener(ExchangeListener* listener);
142 
143  /// Registers the feed listener.
144  ///
145  /// Only single instance of listener can be associated with
146  /// the Handler. Registering new listener removes previous one.
147  ///
148  /// Listeners are to be associated before starting market data
149  /// processing.
150  ///
151  /// \throw exception in case of Handler is in active state.
152  void registerFeedListener(FeedListener* listener);
153 
154  /// Registers the Handler state change listener.
155  ///
156  /// Only single instance of listener can be associated with
157  /// the Handler. Registering new listener removes previous one.
158  ///
159  /// Listeners are to be associated before starting market data
160  /// processing.
161  ///
162  /// \throw exception in case of Handler is in active state.
163  void registerHandlerStateChangeListener(HandlerStateChangeListener* listener);
164 
165  /// Registers the log replay listener.
166  ///
167  /// Only single instance of listener can be associated with
168  /// the Handler. Registering new listener removes previous one.
169  ///
170  /// Listeners are to be associated before starting market data
171  /// processing.
172  ///
173  /// \throw exception in case of Handler is in active state.
174  void registerLogReplayListener(LogReplayListener* listener);
175 
176  /// Registers the packet processing listener.
177  ///
178  /// Only single instance of listener can be associated with
179  /// the Handler. Registering new listener removes previous one.
180  ///
181  /// Listeners are to be associated before starting market data
182  /// processing.
183  ///
184  /// \throw exception in case of Handler is in active state.
185  void registerPacketProcessingListener(PacketProcessingListener* listener);
186 
187  /// Binds Feed Engine to the Handler.
188  ///
189  /// Handler must be in stopped state.
190  ///
191  /// \throw exception in case when Handler is not in configurable state.
192  void bindFeedEngine(FeedEngine& feedEngine);
193 
194  /// Subscribes to the given market. Subscribers are get notified
195  /// about certain events through previously registered handlers.
196  /// Notifications will occur until 'stop' member will be called.
197  ///
198  /// \param marketSubscription - subscription attributes for a
199  /// particular market type.
200  ///
201  /// \throw exception in case of unable to establish TCP connection.
202  void start(const MarketSubscription& marketSubscription);
203 
204  /// Subscribes to the given markets. Subscribers are get notified
205  /// about certain events through previously registered handlers.
206  /// Notifications will occur until 'stop' member will be called.
207  ///
208  /// \param marketSubscriptions - collection of subscriptions each
209  /// entry of which defines subscription attributes for a particular
210  /// market type.
211  ///
212  /// \throw exception in case of unable to establish TCP connection.
213  void start(const MarketSubscriptions& marketSubscriptions);
214 
215  /// Subscribes to the given group. Subscribers are get notified
216  /// about certain events through previously registered handlers.
217  /// Notifications will occur until 'stop' member will be called.
218  ///
219  /// \param groupSubscription - subscription attributes for a
220  /// particular multicast group.
221  ///
222  /// \throw exception in case of unable to establish TCP connection.
223  void start(const GroupSubscription& groupSubscription);
224 
225  /// Subscribes to the given groups. Subscribers are get notified
226  /// about certain events through previously registered handlers.
227  /// Notifications will occur until 'stop' member will be called.
228  ///
229  /// \param groupSubscriptions - collection of subscriptions each
230  /// entry of which defines subscription attributes for a particular
231  /// group.
232  ///
233  /// \throw exception in case of unable to establish TCP connection.
234  void start(const GroupSubscriptions& groupSubscriptions);
235 
236  /// Interrupts all subscriptions.
237  void stop();
238 
239  /// Indicates whether subscriptions are being handled.
240  bool active() const;
241 
242  /// Get handler state.
243  HandlerStates::Enum state() const;
244 
245  /// Set TCP settings.
246  ///
247  /// \param tcpSettings New TCP Settings.
248  void setTcpSettings(const TcpSettings& tcpSettings);
249 
250  /// Get TCP options.
251  ///
252  /// \returns TCP settings.
253  const TcpSettings& getTcpSettings() const;
254 
255  /// Set credentials for a TCP server.
256  ///
257  /// \param name TCP server name.
258  /// \param username Username.
259  /// \param password Password.
260  void setTcpServerCredentials(
261  const std::string& name
262  , const std::string& username
263  , const std::string& password
264  );
265 
266 private:
267  Handler(const Handler&) /*= delete */; // no implementation
268  Handler& operator=(const Handler&) /*= delete */; // no implementation
269 
270 private:
271  class Implementation;
272  Implementation* impl_;
273 };
274 
275 }}}} // namespace MarketData, iMpact, ICE, OnixS
Defines an interface through which the Handler notifies subscribers about all received messages...
Defines set of settings which affect behavior of the Handler.
Manages processing machinery for market data received from feeds.
Definition: FeedEngine.h:32
std::set< GroupSubscription > GroupSubscriptions
Collection of group subscriptions.
Defines the interface through which the Handler notifies subscribers about errors occurred while proc...
Definition: ErrorListener.h:30
Defines TCP connectivity options.
Definition: TcpSettings.h:88
Defines the interface through which the Handler notifies subscribers about feed events.
Definition: FeedListener.h:33
Defines which books should be maintained for given market type id.
Defines which books should be maintained for given group name.
std::set< MarketSubscription > MarketSubscriptions
Collection of market subscriptions.
Class OnixS::ICE::iMpact::MarketData::ExchangeListener (interface)
Defines the interface through which the Handler notifies subscribers about log replay events...
Enum
Available Handler&#39;s states.
Definition: HandlerState.h:30