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

Represents a persistent data store, used to store outbound and inbound messages while they are in flight, enabling delivery to the QoS specified. More...

#include <iclient_persistence.h>

Public Types

using ptr_t = std::shared_ptr< iclient_persistence >
 Smart/shared pointer to an object of this class. More...
 
using const_ptr_t = std::shared_ptr< const iclient_persistence >
 Smart/shared pointer to a const object of this class. More...
 

Public Member Functions

virtual ~iclient_persistence ()
 Virtual destructor.
 
virtual void open (const string &clientId, const string &serverURI)=0
 Initialize the persistent store. More...
 
virtual void close ()=0
 Close the persistent store that was previously opened.
 
virtual void clear ()=0
 Clears persistence, so that it no longer contains any persisted data.
 
virtual bool contains_key (const string &key)=0
 Returns whether or not data is persisted using the specified key. More...
 
virtual const string_collectionkeys () const =0
 Returns a collection of keys in this persistent data store. More...
 
virtual void put (const string &key, const std::vector< string_view > &bufs)=0
 Puts the specified data into the persistent store. More...
 
virtual string_view get (const string &key) const =0
 Gets the specified data out of the persistent store. More...
 
virtual void remove (const string &key)=0
 Remove the data for the specified key. More...
 

Friends

class async_client
 
class iclient_persistence_test
 

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

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

Smart/shared pointer to an object of this class.

Member Function Documentation

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.
virtual string_view 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.
virtual const 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.
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.
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
virtual void mqtt::iclient_persistence::remove ( const string &  key)
pure virtual

Remove the data for the specified key.

Parameters
keyThe key

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