dxFeed Graal CXX API
|
Connects to an instrument profile URL and reads instrument profiles with support of streaming live updates. More...
#include <InstrumentProfileConnection.hpp>
Public Types | |
enum class | State : std::int32_t { NOT_CONNECTED , CONNECTING , CONNECTED , COMPLETED , CLOSED } |
Instrument profile connection state. More... | |
using | Ptr = std::shared_ptr<InstrumentProfileConnection> |
The alias to a type of shared pointer to the InstrumentProfileConnection object. | |
using | Unique = std::unique_ptr<InstrumentProfileConnection> |
The alias to a type of unique pointer to the InstrumentProfileConnection 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::string | getAddress () const noexcept |
Returns the address of this instrument profile connection. | |
std::int64_t | getUpdatePeriod () const noexcept |
Returns update period in milliseconds. | |
std::chrono::milliseconds | getUpdatePeriodAsDuration () const noexcept |
Returns update period in milliseconds as chrono::duration It is period of an update check when the instrument profiles source does not support live updates and/or when connection is dropped. | |
void | setUpdatePeriod (std::int64_t updatePeriod) const noexcept |
Changes the update period in milliseconds. | |
void | setUpdatePeriod (std::chrono::milliseconds updatePeriod) const noexcept |
Changes the update period in milliseconds as chrono::duration. | |
State | getState () const noexcept |
Returns state of this instrument profile connections. | |
std::int64_t | getLastModified () const noexcept |
Returns last modification time (in milliseconds) of instrument profiles or zero if it is unknown. | |
void | start () const noexcept |
Starts this instrument profile connection. | |
void | close () const noexcept |
Closes this instrument profile connection. | |
template<typename StateChangeListener > | |
std::size_t | addStateChangeListener (StateChangeListener &&listener) noexcept |
Adds listener that is notified about changes in state property. | |
void | removeStateChangeListener (std::size_t listenerId) noexcept |
Removes listener that is notified about changes in state property. | |
auto & | onStateChange () noexcept |
Returns the onStateChange handler that can be used to add or remove listeners. | |
bool | waitUntilCompleted (std::int64_t timeout) const noexcept |
Synchronously waits for full first snapshot read with the specified timeout. | |
bool | waitUntilCompleted (std::chrono::milliseconds timeout) const noexcept |
Synchronously waits for full first snapshot read with the specified timeout. | |
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 | createConnection (const std::string &address, InstrumentProfileCollector::Ptr collector) noexcept |
Creates instrument profile connection with a specified address and collector. | |
Connects to an instrument profile URL and reads instrument profiles with support of streaming live updates.
Please see Instrument Profile Format documentation for complete description.
|
strong |
Instrument profile connection state.
Enumerator | |
---|---|
NOT_CONNECTED | Instrument profile connection is not started yet. start was not invoked yet. |
CONNECTING | Connection is being established. |
CONNECTED | Connection was established. |
COMPLETED | Initial instrument profiles snapshot was fully read (this state is set only once). |
CLOSED | Instrument profile connection was closed. |
|
inlinenoexcept |
Adds listener that is notified about changes in state property.
Installed listener can be removed by id
with InstrumentProfileConnection::removeStateChangeListener method or by call InstrumentProfileConnection::onStateChange() -= id
;
StateChangeListener | The listener type. It can be any callable with signature: void(State, State) |
listener | The listener to add |
|
noexcept |
Closes this instrument profile connection.
This connection's state immediately changes to CLOSED and the background update procedures are terminated.
|
staticnoexcept |
Creates instrument profile connection with a specified address and collector.
Address may be just "<host>:<port>" of server, URL, or a file path. The "[update=<period>]" clause can be optionally added at the end of the address to specify an update period via an address string. Default update period is 1 minute.
Connection needs to be started to begin an actual operation.
address | The address. |
collector | The instrument profile collector to push updates into. |
|
noexcept |
Returns the address of this instrument profile connection.
It does not include additional options specified as part of the address.
|
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.
|
noexcept |
Returns state of this instrument profile connections.
|
noexcept |
Returns update period in milliseconds.
It is period of an update check when the instrument profiles source does not support live updates and/or when connection is dropped. Default update period is 1 minute, unless overridden in an address string.
|
inlinenoexcept |
Returns update period in milliseconds as chrono::duration It is period of an update check when the instrument profiles source does not support live updates and/or when connection is dropped.
Default update period is 1 minute, unless overridden in an address string.
|
inlinenoexcept |
Returns the onStateChange handler that can be used to add or remove listeners.
void(State, State)
signature
|
inlinenoexcept |
Removes listener that is notified about changes in state property.
It removes the listener that was previously installed with InstrumentProfileConnection::addStateChangeListener method.
listenerId | The listener id to remove |
|
inlinenoexcept |
Changes the update period in milliseconds as chrono::duration.
updatePeriod | The update period in milliseconds as chrono::duration. |
|
noexcept |
Changes the update period in milliseconds.
updatePeriod | The update period in milliseconds. |
|
noexcept |
Starts this instrument profile connection.
This connection's state immediately changes to CONNECTING and the actual connection establishment proceeds in the background.
|
inlinenoexcept |
Synchronously waits for full first snapshot read with the specified timeout.
timeout | The maximum time to wait |
true
if COMPLETED state was reached and false
if the waiting time elapsed before snapshot was fully read.
|
noexcept |
Synchronously waits for full first snapshot read with the specified timeout.
timeout | The maximum time (in millis) to wait |
true
if COMPLETED state was reached and false
if the waiting time elapsed before snapshot was fully read.