36template <
typename Depth>
41 error +=
"Cannot re-depth order book "
42 "due to lack of capacity [newDepth=";
46 error +=
",maxDepth=";
52 throw std::runtime_error(error);
59template <
class EntryType,
class DepthType>
62 static_assert(std::is_trivially_destructible<EntryType>::value,
"EntryType must be trivially destructible");
104 return bids_.capacity();
115 if (bids_.size() >
depth)
118 if (offers_.size() >
depth)
119 offers_.resize(
depth);
223template <
class TargetPriceLevel,
class SourcePriceLevel,
class Depth>
227 Depth maxDepth =
static_cast<Depth
>(-1)
230 if (maxDepth > source.
depth())
232 maxDepth = source.
depth();
235 target.
depth(maxDepth);
247template <
class PriceLevelType,
class DepthType>
264 return (
sizeof(
Book) + 2 * maxDepth *
sizeof(
Entry));
272 const size_t bookSize =
calcSize(maxDepth);
295 return new (block)
Book(maxDepth, entries, entries + maxDepth);
299 static void inplaceConstruct(Entry* first, Entry* last)
301 while (first != last)
302 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)
static Book * inplaceConstruct(Depth maxDepth, void *block)
static Book * construct(Depth maxDepth)
MbpBook< ConsolidatedPriceLevel, MbpBookDepth > Book
static void destruct(Book *book)
Destructs previously constructed 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)
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)
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.
Provides vector-like access to caller-owned, fixed-capacity storage.
const Item * ConstIterator
void toStr(std::string &, Int8)
Serializes given integer into a string.
UInt8 Byte
Alias for Byte.
MboBook & copy(MboBook &target, const MboBook &source)
Copies content of MBO book to the other one.
void throwMbpBookRedepthFailure(Depth newDepth, Depth maxDepth)
Raises exception on book re-depth failure.
Tag type that selects the bid side of a book.
Describes the lifecycle state of an order book.
Enum
Known order book states.
Tag type that selects the offer side of a book.