dxFeed Graal CXX API
|
Provides API for publishing of events to local or remote DXFeed. More...
#include <DXPublisher.hpp>
Public Types | |
using | Ptr = std::shared_ptr<DXPublisher> |
The alias to a type of shared pointer to the DXPublisher object. | |
using | Unique = std::unique_ptr<DXPublisher> |
The alias to a type of unique pointer to the DXPublisher 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 | |
template<typename EventsCollection > | |
void | publishEvents (EventsCollection &&events) noexcept |
Publishes events to the corresponding feed. | |
void | publishEvents (std::initializer_list< std::shared_ptr< EventType > > events) noexcept |
Publishes events to the corresponding feed. | |
void | publishEvents (std::shared_ptr< EventType > event) noexcept |
Publishes an event to the corresponding feed. | |
template<typename EventIt > | |
void | publishEvents (EventIt begin, EventIt end) noexcept |
Publishes events to the corresponding feed. | |
std::string | toString () const noexcept override |
Returns a string representation of the current object. | |
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. | |
Public Member Functions inherited from dxfcpp::Entity | |
virtual | ~Entity () noexcept=default |
The default virtual d-tor. | |
Static Public Member Functions | |
static std::shared_ptr< DXPublisher > | getInstance () noexcept |
Returns a default application-wide singleton instance of DXPublisher. | |
Provides API for publishing of events to local or remote DXFeed.
This section gives sample usage scenarios.
There is a singleton instance of the publisher that is returned by DXPublisher::getInstance() method. It is created on the first use with default configuration properties that are explained in detail in documentation for DXEndpoint class in the "Default properties" section. In particular, you can provide a default address to connect using 'dxpublisher.address' system property or by putting it into 'dxpublisher.properties' file in the current directory.
The following code publishes a single quote for a "A:TEST" symbol:
auto quote = std::make_shared<Quote>("A:TEST");
quote->setBidPrice(100);
quote->setAskPrice(101);
DXPublisher::getInstance()->publishEvents(quote);
This class is thread-safe and can be used concurrently from multiple threads without external synchronization.
|
staticnoexcept |
Returns a default application-wide singleton instance of DXPublisher.
Most applications use only a single data-sink and should rely on this method to get one. This is a shortcut to DXEndpoint::getInstance(DXEndpoint::Role::PUBLISHER)->getPublisher().
Publishes events to the corresponding feed.
EventIt | The collection's iterator type |
begin | The beginning of the collection of events. |
end | The end of events collection. |
|
inlinenoexcept |
Publishes events to the corresponding feed.
If the endpoint of this publisher has role of DXEndpoint::Role::PUBLISHER and it is connected, the published events will be delivered to the remote endpoints. Local feed will always receive published events.
This method serializes all events into internal representation, so that the instance of the collection as well as the instances of events can be reused after invocation of this method returns.
DXFeed instances that are connected to this publisher either locally or via network receive published events if and only if they are subscribed to the corresponding symbols, or they are subscribed via WildcardSymbol::ALL, or, in case of TimeSeriesEvent type, they are subscribed via DXFeedTimeSeriesSubscription for the corresponding symbol and time frame.
Published events are not stored and get immediately lost if there is no subscription. Last published events of LastingEvent types are cached as long as subscription to them is maintained via a specific event symbol (WildcardSymbol::ALL does not count) and the cache is discarded as soon as subscription disappears.
Example:
EventsCollection | The type of events collection (for example: std::vector<::EventType::Ptr>) |
events | The collection of events to publish. |
|
inlinenoexcept |
Publishes events to the corresponding feed.
collection | The collection of events to publish. |
Publishes an event to the corresponding feed.
event | The event to publish. |
|
overridevirtualnoexcept |
Returns a string representation of the current object.
Reimplemented from dxfcpp::SharedEntity.