OnixS C++ CME MDP Conflated UDP Handler  1.1.2
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.
39 {
40  /// Default listener for Handler-related events.
41  static
44  {
45  static
47  listener;
48 
49  return listener;
50  }
51 
52  /// Default listener for feed-related events.
53  static
56  {
57  static
59  listener;
60 
61  return listener;
62  }
63 
64  /// Default listener for market data -related events.
65  static
68  {
69  static
71  listener;
72 
73  return listener;
74  }
75 
76  /// Default listener for security-related events.
77  static
80  {
81  static
83  listener;
84 
85  return listener;
86  }
87 };
88 
89 /// Set of listeners to be used by the Handler to
90 /// reflect various aspects of market data processing.
93  : public SettingGroup
94 {
95  // Lets grouping and value assignment control functioning.
96  friend
98  (
100  );
101 
102  //
103 
104  HandlerListener* handler_;
105  ChannelFeedListener* feeds_;
106  MarketDataListener* marketData_;
107  SecurityListener* security_;
108 
109  // Re-initializes the instance as a copy of the
110  // other one and bypassing assignment control.
111  void
112  assignNoControl(
113  const HandlerListeners& other)
114  {
115  handler_= other.handler_;
116  feeds_ = other.feeds_;
117 
118  marketData_ = other.marketData_;
119  security_ = other.security_;
120  }
121 
122 public:
123  /// Initializes listeners with default values.
126  controller = NULL)
127  : SettingGroup(controller)
128  , handler_(
130  handler())
131  , feeds_(
133  feeds())
134  , marketData_(
136  marketData())
137  , security_(
139  security())
140  {
141  }
142 
143  /// Re-initializes settings as copies of
144  /// the other ones omitting group belonging.
146  const HandlerListeners& other)
147  : SettingGroup()
148  , handler_(other.handler_)
149  , feeds_(other.feeds_)
150  , marketData_(other.marketData_)
151  , security_(other.security_)
152  {
153  }
154 
155  /// Finalizes the instance.
157  {
158  }
160  /// Returns an instance of HandlerListener to be used
161  /// by the Handler while raising Handler related events.
163  handler() const
164  {
165  return
166  (
167  handler_ !=
169  handler()
170  ? handler_
171  : NULL
172  );
173  }
174 
175  /// Returns an instance of HandlerListener to be used
176  /// by the Handler while raising Handler related events.
177  ///
178  /// If no or a null instance was previously associated,
179  /// the given member returns default listener.
181  handlerOrDefault() const
182  {
183  return *handler_;
184  }
185 
186  /// Assigns listener for Handler related events.
187  ///
188  /// Assigning a null instance tells the Handler
189  /// to omit invoking corresponding events.
190  void
191  handler(
192  HandlerListener* listener)
193  {
194  controlAssignment
195  (
196  "Handler Listener",
197  handler_,
198  listener
199  ? listener
200  : &DefaultListeners::handler()
201  );
202  }
204  /// Returns an instance of ChannelFeedListener to be used
205  /// by the Handler while raising feed related events.
207  feeds() const
208  {
209  return
210  (
211  feeds_ !=
213  feeds()
214  ? feeds_
215  : NULL
216  );
217  }
218 
219  /// Returns an instance of ChannelFeedListener to be used
220  /// by the Handler while raising feed related events.
221  ///
222  /// If no or a null instance was previously associated,
223  /// the given member returns default listener.
225  feedsOrDefault() const
226  {
227  return *feeds_;
228  }
229 
230  /// Assigns listener for feed related events.
231  ///
232  /// Assigning a null instance tells the Handler
233  /// to omit invoking corresponding events.
234  void
235  feeds(
236  ChannelFeedListener* listener)
237  {
238  controlAssignment
239  (
240  "ChannelFeed Listener",
241  feeds_,
242  listener
243  ? listener
244  : &DefaultListeners::feeds()
245  );
246  }
248  /// Returns an instance of MarketDataListener to be used
249  /// by the Handler while raising market data related events.
251  marketData() const
252  {
253  return
254  (
255  marketData_ !=
257  marketData()
258  ? marketData_
259  : NULL
260  );
261  }
262 
263  /// Returns an instance of MarketDataListener to be used
264  /// by the Handler while raising market data related events.
265  ///
266  /// If no or a null instance was previously associated,
267  /// the given member returns default listener.
269  marketDataOrDefault() const
270  {
271  return *marketData_;
272  }
273 
274  /// Assigns listener for market data related events.
275  ///
276  /// Assigning a null instance tells the Handler
277  /// to omit invoking corresponding events.
278  void
279  marketData(
280  MarketDataListener* listener)
281  {
282  controlAssignment
283  (
284  "MarketData Listener",
285  marketData_,
286  listener
287  ? listener
288  : &DefaultListeners::marketData()
289  );
290  }
292  /// Returns an instance of SecurityListener to be used
293  /// by the Handler while raising security-related events.
295  security() const
296  {
297  return
298  (
299  security_ !=
301  security()
302  ? security_
303  : NULL
304  );
305  }
306 
307  /// Returns an instance of SecurityListener to be used
308  /// by the Handler while raising security-related events.
309  ///
310  /// If no or a null instance was previously associated,
311  /// the given member returns default listener.
313  securityOrDefault() const
314  {
315  return *security_;
316  }
317 
318  /// Assigns listener for security related events.
319  ///
320  /// Assigning a null instance tells the Handler
321  /// to omit invoking corresponding events.
322  void
323  security(
324  SecurityListener* listener)
325  {
326  controlAssignment
327  (
328  "Security Listener",
329  security_,
330  listener
331  ? listener
332  : &DefaultListeners::security()
333  );
334  }
335 
336  /// Copies listeners from the given instance.
337  ///
338  /// Attributes controlling value assignment are
339  /// not cloned and thus only listeners are copied.
341  operator =(
342  const HandlerListeners& other)
343  {
344  controlAssignment
345  (
346  "Handler Listeners",
347  &HandlerListeners::assignNoControl,
348  *this,
349  other
350  );
351 
352  return *this;
353  }
354 };
355 
356 /// Serializes information on associated listeners.
357 ONIXS_CONFLATEDUDP_EXPORTED
358 void
359 toStr(
360  std::string&,
361  const HandlerListeners&);
362 
363 /// Serializes information on associated listeners.
364 inline
365 std::string
367  const HandlerListeners& listeners)
368 {
369  std::string str;
370 
371  toStr(str, listeners);
372 
373  return str;
374 }
375 
Callbacks invoked by Handler to expose market data entities.
Handler&#39;s configuration settings.
#define ONIXS_CONFLATEDUDP_LTWT_CLASS_DECL(name)
Definition: Bootstrap.h:107
static MarketDataListener & marketData()
Default listener for market data -related events.
static HandlerListener & handler()
Default listener for Handler-related events.
static SecurityListener & security()
Default listener for security-related events.
#define ONIXS_CONFLATEDUDP_EXPORTED_STRUCT
Definition: Bootstrap.h:59
Base services for settings grouped by a certain criteria.
Definition: SettingGroup.h:123
std::string toStr(const HandlerListeners &listeners)
Serializes information on associated listeners.
#define ONIXS_CONFLATEDUDP_NAMESPACE_END
Definition: Bootstrap.h:157
Events raised by Handler while processing market data.
static ChannelFeedListener & feeds()
Default listener for feed-related events.
#define ONIXS_CONFLATEDUDP_LTWT_CLASS
Definition: Bootstrap.h:95
#define ONIXS_CONFLATEDUDP_NAMESPACE_BEGIN
Definition: Bootstrap.h:153