|
| ~IndexedTxModel () noexcept override |
| Calls close method and destructs this model.
|
|
bool | isBatchProcessing () const |
| Returns whether batch processing is enabled.
|
|
bool | isSnapshotProcessing () const |
| Returns whether snapshot processing is enabled.
|
|
void | attach (const std::shared_ptr< DXFeed > &feed) const |
| Attaches this model to the specified feed.
|
|
void | detach (const std::shared_ptr< DXFeed > &feed) const |
| Detaches this model from the specified feed.
|
|
void | close () const |
| Closes this model and makes it permanently detached.
|
|
std::unordered_set< EventSourceWrapper > | getSources () const |
| Returns the current set of sources.
|
|
template<typename EventSourceIt > |
void | setSources (EventSourceIt begin, EventSourceIt end) const |
| Sets the sources from which to subscribe for indexed events.
|
|
template<ConvertibleToEventSourceWrapperCollection EventSourceCollection> |
void | setSources (EventSourceCollection &&sources) const |
| Sets the sources from which to subscribe for indexed events.
|
|
void | setSources (std::initializer_list< EventSourceWrapper > sources) const |
| Sets the sources from which to subscribe for indexed events.
|
|
std::string | toString () const override |
| Returns a string representation of the current object.
|
|
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.
|
|
template<Derived<
IndexedEvent > E>
struct IndexedTxModel< E >
An incremental model for indexed events.
This model manages all snapshot and transaction logic, subscription handling, and listener notifications.
This model is designed to handle incremental transactions. Users of this model only see the list of events in a consistent state. This model delays incoming events that are part of an incomplete snapshot or ongoing transaction until the snapshot is complete or the transaction has ended. This model notifies the user of received transactions through an installed listener.
Configuration
This model must be configured using the builder, as most configuration settings cannot be changed once the model is built. This model requires configuration with a symbol and a IndexedTxModel::Builder::withSources() sources for subscription, and it must be attached to a DXFeed instance to begin operation. For ease of use, some of these configurations can be changed after the model is built, see setSources and attach and their overloads.
This model only supports single symbol subscriptions; multiple symbols cannot be configured.
Resource management and closed models
Attached model is a potential memory leak. If the pointer to attached model is lost, then there is no way to detach this model from the feed.
The convenient way to detach model from the feed is to call its close method (it is automatically called when the destructor is called, i.e. RAII). Closed model becomes permanently detached from all feeds, removes all its listeners.
Threads and locks
This class is thread-safe and can be used concurrently from multiple threads without external synchronization.
Sample:
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;
});
->withFeed(feed)
->withBatchProcessing(true)
->withSnapshotProcessing(true)
->withListener(listener)
->withSymbol("IBM")
->build();
std::this_thread::sleep_for(10s);
static const OrderSource DEX
Direct-Edge EDGX Exchange.
Definition OrderSource.hpp:202
static const OrderSource NTV
NASDAQ Total View.
Definition OrderSource.hpp:138
@ FEED
FEED endpoint connects to the remote data feed provider and is optimized for real-time or delayed dat...
std::shared_ptr< DXFeed > getFeed()
Definition DXEndpoint.cpp:229
std::shared_ptr< DXEndpoint > connect(const std::string &address)
Connects to the specified remote address.
Definition DXEndpoint.cpp:170
static std::shared_ptr< DXEndpoint > getInstance()
Returns a default application-wide singleton instance of DXEndpoint with a FEED role.
Definition DXEndpoint.cpp:426
static std::shared_ptr< Builder > newBuilder()
Factory method to create a new builder for this model.
Definition IndexedTxModel.hpp:401
static std::shared_ptr< IndexedTxModelListener< E > > create(std::function< void(const IndexedEventSource &, const std::vector< std::shared_ptr< E > > &, bool)> onEventsReceived)
Creates a listener for receiving indexed events (with instantiation by event type E and verification)
Definition TxModelListener.hpp:100
- Template Parameters
-