Loading...
Searching...
No Matches
iclient_persistence.h
Go to the documentation of this file.
/*******************************************************************************
* Copyright (c) 2013-2016 Frank Pagliughi <fpagliughi@mindspring.com>
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v2.0
* and Eclipse Distribution License v1.0 which accompany this distribution.
*
* The Eclipse Public License is available at
* http://www.eclipse.org/legal/epl-v20.html
* and the Eclipse Distribution License is available at
* http://www.eclipse.org/org/documents/edl-v10.php.
*
* Contributors:
* Frank Pagliughi - initial implementation and documentation
*******************************************************************************/
#ifndef __mqtt_iclient_persistence_h
#define __mqtt_iclient_persistence_h
#include <vector>
#include "MQTTAsync.h"
#include "mqtt/buffer_view.h"
#include "mqtt/string_collection.h"
#include "mqtt/types.h"
namespace mqtt {
inline void* persistence_malloc(size_t n) { return MQTTAsync_malloc(n); }
inline void persistence_free(void* p) { MQTTAsync_free(p); }
class iclient_persistence
{
friend class async_client;
friend class mock_persistence;
static int persistence_open(
void** handle, const char* clientID, const char* serverURI, void* context
);
static int persistence_close(void* handle);
static int persistence_put(
void* handle, char* key, int bufcount, char* buffers[], int buflens[]
);
static int persistence_get(void* handle, char* key, char** buffer, int* buflen);
static int persistence_remove(void* handle, char* key);
static int persistence_keys(void* handle, char*** keys, int* nkeys);
static int persistence_clear(void* handle);
static int persistence_containskey(void* handle, char* key);
public:
using ptr_t = std::shared_ptr<iclient_persistence>;
using const_ptr_t = std::shared_ptr<const iclient_persistence>;
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;
};
using iclient_persistence_ptr = iclient_persistence::ptr_t;
using const_iclient_persistence_ptr = iclient_persistence::const_ptr_t;
} // namespace mqtt
#endif // __mqtt_iclient_persistence_h
buffer_view.h
mqtt::iclient_persistence
Definition iclient_persistence.h:70
mqtt::iclient_persistence::open
virtual void open(const string &clientId, const string &serverURI)=0
mqtt::iclient_persistence::close
virtual void close()=0
mqtt::iclient_persistence::const_ptr_t
std::shared_ptr< const iclient_persistence > const_ptr_t
Definition iclient_persistence.h:92
mqtt::iclient_persistence::get
virtual string get(const string &key) const =0
mqtt::iclient_persistence::contains_key
virtual bool contains_key(const string &key)=0
mqtt::iclient_persistence::ptr_t
std::shared_ptr< iclient_persistence > ptr_t
Definition iclient_persistence.h:90
mqtt::iclient_persistence::put
virtual void put(const string &key, const std::vector< string_view > &bufs)=0
mqtt::iclient_persistence::~iclient_persistence
virtual ~iclient_persistence()
Definition iclient_persistence.h:97
mqtt::iclient_persistence::async_client
friend class async_client
Definition iclient_persistence.h:71
mqtt::iclient_persistence::keys
virtual string_collection keys() const =0
mqtt::iclient_persistence::clear
virtual void clear()=0
mqtt::iclient_persistence::mock_persistence
friend class mock_persistence
Definition iclient_persistence.h:72
mqtt::iclient_persistence::remove
virtual void remove(const string &key)=0
mqtt::string_collection
Definition string_collection.h:45
mqtt
Definition async_client.h:60
mqtt::iclient_persistence_ptr
iclient_persistence::ptr_t iclient_persistence_ptr
Definition iclient_persistence.h:145
mqtt::const_iclient_persistence_ptr
iclient_persistence::const_ptr_t const_iclient_persistence_ptr
Definition iclient_persistence.h:148
mqtt::persistence_free
void persistence_free(void *p)
Definition iclient_persistence.h:48
mqtt::persistence_malloc
void * persistence_malloc(size_t n)
Definition iclient_persistence.h:42
string_collection.h
types.h