OnixS C++ CME MDP Premium Market Data Handler  5.8.9
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 
23 #include <OnixS/CME/MDH/Integral.h>
24 #include <OnixS/CME/MDH/Security.h>
25 #include <OnixS/CME/MDH/TinySet.h>
26 
28 
29 /// Represents selection of instruments whose
30 /// market data is to be processed by the Handler.
32 {
33 public:
34  /// Collection of security ids specified
35  /// for given instrument selection.
37 
38  /// Collection of symbols specified
39  /// for given instrument selection.
41 
42  /// Collection of security groups specified
43  /// for given instrument selection.
45 
46  /// Collection of assets specified
47  /// for given instrument selection.
48  typedef TinyStrSet Assets;
49 
50  /// Initializes empty selection.
52 
53  /// Initializes selection as
54  /// copy of the other instance.
56  : securityIds_(other.securityIds())
57  , securityGroups_(other.securityGroups())
58  , symbols_(other.symbols())
59  , assets_(other.assets_)
60  {
61  }
62 
63  /// Securities selected by their identifiers.
64  const SecurityIds& securityIds() const
65  {
66  return securityIds_;
67  }
68 
69  /// Securities selected by their identifiers.
70  SecurityIds& securityIds()
71  {
72  return securityIds_;
73  }
74 
75  /// Securities selected by their groups.
76  const SecurityGroups& securityGroups() const
77  {
78  return securityGroups_;
79  }
80 
81  /// Securities selected by their groups.
82  SecurityGroups& securityGroups()
83  {
84  return securityGroups_;
85  }
86 
87  /// Securities selected by their symbols.
88  const Symbols& symbols() const
89  {
90  return symbols_;
91  }
92 
93  /// Securities selected by their symbols.
94  Symbols& symbols()
95  {
96  return symbols_;
97  }
98 
99  /// Securities selected by their assets.
100  const Assets& assets() const
101  {
102  return assets_;
103  }
104 
105  /// Securities selected by their assets.
106  Assets& assets()
107  {
108  return assets_;
109  }
110 
111  /// Clears selection.
112  void clear()
113  {
114  securityIds_.clear();
115  securityGroups_.clear();
116 
117  symbols_.clear();
118  assets_.clear();
119  }
120 
121  /// Re-initializes selection as
122  /// copy of the other instance.
124  {
125  if (this != &other)
126  {
127  SecurityIds ids(other.securityIds());
128 
129  SecurityGroups groups(other.securityGroups());
130 
131  Symbols symbols(other.symbols());
132 
133  Assets assets(other.assets());
134 
135  //
136 
137  securityIds_.swap(ids);
138  securityGroups_.swap(groups);
139 
140  symbols_.swap(symbols);
141  assets_.swap(assets);
142  }
143 
144  return *this;
145  }
146 
147 private:
148  SecurityIds securityIds_;
149  SecurityGroups securityGroups_;
150 
151  Symbols symbols_;
152  Assets assets_;
153 };
154 
155 /// Serializes instrument selection into text presentation.
157 void toStr(std::string&, const InstrumentSelection&);
158 
159 /// Serializes instrument selection into text presentation.
160 inline std::string toStr(const InstrumentSelection& selection)
161 {
162  std::string str;
163 
164  toStr(str, selection);
165 
166  return str;
167 }
168 
169 //
170 
171 /// Checks whether security with given
172 /// identifier belongs to given selection.
174 {
175  return (ids.empty() || (ids.end() != ids.find(id)));
176 }
177 
178 /// Checks whether security with given
179 /// attribute belongs to given selection.
180 inline bool selected(const TinyStrSet& selection, const StrRef& value)
181 {
182  return (value.empty() || selection.empty() || (selection.end() != selection.find(value)));
183 }
184 
185 /// Checks whether security
186 /// belongs to given selection.
187 inline bool selected(const InstrumentSelection& selection, const Security& security)
188 {
189  return (
190  selected(selection.securityIds(), security.id()) && selected(selection.securityGroups(), security.group())
191  && selected(selection.symbols(), security.symbol()) && selected(selection.assets(), security.asset())
192  );
193 }
194 
bool empty() const
Indicates whether the set is empty.
Definition: TinySet.h:269
ConstIterator end() const
Provides iterating facilities.
Definition: TinySet.h:92
StrRef symbol() const
Security name or symbol.
Definition: Security.h:43
bool empty() const
Indicates whether the referenced text is empty.
Definition: String.h:71
bool selected(const InstrumentSelection &selection, const Security &security)
Checks whether security belongs to given selection.
Definition: Filtering.h:187
TinyStrSet Assets
Collection of assets specified for given instrument selection.
Definition: Filtering.h:48
const SecurityGroups & securityGroups() const
Securities selected by their groups.
Definition: Filtering.h:76
StrRef group() const
Security group code.
Definition: Security.h:59
Represents selection of instruments whose market data is to be processed by the Handler.
Definition: Filtering.h:31
ConstIterator end() const
Provides iterating facilities.
Definition: TinySet.h:294
const SecurityIds & securityIds() const
Securities selected by their identifiers.
Definition: Filtering.h:64
Int32 SecurityId
Unique security identifier.
Definition: Domain.h:31
Implements TinySet for StrRef class.
Definition: TinySet.h:240
#define ONIXS_CMEMDH_LTWT
Definition: Bootstrap.h:46
SecurityId id() const
Unique security identifier.
Definition: Security.h:37
StrRef asset() const
String field that indicates the underlying asset code (Product Code).
Definition: Security.h:72
TinyStrSet SecurityGroups
Collection of security groups specified for given instrument selection.
Definition: Filtering.h:44
bool value(Number &number, const MultiContainer &container, Tag tag)
Finds a tag-value entry in the given collection by the given tag and returns its value component tran...
void clear()
Clears selection.
Definition: Filtering.h:112
TinySet< SecurityId > SecurityIds
Collection of security ids specified for given instrument selection.
Definition: Filtering.h:36
ConstIterator find(const Item &item) const
Tells whether the set contains given item.
Definition: TinySet.h:98
ConstIterator find(const Item &item) const
Looks for the given item and returns iterator pointing to the found entry or to nowhere.
Definition: TinySet.h:301
Provides efficient way of accessing text-based values without copying content of the text being refer...
Definition: String.h:41
#define ONIXS_CMEMDH_NAMESPACE_BEGIN
Definition: Bootstrap.h:67
TinyStrSet Symbols
Collection of symbols specified for given instrument selection.
Definition: Filtering.h:40
Attributes associated with security.
Definition: Security.h:29
Symbols & symbols()
Securities selected by their symbols.
Definition: Filtering.h:94
bool empty() const
Indicates whether the set is empty.
Definition: TinySet.h:67
#define ONIXS_CMEMDH_EXPORTED
Definition: Compiler.h:160
SecurityGroups & securityGroups()
Securities selected by their groups.
Definition: Filtering.h:82
SecurityIds & securityIds()
Securities selected by their identifiers.
Definition: Filtering.h:70
std::string toStr(const InstrumentSelection &selection)
Serializes instrument selection into text presentation.
Definition: Filtering.h:160
const Symbols & symbols() const
Securities selected by their symbols.
Definition: Filtering.h:88
InstrumentSelection & operator=(const InstrumentSelection &other)
Re-initializes selection as copy of the other instance.
Definition: Filtering.h:123
InstrumentSelection(const InstrumentSelection &other)
Initializes selection as copy of the other instance.
Definition: Filtering.h:55
InstrumentSelection()
Initializes empty selection.
Definition: Filtering.h:51
Assets & assets()
Securities selected by their assets.
Definition: Filtering.h:106
const Assets & assets() const
Securities selected by their assets.
Definition: Filtering.h:100
#define ONIXS_CMEMDH_NAMESPACE_END
Definition: Bootstrap.h:68