1 #ifndef _STORAGE_PLUGIN 2 #define _STORAGE_PLUGIN 14 #include <plugin_manager.h> 16 #include <reading_stream.h> 17 #include <plugin_configuration.h> 19 #define STORAGE_PURGE_RETAIN_ANY 0x0001U 20 #define STORAGE_PURGE_RETAIN_ALL 0x0002U 21 #define STORAGE_PURGE_SIZE 0x0004U 40 int commonInsert(
const std::string& table,
const std::string& payload,
const char *schema =
nullptr);
41 char *
commonRetrieve(
const std::string& table,
const std::string& payload,
const char *schema =
nullptr);
42 int commonUpdate(
const std::string& table,
const std::string& payload,
const char *schema =
nullptr);
43 int commonDelete(
const std::string& table,
const std::string& payload,
const char *schema =
nullptr);
47 char *
readingsPurge(
unsigned long age,
unsigned int flags,
unsigned long sent);
48 long *readingsPurge();
50 void release(
const char *response);
56 bool hasStreamSupport() {
return readingStreamPtr != NULL; };
61 *getConfig() {
return m_config; };
63 &getName() {
return m_name; };
66 PLUGIN_HANDLE instance;
67 int (*commonInsertPtr)(PLUGIN_HANDLE,
const char *,
const char *) =
nullptr;
68 char *(*commonRetrievePtr)(PLUGIN_HANDLE,
const char *,
const char *) =
nullptr;
69 int (*commonUpdatePtr)(PLUGIN_HANDLE,
const char *,
const char *) =
nullptr;
70 int (*commonDeletePtr)(PLUGIN_HANDLE,
const char *,
const char *) =
nullptr;
71 int (*storageSchemaInsertPtr)(PLUGIN_HANDLE,
const char *,
const char *,
const char*) =
nullptr;
72 char *(*storageSchemaRetrievePtr)(PLUGIN_HANDLE,
const char *,
const char *,
const char*) =
nullptr;
73 int (*storageSchemaUpdatePtr)(PLUGIN_HANDLE,
const char *,
const char *,
const char*) =
nullptr;
74 int (*storageSchemaDeletePtr)(PLUGIN_HANDLE,
const char *,
const char *,
const char*) =
nullptr;
75 int (*readingsAppendPtr)(PLUGIN_HANDLE,
const char *);
76 char *(*readingsFetchPtr)(PLUGIN_HANDLE,
unsigned long id,
unsigned int blksize);
77 char *(*readingsRetrievePtr)(PLUGIN_HANDLE,
const char *payload);
78 char *(*readingsPurgePtr)(PLUGIN_HANDLE,
unsigned long age,
unsigned int flags,
unsigned long sent);
79 unsigned int (*readingsPurgeAssetPtr)(PLUGIN_HANDLE,
const char *asset);
80 void (*releasePtr)(PLUGIN_HANDLE,
const char *payload);
81 int (*createTableSnapshotPtr)(PLUGIN_HANDLE,
const char *,
const char *);
82 int (*loadTableSnapshotPtr)(PLUGIN_HANDLE,
const char *,
const char *);
83 int (*deleteTableSnapshotPtr)(PLUGIN_HANDLE,
const char *,
const char *);
84 char *(*getTableSnapshotsPtr)(PLUGIN_HANDLE,
const char *);
85 int (*readingStreamPtr)(PLUGIN_HANDLE,
ReadingStream **, bool);
87 bool (*pluginShutdownPtr)(PLUGIN_HANDLE);
88 int (*createSchemaPtr)(PLUGIN_HANDLE,
const char*);
92 bool m_bStorageSchemaFlag =
false;
char * commonRetrieve(const std::string &table, const std::string &payload, const char *schema=nullptr)
Call the retrieve method in the plugin.
Definition: storage_plugin.cpp:159
char * getTableSnapshots(const std::string &table)
Call the get table snaphot method in the plugin.
Definition: storage_plugin.cpp:304
Class that represents a storage plugin.
Definition: storage_plugin.h:34
The storage service must handle its own configuration differently to other services as it is unable t...
Definition: plugin_configuration.h:28
int loadTableSnapshot(const std::string &table, const std::string &id)
Call the load table snaphot method in the plugin.
Definition: storage_plugin.cpp:288
Definition: reading_stream.h:42
int commonInsert(const std::string &table, const std::string &payload, const char *schema=nullptr)
Call the insert method in the plugin.
Definition: storage_plugin.cpp:142
int readingsAppend(const std::string &payload)
Call the readings append method in the plugin.
Definition: storage_plugin.cpp:210
char * readingsFetch(unsigned long id, unsigned int blksize)
Call the readings fetch method in the plugin.
Definition: storage_plugin.cpp:218
bool pluginShutdown()
Call the shutdown entry point of the plugin.
Definition: storage_plugin.cpp:320
int deleteTableSnapshot(const std::string &table, const std::string &id)
Call the delete table snaphot method in the plugin.
Definition: storage_plugin.cpp:296
A generic representation of a plugin.
Definition: plugin.h:20
int commonUpdate(const std::string &table, const std::string &payload, const char *schema=nullptr)
Call the update method in the plugin.
Definition: storage_plugin.cpp:176
char * readingsRetrieve(const std::string &payload)
Call the readings retrieve method in the plugin.
Definition: storage_plugin.cpp:226
char * readingsPurge(unsigned long age, unsigned int flags, unsigned long sent)
Call the readings purge method in the plugin.
Definition: storage_plugin.cpp:234
int createSchema(const std::string &payload)
Call the schema create method in the plugin.
Definition: storage_plugin.cpp:330
int readingStream(ReadingStream **stream, bool commit)
Call the reading stream method in the plugin.
Definition: storage_plugin.cpp:312
void release(const char *response)
Release a result from a retrieve.
Definition: storage_plugin.cpp:264
StoragePlugin(const std::string &name, PLUGIN_HANDLE handle)
Constructor for the class that wraps the storage plugin.
Definition: storage_plugin.cpp:24
PLUGIN_ERROR * lastError()
Get the last error from the plugin.
Definition: storage_plugin.cpp:272
int commonDelete(const std::string &table, const std::string &payload, const char *schema=nullptr)
Call the delete method in the plugin.
Definition: storage_plugin.cpp:193
char * readingsPurgeAsset(const std::string &asset)
Call the readings purge asset method in the plugin.
Definition: storage_plugin.cpp:242
Structure used by plugins to return error information.
Definition: plugin_api.h:44
int createTableSnapshot(const std::string &table, const std::string &id)
Call the create table snaphot method in the plugin.
Definition: storage_plugin.cpp:280