paho-mqtt-cpp
MQTT C++ Client for POSIX and Windows
Loading...
Searching...
No Matches
Public Types | Public Member Functions | Friends
mqtt::iclient_persistence Class Referenceabstract

#include <iclient_persistence.h>

Public Types

using ptr_t = std::shared_ptr<iclient_persistence>
 
using const_ptr_t = std::shared_ptr<const iclient_persistence>
 

Public Member Functions

virtual ~iclient_persistence ()
 
virtual void open (const string &clientId, const string &serverURI)=0
 
virtual void close ()=0
 
virtual void clear ()=0
 
virtual bool contains_key (const string &key)=0
 
virtual string_collection keys () const =0
 
virtual void put (const string &key, const std::vector< string_view > &bufs)=0
 
virtual string get (const string &key) const =0
 
virtual void remove (const string &key)=0
 

Friends

class async_client
 
class mock_persistence
 

Detailed Description

Represents a persistent data store, used to store outbound and inbound messages while they are in flight, enabling delivery to the QoS specified. You can specify an implementation of this interface using client::client(string, string, iclient_persistence), which the client will use to persist QoS 1 and 2 messages.

If the methods defined throw the MqttPersistenceException then the state of the data persisted should remain as prior to the method being called. For example, if put(string, persistable) throws an exception at any point then the data will be assumed to not be in the persistent store. Similarly if remove(string) throws an exception then the data will be assumed to still be held in the persistent store.

It is up to the persistence interface to log any exceptions or error information which may be required when diagnosing a persistence failure.

Member Typedef Documentation

◆ ptr_t

Smart/shared pointer to an object of this class.

◆ const_ptr_t

Smart/shared pointer to a const object of this class.

Constructor & Destructor Documentation

◆ ~iclient_persistence()

virtual mqtt::iclient_persistence::~iclient_persistence ( )
inlinevirtual

Virtual destructor.

Member Function Documentation

◆ open()

virtual void mqtt::iclient_persistence::open ( const string & clientId,
const string & serverURI )
pure virtual

Initialize the persistent store. This uses the client ID and server name to create a unique location for the data store.

Parameters
clientIdThe identifier string for the client.
serverURIThe server to which the client is connected.

◆ close()

virtual void mqtt::iclient_persistence::close ( )
pure virtual

Close the persistent store that was previously opened.

◆ clear()

virtual void mqtt::iclient_persistence::clear ( )
pure virtual

Clears persistence, so that it no longer contains any persisted data.

◆ contains_key()

virtual bool mqtt::iclient_persistence::contains_key ( const string & key)
pure virtual

Returns whether or not data is persisted using the specified key.

Parameters
keyThe key to find
Returns
true if the key exists, false if not.

◆ keys()

virtual string_collection mqtt::iclient_persistence::keys ( ) const
pure virtual

Returns a collection of keys in this persistent data store.

Returns
A collection of strings representing the keys in the store.

◆ put()

virtual void mqtt::iclient_persistence::put ( const string & key,
const std::vector< string_view > & bufs )
pure virtual

Puts the specified data into the persistent store.

Parameters
keyThe key.
bufsThe data to store

◆ get()

virtual string mqtt::iclient_persistence::get ( const string & key) const
pure virtual

Gets the specified data out of the persistent store.

Parameters
keyThe key
Returns
A const view of the data associated with the key.

◆ remove()

virtual void mqtt::iclient_persistence::remove ( const string & key)
pure virtual

Remove the data for the specified key.

Parameters
keyThe key

Friends And Related Symbol Documentation

◆ async_client

friend class async_client
friend

◆ mock_persistence

friend class mock_persistence
friend

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