Paho C++  1.0
The Paho MQTT C++ Client Library
 All Classes Files Functions Variables Typedefs Friends
mqtt::topic Class Reference

Represents a topic destination, used for publish/subscribe messaging. More...

#include <topic.h>

Public Types

using ptr_t = std::shared_ptr< topic >
 A smart/shared pointer to this class. More...
 
using const_ptr_t = std::shared_ptr< const topic >
 A smart/shared pointer to this class. More...
 

Public Member Functions

 topic (iasync_client &cli, const string &name, int qos=message::DFLT_QOS, bool retained=message::DFLT_RETAINED)
 Construct an MQTT topic destination for messages. More...
 
iasync_clientget_client ()
 Gets a reference to the MQTT client used by this topic. More...
 
const string & get_name () const
 Gets the name of the topic. More...
 
int get_qos () const
 Gets the default quality of service for this topic. More...
 
bool get_retained () const
 Gets the default retained flag used for this topic. More...
 
void set_qos (int qos)
 Sets the default quality of service for this topic. More...
 
void set_retained (bool retained)
 Sets the default retained flag used for this topic. More...
 
delivery_token_ptr publish (const void *payload, size_t n)
 Publishes a message on the topic using the default QoS and retained flag. More...
 
delivery_token_ptr publish (const void *payload, size_t n, int qos, bool retained)
 Publishes a message on the topic. More...
 
delivery_token_ptr publish (binary_ref payload)
 Publishes a message on the topic using the default QoS and retained flag. More...
 
delivery_token_ptr publish (binary_ref payload, int qos, bool retained)
 Publishes a message on the topic. More...
 
string to_string () const
 Returns a string representation of this topic. More...
 

Static Public Member Functions

static ptr_t create (iasync_client &cli, const string &name, int qos=message::DFLT_QOS, bool retained=message::DFLT_RETAINED)
 Creates a new topic. More...
 

Detailed Description

Represents a topic destination, used for publish/subscribe messaging.

Member Typedef Documentation

using mqtt::topic::const_ptr_t = std::shared_ptr<const topic>

A smart/shared pointer to this class.

using mqtt::topic::ptr_t = std::shared_ptr<topic>

A smart/shared pointer to this class.

Constructor & Destructor Documentation

mqtt::topic::topic ( iasync_client cli,
const string &  name,
int  qos = message::DFLT_QOS,
bool  retained = message::DFLT_RETAINED 
)
inline

Construct an MQTT topic destination for messages.

Parameters
cliClient to which the topic is attached
nameThe topic string
qosThe default QoS for publishing.
retainedThe default retained flag for the topic.

Member Function Documentation

static ptr_t mqtt::topic::create ( iasync_client cli,
const string &  name,
int  qos = message::DFLT_QOS,
bool  retained = message::DFLT_RETAINED 
)
inlinestatic

Creates a new topic.

Parameters
cliClient to which the topic is attached
nameThe topic string
qosThe default QoS for publishing.
retainedThe default retained flag for the topic.
Returns
A shared pointer to the topic.
iasync_client& mqtt::topic::get_client ( )
inline

Gets a reference to the MQTT client used by this topic.

Returns
The MQTT client used by this topic
const string& mqtt::topic::get_name ( ) const
inline

Gets the name of the topic.

Returns
The name of the topic.
int mqtt::topic::get_qos ( ) const
inline

Gets the default quality of service for this topic.

Returns
The default quality of service for this topic.
bool mqtt::topic::get_retained ( ) const
inline

Gets the default retained flag used for this topic.

Returns
The default retained flag used for this topic.
delivery_token_ptr mqtt::topic::publish ( const void *  payload,
size_t  n 
)

Publishes a message on the topic using the default QoS and retained flag.

Parameters
payloadthe bytes to use as the message payload
nthe number of bytes in the payload
Returns
The delivery token used to track and wait for the publish to complete.
delivery_token_ptr mqtt::topic::publish ( const void *  payload,
size_t  n,
int  qos,
bool  retained 
)

Publishes a message on the topic.

Parameters
payloadthe bytes to use as the message payload
nthe number of bytes in the payload
qosthe Quality of Service to deliver the message at. Valid values are 0, 1 or 2.
retainedwhether or not this message should be retained by the server.
Returns
The delivery token used to track and wait for the publish to complete.
delivery_token_ptr mqtt::topic::publish ( binary_ref  payload)

Publishes a message on the topic using the default QoS and retained flag.

Parameters
payloadthe bytes to use as the message payload
Returns
The delivery token used to track and wait for the publish to complete.
delivery_token_ptr mqtt::topic::publish ( binary_ref  payload,
int  qos,
bool  retained 
)

Publishes a message on the topic.

Parameters
payloadthe bytes to use as the message payload
qosthe Quality of Service to deliver the message at. Valid values are 0, 1 or 2.
retainedwhether or not this message should be retained by the server.
Returns
The delivery token used to track and wait for the publish to complete.
void mqtt::topic::set_qos ( int  qos)
inline

Sets the default quality of service for this topic.

Parameters
qosThe default quality of service for this topic.
void mqtt::topic::set_retained ( bool  retained)
inline

Sets the default retained flag used for this topic.

Parameters
retainedThe default retained flag used for this topic.
string mqtt::topic::to_string ( ) const
inline

Returns a string representation of this topic.

Returns
The name of the topic

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