dxFeed Graal CXX API v4.0.0
|
Subscription for a set of symbols and event types. More...
#include <DXFeedSubscription.hpp>
Public Types | |
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. | |
Public Types inherited from SharedEntity | |
using | Ptr = std::shared_ptr<SharedEntity> |
The alias to a type of shared pointer to the SharedEntity object. | |
Public Member Functions | |
std::string | toString () const override |
Returns a string representation of the current object. | |
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. | |
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. | |
Public Member Functions inherited from Entity | |
virtual | ~Entity () noexcept=default |
The default virtual d-tor. | |
Public Member Functions inherited from ObservableSubscription |
Static Public Member Functions | |
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 Public Member Functions inherited from RequireMakeShared< DXFeedSubscription > | |
static auto | createShared (Args &&...args) |
Creates smart pointer to object. | |
Friends | |
struct | DXFeed |
Subscription for a set of symbols and event types.
|
overridevirtual |
Adds subscription change listener.
This method does nothing if subscription is closed. Otherwise, it installs the corresponding listener and immediately invokes ObservableSubscriptionChangeListener::symbolsAdded() on the given listener while holding the lock for this subscription. This way the given listener synchronously receives existing subscription state and is synchronously notified on all changes in subscription afterwards.
listener | The subscription change listener. |
Implements ObservableSubscription.
|
inline |
Adds listener for events.
Event lister can be added only when subscription is not producing any events. The subscription must be either empty (its set of symbols is empty or not attached to any feed (its set of change listeners is empty).
This method does nothing if this subscription is closed.
Example:
EventListener | The listener type. Listener can be callable with signature: void(const std::vector<std::shared_ptr<EventType>&) |
listener | The event listener |
|
inline |
Adds typed listener for events.
Event lister can be added only when subscription is not producing any events. The subscription must be either empty (its set of symbols is empty or not attached to any feed (its set of change listeners is empty).
This method does nothing if this subscription is closed.
Example:
EventT | The event type (EventType's child with field TYPE, convertible to EventTypeEnum or MarketEvent or LastingEvent or TimeSeriesEvent or IndexedEvent) |
listener | The listener. Listener can be callable with signature: void(const std::vector<std::shared_ptr<EventT>&) |
|
inline |
Adds the specified collection of symbols to the set of subscribed symbols.
Example:
SymbolsCollection | The symbols collection's type |
collection | The symbols collection |
void DXFeedSubscription::addSymbols | ( | const SymbolWrapper & | symbolWrapper | ) | const |
Adds the specified symbol to the set of subscribed symbols.
This is a convenience method to subscribe to one symbol at a time that has a return fast-path for a case when the symbol is already in the set. When subscribing to multiple symbols at once it is preferable to use addSymbols(symbols) method.
Example:
symbolWrapper | The symbol. |
void DXFeedSubscription::addSymbols | ( | std::initializer_list< SymbolWrapper > | collection | ) | const |
Adds the specified collection (initializer list) of symbols to the set of subscribed symbols.
Example:
collection | The symbols collection |
|
inline |
Adds the specified collection (using iterators) of symbols to the set of subscribed symbols.
Example:
SymbolIt | The collection's iterator type |
begin | The beginning of the collection of symbols. |
end | The end of symbol collection. |
void DXFeedSubscription::attach | ( | std::shared_ptr< DXFeed > | feed | ) |
Attaches subscription to the specified feed.
feed | The feed to attach to. |
void DXFeedSubscription::close | ( | ) | const |
Closes this subscription and makes it permanently detached.
This method notifies all installed instances of subscription change listeners by invoking subscriptionClosed
while holding the lock for this subscription. This method clears lists of all installed event listeners and subscription change listeners and makes sure that no more listeners can be added.
|
overridevirtual |
Returns true
if this subscription contains the corresponding event type.
eventType | The type of event that is checked. |
true
if this subscription contains the corresponding event type.Implements ObservableSubscription.
|
static |
Creates detached subscription for a single event type.
Example:
eventType | the event type. |
References EventTypeEnum::getName().
|
inlinestatic |
Creates detached subscription for the given collection of event types.
Example:
EventTypeIt | The collection's iterator type |
begin | The beginning of the collection of event types. |
end | The end of event type collection. |
|
inlinestatic |
Creates detached subscription for the given collection of event types.
Example:
EventTypesCollection | The type of the collection of event types |
eventTypes | The event type collection. |
|
static |
Creates detached subscription for the given collection of event types.
Example:
eventTypes | The event type collection. |
void DXFeedSubscription::detach | ( | std::shared_ptr< DXFeed > | feed | ) |
Detaches subscription from the specified feed.
feed | The feed to detach from. |
TimePeriod DXFeedSubscription::getAggregationPeriod | ( | ) | const |
Returns the aggregation period for data for this subscription instance.
std::vector< SymbolWrapper > DXFeedSubscription::getDecoratedSymbols | ( | ) | const |
Returns a set of decorated symbols (depending on the actual implementation of subscription).
The resulting set maybe either a snapshot of the set of the subscribed symbols at the time of invocation or a weakly consistent view of the set.
std::int32_t DXFeedSubscription::getEventsBatchLimit | ( | ) | const |
|
overridevirtual |
Returns a set of subscribed event types.
Implements ObservableSubscription.
std::vector< SymbolWrapper > DXFeedSubscription::getSymbols | ( | ) | const |
Returns a set of subscribed symbols (depending on the actual implementation of subscription).
The resulting set maybe either a snapshot of the set of the subscribed symbols at the time of invocation or a weakly consistent view of the set.
|
overridevirtual |
Returns true
if this subscription is closed.
true
if this subscription is closed.Implements ObservableSubscription.
DXFeedSubscription::OnEventHandler & DXFeedSubscription::onEvent | ( | ) |
Returns a reference to an incoming events' handler (delegate), to which listeners can be added and removed.
Listener can be callable with signature: void(const std::vector<std::shared_ptr<EventType>&)
Example:
|
overridevirtual |
Removes subscription change listener by id.
This method does nothing if the listener with the given id was not installed or was already removed as subscription change listener for this subscription. Otherwise, it removes the corresponding listener and immediately invokes ObservableSubscriptionChangeListener::subscriptionClosed() on the given listener while holding the lock for this subscription.
id | The subscription change listener id. |
Implements ObservableSubscription.
void DXFeedSubscription::removeEventListener | ( | std::size_t | listenerId | ) |
Removes listener for events.
Example:
listenerId | The listener id |
void DXFeedSubscription::removeSymbols | ( | const SymbolWrapper & | symbolWrapper | ) | const |
Removes the specified symbol from the set of subscribed symbols.
To conveniently remove one or few symbols you can use removeSymbols(symbols) method.
Example:
symbolWrapper | The symbol. |
void DXFeedSubscription::removeSymbols | ( | std::initializer_list< SymbolWrapper > | collection | ) | const |
Removes the specified collection (initializer list) of symbols from the set of subscribed symbols.
Example:
collection | The symbols collection |
|
inline |
Removes the specified collection (using iterators) of symbols from the set of subscribed symbols.
Example:
SymbolIt | The collection's iterator type |
begin | The beginning of the collection of symbols. |
end | The end of symbol collection. |
|
inline |
Removes the specified collection of symbols from the set of subscribed symbols.
Example:
SymbolsCollection | The symbols collection's type |
collection | The symbols collection |
void DXFeedSubscription::setAggregationPeriod | ( | const TimePeriod & | aggregationPeriod | ) | const |
Sets the aggregation period for data.
This method sets a new aggregation period for data, which will only take effect on the next iteration of data notification. For example, if the current aggregation period is 5 seconds and it is changed to 1 second, the next call to the next call to the retrieve method may take up to 5 seconds, after which the new aggregation period will take effect.
aggregationPeriod | the new aggregation period for data |
Referenced by setAggregationPeriod().
|
inline |
Sets the aggregation period for data.
This method sets a new aggregation period for data, which will only take effect on the next iteration of data notification. For example, if the current aggregation period is 5 seconds and it is changed to 1 second, the next call to the next call to the retrieve method may take up to 5 seconds, after which the new aggregation period will take effect.
aggregationPeriod | the new aggregation period (in millis) for data |
|
inline |
Sets the aggregation period for data.
This method sets a new aggregation period for data, which will only take effect on the next iteration of data notification. For example, if the current aggregation period is 5 seconds and it is changed to 1 second, the next call to the next call to the retrieve method may take up to 5 seconds, after which the new aggregation period will take effect.
aggregationPeriod | the new aggregation period (in millis) for data |
References setAggregationPeriod(), and TimePeriod::valueOf().
void DXFeedSubscription::setEventsBatchLimit | ( | std::int32_t | eventsBatchLimit | ) | const |
Sets maximum number of events in the single notification of OnEventHandler.
Special cases are supported for constants OPTIMAL_BATCH_LIMIT and MAX_BATCH_LIMIT.
eventsBatchLimit | the notification events limit |
JavaException | if eventsBatchLimit < 0 (see OPTIMAL_BATCH_LIMIT or MAX_BATCH_LIMIT) |
void DXFeedSubscription::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).
Example:
collection | The symbols collection |
|
inline |
Changes the set of subscribed symbols so that it contains just the symbols from the specified collection (using iterators).
Example:
SymbolIt | The collection's iterator type |
begin | The beginning of the collection of symbols. |
end | The end of symbol collection. |
|
inline |
Changes the set of subscribed symbols so that it contains just the symbols from the specified collection.
Example:
SymbolsCollection | The symbols collection's type |
collection | The symbols collection |
|
overridevirtual |
Returns a string representation of the current object.
Reimplemented from SharedEntity.