35template <
typename Depth>
40 error +=
"Cannot re-depth order book "
41 "due to lack of capacity [newDepth=";
43 toStr(error, newDepth);
45 error +=
",maxDepth=";
47 toStr(error, maxDepth);
51 throw std::runtime_error(error);
58template <
class EntryType,
class DepthType>
101 return bids_.capacity();
112 if (bids_.size() >
depth)
115 if (offers_.size() >
depth)
116 offers_.resize(
depth);
220template <
class TargetPriceLevel,
class SourcePriceLevel,
class Depth>
224 Depth maxDepth =
static_cast<Depth
>(-1)
227 if (maxDepth > source.
depth())
229 maxDepth = source.
depth();
232 target.
depth(maxDepth);
244template <
class PriceLevelType,
class DepthType>
261 return (
sizeof(
Book) + 2 * maxDepth *
sizeof(
Entry));
269 const size_t bookSize =
calcSize(maxDepth);
281 delete[]
reinterpret_cast<Byte*
>(book);
288 Entry*
const entries =
reinterpret_cast<Entry*
>(
reinterpret_cast<Byte*
>(block) +
sizeof(
Book));
292 return new (block)
Book(maxDepth, entries, entries + maxDepth);
296 static void inplaceConstruct(Entry* first, Entry* last)
298 while (first != last)
299 new (first++) Entry();
#define ONIXS_CMEMDH_NAMESPACE_BEGIN
#define ONIXS_CMEMDH_NAMESPACE_END
Serves as a factory for book of given type.
static size_t calcSize(Depth maxDepth)
Calculates size of memory required to keep in memory book of given depth.
static Book * inplaceConstruct(Depth maxDepth, void *block)
static Book * construct(Depth maxDepth)
Constructs book instance of given capacity.
MbpBook< ConsolidatedPriceLevel, MbpBookDepth > Book
static void destruct(Book *book)
Destructs previously constructed book.
Base attributes of order book.
const Entries & operator[](const Bids &) const
List of descending bid prices.
const Entries & offers() const
List of ascending offer prices.
Entries & operator[](const Offers &)
List of ascending offer prices.
ConsolidatedPriceLevel Entry
void reset(BookState::Enum bookState)
Wipes out all bids and offers and other data associated with book (like instance of last applied FIX ...
void state(BookState::Enum state)
Updates state of book.
Depth depth() const
Returns the maximal number of price levels.
const Entries & bids() const
List of descending bid prices.
VectorOverArray< Entry, Depth > Entries
Entries::ConstIterator EntryIterator
MbpBook(Depth capacity, Entry *bids, Entry *offers)
Initializes instance with given attributes.
const Entries & operator[](const Offers &) const
List of ascending offer prices.
Entries & operator[](const Bids &)
List of descending bid prices.
void depth(Depth depth)
Updates the maximal number of price levels.
BookState::Enum state() const
Indicates current state of book.
Implements vector-like container over built-in array of fixed size being referenced.
const Item * ConstIterator
MboBook & copy(MboBook &target, const MboBook &source)
Copies content of MBO book to the other one.
void toStr(std::string &, BookState::Enum)
Serializes book state value into a string.
void throwMbpBookRedepthFailure(Depth newDepth, Depth maxDepth)
Raises exception on book re-depth failure.
UInt8 Byte
Alias for Byte.
Tag class for accessing bids in templates.
Tag class for accessing offers in templates.