Fledge
An open source edge computing platform for industrial users
plugin_configuration.h
1 #ifndef _PLUGIN_CONFIGURATION_H
2 #define _PLUGIN_CONFIGURATION_H
3 /*
4  * Fledge storage service.
5  *
6  * Copyright (c) 2020 Dianomic Systems
7  *
8  * Released under the Apache 2.0 Licence
9  *
10  * Author: Mark Riddoch
11  */
12 
13 #include <logger.h>
14 #include <string>
15 #include <rapidjson/document.h>
16 #include <config_category.h>
17 #include <management_client.h>
18 
19 class StoragePlugin;
20 
29  public:
30  StoragePluginConfiguration(const std::string& name, StoragePlugin *plugin);
31  const char *getValue(const std::string& key);
32  bool hasValue(const std::string& key);
33  bool setValue(const std::string& key, const std::string& value);
34  void updateCategory(const std::string& json);
35  void registerCategory(ManagementClient *client);
38  private:
39  void getConfigCache(std::string& cache);
40  void readCache();
41  void writeCache();
42  void updateCache();
43  const std::string m_name;
44  const StoragePlugin *m_plugin;
45  std::string m_category;
46  std::string m_defaultConfiguration;
47  rapidjson::Document *m_document;
48  Logger *m_logger;
49 };
50 
51 #endif
Fledge Logger class used to log to syslog.
Definition: logger.h:26
ConfigCategory * getConfiguration()
Return the category to register with the core.
Definition: pluginconfiguration.cpp:235
DefaultConfigCategory.
Definition: config_category.h:236
Definition: config_category.h:56
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
DefaultConfigCategory * getDefaultCategory()
Return the default category to register with the core.
Definition: pluginconfiguration.cpp:220
The management client class used by services and tasks to communicate with the management API of the ...
Definition: management_client.h:43
const char * getValue(const std::string &key)
Return a value from the cached configuration category.
Definition: pluginconfiguration.cpp:59
bool setValue(const std::string &key, const std::string &value)
Set the value of a configuration item.
Definition: pluginconfiguration.cpp:77
StoragePluginConfiguration(const std::string &name, StoragePlugin *plugin)
Constructor for storage service configuration class.
Definition: pluginconfiguration.cpp:28
void updateCategory(const std::string &json)
Called when the configuration category is updated.
Definition: pluginconfiguration.cpp:92
bool hasValue(const std::string &key)
Return if a value exsits for the cached configuration category.
Definition: pluginconfiguration.cpp:42