dxFeed Graal CXX API v4.2.0
|
Extends DXFeedSubscription to conveniently subscribe to time-series of events for a set of symbols and event types. More...
#include <DXFeedSubscription.hpp>
Public Member Functions | |
std::string | toString () const override |
Returns a string representation of the current object. | |
std::int64_t | getFromTime () |
Returns the earliest timestamp from which time-series of events shall be received. | |
void | setFromTime (std::int64_t fromTime) |
Sets the earliest timestamp from which time-series of events shall be received. | |
void | setFromTime (std::chrono::milliseconds fromTime) |
Sets the earliest timestamp from which time-series of events shall be received. | |
![]() | |
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 | ~Entity () noexcept=default |
The default virtual d-tor. | |
![]() | |
void | attach (std::shared_ptr< DXFeed > feed) |
Attaches subscription to the specified feed. | |
void | detach (std::shared_ptr< DXFeed > feed) |
Detaches subscription from the specified feed. | |
bool | isClosed () override |
Returns true if this subscription is closed. | |
void | close () const |
Closes this subscription and makes it permanently detached. | |
std::unordered_set< EventTypeEnum > | getEventTypes () override |
Returns a set of subscribed event types. | |
bool | containsEventType (const EventTypeEnum &eventType) override |
Returns true if this subscription contains the corresponding event type. | |
void | clear () const |
Clears the set of subscribed symbols. | |
std::vector< SymbolWrapper > | getSymbols () const |
Returns a set of subscribed symbols (depending on the actual implementation of subscription). | |
std::vector< SymbolWrapper > | getDecoratedSymbols () const |
Returns a set of decorated symbols (depending on the actual implementation of subscription). | |
template<typename SymbolIt> | |
void | setSymbols (SymbolIt begin, SymbolIt end) const |
Changes the set of subscribed symbols so that it contains just the symbols from the specified collection (using iterators). | |
template<ConvertibleToSymbolWrapperCollection SymbolsCollection> | |
void | setSymbols (SymbolsCollection &&collection) const |
Changes the set of subscribed symbols so that it contains just the symbols from the specified collection. | |
void | setSymbols (std::initializer_list< SymbolWrapper > collection) const |
Changes the set of subscribed symbols so that it contains just the symbols from the specified collection (initializer list). | |
void | addSymbols (const SymbolWrapper &symbolWrapper) const |
Adds the specified symbol to the set of subscribed symbols. | |
template<typename SymbolIt> | |
void | addSymbols (SymbolIt begin, SymbolIt end) const |
Adds the specified collection (using iterators) of symbols to the set of subscribed symbols. | |
template<ConvertibleToSymbolWrapperCollection SymbolsCollection> | |
void | addSymbols (const SymbolsCollection &collection) const |
Adds the specified collection of symbols to the set of subscribed symbols. | |
void | addSymbols (std::initializer_list< SymbolWrapper > collection) const |
Adds the specified collection (initializer list) of symbols to the set of subscribed symbols. | |
void | removeSymbols (const SymbolWrapper &symbolWrapper) const |
Removes the specified symbol from the set of subscribed symbols. | |
template<typename SymbolIt> | |
void | removeSymbols (SymbolIt begin, SymbolIt end) const |
Removes the specified collection (using iterators) of symbols from the set of subscribed symbols. | |
template<ConvertibleToSymbolWrapperCollection SymbolsCollection> | |
void | removeSymbols (SymbolsCollection &&collection) const |
Removes the specified collection of symbols from the set of subscribed symbols. | |
void | removeSymbols (std::initializer_list< SymbolWrapper > collection) const |
Removes the specified collection (initializer list) of symbols from the set of subscribed symbols. | |
TimePeriod | getAggregationPeriod () const |
Returns the aggregation period for data for this subscription instance. | |
void | setAggregationPeriod (const TimePeriod &aggregationPeriod) const |
Sets the aggregation period for data. | |
void | setAggregationPeriod (std::chrono::milliseconds aggregationPeriod) const |
Sets the aggregation period for data. | |
void | setAggregationPeriod (std::int64_t aggregationPeriod) const |
Sets the aggregation period for data. | |
template<typename EventListener> | |
std::size_t | addEventListener (EventListener &&listener) |
Adds listener for events. | |
template<typename EventT> | |
std::size_t | addEventListener (std::function< void(const std::vector< std::shared_ptr< EventT > > &)> &&listener) |
Adds typed listener for events. | |
void | removeEventListener (std::size_t listenerId) |
Removes listener for events. | |
OnEventHandler & | onEvent () |
Returns a reference to an incoming events' handler (delegate), to which listeners can be added and removed. | |
std::size_t | addChangeListener (std::shared_ptr< ObservableSubscriptionChangeListener > listener) override |
Adds subscription change listener. | |
void | removeChangeListener (std::size_t changeListenerId) override |
Removes subscription change listener by id. | |
std::int32_t | getEventsBatchLimit () const |
void | setEventsBatchLimit (std::int32_t eventsBatchLimit) const |
Sets maximum number of events in the single notification of OnEventHandler. | |
Static Public Member Functions | |
static std::shared_ptr< DXFeedTimeSeriesSubscription > | create (std::initializer_list< EventTypeEnum > eventTypes) |
Creates detached subscription for the given collection of event types. | |
![]() | |
static auto | createShared (Args &&...args) |
Creates smart pointer to object. | |
![]() | |
static std::shared_ptr< DXFeedSubscription > | create (const EventTypeEnum &eventType) |
Creates detached subscription for a single event type. | |
template<typename EventTypeIt> | |
static std::shared_ptr< DXFeedSubscription > | create (EventTypeIt begin, EventTypeIt end) |
Creates detached subscription for the given collection of event types. | |
static std::shared_ptr< DXFeedSubscription > | create (std::initializer_list< EventTypeEnum > eventTypes) |
Creates detached subscription for the given collection of event types. | |
template<typename EventTypesCollection> | |
static std::shared_ptr< DXFeedSubscription > | create (EventTypesCollection &&eventTypes) |
Creates detached subscription for the given collection of event types. | |
![]() | |
static auto | createShared (Args &&...args) |
Creates smart pointer to object. | |
Additional Inherited Members | |
![]() | |
using | Ptr = std::shared_ptr<SharedEntity> |
The alias to a type of shared pointer to the SharedEntity object. | |
![]() | |
using | Ptr = std::shared_ptr<DXFeedSubscription> |
The alias to a type of shared pointer to the DXFeedSubscription object. | |
using | Unique = std::unique_ptr<DXFeedSubscription> |
The alias to a type of unique pointer to the DXFeedSubscription object. | |
![]() | |
static const std::int32_t | OPTIMAL_BATCH_LIMIT = 0 |
The optimal events' batch limit for single notification in OnEventHandler. | |
static const std::int32_t | MAX_BATCH_LIMIT = std::numeric_limits<std::int32_t>::max() |
The maximum events' batch limit for single notification in OnEventHandler. | |
Extends DXFeedSubscription to conveniently subscribe to time-series of events for a set of symbols and event types.
This class decorates symbols that are passed to xxxSymbols
methods in DXFeedSubscription by wrapping them into TimeSeriesSubscriptionSymbol instances with the current value of fromTime property. While getSymbols method returns original (undecorated) symbols, any installed ObservableSubscriptionChangeListener will see decorated ones.
Only events that implement TimeSeriesEvent interface can be subscribed to with DXFeedTimeSeriesSubscription.
The value of fromTime property defines the time-span of events that are subscribed to. Only events that satisfy event.getEventTime() >= thisSubscription->getFromTime()
are looked for.
The value fromTime
is initially set to std::numeric_limits<std::int64_t>::max()
with a special meaning that no events will be received until fromTime
is changed with setFromTime method.
This class is thread-safe and can be used concurrently from multiple threads without external synchronization.
|
static |
Creates detached subscription for the given collection of event types.
Example:
eventTypes | The event type collection. |
std::int64_t DXFeedTimeSeriesSubscription::getFromTime | ( | ) |
Returns the earliest timestamp from which time-series of events shall be received.
The timestamp is in milliseconds from midnight, January 1, 1970 UTC.
void DXFeedTimeSeriesSubscription::setFromTime | ( | std::chrono::milliseconds | fromTime | ) |
Sets the earliest timestamp from which time-series of events shall be received.
The timestamp is in milliseconds from midnight, January 1, 1970 UTC.
fromTime | the timestamp. |
void DXFeedTimeSeriesSubscription::setFromTime | ( | std::int64_t | fromTime | ) |
Sets the earliest timestamp from which time-series of events shall be received.
The timestamp is in milliseconds from midnight, January 1, 1970 UTC.
fromTime | the timestamp. |
|
overridevirtual |
Returns a string representation of the current object.
Reimplemented from SharedEntity.