|
Leosac
0.7.0
OpenSourceAccessControl
|
That class helps manage the configuration for the application and its module. More...
#include <ConfigManager.hpp>
Collaboration diagram for Leosac::ConfigManager:Public Types | |
| enum | ConfigFormat : uint8_t { ConfigFormat::BOOST_ARCHIVE = 0, ConfigFormat::XML = 1 } |
| This enum is used internally, when core request module configuration. More... | |
Public Member Functions | |
| ConfigManager (const boost::property_tree::ptree &cfg) | |
| Construct the Configuration Manager from a property tree. More... | |
| virtual | ~ConfigManager ()=default |
| ConfigManager (const ConfigManager &)=default | |
| ConfigManager (ConfigManager &&)=delete | |
| ConfigManager & | operator= (const ConfigManager &)=delete |
| ConfigManager & | operator= (ConfigManager &&)=delete |
| boost::property_tree::ptree | get_general_config () const |
| Extract the current "general configuration". More... | |
| boost::property_tree::ptree | get_exportable_general_config () const |
Return the property_tree of item inside the <kernel> tag (except <modules>`) that are marked exportable. More... | |
| boost::property_tree::ptree | get_application_config () |
| Retrieve the (current, running) configuration from the application and its modules. More... | |
| bool | store_config (const std::string &module, const boost::property_tree::ptree &cfg) |
| Store the configuration tree for a module. More... | |
| bool | has_config (const std::string &module) const |
| Do we have config information for the module. More... | |
| const boost::property_tree::ptree & | load_config (const std::string &module) const |
| Return the stored configuration for a given module. More... | |
| bool | remove_config (const std::string &module) |
| Remove the config entry for the module named module. More... | |
| const boost::property_tree::ptree & | kconfig () const |
| Return const & on the general config tree. More... | |
| boost::property_tree::ptree & | kconfig () |
| Returns non-const ref to general config tree. More... | |
| void | set_kconfig (const boost::property_tree::ptree &new_cfg) |
| Update Leosac's core config ptree. More... | |
| std::list< std::string > | get_non_importable_modules () const |
| Returns a list of module name that should not be imported. More... | |
| bool | is_module_importable (const std::string &) const |
| Helper around get_non_importable_modules() More... | |
| uint64_t | config_version () const |
| Return the current configuration version. More... | |
| void | config_version (uint64_t new_version) |
| void | incr_version () |
| Increment by 1 the current version number. More... | |
| const std::string & | instance_name () const |
| Return the name of the instanced assigned in the configuration file. More... | |
Private Attributes | |
| std::map< std::string, boost::property_tree::ptree > | modules_configs_ |
| Maps a module's name to a property tree object. More... | |
| boost::property_tree::ptree | kernel_config_ |
| Property tree for general configuration. More... | |
| uint64_t | version_ |
| std::string | instance_name_ |
That class helps manage the configuration for the application and its module.
It's goal is to help saving the configuration to be used to maintain each module configuration.
The load_config() and store_config() are used to retrieve or update module config. For example, when remote control is doing a SYNC_FROM, it pushes the new config to the ConfigManager using store_config().
Definition at line 45 of file ConfigManager.hpp.
|
strong |
This enum is used internally, when core request module configuration.
| Enumerator | |
|---|---|
| BOOST_ARCHIVE | |
| XML | |
Definition at line 118 of file ConfigManager.hpp.
| ConfigManager::ConfigManager | ( | const boost::property_tree::ptree & | cfg | ) |
Construct the Configuration Manager from a property tree.
Definition at line 31 of file ConfigManager.cpp.
|
virtualdefault |
|
default |
|
delete |
| uint64_t ConfigManager::config_version | ( | ) | const |
Return the current configuration version.
This is supposed to work similar to Bind9 serial.
It should only ever increase.
Definition at line 251 of file ConfigManager.cpp.
| void ConfigManager::config_version | ( | uint64_t | new_version | ) |
Definition at line 266 of file ConfigManager.cpp.
| boost::property_tree::ptree ConfigManager::get_application_config | ( | ) |
Retrieve the (current, running) configuration from the application and its modules.
Since the ConfigManager shall have an up-to-date view of the modules' configuration tree, it can build a global config tree. It returns a proper property tree that can be serialized.
Definition at line 41 of file ConfigManager.cpp.
| boost::property_tree::ptree ConfigManager::get_exportable_general_config | ( | ) | const |
Return the property_tree of item inside the <kernel> tag (except <modules>`) that are marked exportable.
See the <sync_source> tag in general_config_main.
Definition at line 76 of file ConfigManager.cpp.
| boost::property_tree::ptree ConfigManager::get_general_config | ( | ) | const |
Extract the current "general configuration".
General configuration means anything that is not module configuration, i/e "log", "network" and "remote".
Definition at line 59 of file ConfigManager.cpp.
| std::list< std::string > ConfigManager::get_non_importable_modules | ( | ) | const |
Returns a list of module name that should not be imported.
Imported means added or updated when a SYNC_FROM is executed.
Definition at line 230 of file ConfigManager.cpp.
| bool ConfigManager::has_config | ( | const std::string & | module | ) | const |
Do we have config information for the module.
Definition at line 261 of file ConfigManager.cpp.
| void ConfigManager::incr_version | ( | ) |
Increment by 1 the current version number.
Definition at line 256 of file ConfigManager.cpp.
| const std::string & ConfigManager::instance_name | ( | ) | const |
Return the name of the instanced assigned in the configuration file.
Definition at line 271 of file ConfigManager.cpp.
| bool ConfigManager::is_module_importable | ( | const std::string & | module_name | ) | const |
Helper around get_non_importable_modules()
Definition at line 245 of file ConfigManager.cpp.
| const boost::property_tree::ptree & ConfigManager::kconfig | ( | ) | const |
Return const & on the general config tree.
Definition at line 166 of file ConfigManager.cpp.
| boost::property_tree::ptree & ConfigManager::kconfig | ( | ) |
Returns non-const ref to general config tree.
Definition at line 171 of file ConfigManager.cpp.
| const boost::property_tree::ptree & ConfigManager::load_config | ( | const std::string & | module | ) | const |
Return the stored configuration for a given module.
Definition at line 133 of file ConfigManager.cpp.
|
delete |
|
delete |
| bool ConfigManager::remove_config | ( | const std::string & | module | ) |
Remove the config entry for the module named module.
Return true if successfully removed entry, false otherwise.
Definition at line 176 of file ConfigManager.cpp.
| void ConfigManager::set_kconfig | ( | const boost::property_tree::ptree & | new_cfg | ) |
Update Leosac's core config ptree.
This function filter the new_cfg tree and does not store configuration for category that are excluded through the sync_dest option.
Definition at line 186 of file ConfigManager.cpp.
| bool ConfigManager::store_config | ( | const std::string & | module, |
| const boost::property_tree::ptree & | cfg | ||
| ) |
Store the configuration tree for a module.
If pushing the configuration overwrote a previously existing one, this will return true. Otherwise it will return false.
Definition at line 117 of file ConfigManager.cpp.
|
private |
Definition at line 189 of file ConfigManager.hpp.
|
private |
Property tree for general configuration.
This is the base config tree.
Definition at line 185 of file ConfigManager.hpp.
|
private |
Maps a module's name to a property tree object.
Definition at line 179 of file ConfigManager.hpp.
|
private |
Definition at line 187 of file ConfigManager.hpp.