|
dxFeed Graal CXX API v9.0.0
|
Collects instrument profile updates and provides the live list of instrument profiles. More...
#include <InstrumentProfileCollector.hpp>
Public Types | |
| using | Ptr = std::shared_ptr<InstrumentProfileCollector> |
| The alias to a type of shared pointer to the InstrumentProfileCollector object. | |
| using | Unique = std::unique_ptr<InstrumentProfileCollector> |
| The alias to a type of unique pointer to the InstrumentProfileCollector 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::int64_t | getLastUpdateTime () const |
| Returns last modification time (in milliseconds) of instrument profiles or zero if it is unknown. | |
| std::chrono::milliseconds | getLastUpdateTimeAsDuration () const |
| Returns last modification time (as std::chrono::milliseconds) of instrument profiles or zero if it is unknown. | |
| void | updateInstrumentProfile (std::shared_ptr< InstrumentProfile > ip) const |
| Convenience method to update one instrument profile in this collector. | |
| std::shared_ptr< IterableInstrumentProfile > | view () const |
| Returns a concurrent view of the set of instrument profiles. | |
| template<typename InstrumentProfileUpdateListener> | |
| std::size_t | addUpdateListener (InstrumentProfileUpdateListener listener) |
| Adds listener that is notified about any updates in the set of instrument profiles. | |
| void | removeUpdateListener (std::size_t listenerId) |
| Removes listener for instrument profile updates. | |
| 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 Ptr | create () |
| Creates the new InstrumentProfileCollector. | |
Collects instrument profile updates and provides the live list of instrument profiles.
This class contains a map that keeps a unique instrument profile per symbol. This class is intended to be used with InstrumentProfileConnection as a repository that keeps profiles of all known instruments. See InstrumentProfileConnection for a usage example.
As set of instrument profiles stored in this collector can be accessed with view method. A snapshot plus a live stream of updates can be accessed with addUpdateListener method.
Removal of instrument profile is represented by an InstrumentProfile instance with a type equal to InstrumentProfileType::REMOVED.getName().
This class is thread-safe.
|
inline |
Adds listener that is notified about any updates in the set of instrument profiles.
If a set of instrument profiles is not empty, then this listener will be immediately notified.
Example:
Example:
| InstrumentProfileUpdateListener | The listener type. Listener can be callable with signature: void(const std::vector<std::shared_ptr<InstrumentProfile>&) |
| listener | The profile update listener. The listener can be callable with signature: void(const std::vector<std::shared_ptr<InstrumentProfile>&) |
| InvalidArgumentException | if the listener ids of this collector are exhausted (about 2^32 listeners were added on a 64-bit platform) |
References addUpdateListener().
Referenced by addUpdateListener().
|
static |
Creates the new InstrumentProfileCollector.
| std::int64_t InstrumentProfileCollector::getLastUpdateTime | ( | ) | const |
Returns last modification time (in milliseconds) of instrument profiles or zero if it is unknown.
Note, that while the time is represented in milliseconds, the actual granularity of time here is a second.
Referenced by getLastUpdateTimeAsDuration().
| std::chrono::milliseconds InstrumentProfileCollector::getLastUpdateTimeAsDuration | ( | ) | const |
Returns last modification time (as std::chrono::milliseconds) of instrument profiles or zero if it is unknown.
Note, that while the time is represented in milliseconds, the actual granularity of time here is a second.
References getLastUpdateTime().
| void InstrumentProfileCollector::removeUpdateListener | ( | std::size_t | listenerId | ) |
Removes listener for instrument profile updates.
Example:
| listenerId | The listener id |
| void InstrumentProfileCollector::updateInstrumentProfile | ( | std::shared_ptr< InstrumentProfile > | ip | ) | const |
Convenience method to update one instrument profile in this collector.
| ip | The instrument profile. |
| std::shared_ptr< IterableInstrumentProfile > InstrumentProfileCollector::view | ( | ) | const |
Returns a concurrent view of the set of instrument profiles.
Note, that removal of instrument profile is represented by an InstrumentProfile instance with a type equal to InstrumentProfileType::REMOVED.getName(). Normally, this view exposes only non-removed profiles. However, if iteration is concurrent with removal, then a removed instrument profile (with a removed type) can be exposed by this view.