25 return store(newEntry, newEntry->id());
30 const Guard guard(mutex_);
32 store(entry->sellSideOrder_);
33 store(entry->buySideOrder_);
35 const auto res = crossOrders_.insert(std::make_pair(entry->id(), entry));
38 throw std::domain_error(
"Cross orders already has an entry registered under ID = '" + std::to_string(entry->id()) +
"'.");
40 return *res.first->second;
47 const Guard guard(mutex_);
49 const auto res = entries_.emplace(
50 std::piecewise_construct,
51 std::forward_as_tuple(
id),
52 std::forward_as_tuple(newEntry)
56 throw std::domain_error(
"Book already has an entry registered under ID = '" + std::to_string(
id) +
"'.");
58 auto& order = res.first->second;
60 assert(
id == order->id());
69 const Guard guard(mutex_);
71 for (
const auto& entry : entries_)
72 if(predicate(*entry.second))
73 list.push_back(entry.second);
80 const Guard guard(mutex_);
82 const auto entry = entries_.find(
id);
88 const Guard guard(mutex_);
90 const auto entry = crossOrders_.find(
id);
OptionalRef< CrossOrder > findCross(BookEntryId id)
Finds a cross order.
OrdersList getEntries(std::function< bool(const Order &)> predicate=[](const Order &){ return true;})
Order & store(OrderPtr entry)
Adds an entry to the book.
Order::OrderId BookEntryId
OptionalRef< Order > find(BookEntryId id)
Finds an instance of the entry by its identifier.
std::vector< OrderPtr > OrdersList
Returns collection of all the entries.
std::shared_ptr< CrossOrder > CrossOrderPtr
std::optional< std::shared_ptr< T > > OptionalRef
Manages an optional contained reference.
std::shared_ptr< Order > OrderPtr