Paho C++  1.0
The Paho MQTT C++ Client Library
 All Classes Files Functions Variables Typedefs Friends
iclient_persistence.h
Go to the documentation of this file.
1 
8 /*******************************************************************************
9  * Copyright (c) 2013-2016 Frank Pagliughi <fpagliughi@mindspring.com>
10  *
11  * All rights reserved. This program and the accompanying materials
12  * are made available under the terms of the Eclipse Public License v1.0
13  * and Eclipse Distribution License v1.0 which accompany this distribution.
14  *
15  * The Eclipse Public License is available at
16  * http://www.eclipse.org/legal/epl-v10.html
17  * and the Eclipse Distribution License is available at
18  * http://www.eclipse.org/org/documents/edl-v10.php.
19  *
20  * Contributors:
21  * Frank Pagliughi - initial implementation and documentation
22  *******************************************************************************/
23 
24 #ifndef __mqtt_iclient_persistence_h
25 #define __mqtt_iclient_persistence_h
26 
27 #include "MQTTAsync.h"
28 #include "mqtt/types.h"
29 #include "mqtt/buffer_view.h"
30 #include "mqtt/string_collection.h"
31 #include <vector>
32 
33 namespace mqtt {
34 
36 
55 {
56  friend class async_client;
57  friend class iclient_persistence_test;
58 
60  static int persistence_open(void** handle, const char* clientID, const char* serverURI, void* context);
61  static int persistence_close(void* handle);
62  static int persistence_put(void* handle, char* key, int bufcount, char* buffers[], int buflens[]);
63  static int persistence_get(void* handle, char* key, char** buffer, int* buflen);
64  static int persistence_remove(void* handle, char* key);
65  static int persistence_keys(void* handle, char*** keys, int* nkeys);
66  static int persistence_clear(void* handle);
67  static int persistence_containskey(void* handle, char* key);
68 
69 public:
71  using ptr_t = std::shared_ptr<iclient_persistence>;
73  using const_ptr_t = std::shared_ptr<const iclient_persistence>;
74 
78  virtual ~iclient_persistence() {}
86  virtual void open(const string& clientId, const string& serverURI) =0;
90  virtual void close() =0;
94  virtual void clear() =0;
100  virtual bool contains_key(const string& key) =0;
105  virtual const string_collection& keys() const =0;
111  virtual void put(const string& key, const std::vector<string_view>& bufs) =0;
117  virtual string_view get(const string& key) const =0;
122  virtual void remove(const string& key) =0;
123 };
124 
126 using iclient_persistence_ptr = iclient_persistence::ptr_t;
127 
129 using const_iclient_persistence_ptr = iclient_persistence::const_ptr_t;
130 
132 // end namespace mqtt
133 }
134 
135 #endif // __mqtt_iclient_persistence_h
Lightweight client for talking to an MQTT server using non-blocking methods that allow an operation t...
Definition: async_client.h:60
Represents a persistent data store, used to store outbound and inbound messages while they are in fli...
Definition: iclient_persistence.h:54
virtual ~iclient_persistence()
Virtual destructor.
Definition: iclient_persistence.h:78
Basic types and type conversions for the Paho MQTT C++ library.
std::shared_ptr< const iclient_persistence > const_ptr_t
Smart/shared pointer to a const object of this class.
Definition: iclient_persistence.h:73
Buffer reference type for the Paho MQTT C++ library.
Definition of the string_collection class for the Paho MQTT C++ library.
std::shared_ptr< iclient_persistence > ptr_t
Smart/shared pointer to an object of this class.
Definition: iclient_persistence.h:71
Type for a collection of topics.
Definition: string_collection.h:40
virtual void open(const string &clientId, const string &serverURI)=0
Initialize the persistent store.
virtual void clear()=0
Clears persistence, so that it no longer contains any persisted data.
virtual void put(const string &key, const std::vector< string_view > &bufs)=0
Puts the specified data into the persistent store.
virtual void close()=0
Close the persistent store that was previously opened.
A reference to a contiguous sequence of items, with no ownership.
Definition: buffer_view.h:40
virtual bool contains_key(const string &key)=0
Returns whether or not data is persisted using the specified key.
virtual const string_collection & keys() const =0
Returns a collection of keys in this persistent data store.