dxFeed Graal CXX API v9.0.0
Loading...
Searching...
No Matches

Message event with an application-specific attachment. More...

#include <Message.hpp>

Inheritance diagram for Message:

Public Types

using Ptr = std::shared_ptr<Message>
 The alias to a type of shared pointer to the Message object.
using Unique = std::unique_ptr<Message>
 The alias to a type of unique pointer to the Message object.
Public Types inherited from EventTypeWithSymbol< std::string >
using Ptr = std::shared_ptr<EventTypeWithSymbol<std::string>>
 The alias to a type of shared pointer to the EventTypeWithSymbol's child object.
Public Types inherited from EventType
using Ptr = std::shared_ptr<EventType>
 The alias to a type of shared pointer to the EventType 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

void * toGraal () const override
 Allocates memory for the dxFeed Graal SDK structure (recursively if necessary).
void assign (std::shared_ptr< EventType > event) override
 Replaces the contents of the event.
 Message () noexcept
 Creates a new message with default values.
 Message (StringParam eventSymbol)
 Creates a new message with the specified event symbol.
 Message (StringParam eventSymbol, StringParam attachment)
 Creates a new message with the specified event symbol and attachment.
const std::string & getEventSymbol () const &noexcept override
 Returns a symbol of this event.
const std::optional< std::string > & getEventSymbolOpt () const &noexcept override
 Returns a symbol of this event.
void setEventSymbol (StringParam eventSymbol) override
 Changes symbol of this event.
Message & withEventSymbol (StringParam eventSymbol)
 Changes an event's symbol and returns the current message.
std::int64_t getEventTime () const noexcept override
 Returns time when an event was created or zero when time is not available.
void setEventTime (std::int64_t eventTime) noexcept override
 Changes event creation time.
Message & withEventTime (std::int64_t eventTime) noexcept
 Changes the event's creation time and returns the current message.
const std::string & getAttachment () const &
 Returns attachment.
const std::optional< std::string > & getAttachmentOpt () const &noexcept
 Returns attachment of this event.
void setAttachment (StringParam attachment)
 Changes attachment.
template<OptionalString S>
void setAttachment (S &&attachment)
 Changes the attachment, or makes it null with std::nullopt.
Message & withAttachment (StringParam attachment)
 Changes attachment and returns the current message.
template<OptionalString S>
Message & withAttachment (S &&attachment) noexcept
 Changes the attachment, or makes it null with std::nullopt.
std::string toString () const override
 Returns a string representation of the current object.
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.
Public Member Functions inherited from Entity
virtual ~Entity () noexcept
 The default virtual d-tor.

Static Public Member Functions

static Ptr fromGraal (void *graalNative)
 Creates an object of the current type and fills it with data from the dxFeed Graal SDK structure.
static void freeGraal (void *graalNative)
 Releases the memory occupied by the dxFeed Graal SDK structure (recursively if necessary).

Static Public Attributes

static const EventTypeEnum & TYPE = EventTypeEnum::MESSAGE
 Type identifier and additional information about the current event class.

Detailed Description

Message event with an application-specific attachment.

Messages are never conflated and are delivered to all connected subscribers. There is no built-in persistence for messages. They are lost when subscribers are not connected to the message publisher, so they shall be only used for notification purposes in addition to a persistence mechanism.

Implementation details.

This event is implemented on top of the QDS record Message .

Constructor & Destructor Documentation

◆ Message() [1/2]

Message::Message ( StringParam eventSymbol)
explicit

Creates a new message with the specified event symbol.

Parameters
eventSymbolevent symbol.

◆ Message() [2/2]

Message::Message ( StringParam eventSymbol,
StringParam attachment )

Creates a new message with the specified event symbol and attachment.

Parameters
eventSymbolevent symbol.
attachmentattachment.

References Message().

Referenced by Message().

Member Function Documentation

◆ assign()

void Message::assign ( std::shared_ptr< EventType > event)
overridevirtual

Replaces the contents of the event.

Parameters
eventthe event to use as a source.

Reimplemented from EventType.

◆ freeGraal()

void Message::freeGraal ( void * graalNative)
static

Releases the memory occupied by the dxFeed Graal SDK structure (recursively if necessary).

Parameters
graalNativeThe pointer to the dxFeed Graal SDK structure.
Exceptions
InvalidArgumentException

◆ fromGraal()

std::shared_ptr< Message > Message::fromGraal ( void * graalNative)
static

Creates an object of the current type and fills it with data from the dxFeed Graal SDK structure.

Parameters
graalNativeThe pointer to the dxFeed Graal SDK structure.
Returns
The object of the current type.
Exceptions
InvalidArgumentException

◆ getAttachment()

const std::string & Message::getAttachment ( ) const &

Returns attachment.

Returns
attachment.

◆ getAttachmentOpt()

const std::optional< std::string > & Message::getAttachmentOpt ( ) const &
noexcept

Returns attachment of this event.

Returns
attachment of this event or std::nullopt.

◆ getEventSymbol()

const std::string & Message::getEventSymbol ( ) const &
overridevirtualnoexcept

Returns a symbol of this event.

Returns
symbol of this event or dxfcpp::String::NUL (std::string{"<null>"})

Implements EventTypeWithSymbol< std::string >.

◆ getEventSymbolOpt()

const std::optional< std::string > & Message::getEventSymbolOpt ( ) const &
overridevirtualnoexcept

Returns a symbol of this event.

Returns
symbol of this event or std::nullopt.

Implements EventTypeWithSymbol< std::string >.

◆ getEventTime()

std::int64_t Message::getEventTime ( ) const
overridevirtualnoexcept

Returns time when an event was created or zero when time is not available.

This event time is available only when the corresponding DXEndpoint is created with DXENDPOINT_EVENT_TIME_PROPERTY and the data source has embedded event times. This is typically true only for data events that are read from historical tape files and from OnDemandService. Events that are coming from network connections do not have an embedded event time information, and this method will return zero for them, meaning that event was received just now.

The default implementation returns 0.

Returns
The difference, measured in milliseconds, between the event creation time and midnight, January 1, 1970 UTC or zero when time is not available.

Reimplemented from EventType.

◆ setAttachment() [1/2]

template<OptionalString S>
void Message::setAttachment ( S && attachment)
inline

Changes the attachment, or makes it null with std::nullopt.

setAttachment(other.getAttachmentOpt()) copies it from another event, null included.

Parameters
attachmentthe attachment or std::nullopt.

◆ setAttachment() [2/2]

void Message::setAttachment ( StringParam attachment)

Changes attachment.

Parameters
attachmentattachment.

◆ setEventSymbol()

void Message::setEventSymbol ( StringParam eventSymbol)
overridevirtual

Changes symbol of this event.

Parameters
eventSymbolThe symbol of this event.

Implements EventTypeWithSymbol< std::string >.

◆ setEventTime()

void Message::setEventTime ( std::int64_t eventTime)
overridevirtualnoexcept

Changes event creation time.

The default implementation does nothing.

Parameters
eventTimethe difference, measured in milliseconds, between the event creation time and midnight, January 1, 1970 UTC.

Reimplemented from EventType.

Referenced by withEventTime().

◆ toGraal()

void * Message::toGraal ( ) const
overridevirtual

Allocates memory for the dxFeed Graal SDK structure (recursively if necessary).

Fills the dxFeed Graal SDK structure's fields by the data of the current entity (recursively if necessary). Returns the pointer to the filled structure.

Returns
The pointer to the filled dxFeed Graal SDK structure

Implements EventType.

◆ toString()

std::string Message::toString ( ) const
overridevirtual

Returns a string representation of the current object.

Returns
a string representation

Reimplemented from EventType.

◆ withAttachment() [1/2]

template<OptionalString S>
Message & Message::withAttachment ( S && attachment)
inlinenoexcept

Changes the attachment, or makes it null with std::nullopt.

Returns the current message.

Parameters
attachmentthe attachment or std::nullopt.
Returns
The current message.

◆ withAttachment() [2/2]

Message & Message::withAttachment ( StringParam attachment)

Changes attachment and returns the current message.

Parameters
attachmentattachment.
Returns
The current message.

◆ withEventSymbol()

Message & Message::withEventSymbol ( StringParam eventSymbol)

Changes an event's symbol and returns the current message.

Parameters
eventSymbolThe symbol of this event.
Returns
The current message.

◆ withEventTime()

Message & Message::withEventTime ( std::int64_t eventTime)
noexcept

Changes the event's creation time and returns the current message.

Parameters
eventTimethe difference, measured in milliseconds, between the event creation time and midnight, January 1, 1970 UTC.
Returns
The current message.

References setEventTime().