OnixS C++ CME MDP Premium Market Data Handler  5.8.9
API Documentation
HandlerListeners.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 
27 
30 
32 
34 
35 /// Default listeners used by the Handler
36 /// if no user-defined instances are provided.
38 {
39  /// Default listener for Handler-related events.
41  {
42  static HandlerListener listener;
43 
44  return listener;
45  }
46 
47  /// Default listener for feed-related events.
49  {
50  static ChannelFeedListener listener;
51 
52  return listener;
53  }
54 
55  /// Default listener for market data -related events.
57  {
58  static MarketDataListener listener;
59 
60  return listener;
61  }
62 
63  /// Default listener for security-related events.
65  {
66  static SecurityListener listener;
67 
68  return listener;
69  }
70 };
71 
72 /// Set of listeners to be used by the Handler to
73 /// reflect various aspects of market data processing.
75 {
76 public:
77  /// Initializes listeners with default values.
79  : SettingGroup(controller)
80  , handler_(&DefaultListeners::handler())
81  , feeds_(&DefaultListeners::feeds())
82  , marketData_(&DefaultListeners::marketData())
83  , security_(&DefaultListeners::security())
84  {
85  }
86 
87  /// Re-initializes settings as copies of
88  /// the other ones omitting group belonging.
90  : SettingGroup()
91  , handler_(other.handler_)
92  , feeds_(other.feeds_)
93  , marketData_(other.marketData_)
94  , security_(other.security_)
95  {
96  }
97 
98  /// Finalizes the instance.
100 
101  /// Returns an instance of HandlerListener to be used
102  /// by the Handler while raising Handler related events.
104  {
105  return (handler_ != &DefaultListeners::handler() ? handler_ : ONIXS_CMEMDH_NULLPTR);
106  }
107 
108  /// Returns an instance of HandlerListener to be used
109  /// by the Handler while raising Handler related events.
110  ///
111  /// If no or a null instance was previously associated,
112  /// the given member returns default listener.
114  {
115  return *handler_;
116  }
117 
118  /// Assigns listener for Handler related events.
119  ///
120  /// Assigning a null instance tells the Handler
121  /// to omit invoking corresponding events.
123  {
124  controlAssignment("Handler Listener", handler_, listener ? listener : &DefaultListeners::handler());
125 
126  return *this;
127  }
128 
129  /// Returns an instance of ChannelFeedListener to be used
130  /// by the Handler while raising feed related events.
132  {
133  return (feeds_ != &DefaultListeners::feeds() ? feeds_ : ONIXS_CMEMDH_NULLPTR);
134  }
135 
136  /// Returns an instance of ChannelFeedListener to be used
137  /// by the Handler while raising feed related events.
138  ///
139  /// If no or a null instance was previously associated,
140  /// the given member returns default listener.
142  {
143  return *feeds_;
144  }
145 
146  /// Assigns listener for feed related events.
147  ///
148  /// Assigning a null instance tells the Handler
149  /// to omit invoking corresponding events.
151  {
152  controlAssignment("ChannelFeed Listener", feeds_, listener ? listener : &DefaultListeners::feeds());
153 
154  return *this;
155  }
156 
157  /// Returns an instance of MarketDataListener to be used
158  /// by the Handler while raising market data related events.
160  {
161  return (marketData_ != &DefaultListeners::marketData() ? marketData_ : ONIXS_CMEMDH_NULLPTR);
162  }
163 
164  /// Returns an instance of MarketDataListener to be used
165  /// by the Handler while raising market data related events.
166  ///
167  /// If no or a null instance was previously associated,
168  /// the given member returns default listener.
170  {
171  return *marketData_;
172  }
173 
174  /// Assigns listener for market data related events.
175  ///
176  /// Assigning a null instance tells the Handler
177  /// to omit invoking corresponding events.
179  {
180  controlAssignment("MarketData Listener", marketData_, listener ? listener : &DefaultListeners::marketData());
181 
182  return *this;
183  }
184 
185  /// Returns an instance of SecurityListener to be used
186  /// by the Handler while raising security-related events.
188  {
189  return (security_ != &DefaultListeners::security() ? security_ : ONIXS_CMEMDH_NULLPTR);
190  }
191 
192  /// Returns an instance of SecurityListener to be used
193  /// by the Handler while raising security-related events.
194  ///
195  /// If no or a null instance was previously associated,
196  /// the given member returns default listener.
198  {
199  return *security_;
200  }
201 
202  /// Assigns listener for security related events.
203  ///
204  /// Assigning a null instance tells the Handler
205  /// to omit invoking corresponding events.
207  {
208  controlAssignment("Security Listener", security_, listener ? listener : &DefaultListeners::security());
209 
210  return *this;
211  }
212 
213  /// Copies listeners from the given instance.
214  ///
215  /// Attributes controlling value assignment are
216  /// not cloned and thus only listeners are copied.
218  {
219  controlChange("Handler Listeners", &HandlerListeners::assignNoControl, *this, other);
220 
221  return *this;
222  }
223 
224 private:
225  // Lets grouping and value assignment control functioning.
227 
228  //
229 
230  HandlerListener* handler_;
231  ChannelFeedListener* feeds_;
232  MarketDataListener* marketData_;
233  SecurityListener* security_;
234 
235  // Re-initializes the instance as a copy of the
236  // other one and bypassing assignment control.
237  void assignNoControl(const HandlerListeners& other)
238  {
239  handler_ = other.handler_;
240  feeds_ = other.feeds_;
241 
242  marketData_ = other.marketData_;
243  security_ = other.security_;
244  }
245 };
246 
247 /// Serializes information on associated listeners.
249 void toStr(std::string&, const HandlerListeners&);
250 
251 /// Serializes information on associated listeners.
252 inline std::string toStr(const HandlerListeners& listeners)
253 {
254  std::string str;
255 
256  toStr(str, listeners);
257 
258  return str;
259 }
260 
Handler&#39;s configuration settings.
MarketDataListener * marketData() const
Returns an instance of MarketDataListener to be used by the Handler while raising market data related...
HandlerListener * handler() const
Returns an instance of HandlerListener to be used by the Handler while raising Handler related events...
SecurityListener * security() const
Returns an instance of SecurityListener to be used by the Handler while raising security-related even...
#define ONIXS_CMEMDH_NULLPTR
Definition: Compiler.h:167
~HandlerListeners()
Finalizes the instance.
Callbacks invoked by Handler during market data processing to reflect various stages of processing...
SecurityListener & securityOrDefault() const
Returns an instance of SecurityListener to be used by the Handler while raising security-related even...
HandlerListeners & feeds(ChannelFeedListener *listener)
Assigns listener for feed related events.
HandlerListener & handlerOrDefault() const
Returns an instance of HandlerListener to be used by the Handler while raising Handler related events...
HandlerListeners(const HandlerListeners &other)
Re-initializes settings as copies of the other ones omitting group belonging.
ChannelFeedListener & feedsOrDefault() const
Returns an instance of ChannelFeedListener to be used by the Handler while raising feed related event...
#define ONIXS_CMEMDH_LTWT
Definition: Bootstrap.h:46
HandlerListeners & marketData(MarketDataListener *listener)
Assigns listener for market data related events.
static HandlerListener & handler()
Default listener for Handler-related events.
Callbacks invoked by Handler to expose market data entities.
static SecurityListener & security()
Default listener for security-related events.
static ChannelFeedListener & feeds()
Default listener for feed-related events.
A listener for the feed-related events in the bounds of a single Handler instance.
HandlerListeners & handler(HandlerListener *listener)
Assigns listener for Handler related events.
#define ONIXS_CMEMDH_NAMESPACE_BEGIN
Definition: Bootstrap.h:67
Base services for settings grouped by a certain criteria.
Definition: SettingGroup.h:91
HandlerListeners & security(SecurityListener *listener)
Assigns listener for security related events.
MarketDataListener & marketDataOrDefault() const
Returns an instance of MarketDataListener to be used by the Handler while raising market data related...
std::string toStr(const HandlerListeners &listeners)
Serializes information on associated listeners.
static MarketDataListener & marketData()
Default listener for market data -related events.
#define ONIXS_CMEMDH_EXPORTED
Definition: Compiler.h:160
HandlerListeners & operator=(const HandlerListeners &other)
Copies listeners from the given instance.
#define ONIXS_CMEMDH_LTWT_CLASS_DECL(name)
Definition: Bootstrap.h:48
Set of listeners to be used by the Handler to reflect various aspects of market data processing...
HandlerListeners(SettingChangeController *controller=nullptr)
Initializes listeners with default values.
ChannelFeedListener * feeds() const
Returns an instance of ChannelFeedListener to be used by the Handler while raising feed related event...
Represents a service controlling change/update operations for the collections of settings.
Definition: SettingGroup.h:33
Default listeners used by the Handler if no user-defined instances are provided.
Events raised by Handler while processing market data.
#define ONIXS_CMEMDH_NAMESPACE_END
Definition: Bootstrap.h:68