dxFeed Graal CXX API v9.0.0
Loading...
Searching...
No Matches
SubscriptionController Struct Referencefinal

Controls the subscription of an object that owns an underlying DXFeedSubscription (for example, IndexedEventTxModel): attaches it to and detaches it from a feed and changes the settings of the event delivery. More...

#include <SubscriptionController.hpp>

Inheritance diagram for SubscriptionController:

Public Types

using Ptr = std::shared_ptr<SubscriptionController>
 The alias to a type of shared pointer to the SubscriptionController 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

void attach (const std::shared_ptr< DXFeed > &feed) const
 Attaches the underlying subscription to the given feed.
void detach (const std::shared_ptr< DXFeed > &feed) const
 Detaches the underlying subscription from the given feed.
std::int32_t getEventsBatchLimit () const
 Returns the maximum number of events in a single notification of the listener.
void setEventsBatchLimit (std::int32_t eventsBatchLimit) const
 Sets the maximum number of events in a single notification of the listener.
TimePeriod getAggregationPeriod () const
 Returns the aggregation period of the events: the listener is notified at most once per this period, and the events of the same symbol within the period may be conflated.
void setAggregationPeriod (const TimePeriod &aggregationPeriod) const
 Sets the aggregation period of the events.
void setAggregationPeriod (std::chrono::milliseconds aggregationPeriod) const
 Sets the aggregation period of the events.
void setAggregationPeriod (std::int64_t aggregationPeriod) const
 Sets the aggregation period of the events.
template<typename Executor>
void setExecutor (const std::shared_ptr< Executor > &executor) const
 Sets the executor that notifies the listener (for example, InPlaceExecutor).
void setExecutor (std::nullptr_t) const
 Makes the executor of the endpoint of the feed notify the listener.
Public Member Functions inherited from SharedEntity
template<typename T>
bool is () const noexcept
 Checks that the object is of type T: its dynamic type is T or derived from T.
template<typename T>
std::shared_ptr< T > sharedAs () noexcept
 Returns a pointer to the current object wrapped in a smart pointer to type T or std::shared_ptr<T>{nullptr} if the object is not managed by std::shared_ptr.
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 or std::shared_ptr<T>{nullptr} if the object is not managed by std::shared_ptr.
virtual std::string toString () const
 Returns a string representation of the current object.
Public Member Functions inherited from Entity
virtual ~Entity () noexcept
 The default virtual d-tor.

Additional Inherited Members

Static Public Member Functions inherited from RequireMakeShared< SubscriptionController >
static auto createShared (Args &&...args)
 Creates a smart pointer to an object.

Detailed Description

Controls the subscription of an object that owns an underlying DXFeedSubscription (for example, IndexedEventTxModel): attaches it to and detaches it from a feed and changes the settings of the event delivery.

auto controller = model->getSubscriptionController();
controller->setAggregationPeriod(std::chrono::milliseconds(100));
controller->detach(feed);

Member Function Documentation

◆ attach()

void SubscriptionController::attach ( const std::shared_ptr< DXFeed > & feed) const

Attaches the underlying subscription to the given feed.

Parameters
feedThe feed to attach to.

◆ detach()

void SubscriptionController::detach ( const std::shared_ptr< DXFeed > & feed) const

Detaches the underlying subscription from the given feed.

Parameters
feedThe feed to detach from.

◆ getAggregationPeriod()

TimePeriod SubscriptionController::getAggregationPeriod ( ) const

Returns the aggregation period of the events: the listener is notified at most once per this period, and the events of the same symbol within the period may be conflated.

Returns
the aggregation period; TimePeriod::ZERO when it is not set (then only the aggregation period of the feed applies).

◆ getEventsBatchLimit()

std::int32_t SubscriptionController::getEventsBatchLimit ( ) const

Returns the maximum number of events in a single notification of the listener.

Returns
the events batch limit (DXFeedSubscription::OPTIMAL_BATCH_LIMIT is the default one).

◆ setAggregationPeriod() [1/3]

void SubscriptionController::setAggregationPeriod ( const TimePeriod & aggregationPeriod) const

Sets the aggregation period of the events.

Parameters
aggregationPeriodThe aggregation period.
See also
getAggregationPeriod()

References TimePeriod::getTime().

◆ setAggregationPeriod() [2/3]

void SubscriptionController::setAggregationPeriod ( std::chrono::milliseconds aggregationPeriod) const

Sets the aggregation period of the events.

Parameters
aggregationPeriodThe aggregation period.
See also
getAggregationPeriod()

◆ setAggregationPeriod() [3/3]

void SubscriptionController::setAggregationPeriod ( std::int64_t aggregationPeriod) const

Sets the aggregation period of the events.

Parameters
aggregationPeriodThe aggregation period in milliseconds.
See also
getAggregationPeriod()

◆ setEventsBatchLimit()

void SubscriptionController::setEventsBatchLimit ( std::int32_t eventsBatchLimit) const

Sets the maximum number of events in a single notification of the listener.

Parameters
eventsBatchLimitThe events batch limit: DXFeedSubscription::OPTIMAL_BATCH_LIMIT, DXFeedSubscription::MAX_BATCH_LIMIT or a positive number.

◆ setExecutor()

template<typename Executor>
void SubscriptionController::setExecutor ( const std::shared_ptr< Executor > & executor) const
inline

Sets the executor that notifies the listener (for example, InPlaceExecutor).

Template Parameters
ExecutorThe type of the executor.
Parameters
executorThe executor, or nullptr to use the executor of the endpoint of the feed.