Fledge
An open source edge computing platform for industrial users
configuration.h
1 #ifndef _CONFIGURATION_H
2 #define _CONFIGURATION_H
3 /*
4  * Fledge storage service.
5  *
6  * Copyright (c) 2017 OSisoft, LLC
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 
18 #define STORAGE_CATEGORY "Storage"
19 #define CATEGORY_DESCRIPTION "Storage configuration"
20 #define ADVANCED "Advanced"
21 #define CONFIGURATION_CACHE_FILE "storage.json"
22 
33  public:
36  const char *getValue(const std::string& key);
37  bool hasValue(const std::string& key);
38  bool setValue(const std::string& key, const std::string& value);
39  void updateCategory(const std::string& json);
41  private:
42  void getConfigCache(std::string& cache);
43  rapidjson::Document *document;
44  void readCache();
45  void writeCache();
46  void checkCache();
47  void updateStoragePluginConfig();
48  Logger *logger;
49 };
50 
51 #endif
Fledge Logger class used to log to syslog.
Definition: logger.h:26
DefaultConfigCategory.
Definition: config_category.h:236
The storage service must handle its own configuration differently to other services as it is unable t...
Definition: configuration.h:32
DefaultConfigCategory * getDefaultCategory()
Return the default category to register with the core.
Definition: configuration.cpp:326
StorageConfiguration()
Constructor for storage service configuration class.
Definition: configuration.cpp:121
~StorageConfiguration()
Storage configuration destructor.
Definition: configuration.cpp:142
void updateCategory(const std::string &json)
Called when the configuration category is updated.
Definition: configuration.cpp:200
const char * getValue(const std::string &key)
Return a value from the cached configuration category.
Definition: configuration.cpp:167
bool hasValue(const std::string &key)
Return if a value exsits for the cached configuration category.
Definition: configuration.cpp:150
bool setValue(const std::string &key, const std::string &value)
Set the value of a configuration item.
Definition: configuration.cpp:185