dxFeed Graal CXX API
Loading...
Searching...
No Matches
dxfcpp::InstrumentProfileCollector Class Referencefinal

Collects instrument profile updates and provides the live list of instrument profiles. More...

#include <InstrumentProfileCollector.hpp>

+ Inheritance diagram for dxfcpp::InstrumentProfileCollector:

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 dxfcpp::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 noexcept
 Returns last modification time (in milliseconds) of instrument profiles or zero if it is unknown.
 
std::chrono::milliseconds getLastUpdateTimeAsDuration () const noexcept
 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 noexcept
 Convenience method to update one instrument profile in this collector.
 
void updateInstrumentProfile (const InstrumentProfile &ip) const noexcept
 Convenience method to update one instrument profile in this collector.
 
std::shared_ptr< IterableInstrumentProfileview () const noexcept
 Returns a concurrent view of the set of instrument profiles.
 
- Public Member Functions inherited from dxfcpp::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.
 
virtual std::string toString () const noexcept
 Returns a string representation of the current object.
 
- Public Member Functions inherited from dxfcpp::Entity
virtual ~Entity () noexcept=default
 The default virtual d-tor.
 

Static Public Member Functions

static Ptr create () noexcept
 Creates the new InstrumentProfileCollector.
 

Detailed Description

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.

Member Function Documentation

◆ create()

InstrumentProfileCollector::Ptr dxfcpp::InstrumentProfileCollector::create ( )
staticnoexcept

Creates the new InstrumentProfileCollector.

Returns
The new InstrumentProfileCollector

◆ getLastUpdateTime()

std::int64_t dxfcpp::InstrumentProfileCollector::getLastUpdateTime ( ) const
noexcept

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.

Returns
The last modification time (in milliseconds) of instrument profiles or zero if it is unknown.

◆ getLastUpdateTimeAsDuration()

std::chrono::milliseconds dxfcpp::InstrumentProfileCollector::getLastUpdateTimeAsDuration ( ) const
inlinenoexcept

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.

Returns
The last modification time (as std::chrono::milliseconds) of instrument profiles or zero if it is unknown.

◆ updateInstrumentProfile() [1/2]

void dxfcpp::InstrumentProfileCollector::updateInstrumentProfile ( const InstrumentProfile & ip) const
noexcept

Convenience method to update one instrument profile in this collector.

This is a shortcut for:


   updateInstrumentProfiles({ip}, nullptr);
Parameters
ipThe instrument profile.

◆ updateInstrumentProfile() [2/2]

void dxfcpp::InstrumentProfileCollector::updateInstrumentProfile ( std::shared_ptr< InstrumentProfile > ip) const
noexcept

Convenience method to update one instrument profile in this collector.

This is a shortcut for:


   updateInstrumentProfiles({ip}, nullptr);
Parameters
ipThe instrument profile.

◆ view()

std::shared_ptr< IterableInstrumentProfile > dxfcpp::InstrumentProfileCollector::view ( ) const
noexcept

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.

Returns
A concurrent view of the set of instrument profiles.