dxFeed Graal CXX API v9.0.0
Loading...
Searching...
No Matches
IndexedEventTxModel< E > Struct Template Referencefinal

An incremental model of the indexed events of one symbol and one source (the IndexedEventTxModel of dxFeed Java API, an experimental API there). More...

#include <IndexedEventTxModel.hpp>

Inheritance diagram for IndexedEventTxModel< E >:

Classes

struct  Builder
 The builder of IndexedEventTxModel. More...

Public Types

using EventsListener
 The function that receives the events of one or more complete transactions and whether they form a snapshot.
Public Types inherited from IndexedEventTxModelImpl
using EventsReceived = std::function<void(const std::vector<std::shared_ptr<EventType>> &, bool)>
 The function that receives the events of the model.
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

 ~IndexedEventTxModel () noexcept override
 Closes the model and destructs it.
IndexedEventSubscriptionSymbol getIndexedEventSubscriptionSymbol () const
 Returns the symbol of the model with its source.
std::string getSymbol () const
 Returns the symbol of the model.
EventSourceWrapper getSource () const
 Returns the source of the model.
std::shared_ptr< SubscriptionController > getSubscriptionController () const
 Returns the controller of the underlying subscription of the model: it attaches the model to and detaches it from a feed and changes the events batch limit, the aggregation period and the executor.
bool isClosed () const
 Returns whether the model is closed.
void close () const
 Closes the model: it is permanently detached from all feeds.
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.

Static Public Member Functions

static std::shared_ptr< Builder > newBuilder ()
 Creates a new builder of the model.
Static Public Member Functions inherited from RequireMakeShared< IndexedEventTxModel< E > >
static auto createShared (Args &&...args)
 Creates a smart pointer to an object.

Detailed Description

template<Derived< IndexedEvent > E>
struct IndexedEventTxModel< E >

An incremental model of the indexed events of one symbol and one source (the IndexedEventTxModel of dxFeed Java API, an experimental API there).

The model delivers the events of complete snapshots and transactions only: it delays the events of an incomplete snapshot or of an ongoing transaction until the snapshot is complete or the transaction has ended.

IndexedEventTxModel or IndexedTxModel

  • IndexedEventTxModel is the model of dxFeed Java API: one source, the events batch limit, the aggregation period and the executor of the underlying subscription, which can be changed later through the subscription controller (it also attaches the model to and detaches it from a feed).
  • IndexedTxModel is the model of the Graal SDK: several sources, which can be changed later, batch and snapshot processing flags, attach and detach on the model itself.

Configuration

The model is configured with the builder: the symbol, the source and the listener (required), and the feed to attach to. The symbol and the source cannot be changed after the model is built.

Listener and resource management

The listener receives the events of one or more complete transactions and whether they form a snapshot. It is never called concurrently with itself. By default, it is called by the executor of the endpoint of the feed.

The model is closed by close or by the destructor: a closed model is permanently detached from all feeds. The listener is released with the last of its owners: the models built with it and the builder that holds it. Releasing it waits for its calls in progress on other threads, so do not destroy the last owner while holding a lock that the listener takes. Until then, a call that was already scheduled may still run after the model is closed. A listener must not own its model (for example, capture its std::shared_ptr): such a model is never destroyed.

->withFeed(DXFeed::getInstance())
->withSymbol("AAPL")
->withSource(OrderSource::NTV)
->withListener([](const auto &orders, bool isSnapshot) {
std::cout << (isSnapshot ? "Snapshot: " : "Update: ") << orders.size() << std::endl;
})
->build();
static const OrderSource NTV
NASDAQ Total View.
Definition OrderSource.hpp:235
static std::shared_ptr< DXFeed > getInstance()
Returns a default application-wide singleton instance of feed.
Definition DXFeed.cpp:25
static std::shared_ptr< Builder > newBuilder()
Creates a new builder of the model.
Definition IndexedEventTxModel.hpp:343
Template Parameters
EThe type of events (derived from IndexedEvent).

Constructor & Destructor Documentation

◆ ~IndexedEventTxModel()

template<Derived< IndexedEvent > E>
IndexedEventTxModel< E >::~IndexedEventTxModel ( )
inlineoverridenoexcept

Closes the model and destructs it.

If the model is the last owner of its listener, waits for the calls of the listener in progress on other threads.

References close().

Member Function Documentation

◆ close()

template<Derived< IndexedEvent > E>
void IndexedEventTxModel< E >::close ( ) const
inline

Closes the model: it is permanently detached from all feeds.

The next calls of close() do nothing.

Referenced by ~IndexedEventTxModel().

◆ getIndexedEventSubscriptionSymbol()

template<Derived< IndexedEvent > E>
IndexedEventSubscriptionSymbol IndexedEventTxModel< E >::getIndexedEventSubscriptionSymbol ( ) const
inline

Returns the symbol of the model with its source.

Returns
the symbol with the source.

◆ getSource()

template<Derived< IndexedEvent > E>
EventSourceWrapper IndexedEventTxModel< E >::getSource ( ) const
inline

Returns the source of the model.

Returns
the source.

◆ getSubscriptionController()

template<Derived< IndexedEvent > E>
std::shared_ptr< SubscriptionController > IndexedEventTxModel< E >::getSubscriptionController ( ) const
inline

Returns the controller of the underlying subscription of the model: it attaches the model to and detaches it from a feed and changes the events batch limit, the aggregation period and the executor.

Returns
the subscription controller.

◆ getSymbol()

template<Derived< IndexedEvent > E>
std::string IndexedEventTxModel< E >::getSymbol ( ) const
inline

Returns the symbol of the model.

Returns
the symbol.

◆ isClosed()

template<Derived< IndexedEvent > E>
bool IndexedEventTxModel< E >::isClosed ( ) const
inline

Returns whether the model is closed.

Returns
true if the model is closed.

◆ newBuilder()

template<Derived< IndexedEvent > E>
std::shared_ptr< Builder > IndexedEventTxModel< E >::newBuilder ( )
inlinestatic

Creates a new builder of the model.

Returns
a new builder.