Leka
A low-latency C++20 price-time-priority limit order book and matching engine
▶ Replay viewer
Loading...
Searching...
No Matches
lob::OrderEvent Class Reference

Type-safe event-first command for the matching engine. More...

#include <order_event.hpp>

Public Member Functions

 OrderEvent (NewOrder order)
 Creates a NEW event.
 OrderEvent (CancelOrder order)
 Creates a CANCEL event.
 OrderEvent (ReduceOrder order)
 Creates a REDUCE event.
OrderEventType getEventType () const
 Returns the operation represented by the active payload.
const NewOrdergetNewOrder () const
 Returns the NEW payload or throws when this is not a NEW event.
const CancelOrdergetCancelOrder () const
 Returns the CANCEL payload or throws when this is not a CANCEL event.
const ReduceOrdergetReduceOrder () const
 Returns the REDUCE payload or throws when this is not a REDUCE event.

Detailed Description

Type-safe event-first command for the matching engine.

The active payload determines which fields are relevant. Accessing a payload for a different event type throws std::logic_error.

Definition at line 77 of file order_event.hpp.

Constructor & Destructor Documentation

◆ OrderEvent() [1/3]

lob::OrderEvent::OrderEvent ( NewOrder order)
explicit

Creates a NEW event.

Constructs a NEW event from its payload.

Definition at line 14 of file order_event.cpp.

◆ OrderEvent() [2/3]

lob::OrderEvent::OrderEvent ( CancelOrder order)
explicit

Creates a CANCEL event.

Constructs a CANCEL event from its payload.

Definition at line 17 of file order_event.cpp.

◆ OrderEvent() [3/3]

lob::OrderEvent::OrderEvent ( ReduceOrder order)
explicit

Creates a REDUCE event.

Constructs a REDUCE event from its payload.

Definition at line 20 of file order_event.cpp.

Member Function Documentation

◆ getEventType()

OrderEventType lob::OrderEvent::getEventType ( ) const

Returns the operation represented by the active payload.

Returns the variant index corresponding to the event operation.

Definition at line 23 of file order_event.cpp.

Referenced by lob::MatchingEngine::processEvent().

◆ getNewOrder()

const NewOrder & lob::OrderEvent::getNewOrder ( ) const

Returns the NEW payload or throws when this is not a NEW event.

The accessors test the active alternative once through get_if rather than pairing holds_alternative with get, which would discriminate the variant twice on every dispatched event.

Definition at line 32 of file order_event.cpp.

◆ getCancelOrder()

const CancelOrder & lob::OrderEvent::getCancelOrder ( ) const

Returns the CANCEL payload or throws when this is not a CANCEL event.

Returns the CANCEL payload after checking the active event type.

Definition at line 41 of file order_event.cpp.

Referenced by lob::MatchingEngine::processEvent().

◆ getReduceOrder()

const ReduceOrder & lob::OrderEvent::getReduceOrder ( ) const

Returns the REDUCE payload or throws when this is not a REDUCE event.

Returns the REDUCE payload after checking the active event type.

Definition at line 50 of file order_event.cpp.


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