dxFeed Graal CXX API
Loading...
Searching...
No Matches
dxfcpp::EventFlag Class Referencefinal

#include <EventFlag.hpp>

Public Member Functions

 EventFlag () noexcept
 Creates the invalid event flag.
 
std::uint32_t getFlag () const noexcept
 
bool in (std::uint32_t eventFlagsMask) const noexcept
 Determines if the given flag is in the mask.
 
template<typename EventFlagsMask >
bool in (const EventFlagsMask &eventFlagsMask) const noexcept
 Determines if the given flag is in the mask.
 

Static Public Attributes

static const EventFlag TX_PENDING {0x01u, "TX_PENDING"}
 0x01 - A bitmask to get transaction pending indicator from the value of eventFlags property.
 
static const EventFlag REMOVE_EVENT {0x02u, "REMOVE_EVENT"}
 0x02 - A bitmask to get removal indicator from the value of eventFlags property.
 
static const EventFlag SNAPSHOT_BEGIN {0x04u, "SNAPSHOT_BEGIN"}
 0x04 - A bitmask to get snapshot begin indicator from the value of eventFlags property.
 
static const EventFlag SNAPSHOT_END {0x08u, "SNAPSHOT_END"}
 0x08 - A bitmask to get snapshot end indicator from the value of eventFlags property.
 
static const EventFlag SNAPSHOT_SNIP {0x10u, "SNAPSHOT_SNIP"}
 0x10 - A bitmask to get snapshot snip indicator from the value of eventFlags property.
 
static const EventFlag SNAPSHOT_MODE {0x40u, "SNAPSHOT_MODE"}
 0x40 - A bitmask to set snapshot mode indicator into the value of eventFlags property.
 
static const EventFlag REMOVE_SYMBOL {0x80u, "REMOVE_SYMBOL"}
 0x80 - For internal use.
 

Friends

std::int32_t operator| (const EventFlag &eventFlag1, std::int32_t eventFlag2) noexcept
 Performs a bit or operation with two event flags.
 
std::int32_t operator| (std::int32_t eventFlag1, const EventFlag &eventFlag2) noexcept
 Performs a bit or operation with two event flags.
 
std::int32_t operator& (const EventFlag &eventFlag1, std::int32_t eventFlag2) noexcept
 Performs a bit and operation with two event flags.
 
std::int32_t operator& (std::int32_t eventFlag1, const EventFlag &eventFlag2) noexcept
 Performs a bit and operation with two event flags.
 
std::uint32_t operator| (const EventFlag &eventFlag1, std::uint32_t eventFlag2) noexcept
 Performs a bit or operation with two event flags.
 
std::uint32_t operator| (std::uint32_t eventFlag1, const EventFlag &eventFlag2) noexcept
 Performs a bit or operation with two event flags.
 
std::uint32_t operator& (const EventFlag &eventFlag1, std::uint32_t eventFlag2) noexcept
 Performs a bit and operation with two event flags.
 
std::uint32_t operator& (std::uint32_t eventFlag1, const EventFlag &eventFlag2) noexcept
 Performs a bit and operation with two event flags.
 

Detailed Description

Event flags, transactions and snapshots

Some indexed event sources provide a consistent view of a set of events for a given symbol. Their updates may incorporate multiple changes that have to be processed at the same time. The corresponding information is carried in eventFlags property.

The value of eventFlags property has several significant bits that are packed into an integer in the following way:


   31..7    6    5    4    3    2    1    0
+---------+----+----+----+----+----+----+----+
|         | SM |    | SS | SE | SB | RE | TX |
+---------+----+----+----+----+----+----+----+

Each source updates its transactional state using these bits separately. The state of each source has to be tracked separately in a map for each source. However, event index is unique across the sources. This is achieved by allocating an event-specific number of most significant bits of index for use as a source id.

TX (bit 0) — TX_PENDING is an indicator of pending transactional update. It can be retrieved from eventFlags with the following piece of code:

bool txPending = (event-> getEventFlags() & IndexedEvent::TX_PENDING) != 0;
static const EventFlag TX_PENDING
0x01 - A bitmask to get transaction pending indicator from the value of eventFlags property.
Definition IndexedEvent.hpp:44

When txPending is true it means, that an ongoing transaction update that spans multiple events is in process. All events with txPending true shall be put into a separate pending list for each source id and should be processed later when an event for this source id with txPending false comes.

RE (bit 1) — REMOVE_EVENT is used to indicate that that the event with the corresponding index has to be removed.

bool removeEvent = (event-> getEventFlags() & IndexedEvent::REMOVE_EVENT) != 0;
static const EventFlag REMOVE_EVENT
0x02 - A bitmask to get removal indicator from the value of eventFlags property.
Definition IndexedEvent.hpp:47

SB (bit 2) — SNAPSHOT_BEGIN is used to indicate when the loading of a snapshot starts.

bool snapshotBegin = (event-> getEventFlags() & IndexedEvent::SNAPSHOT_BEGIN) != 0;
static const EventFlag SNAPSHOT_BEGIN
0x04 - A bitmask to get snapshot begin indicator from the value of eventFlags property.
Definition IndexedEvent.hpp:50

Snapshot load starts on new subscription and the first indexed event that arrives for each non-zero source id on new subscription may have snapshotBegin set to true. It means, that an ongoing snapshot consisting of multiple events is incoming. All events for this source id shall be put into a separate pending list for each source id.

SE (bit 3) — SNAPSHOT_END or SS (bit 4) — SNAPSHOT_SNIP are used to indicate the end of a snapshot.

bool snapshotEnd = (event->getEventFlags() & IndexedEvent::SNAPSHOT_END) != 0;
bool snapshotSnip = (event->getEventFlags() & IndexedEvent::SNAPSHOT_SNIP) != 0;
static const EventFlag SNAPSHOT_SNIP
0x10 - A bitmask to get snapshot snip indicator from the value of eventFlags property.
Definition IndexedEvent.hpp:56
static const EventFlag SNAPSHOT_END
0x08 - A bitmask to get snapshot end indicator from the value of eventFlags property.
Definition IndexedEvent.hpp:53

The last event of a snapshot is marked with either snapshotEnd or snapshotSnip. At this time, all events from a pending list for the corresponding source can be processed, unless txPending is also set to true. In the later case, the processing shall be further delayed due to ongoing transaction.

The difference between snapshotEnd and snapshotSnip is the following. snapshotEnd indicates that the data source had sent all the data pertaining to the subscription for the corresponding indexed event, while snapshotSnip indicates that some limit on the amount of data was reached and while there still might be more data available, it will not be provided.

SM (bit 6) — SNAPSHOT_MODE is used to instruct dxFeed to use snapshot mode. It is intended to be used only for publishing to activate (if not yet activated) snapshot mode. The difference from SNAPSHOT_BEGIN flag is that SNAPSHOT_MODE only switches on snapshot mode without starting snapshot synchronization protocol.

When a snapshot is empty or consists of a single event, then the event can have both snapshotBegin and snapshotEnd or snapshotSnip flags. In case of an empty snapshot, removeEvent on this event is also set to true.

Member Function Documentation

◆ getFlag()

std::uint32_t dxfcpp::EventFlag::getFlag ( ) const
inlinenoexcept
Returns
The event flag's value

◆ in() [1/2]

template<typename EventFlagsMask >
bool dxfcpp::EventFlag::in ( const EventFlagsMask & eventFlagsMask) const
inlinenoexcept

Determines if the given flag is in the mask.

Template Parameters
EventFlagsMaskAn event flags mask type that satisfies the condition: there is a getMask method that returns std::uint32_t
Parameters
eventFlagsMaskThe event flags mask.
Returns
true the given flag is in the mask.

◆ in() [2/2]

bool dxfcpp::EventFlag::in ( std::uint32_t eventFlagsMask) const
inlinenoexcept

Determines if the given flag is in the mask.

Parameters
eventFlagsMaskThe event flags mask
Returns
true the given flag is in the mask.

Friends And Related Symbol Documentation

◆ operator& [1/4]

std::int32_t operator& ( const EventFlag & eventFlag1,
std::int32_t eventFlag2 )
friend

Performs a bit and operation with two event flags.

Parameters
eventType1The first event flag
eventType2The second event flag (std::int32_t)
Returns
The result (std::int32_t)

◆ operator& [2/4]

std::uint32_t operator& ( const EventFlag & eventFlag1,
std::uint32_t eventFlag2 )
friend

Performs a bit and operation with two event flags.

Parameters
eventType1The first event flag
eventType2The second event flag (std::uint32_t)
Returns
The result (std::uint32_t)

◆ operator& [3/4]

std::int32_t operator& ( std::int32_t eventFlag1,
const EventFlag & eventFlag2 )
friend

Performs a bit and operation with two event flags.

Parameters
eventType1The first event flag (std::int32_t)
eventType2The second event flag
Returns
The result (std::int32_t)

◆ operator& [4/4]

std::uint32_t operator& ( std::uint32_t eventFlag1,
const EventFlag & eventFlag2 )
friend

Performs a bit and operation with two event flags.

Parameters
eventType1The first event flag (std::uint32_t)
eventType2The second event flag
Returns
The result (std::uint32_t)

◆ operator| [1/4]

std::int32_t operator| ( const EventFlag & eventFlag1,
std::int32_t eventFlag2 )
friend

Performs a bit or operation with two event flags.

Parameters
eventType1The first event flag
eventType2The second event flag (std::int32_t)
Returns
The result (std::int32_t)

◆ operator| [2/4]

std::uint32_t operator| ( const EventFlag & eventFlag1,
std::uint32_t eventFlag2 )
friend

Performs a bit or operation with two event flags.

Parameters
eventType1The first event flag
eventType2The second event flag (std::uint32_t)
Returns
The result (std::uint32_t)

◆ operator| [3/4]

std::int32_t operator| ( std::int32_t eventFlag1,
const EventFlag & eventFlag2 )
friend

Performs a bit or operation with two event flags.

Parameters
eventType1The first event flag (std::int32_t)
eventType2The second event flag
Returns
The result (std::int32_t)

◆ operator| [4/4]

std::uint32_t operator| ( std::uint32_t eventFlag1,
const EventFlag & eventFlag2 )
friend

Performs a bit or operation with two event flags.

Parameters
eventType1The first event flag (std::uint32_t)
eventType2The second event flag
Returns
The result (std::uint32_t)

Member Data Documentation

◆ REMOVE_EVENT

const EventFlag dxfcpp::EventFlag::REMOVE_EVENT {0x02u, "REMOVE_EVENT"}
static

0x02 - A bitmask to get removal indicator from the value of eventFlags property.

bool removeEvent = (event-> getEventFlags() & IndexedEvent::REMOVE_EVENT) != 0;

See "Event Flags" section

◆ REMOVE_SYMBOL

const EventFlag dxfcpp::EventFlag::REMOVE_SYMBOL {0x80u, "REMOVE_SYMBOL"}
static

0x80 - For internal use.

Marks a subscription for deletion.

◆ SNAPSHOT_BEGIN

const EventFlag dxfcpp::EventFlag::SNAPSHOT_BEGIN {0x04u, "SNAPSHOT_BEGIN"}
static

0x04 - A bitmask to get snapshot begin indicator from the value of eventFlags property.

bool snapshotBegin = (event-> getEventFlags() & IndexedEvent::SNAPSHOT_BEGIN) != 0;

See "Event Flags" section

◆ SNAPSHOT_END

const EventFlag dxfcpp::EventFlag::SNAPSHOT_END {0x08u, "SNAPSHOT_END"}
static

0x08 - A bitmask to get snapshot end indicator from the value of eventFlags property.

bool snapshotEnd = (event-> getEventFlags() & IndexedEvent::SNAPSHOT_END) != 0;

See "Event Flags" section

◆ SNAPSHOT_MODE

const EventFlag dxfcpp::EventFlag::SNAPSHOT_MODE {0x40u, "SNAPSHOT_MODE"}
static

0x40 - A bitmask to set snapshot mode indicator into the value of eventFlags property.

This flag is intended for publishing only.

See "Event Flags" section

◆ SNAPSHOT_SNIP

const EventFlag dxfcpp::EventFlag::SNAPSHOT_SNIP {0x10u, "SNAPSHOT_SNIP"}
static

0x10 - A bitmask to get snapshot snip indicator from the value of eventFlags property.

bool snapshotSnip = (event-> getEventFlags() & IndexedEvent::SNAPSHOT_SNIP) != 0;

See "Event Flags" section

◆ TX_PENDING

const EventFlag dxfcpp::EventFlag::TX_PENDING {0x01u, "TX_PENDING"}
static

0x01 - A bitmask to get transaction pending indicator from the value of eventFlags property.

bool txPending = (event-> getEventFlags() & IndexedEvent::TX_PENDING) != 0;

See "Event Flags" section