24 #ifndef __mqtt_topic_h
25 #define __mqtt_topic_h
27 #include "MQTTAsync.h"
55 using ptr_t = std::shared_ptr<topic>;
68 : cli_(cli), name_(name), qos_(qos), retained_(retained) {}
80 return std::make_shared<topic>(cli, name, qos, retained);
91 const string&
get_name()
const {
return name_; }
123 delivery_token_ptr
publish(
const void* payload,
size_t n);
135 delivery_token_ptr
publish(
const void* payload,
size_t n,
136 int qos,
bool retained);
173 #endif // __mqtt_topic_h
Basic types and type conversions for the Paho MQTT C++ library.
topic(iasync_client &cli, const string &name, int qos=message::DFLT_QOS, bool retained=message::DFLT_RETAINED)
Construct an MQTT topic destination for messages.
Definition: topic.h:66
std::shared_ptr< const topic > const_ptr_t
A smart/shared pointer to this class.
Definition: topic.h:57
const string & get_name() const
Gets the name of the topic.
Definition: topic.h:91
bool get_retained() const
Gets the default retained flag used for this topic.
Definition: topic.h:101
void set_qos(int qos)
Sets the default quality of service for this topic.
Definition: topic.h:106
Represents a topic destination, used for publish/subscribe messaging.
Definition: topic.h:42
Declaration of MQTT message class.
iasync_client & get_client()
Gets a reference to the MQTT client used by this topic.
Definition: topic.h:86
Enables an application to communicate with an MQTT server using non-blocking methods.
Definition: iasync_client.h:57
delivery_token_ptr publish(const void *payload, size_t n)
Publishes a message on the topic using the default QoS and retained flag.
std::shared_ptr< topic > ptr_t
A smart/shared pointer to this class.
Definition: topic.h:55
static constexpr bool DFLT_RETAINED
The default retained flag.
Definition: message.h:58
static ptr_t create(iasync_client &cli, const string &name, int qos=message::DFLT_QOS, bool retained=message::DFLT_RETAINED)
Creates a new topic.
Definition: topic.h:77
string to_string() const
Returns a string representation of this topic.
Definition: topic.h:160
void set_retained(bool retained)
Sets the default retained flag used for this topic.
Definition: topic.h:114
Declaration of MQTT delivery_token class.
static void validate_qos(int qos)
Determines if the QOS value is a valid one.
Definition: message.h:320
static constexpr int DFLT_QOS
The default QoS for a message.
Definition: message.h:56
int get_qos() const
Gets the default quality of service for this topic.
Definition: topic.h:96