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