Slick Sim 0.10.1
Exchange simulator that shadows real venues for risk-free strategy testing
Loading...
Searching...
No Matches
slick::sim::order_gateway::ClOrdIdIndex< Key, Hash, Eq > Class Template Reference

One session's ClOrdIDs, each mapped to the working order that holds it. More...

#include <order_gateway/cl_ord_id_index.hpp>

Collaboration diagram for slick::sim::order_gateway::ClOrdIdIndex< Key, Hash, Eq >:

Public Member Functions

template<typename K>
uint64_t find (const K &id) const noexcept
 The working order named id, or 0 when no order holds it (a request may).
bool claim (const Key &id, uint64_t order_num=0)
 Claims id for a new order (order_num 0) or for a replace of order_num.
template<typename K>
bool claim (const K &id, uint64_t order_num=0)
 The same, by the key's lookup form.
template<typename K>
void release (const K &id) noexcept
 The request that claimed id was answered.
template<typename K>
void assign (const K &id, uint64_t order_num)
 id now names order_num.
template<typename K>
void forget (const K &id, uint64_t order_num) noexcept
 order_num no longer holds id: it is done, or was renamed.
template<typename K>
void rename (const K &from, const K &to, uint64_t order_num)
 A replace renamed order_num from from to to.
size_t size () const noexcept
 How many ids are taken - by a working order, by a request in flight, or both.
bool empty () const noexcept

Detailed Description

template<typename Key, typename Hash = std::hash<Key>, typename Eq = std::equal_to<Key>>
class slick::sim::order_gateway::ClOrdIdIndex< Key, Hash, Eq >

One session's ClOrdIDs, each mapped to the working order that holds it.

A new order or replace claims its ClOrdID when it is sent, so no other request can take it before the exchange answers. Replaces of one order may share a claim with each other and with that order: a ClOrdID it is renamed away from stays taken while one of them still needs it. Each claim is released once, when its request is answered. Order number 0 means none.

Definition at line 18 of file cl_ord_id_index.hpp.

Member Function Documentation

◆ assign()

template<typename Key, typename Hash = std::hash<Key>, typename Eq = std::equal_to<Key>>
template<typename K>
void slick::sim::order_gateway::ClOrdIdIndex< Key, Hash, Eq >::assign ( const K & id,
uint64_t order_num )
inline

id now names order_num.

Definition at line 56 of file cl_ord_id_index.hpp.

Referenced by rename().

◆ claim() [1/2]

template<typename Key, typename Hash = std::hash<Key>, typename Eq = std::equal_to<Key>>
template<typename K>
bool slick::sim::order_gateway::ClOrdIdIndex< Key, Hash, Eq >::claim ( const K & id,
uint64_t order_num = 0 )
inlinenodiscard

The same, by the key's lookup form.

Building the key costs less than the second hash a find-then-insert would take, and a new claim stores it anyway.

Definition at line 41 of file cl_ord_id_index.hpp.

References claim().

◆ claim() [2/2]

template<typename Key, typename Hash = std::hash<Key>, typename Eq = std::equal_to<Key>>
bool slick::sim::order_gateway::ClOrdIdIndex< Key, Hash, Eq >::claim ( const Key & id,
uint64_t order_num = 0 )
inlinenodiscard

Claims id for a new order (order_num 0) or for a replace of order_num.

False when another order, or a request for one, has it.

Definition at line 29 of file cl_ord_id_index.hpp.

Referenced by claim().

◆ empty()

template<typename Key, typename Hash = std::hash<Key>, typename Eq = std::equal_to<Key>>
bool slick::sim::order_gateway::ClOrdIdIndex< Key, Hash, Eq >::empty ( ) const
inlinenodiscardnoexcept

Definition at line 84 of file cl_ord_id_index.hpp.

◆ find()

template<typename Key, typename Hash = std::hash<Key>, typename Eq = std::equal_to<Key>>
template<typename K>
uint64_t slick::sim::order_gateway::ClOrdIdIndex< Key, Hash, Eq >::find ( const K & id) const
inlinenodiscardnoexcept

The working order named id, or 0 when no order holds it (a request may).

Definition at line 22 of file cl_ord_id_index.hpp.

◆ forget()

template<typename Key, typename Hash = std::hash<Key>, typename Eq = std::equal_to<Key>>
template<typename K>
void slick::sim::order_gateway::ClOrdIdIndex< Key, Hash, Eq >::forget ( const K & id,
uint64_t order_num )
inlinenoexcept

order_num no longer holds id: it is done, or was renamed.

Definition at line 68 of file cl_ord_id_index.hpp.

Referenced by rename().

◆ release()

template<typename Key, typename Hash = std::hash<Key>, typename Eq = std::equal_to<Key>>
template<typename K>
void slick::sim::order_gateway::ClOrdIdIndex< Key, Hash, Eq >::release ( const K & id)
inlinenoexcept

The request that claimed id was answered.

Definition at line 47 of file cl_ord_id_index.hpp.

◆ rename()

template<typename Key, typename Hash = std::hash<Key>, typename Eq = std::equal_to<Key>>
template<typename K>
void slick::sim::order_gateway::ClOrdIdIndex< Key, Hash, Eq >::rename ( const K & from,
const K & to,
uint64_t order_num )
inline

A replace renamed order_num from from to to.

Definition at line 77 of file cl_ord_id_index.hpp.

References assign(), and forget().

◆ size()

template<typename Key, typename Hash = std::hash<Key>, typename Eq = std::equal_to<Key>>
size_t slick::sim::order_gateway::ClOrdIdIndex< Key, Hash, Eq >::size ( ) const
inlinenodiscardnoexcept

How many ids are taken - by a working order, by a request in flight, or both.

Definition at line 83 of file cl_ord_id_index.hpp.


The documentation for this class was generated from the following file: