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

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

#include <TimeSeriesTxModel.hpp>

+ Inheritance diagram for TimeSeriesTxModel< 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< TimeSeriesTxModelListener< E > > listener) const
 Sets the listener for transaction notifications.
 
std::shared_ptr< BuilderwithListener (std::function< void(const std::vector< std::shared_ptr< E > > &, bool)> onEventsReceived) const
 Sets the listener for transaction notifications.
 
std::shared_ptr< BuilderwithFromTime (std::int64_t fromTime) const
 Sets the time from which to subscribe for time-series.
 
std::shared_ptr< BuilderwithFromTime (std::chrono::milliseconds fromTime) const
 Sets the time from which to subscribe for time-series.
 
std::shared_ptr< TimeSeriesTxModelbuild () const
 Builds an instance of TimeSeriesTxModel 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< TimeSeriesEvent > E>
struct TimeSeriesTxModel< E >::Builder

A builder class for creating an instance of TimeSeriesTxModel.

Member Function Documentation

◆ build()

template<Derived< TimeSeriesEvent > E>
std::shared_ptr< TimeSeriesTxModel > TimeSeriesTxModel< E >::Builder::build ( ) const
inline

Builds an instance of TimeSeriesTxModel based on the provided parameters.

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

◆ withBatchProcessing()

template<Derived< TimeSeriesEvent > E>
std::shared_ptr< Builder > TimeSeriesTxModel< 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< TimeSeriesEvent > E>
std::shared_ptr< Builder > TimeSeriesTxModel< 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.

◆ withFromTime() [1/2]

template<Derived< TimeSeriesEvent > E>
std::shared_ptr< Builder > TimeSeriesTxModel< E >::Builder::withFromTime ( std::chrono::milliseconds fromTime) const
inline

Sets the time from which to subscribe for time-series.

This time defaults to std::chrono::milliseconds(std::numeric_limits<std::int64_t>::max()), which means that this model is not subscribed. This time can be changed later, after the model has been created, by calling setFromTime.

Parameters
fromTimeThe duration in milliseconds, since Unix epoch of January 1, 1970.
Returns
The builder instance.

◆ withFromTime() [2/2]

template<Derived< TimeSeriesEvent > E>
std::shared_ptr< Builder > TimeSeriesTxModel< E >::Builder::withFromTime ( std::int64_t fromTime) const
inline

Sets the time from which to subscribe for time-series.

This time defaults to std::numeric_limits<std::int64_t>::max(), which means that this model is not subscribed. This time can be changed later, after the model has been created, by calling setFromTime.

Parameters
fromTimeThe time in milliseconds, since Unix epoch of January 1, 1970.
Returns
The builder instance.

◆ withListener() [1/2]

template<Derived< TimeSeriesEvent > E>
std::shared_ptr< Builder > TimeSeriesTxModel< E >::Builder::withListener ( std::function< void(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([](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;
});
static std::shared_ptr< Builder > newBuilder()
Factory method to create a new builder for this model.
Definition TimeSeriesTxModel.hpp:359
Parameters
onEventsReceivedA functional object, lambda, or function to which time series event data will be passed.
Returns
The builder instance.

◆ withListener() [2/2]

template<Derived< TimeSeriesEvent > E>
std::shared_ptr< Builder > TimeSeriesTxModel< E >::Builder::withListener ( std::shared_ptr< TimeSeriesTxModelListener< 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 = TimeSeriesTxModelListener<Candle>::create([](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< TimeSeriesTxModelListener< E > > create(std::function< void(const std::vector< std::shared_ptr< E > > &, bool)> onEventsReceived)
Creates a listener for receiving time series events (with instantiation by event type E and verificat...
Definition TxModelListener.hpp:176
Template Parameters
EThe type of event (derived from TimeSeriesEvent)
Parameters
listenerThe transaction listener.
Returns
The builder instance.

◆ withSnapshotProcessing()

template<Derived< TimeSeriesEvent > E>
std::shared_ptr< Builder > TimeSeriesTxModel< 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.

◆ withSymbol()

template<Derived< TimeSeriesEvent > E>
std::shared_ptr< Builder > TimeSeriesTxModel< 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.