OnixS C++ CME MDP Conflated UDP Handler  1.1.2
API documentation
Filtering.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 
26 
28 
29 /// Represents selection of instruments whose
30 /// market data is to be processed by the Handler.
33 {
34 public:
35  /// Collection of security ids specified
36  /// for given instrument selection.
37  typedef
40 
41  /// Collection of symbols specified
42  /// for given instrument selection.
43  typedef
46 
47  /// Collection of security groups specified
48  /// for given instrument selection.
49  typedef
52 
53  /// Collection of assets specified
54  /// for given instrument selection.
55  typedef
58 
59  /// Initializes empty selection.
61  {
62  }
63 
64  /// Initializes selection as
65  /// copy of the other instance.
67  const
68  InstrumentSelection& other)
69  : securityIds_(
70  other.securityIds())
71  , securityGroups_(
72  other.securityGroups())
73  , symbols_(
74  other.symbols())
75  , assets_(
76  other.assets_)
77  {
78  }
79 
80  /// Securities selected by their identifiers.
81  const
82  SecurityIds&
83  securityIds() const
84  {
85  return securityIds_;
86  }
87 
88  /// Securities selected by their identifiers.
89  SecurityIds&
91  {
92  return securityIds_;
93  }
94 
95  /// Securities selected by their groups.
96  const
99  {
100  return securityGroups_;
101  }
102 
103  /// Securities selected by their groups.
106  {
107  return securityGroups_;
108  }
109 
110  /// Securities selected by their symbols.
111  const
112  Symbols&
113  symbols() const
114  {
115  return symbols_;
116  }
117 
118  /// Securities selected by their symbols.
119  Symbols&
121  {
122  return symbols_;
123  }
124 
125  /// Securities selected by their assets.
126  const
127  Assets&
128  assets() const
129  {
130  return assets_;
131  }
132 
133  /// Securities selected by their assets.
134  Assets&
136  {
137  return assets_;
138  }
139 
140  /// Clears selection.
141  void clear()
142  {
143  securityIds_.clear();
144  securityGroups_.clear();
145 
146  symbols_.clear();
147  assets_.clear();
148  }
149 
150  /// Re-initializes selection as
151  /// copy of the other instance.
153  operator =(
154  const
155  InstrumentSelection& other)
156  {
157  if (this != &other)
158  {
159  SecurityIds
160  ids(
161  other.securityIds());
162 
164  groups(
165  other.securityGroups());
166 
167  Symbols symbols(
168  other.symbols());
169 
170  Assets assets(
171  other.assets());
172 
173  //
174 
175  securityIds_.swap(ids);
176  securityGroups_.swap(groups);
177 
178  symbols_.swap(symbols);
179  assets_.swap(assets);
180  }
181 
182  return *this;
183  }
184 
185 private:
186  SecurityIds securityIds_;
187  SecurityGroups securityGroups_;
188 
189  Symbols symbols_;
190  Assets assets_;
191 };
192 
193 /// Serializes instrument selection into text presentation.
194 ONIXS_CONFLATEDUDP_EXPORTED
195 void
196 toStr(
197  std::string&,
198  const
200 
201 /// Serializes instrument selection into text presentation.
202 inline
203 std::string
205  const
207  selection)
208 {
209  std::string str;
210 
211  toStr(str, selection);
212 
213  return str;
214 }
215 
216 //
217 
218 /// Checks whether security with given
219 /// identifier belongs to given selection.
220 inline
221 bool
223  const
225  SecurityIds& ids,
226  SecurityId id)
227 {
228  return (
229  ids.empty() ||
230  (ids.end() != ids.find(id))
231  );
232 }
233 
234 /// Checks whether security with given
235 /// attribute belongs to given selection.
236 inline
237 bool
239  const TinyStrSet& selection,
240  const StrRef& value)
241 {
242  return (
243  value.empty()
244  ||
245  selection.empty()
246  ||
247  (selection.end() !=
248  selection.find(value))
249  );
250 }
251 
252 /// Checks whether security
253 /// belongs to given selection.
254 inline
255 bool
257  const InstrumentSelection& selection,
258  const Security& security)
259 {
260  return (
261  selected(
262  selection.securityIds(),
263  security.id())
264  &&
265  selected(
266  selection.securityGroups(),
267  security.group())
268  &&
269  selected(
270  selection.symbols(),
271  security.symbol())
272  &&
273  selected(
274  selection.assets(),
275  security.asset())
276  );
277 }
278 
const SecurityGroups & securityGroups() const
Securities selected by their groups.
Definition: Filtering.h:98
ConstIterator end() const
Provides iterating facilities.
Definition: TinySet.h:410
SecurityId id() const
Definition: Security.h:74
Int32 SecurityId
Unique security identifier.
Definition: Domain.h:31
SecurityIds & securityIds()
Securities selected by their identifiers.
Definition: Filtering.h:90
InstrumentSelection(const InstrumentSelection &other)
Definition: Filtering.h:66
void swap(TinyStrSet &other)
Exchanges content with the other instance.
Definition: TinySet.h:485
const Symbols & symbols() const
Securities selected by their symbols.
Definition: Filtering.h:113
std::string toStr(const InstrumentSelection &selection)
Serializes instrument selection into text presentation.
Definition: Filtering.h:204
StrRef symbol() const
Security name or symbol.
Definition: Security.h:80
const SecurityIds & securityIds() const
Securities selected by their identifiers.
Definition: Filtering.h:83
Assets & assets()
Securities selected by their assets.
Definition: Filtering.h:135
InstrumentSelection()
Initializes empty selection.
Definition: Filtering.h:60
bool empty() const
Indicates whether the referenced text is empty.
Definition: String.h:80
bool selected(const InstrumentSelection &selection, const Security &security)
Definition: Filtering.h:256
#define ONIXS_CONFLATEDUDP_NAMESPACE_END
Definition: Bootstrap.h:157
ConstIterator find(const Item &item) const
Definition: TinySet.h:420
bool empty() const
Indicates whether the set is empty.
Definition: TinySet.h:379
SecurityGroups & securityGroups()
Securities selected by their groups.
Definition: Filtering.h:105
bool value(Number &number, const MultiContainer &container, Tag tag)
#define ONIXS_CONFLATEDUDP_LTWT_CLASS
Definition: Bootstrap.h:95
const Assets & assets() const
Securities selected by their assets.
Definition: Filtering.h:128
#define ONIXS_CONFLATEDUDP_NAMESPACE_BEGIN
Definition: Bootstrap.h:153
Attributes associated with security.
Definition: Security.h:29
Symbols & symbols()
Securities selected by their symbols.
Definition: Filtering.h:120