OnixS C++ CME Market Data Handler  4.8.0.10
API documentation
TradeOrderIds.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 <vector>
24 
25 #include <OnixS/CME/MDH/Order.h>
26 #include <OnixS/CME/MDH/Messages.h>
27 
29 
30 /// Collection of order details
31 /// referring to a single trade.
33 {
34 public:
35  /// Stores information on order id and other details.
37  {
38  OrderId orderId_;
39  Int32 lastQty_;
40 
41  public:
42  /// Initializes blank instance with no valid attributes.
44  : orderId_(0)
45  , lastQty_(0)
46  {
47  }
48 
49  /// Retrieves order details from given market data entry.
50  template
51  <
52  class Entry
53  >
55  const Entry& entry)
56  : orderId_(entry.orderId())
57  , lastQty_(entry.lastQty())
58  {
59  }
60 
61  /// Returns order identifier.
62  OrderId orderId() const
63  {
64  return orderId_;
65  }
66 
67  /// Returns last quantity for order.
68  Int32 lastQty() const
69  {
70  return lastQty_;
71  }
72  };
73 
74  /// Initializes blank instance.
76  {
77  }
78 
79  /// Initializes blank instance capacious
80  /// enough to store given number of orders.
81  explicit
83  size_t capacity)
84  {
85  reserve(capacity);
86  }
87 
88  /// Initializes as copy of other instance.
90  const TradeOrderIds& other)
91  : ids_(other.ids_)
92  {
93  }
94 
95  /// Destructs internal storage.
97  {
98  }
99 
100  /// Indicates whether collection is empty.
101  bool empty() const
102  {
103  return ids_.empty();
104  }
105 
106  /// Number of items in given collection.
107  size_t size() const
108  {
109  return ids_.size();
110  }
111 
112  /// Provides access to item by its index.
113  const
114  Details&
115  operator [](
116  size_t index) const
117  {
118  assert(
119  index <
120  ids_.size());
121 
122  return ids_[index];
123  }
124 
125  /// Adds order details to collection.
126  template
127  <
128  class Entry
129  >
130  void
132  const Entry& entry)
133  {
134  ids_.push_back(Details(entry));
135  }
136 
137  /// Resets collection to blank state.
138  void clear()
139  {
140  ids_.clear();
141  }
142 
143  /// Makes collection capacious enough
144  /// to store given number of items.
145  void
147  size_t capacity)
148  {
149  ids_.reserve(capacity);
150  }
151 
152 private:
153  typedef
154  std::vector<Details>
155  Ids;
156 
157  Ids ids_;
158 };
159 
#define ONIXS_CMEMDH_LTWT_CLASS
Definition: Bootstrap.h:110
OrderId orderId() const
Returns order identifier.
Definition: TradeOrderIds.h:62
Int32 Int32
int32.
Definition: Fields.h:63
void add(const Entry &entry)
Adds order details to collection.
TradeOrderIds(size_t capacity)
Definition: TradeOrderIds.h:82
Details(const Entry &entry)
Retrieves order details from given market data entry.
Definition: TradeOrderIds.h:54
Int32 lastQty() const
Returns last quantity for order.
Definition: TradeOrderIds.h:68
TradeOrderIds(const TradeOrderIds &other)
Initializes as copy of other instance.
Definition: TradeOrderIds.h:89
TradeOrderIds()
Initializes blank instance.
Definition: TradeOrderIds.h:75
void clear()
Resets collection to blank state.
#define ONIXS_CMEMDH_NAMESPACE_BEGIN
Definition: Bootstrap.h:168
size_t size() const
Number of items in given collection.
Details()
Initializes blank instance with no valid attributes.
Definition: TradeOrderIds.h:43
bool empty() const
Indicates whether collection is empty.
void reserve(size_t capacity)
Stores information on order id and other details.
Definition: TradeOrderIds.h:36
UInt64 OrderId
Type for order identification.
Definition: Order.h:29
~TradeOrderIds()
Destructs internal storage.
Definition: TradeOrderIds.h:96
#define ONIXS_CMEMDH_NAMESPACE_END
Definition: Bootstrap.h:172