PahoMqttCpp
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 <vector>
28
29#include "MQTTAsync.h"
30#include "mqtt/buffer_view.h"
32#include "mqtt/types.h"
33
34namespace mqtt {
35
42inline void* persistence_malloc(size_t n) { return MQTTAsync_malloc(n); }
43
48inline void persistence_free(void* p) { MQTTAsync_free(p); }
49
51
70{
71 friend class async_client;
72 friend class mock_persistence;
73
75 static int persistence_open(
76 void** handle, const char* clientID, const char* serverURI, void* context
77 );
78 static int persistence_close(void* handle);
79 static int persistence_put(
80 void* handle, char* key, int bufcount, char* buffers[], int buflens[]
81 );
82 static int persistence_get(void* handle, char* key, char** buffer, int* buflen);
83 static int persistence_remove(void* handle, char* key);
84 static int persistence_keys(void* handle, char*** keys, int* nkeys);
85 static int persistence_clear(void* handle);
86 static int persistence_containskey(void* handle, char* key);
87
88public:
90 using ptr_t = std::shared_ptr<iclient_persistence>;
92 using const_ptr_t = std::shared_ptr<const iclient_persistence>;
93
105 virtual void open(const string& clientId, const string& serverURI) = 0;
109 virtual void close() = 0;
113 virtual void clear() = 0;
119 virtual bool contains_key(const string& key) = 0;
124 virtual string_collection keys() const = 0;
130 virtual void put(const string& key, const std::vector<string_view>& bufs) = 0;
136 virtual string get(const string& key) const = 0;
141 virtual void remove(const string& key) = 0;
142};
143
146
149
151} // namespace mqtt
152
153#endif // __mqtt_iclient_persistence_h
Definition async_client.h:137
Definition iclient_persistence.h:70
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:92
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:90
virtual void put(const string &key, const std::vector< string_view > &bufs)=0
virtual ~iclient_persistence()
Definition iclient_persistence.h:97
virtual string_collection keys() const =0
virtual void clear()=0
friend class mock_persistence
Definition iclient_persistence.h:72
virtual void remove(const string &key)=0
Definition string_collection.h:45
Definition async_client.h:60
iclient_persistence::ptr_t iclient_persistence_ptr
Definition iclient_persistence.h:145
void persistence_free(void *p)
Definition iclient_persistence.h:48
void * persistence_malloc(size_t n)
Definition iclient_persistence.h:42
iclient_persistence::const_ptr_t const_iclient_persistence_ptr
Definition iclient_persistence.h:148