dxFeed Graal CXX API v4.2.0
Loading...
Searching...
No Matches
TextMessage Class Reference

Message event with text payload. More...

#include <TextMessage.hpp>

+ Inheritance diagram for TextMessage:

Public Types

using Ptr = std::shared_ptr<TextMessage>
 The alias to a type of shared pointer to the TextMessage object.
 
using Unique = std::unique_ptr<TextMessage>
 The alias to a type of unique pointer to the TextMessage object.
 
- Public Types inherited from EventTypeWithSymbol< std::string >
using Ptr
 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.
 
 TextMessage () noexcept=default
 Creates new message with default values.
 
 TextMessage (std::string eventSymbol) noexcept
 Creates new message with the specified event symbol.
 
 TextMessage (std::string eventSymbol, std::string text) noexcept
 Creates new message with the specified event symbol and text.
 
 TextMessage (std::string eventSymbol, std::int64_t time, std::string text) noexcept
 Creates new message with the specified event symbol, time and text.
 
const std::string & getEventSymbol () const &noexcept override
 Returns symbol of this event.
 
const std::optional< std::string > & getEventSymbolOpt () const &noexcept override
 Returns symbol of this event.
 
void setEventSymbol (const std::string &eventSymbol) noexcept override
 Changes symbol of this event.
 
TextMessagewithEventSymbol (const std::string &eventSymbol) noexcept
 Changes event's symbol and returns the current message.
 
std::int64_t getEventTime () const noexcept override
 Returns time when event was created or zero when time is not available.
 
void setEventTime (std::int64_t eventTime) noexcept override
 Changes event creation time.
 
TextMessagewithEventTime (std::int64_t eventTime) noexcept
 Changes event's creation time and returns the current message.
 
std::int64_t getTimeSequence () const noexcept
 Returns time and sequence of text message packaged into single long value.
 
void setTimeSequence (std::int64_t timeSequence) noexcept
 Changes time and sequence of text message.
 
std::int64_t getTime () const noexcept
 Returns time of the text message.
 
void setTime (std::int64_t time) noexcept
 Changes time of the text message.
 
TextMessagewithTime (std::int64_t time) noexcept
 Changes time and returns the current message.
 
std::int32_t getSequence () const noexcept
 Returns sequence number of the text message to distinguish messages that have the same time.
 
void setSequence (std::int32_t sequence)
 Changes getSequence() sequence number of the text message.
 
TextMessagewithSequence (std::int32_t sequence) noexcept
 Changes event's sequence number and returns the current message.
 
const std::string & getText () const &
 Returns text.
 
void setText (std::string text)
 Changes text.
 
TextMessagewithText (std::string text) noexcept
 Changes text and returns the current message.
 
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 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 Entity
virtual ~Entity () noexcept=default
 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 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 constexpr std::uint32_t MAX_SEQUENCE = (1U << 22U) - 1U
 Maximum allowed sequence value.
 
static const EventTypeEnumTYPE = EventTypeEnum::TEXT_MESSAGE
 Type identifier and additional information about the current event class.
 

Detailed Description

Message event with text payload.

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 persistence mechanism.

Implementation details

This event is implemented on top of QDS record TextMessage.

Constructor & Destructor Documentation

◆ TextMessage() [1/3]

TextMessage::TextMessage ( std::string eventSymbol)
inlineexplicitnoexcept

Creates new message with the specified event symbol.

Parameters
eventSymbolevent symbol.

◆ TextMessage() [2/3]

TextMessage::TextMessage ( std::string eventSymbol,
std::string text )
inlinenoexcept

Creates new message with the specified event symbol and text.

Parameters
eventSymbolevent symbol.
texttext.

References TextMessage().

Referenced by TextMessage().

◆ TextMessage() [3/3]

TextMessage::TextMessage ( std::string eventSymbol,
std::int64_t time,
std::string text )
inlinenoexcept

Creates new message with the specified event symbol, time and text.

Parameters
eventSymbolevent symbol.
timetime.
texttext.

References TextMessage().

Referenced by TextMessage().

Member Function Documentation

◆ assign()

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

Replaces the contents of the event.

Parameters
eventthe event to use as source.

Reimplemented from EventType.

◆ freeGraal()

void TextMessage::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< TextMessage > TextMessage::fromGraal ( void * graalNative)
static

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

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

◆ getEventSymbol()

const std::string & TextMessage::getEventSymbol ( ) const &
inlineoverridevirtualnoexcept

Returns 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 > & TextMessage::getEventSymbolOpt ( ) const &
inlineoverridevirtualnoexcept

Returns symbol of this event.

Returns
symbol of this event or std::nullopt.

Implements EventTypeWithSymbol< std::string >.

◆ getEventTime()

std::int64_t TextMessage::getEventTime ( ) const
inlineoverridevirtualnoexcept

Returns time when 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 a 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.

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.

◆ getSequence()

std::int32_t TextMessage::getSequence ( ) const
inlinenoexcept

Returns sequence number of the text message to distinguish messages that have the same time.

This sequence number does not have to be unique and does not need to be sequential. Sequence can range from 0 to MAX_SEQUENCE.

Returns
sequence of the text message.

References MAX_SEQUENCE.

Referenced by setTime().

◆ getText()

const std::string & TextMessage::getText ( ) const &
inline

Returns text.

Returns
text.

◆ getTime()

std::int64_t TextMessage::getTime ( ) const
inlinenoexcept

Returns time of the text message.

Time is measured in milliseconds between the current time and midnight, January 1, 1970 UTC.

Returns
time of the text message.

◆ getTimeSequence()

std::int64_t TextMessage::getTimeSequence ( ) const
inlinenoexcept

Returns time and sequence of text message packaged into single long value.

Returns
time and sequence of text message.

◆ setEventSymbol()

void TextMessage::setEventSymbol ( const std::string & eventSymbol)
inlineoverridevirtualnoexcept

Changes symbol of this event.

Parameters
eventSymbolThe symbol of this event.

Implements EventTypeWithSymbol< std::string >.

Referenced by withEventSymbol().

◆ setEventTime()

void TextMessage::setEventTime ( std::int64_t )
inlineoverridevirtualnoexcept

Changes event creation time.

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().

◆ setSequence()

void TextMessage::setSequence ( std::int32_t sequence)
inline

Changes getSequence() sequence number of the text message.

Parameters
sequencethe sequence.
Exceptions
InvalidArgumentExceptionif sequence is below zero or above MAX_SEQUENCE.
See also
getSequence()

References MAX_SEQUENCE.

Referenced by withSequence().

◆ setText()

void TextMessage::setText ( std::string text)
inline

Changes text.

Parameters
texttext.

Referenced by withText().

◆ setTime()

void TextMessage::setTime ( std::int64_t time)
inlinenoexcept

Changes time of the text message.

Time is measured in milliseconds between the current time and midnight, January 1, 1970 UTC.

Parameters
timetime of the text message.

References getSequence().

Referenced by withTime().

◆ setTimeSequence()

void TextMessage::setTimeSequence ( std::int64_t timeSequence)
inlinenoexcept

Changes time and sequence of text message.

Do not use this method directly. Change time and/or sequence.

Parameters
timeSequencethe time and sequence.
See also
getTimeSequence()

◆ toGraal()

void * TextMessage::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.

References toString().

◆ toString()

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

Returns a string representation of the current object.

Returns
a string representation

Reimplemented from EventType.

Referenced by toGraal().

◆ withEventSymbol()

TextMessage & TextMessage::withEventSymbol ( const std::string & eventSymbol)
inlinenoexcept

Changes event's symbol and returns the current message.

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

References setEventSymbol().

◆ withEventTime()

TextMessage & TextMessage::withEventTime ( std::int64_t eventTime)
inlinenoexcept

Changes 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().

◆ withSequence()

TextMessage & TextMessage::withSequence ( std::int32_t sequence)
inlinenoexcept

Changes event's sequence number and returns the current message.

Parameters
sequencethe sequence.
Returns
The current message.
Exceptions
InvalidArgumentExceptionif sequence is below zero or above MAX_SEQUENCE.

References setSequence().

◆ withText()

TextMessage & TextMessage::withText ( std::string text)
inlinenoexcept

Changes text and returns the current message.

Parameters
texttext.
Returns
The current message.

References setText().

◆ withTime()

TextMessage & TextMessage::withTime ( std::int64_t time)
inlinenoexcept

Changes time and returns the current message.

Parameters
timetime of the text message.
Returns
The current message.

References setTime().

Member Data Documentation

◆ MAX_SEQUENCE

std::uint32_t TextMessage::MAX_SEQUENCE = (1U << 22U) - 1U
staticconstexpr

Maximum allowed sequence value.

See also
TextMessage::setSequence()

Referenced by getSequence(), and setSequence().