OnixS C++ CME MDP Premium Market Data Handler 5.9.0
API Documentation
Loading...
Searching...
No Matches
MboBook.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
25
27
33{
34protected:
37
40 : pool_(*makeMemoryPool(64, 1, 20, 1))
41 , releasePool_(true)
42 {
43 }
44
47 : pool_(sharedPool)
48 , releasePool_(false)
49 {
50 }
51
54 {
55 if (releasePool_)
56 pool_.release();
57 }
58
61 {
62 return OrderAllocator(pool_);
63 }
64
65private:
66 MemoryPool& pool_;
67 const bool releasePool_;
68};
69
72{
73public:
75 typedef Order Entry;
76
78 typedef SortedOrders::size_type Depth;
79
82
84 typedef Entries::const_iterator EntryIterator;
85
88 : state_(BookState::Constructed)
89 , bids_(allocator())
90 , offers_(allocator())
91 {
92 }
93
96 : MboBookBase(pool)
97 , state_(BookState::Constructed)
98 , bids_(allocator())
99 , offers_(allocator())
100 {
101 }
102
104 MboBook(const MboBook& other)
105 : MboBookBase()
106 , state_(other.state())
107 , bids_(allocator())
108 , offers_(allocator())
109 {
110 bids_ = other.bids();
111 offers_ = other.offers();
112 }
113
116
119 {
120 return bids_;
121 }
122
125 {
126 return bids_;
127 }
128
130 const Entries& bids() const
131 {
132 return bids_;
133 }
134
136 const Entries& operator[](const Bids&) const
137 {
138 return bids_;
139 }
140
143 {
144 return offers_;
145 }
146
149 {
150 return offers_;
151 }
152
154 const Entries& offers() const
155 {
156 return offers_;
157 }
158
160 const Entries& operator[](const Offers&) const
161 {
162 return offers_;
163 }
164
167 {
168 return state_;
169 }
170
173 {
174 state_ = state;
175 }
176
180 void reset(BookState::Enum bookState)
181 {
182 state(bookState);
183
184 bids_.clear();
185 offers_.clear();
186 }
187
189 MboBook& operator=(const MboBook& other)
190 {
191 if (this != &other)
192 {
193 state_ = other.state();
194
195 bids_ = other.bids();
196 offers_ = other.offers();
197 }
198
199 return *this;
200 }
201
202private:
203 BookState::Enum state_;
204
205 SortedOrders bids_;
206 SortedOrders offers_;
207};
208
210inline MboBook& copy(MboBook& target, const MboBook& source)
211{
212 target = source;
213 return target;
214}
215
218void brief(std::string&, const MboBook&);
219
221inline std::string brief(const MboBook& book)
222{
223 std::string str;
224
225 brief(str, book);
226
227 return str;
228}
229
232void toStr(std::string&, const MboBook&);
233
235inline std::string toStr(const MboBook& book)
236{
237 std::string str;
238
239 toStr(str, book);
240
241 return str;
242}
243
246void toFormattedStr(std::string&, const MboBook&);
247
249inline std::string toFormattedStr(const MboBook& book)
250{
251 std::string str;
252
253 toFormattedStr(str, book);
254
255 return str;
256}
257
#define ONIXS_CMEMDH_NAMESPACE_BEGIN
Definition Bootstrap.h:67
#define ONIXS_CMEMDH_LTWT
Definition Bootstrap.h:46
#define ONIXS_CMEMDH_NAMESPACE_END
Definition Bootstrap.h:68
#define ONIXS_CMEMDH_EXPORTED
Definition Compiler.h:171
~MboBookBase()
Releases memory pool according to policy.
Definition MboBook.h:53
MboBookBase(MemoryPool &sharedPool)
Binds to given memory pool.
Definition MboBook.h:46
MemoryPoolAllocator< Order > OrderAllocator
Instantiates allocator using MemoryPool for orders.
Definition MboBook.h:36
MboBookBase()
Initializes with privately maintained memory pool.
Definition MboBook.h:39
OrderAllocator allocator() const
Allocator over memory pool.
Definition MboBook.h:60
Market By Order book.
Definition MboBook.h:72
~MboBook()
Disposes allocated resources.
Definition MboBook.h:115
const Entries & operator[](const Bids &) const
List of descending bid prices.
Definition MboBook.h:136
SortedOrders::size_type Depth
Book depth type.
Definition MboBook.h:78
const Entries & offers() const
List of ascending offer prices.
Definition MboBook.h:154
Entries & operator[](const Offers &)
List of ascending offer prices.
Definition MboBook.h:148
Entries::const_iterator EntryIterator
Iterator over bids and offers.
Definition MboBook.h:84
Entries & offers()
List of ascending offer prices.
Definition MboBook.h:142
void reset(BookState::Enum bookState)
Wipes out all bids and offers and other data associated with book (like instance of last applied FIX ...
Definition MboBook.h:180
MboBook(MemoryPool &pool)
Initializes book using given memory pool.
Definition MboBook.h:95
void state(BookState::Enum state)
Updates state of book.
Definition MboBook.h:172
MboBook & operator=(const MboBook &other)
Re-initializes as copy of other instance.
Definition MboBook.h:189
const Entries & bids() const
List of descending bid prices.
Definition MboBook.h:130
SortedOrders Entries
Sorted orders are book entries.
Definition MboBook.h:81
MboBook()
Initializes blank order book.
Definition MboBook.h:87
Entries & bids()
List of descending bid prices.
Definition MboBook.h:118
const Entries & operator[](const Offers &) const
List of ascending offer prices.
Definition MboBook.h:160
Entries & operator[](const Bids &)
List of descending bid prices.
Definition MboBook.h:124
Order Entry
Order as book entry.
Definition MboBook.h:75
MboBook(const MboBook &other)
Initializes as copy of other book.
Definition MboBook.h:104
BookState::Enum state() const
Indicates current state of book.
Definition MboBook.h:166
Memory pool abstraction.
Definition MemoryPool.h:36
Order as the member of the Market By Order (MBO) book.
Definition Order.h:73
void toFormattedStr(std::string &, const ConsolidatedBook &)
Serializes book in formatted form.
std::list< Order, MemoryPoolAllocator< Order > > SortedOrders
Arranged collection of orders.
MboBook & copy(MboBook &target, const MboBook &source)
Copies content of MBO book to the other one.
Definition MboBook.h:210
void toStr(std::string &, BookState::Enum)
Serializes book state value into a string.
MemoryPool * makeMemoryPool(size_t, size_t, size_t, size_t)
Constructs a memory pool instance according to the given configuration.
void brief(std::string &, const ConsolidatedBook &)
Book brief info.
Tag class for accessing bids in templates.
State of order book.
Tag class for accessing offers in templates.