dxFeed Graal CXX API v4.0.0
Loading...
Searching...
No Matches
IndexedTxModel< E >::Builder Struct Referencefinal

A builder class for creating an instance of IndexedTxModel. More...

#include <IndexedTxModel.hpp>

+ Inheritance diagram for IndexedTxModel< E >::Builder:

Public Member Functions

std::shared_ptr< BuilderwithBatchProcessing (bool isBatchProcessing) const
 Enables or disables batch processing.
 
std::shared_ptr< BuilderwithSnapshotProcessing (bool isSnapshotProcessing) const
 Enables or disables snapshot processing.
 
std::shared_ptr< BuilderwithFeed (const std::shared_ptr< DXFeed > &feed) const
 Sets the feed for the model being created.
 
std::shared_ptr< BuilderwithSymbol (const SymbolWrapper &symbol) const
 Sets the subscription symbol for the model being created.
 
std::shared_ptr< BuilderwithListener (std::shared_ptr< IndexedTxModelListener< E > > listener) const
 Sets the listener for transaction notifications.
 
std::shared_ptr< BuilderwithListener (std::function< void(const IndexedEventSource &, const std::vector< std::shared_ptr< E > > &, bool)> onEventsReceived) const
 Sets the listener for transaction notifications.
 
template<typename EventSourceIt >
std::shared_ptr< BuilderwithSources (EventSourceIt begin, EventSourceIt end) const
 Sets the sources from which to subscribe for indexed events.
 
template<ConvertibleToEventSourceWrapperCollection EventSourceCollection>
std::shared_ptr< BuilderwithSources (EventSourceCollection &&sources) const
 Sets the sources from which to subscribe for indexed events.
 
std::shared_ptr< BuilderwithSources (std::initializer_list< EventSourceWrapper > sources) const
 Sets the sources from which to subscribe for indexed events.
 
std::shared_ptr< IndexedTxModelbuild () const
 Builds an instance of IndexedTxModel based on the provided parameters.
 
- Public Member Functions inherited from SharedEntity
template<typename T >
bool is () const noexcept
 Checks that pointer to the current type could be converted to type T* In other words: whether type T belongs to the type hierarchy in which the current type resides.
 
template<typename T >
std::shared_ptr< T > sharedAs () noexcept
 Returns a pointer to the current object wrapped in a smart pointer to type T.
 
template<typename T >
std::shared_ptr< T > sharedAs () const noexcept
 Returns a pointer to the current object wrapped in a smart pointer to type T.
 
virtual std::string toString () const
 Returns a string representation of the current object.
 
- Public Member Functions inherited from Entity
virtual ~Entity () noexcept=default
 The default virtual d-tor.
 

Additional Inherited Members

- Public Types inherited from SharedEntity
using Ptr = std::shared_ptr<SharedEntity>
 The alias to a type of shared pointer to the SharedEntity object.
 
- Static Public Member Functions inherited from RequireMakeShared< Builder >
static auto createShared (Args &&...args)
 Creates smart pointer to object.
 

Detailed Description

template<Derived< IndexedEvent > E>
struct IndexedTxModel< E >::Builder

A builder class for creating an instance of IndexedTxModel.

Member Function Documentation

◆ build()

template<Derived< IndexedEvent > E>
std::shared_ptr< IndexedTxModel > IndexedTxModel< E >::Builder::build ( ) const
inline

Builds an instance of IndexedTxModel based on the provided parameters.

auto model = builder->build();
Returns
The created IndexedTxModel.

◆ withBatchProcessing()

template<Derived< IndexedEvent > E>
std::shared_ptr< Builder > IndexedTxModel< E >::Builder::withBatchProcessing ( bool isBatchProcessing) const
inline

Enables or disables batch processing.

This is enabled by default.

If batch processing is disabled, the model will notify listener separately for each transaction (even if it is represented by a single event); otherwise, transactions can be combined in a single listener call.

A transaction may represent either a snapshot or update events that are received after a snapshot. Whether this flag is set or not, the model will always notify listeners that a snapshot has been received and will not combine multiple snapshots or a snapshot with another transaction into a single listener notification.

Parameters
isBatchProcessingtrue to enable batch processing; false otherwise.
Returns
The builder instance.

◆ withFeed()

template<Derived< IndexedEvent > E>
std::shared_ptr< Builder > IndexedTxModel< E >::Builder::withFeed ( const std::shared_ptr< DXFeed > & feed) const
inline

Sets the feed for the model being created.

The feed can also be attached later, after the model has been created, by calling attach.

Parameters
feedThe feed.
Returns
The builder instance.

◆ withListener() [1/2]

template<Derived< IndexedEvent > E>
std::shared_ptr< Builder > IndexedTxModel< E >::Builder::withListener ( std::function< void(const IndexedEventSource &, const std::vector< std::shared_ptr< E > > &, bool)> onEventsReceived) const
inline

Sets the listener for transaction notifications.

The listener cannot be changed or added once the model has been built.

builder = builder->withListener<Order>([](const auto &, const auto &events, bool isSnapshot) {
if (isSnapshot) {
std::cout << "Snapshot:" << std::endl;
} else {
std::cout << "Update:" << std::endl;
}
for (const auto &e : events) {
std::cout << "[" << e->getEventFlagsMask().toString() << "]:" << e << std::endl;
}
std::cout << std::endl;
});
Order event is a snapshot for a full available market depth for a symbol.
Definition Order.hpp:95
static const EventTypeEnum & TYPE
Type identifier and additional information about the current event class.
Definition Order.hpp:117
static std::shared_ptr< Builder > newBuilder()
Factory method to create a new builder for this model.
Definition IndexedTxModel.hpp:401
Parameters
onEventsReceivedA functional object, lambda, or function to which indexed event data will be passed.
Returns
The builder instance.

◆ withListener() [2/2]

template<Derived< IndexedEvent > E>
std::shared_ptr< Builder > IndexedTxModel< E >::Builder::withListener ( std::shared_ptr< IndexedTxModelListener< E > > listener) const
inline

Sets the listener for transaction notifications.

The listener cannot be changed or added once the model has been built.

auto listener = IndexedTxModelListener<Order>::create([](const auto &, const auto &events, bool isSnapshot) {
if (isSnapshot) {
std::cout << "Snapshot:" << std::endl;
} else {
std::cout << "Update:" << std::endl;
}
for (const auto &e : events) {
std::cout << "[" << e->getEventFlagsMask().toString() << "]:" << e << std::endl;
}
std::cout << std::endl;
});
builder->withListener(listener);
static std::shared_ptr< IndexedTxModelListener< E > > create(std::function< void(const IndexedEventSource &, const std::vector< std::shared_ptr< E > > &, bool)> onEventsReceived)
Creates a listener for receiving indexed events (with instantiation by event type E and verification)
Definition TxModelListener.hpp:100
Parameters
listenerThe transaction listener.
Returns
The builder instance.

◆ withSnapshotProcessing()

template<Derived< IndexedEvent > E>
std::shared_ptr< Builder > IndexedTxModel< E >::Builder::withSnapshotProcessing ( bool isSnapshotProcessing) const
inline

Enables or disables snapshot processing.

This is disabled by default.

If snapshot processing is enabled, transactions representing a snapshot will be processed as follows: events that are marked for removal will be removed, repeated indexes will be merged, and eventFlags of events are set to zero; otherwise, the user will see the snapshot in raw form, with possible repeated indexes, events marked for removal, and eventFlags unchanged.

Whether this flag is set or not, in transactions that are not a snapshot, events that are marked for removal will not be removed, repeated indexes will not be merged, and eventFlags of events will not be changed. This flag only affects the processing of transactions that are a snapshot.

Parameters
isSnapshotProcessingtrue to enable snapshot processing; false otherwise.
Returns
The builder instance.

◆ withSources() [1/3]

template<Derived< IndexedEvent > E>
template<ConvertibleToEventSourceWrapperCollection EventSourceCollection>
std::shared_ptr< Builder > IndexedTxModel< E >::Builder::withSources ( EventSourceCollection && sources) const
inline

Sets the sources from which to subscribe for indexed events.

If no sources have been set, subscriptions will default to all possible sources.

The default value for this source is empty, which means that this model subscribes to all available sources. These sources can be changed later, after the model has been created, by calling setSources.

builder->withSources(std::vector{OrderSource::NTV, OrderSource::DEX});
// or
builder->withSources(std::unordered_set{OrderSource::NTV, OrderSource::DEX});
static const OrderSource DEX
Direct-Edge EDGX Exchange.
Definition OrderSource.hpp:202
static const OrderSource NTV
NASDAQ Total View.
Definition OrderSource.hpp:138
Template Parameters
EventSourceCollectionA type of the collection of sources (std::vector<EventSourceWrapper>, std::set<OrderSource>, etc.)
Parameters
sourcesThe specified sources.
Returns
The builder instance.

◆ withSources() [2/3]

template<Derived< IndexedEvent > E>
template<typename EventSourceIt >
std::shared_ptr< Builder > IndexedTxModel< E >::Builder::withSources ( EventSourceIt begin,
EventSourceIt end ) const
inline

Sets the sources from which to subscribe for indexed events.

If no sources have been set, subscriptions will default to all possible sources.

The default value for this source is empty, which means that this model subscribes to all available sources. These sources can be changed later, after the model has been created, by calling setSources.

std::vector<EventSourceWrapper> sources{OrderSource::NTV, OrderSource::DEX};
builder->withSources(sources.begin(), sources.end());
Template Parameters
EventSourceItThe source collection iterator type.
Parameters
beginThe beginning of the collection of sources.
endThe end of the collection of sources.
Returns
The builder instance.

◆ withSources() [3/3]

template<Derived< IndexedEvent > E>
std::shared_ptr< Builder > IndexedTxModel< E >::Builder::withSources ( std::initializer_list< EventSourceWrapper > sources) const
inline

Sets the sources from which to subscribe for indexed events.

If no sources have been set, subscriptions will default to all possible sources.

The default value for this source is empty, which means that this model subscribes to all available sources. These sources can be changed later, after the model has been created, by calling setSources.

builder->withSources({OrderSource::NTV, OrderSource::DEX});
builder->withSources({OrderSource::NTV});
Parameters
sourcesThe specified sources.
Returns
The builder instance.

◆ withSymbol()

template<Derived< IndexedEvent > E>
std::shared_ptr< Builder > IndexedTxModel< E >::Builder::withSymbol ( const SymbolWrapper & symbol) const
inline

Sets the subscription symbol for the model being created.

The symbol cannot be added or changed after the model has been built.

Parameters
symbolThe subscription symbol.
Returns
The builder instance.