Astarte device API for C++ 0.8.1
Astarte device SDK for C++
Loading...
Searching...
No Matches
AstarteDeviceSdk::AstarteMessage Class Reference

Astarte message class, represents a full message for/from Astarte. More...

#include <msg.hpp>

Public Member Functions

template<typename T>
 AstarteMessage (std::string_view interface, std::string_view path, T data)
 Constructor for the AstarteMessage class.
 
auto get_interface () const -> const std::string &
 Get the interface of the message.
 
auto get_path () const -> const std::string &
 Get the path of the message.
 
auto is_datastream () const -> bool
 Check if this message contains a datastream.
 
auto is_individual () const -> bool
 Check if this message contains individual data.
 
template<typename T>
auto into () const -> const T &
 Get the content of the message.
 
template<typename T>
auto try_into () const -> std::optional< T >
 Return the content of the message if it's of the correct type.
 
auto get_raw_data () const -> const std::variant< AstarteDatastreamIndividual, AstarteDatastreamObject, AstartePropertyIndividual > &
 Return the raw data contained in this class instance.
 
auto operator== (const AstarteMessage &other) const -> bool
 Overloader for the comparison operator ==.
 
auto operator!= (const AstarteMessage &other) const -> bool
 Overloader for the comparison operator !=.
 

Detailed Description

Astarte message class, represents a full message for/from Astarte.

Constructor & Destructor Documentation

◆ AstarteMessage()

template<typename T>
AstarteDeviceSdk::AstarteMessage::AstarteMessage ( std::string_view interface,
std::string_view path,
T data )
inline

Constructor for the AstarteMessage class.

Parameters
interfaceThe interface for the message.
pathThe path for the message.
dataThe data for the message.

Member Function Documentation

◆ get_interface()

auto AstarteDeviceSdk::AstarteMessage::get_interface ( ) const -> const std::string &
nodiscard

Get the interface of the message.

Returns
The interface.

◆ get_path()

auto AstarteDeviceSdk::AstarteMessage::get_path ( ) const -> const std::string &
nodiscard

Get the path of the message.

Returns
The path.

◆ get_raw_data()

auto AstarteDeviceSdk::AstarteMessage::get_raw_data ( ) const -> const std::variant< AstarteDatastreamIndividual, AstarteDatastreamObject, AstartePropertyIndividual > &
nodiscard

Return the raw data contained in this class instance.

Returns
The raw data contained in this class instance.

◆ into()

template<typename T>
auto AstarteDeviceSdk::AstarteMessage::into ( ) const -> const T&
inlinenodiscard

Get the content of the message.

Returns
The value contained in the message.

◆ is_datastream()

auto AstarteDeviceSdk::AstarteMessage::is_datastream ( ) const -> bool
nodiscard

Check if this message contains a datastream.

Returns
True if the message contains a datastream, false otherwise.

◆ is_individual()

auto AstarteDeviceSdk::AstarteMessage::is_individual ( ) const -> bool
nodiscard

Check if this message contains individual data.

Returns
True if the message contains individual data, false otherwise.

◆ operator!=()

auto AstarteDeviceSdk::AstarteMessage::operator!= ( const AstarteMessage & other) const -> bool
nodiscard

Overloader for the comparison operator !=.

Parameters
otherThe object to compare to.
Returns
True when different, false otherwise.

◆ operator==()

auto AstarteDeviceSdk::AstarteMessage::operator== ( const AstarteMessage & other) const -> bool
nodiscard

Overloader for the comparison operator ==.

Parameters
otherThe object to compare to.
Returns
True when equal, false otherwise.

◆ try_into()

template<typename T>
auto AstarteDeviceSdk::AstarteMessage::try_into ( ) const -> std::optional<T>
inlinenodiscard

Return the content of the message if it's of the correct type.

Returns
The value contained in the message or nullopt.

The documentation for this class was generated from the following file: