Files
2026-10-23 16:13:31 +00:00

54 lines
1.6 KiB
C++

#pragma once
#include "ddkit/base/ConfigRw.hpp"
#include "ddkit/base/ConfigLoader.hpp"
#include "ddkit/access/System.hpp"
#include <string>
#include <set>
#include <memory>
#include <utility>
namespace ddkit {
namespace access {
/// @brief ConfigLoaderDds holds the ConfigLoader (Config) and the DdsSystem (process-wide dds-initialization)
/// if created before everything else (on the stack), this will do for clean termination.
class ConfigLoaderDds;
typedef std::shared_ptr<ConfigLoaderDds> ConfigLoaderDdsPtr;
class ConfigLoaderDds {
public:
ConfigLoaderDds();
ConfigLoaderDds(const std::string& configFile);
~ConfigLoaderDds();
base::IConfig& config() { return m_configRw; }
base::IConfigWrite& configWrite() { return m_configRw; }
// checks all keys, which start '<section>.' to be '<section>.<key>' with a <key> from given list
// - checks whole config(-file) right now.
// - enables checking from now on in all calls to above config-functions has(), get(), set().
// the checking-function will throw, if a violation is detected.
void registerKnownConfigKey(const std::string& section, const std::string& key);
void reloadConfig(const std::string& configFile);
static ConfigLoaderDdsPtr instance();
private:
// no copying
ConfigLoaderDds(ConfigLoaderDds const&) = delete;
ConfigLoaderDds(ConfigLoaderDds&&) = delete;
void operator=(ConfigLoaderDds const&) = delete;
void operator=(ConfigLoaderDds&&) = delete;
void loadDefaultTerminateHandlers();
std::unique_ptr<base::ConfigLoader> m_configLoader;
base::ConfigRw m_configRw;
};
} // namespace access
} // namespace ddkit