paho-mqtt-cpp
MQTT C++ Client for POSIX and Windows
Loading...
Searching...
No Matches
iclient_persistence.h
Go to the documentation of this file.
1
7
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 v2.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-v20.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"
31#include <vector>
32
33namespace mqtt {
34
41inline void* persistence_malloc(size_t n) {
42 return MQTTAsync_malloc(n);
43}
44
49inline void persistence_free(void* p) {
50 MQTTAsync_free(p);
51}
52
54
73{
74 friend class async_client;
75 friend class mock_persistence;
76
78 static int persistence_open(void** handle, const char* clientID, const char* serverURI, void* context);
79 static int persistence_close(void* handle);
80 static int persistence_put(void* handle, char* key, int bufcount, char* buffers[], int buflens[]);
81 static int persistence_get(void* handle, char* key, char** buffer, int* buflen);
82 static int persistence_remove(void* handle, char* key);
83 static int persistence_keys(void* handle, char*** keys, int* nkeys);
84 static int persistence_clear(void* handle);
85 static int persistence_containskey(void* handle, char* key);
86
87public:
89 using ptr_t = std::shared_ptr<iclient_persistence>;
91 using const_ptr_t = std::shared_ptr<const iclient_persistence>;
92
104 virtual void open(const string& clientId, const string& serverURI) =0;
108 virtual void close() =0;
112 virtual void clear() =0;
118 virtual bool contains_key(const string& key) =0;
123 virtual string_collection keys() const =0;
129 virtual void put(const string& key, const std::vector<string_view>& bufs) =0;
135 virtual string get(const string& key) const =0;
140 virtual void remove(const string& key) =0;
141};
142
145
148
150// end namespace mqtt
151}
152
153#endif // __mqtt_iclient_persistence_h
154
Definition: async_client.h:108
Definition: iclient_persistence.h:73
virtual void open(const string &clientId, const string &serverURI)=0
virtual void close()=0
std::shared_ptr< const iclient_persistence > const_ptr_t
Definition: iclient_persistence.h:91
virtual string get(const string &key) const =0
virtual bool contains_key(const string &key)=0
std::shared_ptr< iclient_persistence > ptr_t
Definition: iclient_persistence.h:89
virtual void put(const string &key, const std::vector< string_view > &bufs)=0
virtual ~iclient_persistence()
Definition: iclient_persistence.h:96
virtual string_collection keys() const =0
virtual void clear()=0
friend class mock_persistence
Definition: iclient_persistence.h:75
virtual void remove(const string &key)=0
Definition: string_collection.h:43
Definition: async_client.h:49
iclient_persistence::ptr_t iclient_persistence_ptr
Definition: iclient_persistence.h:144
void persistence_free(void *p)
Definition: iclient_persistence.h:49
void * persistence_malloc(size_t n)
Definition: iclient_persistence.h:41
iclient_persistence::const_ptr_t const_iclient_persistence_ptr
Definition: iclient_persistence.h:147