Kea  1.9.9-git
d_cfg_mgr.h
Go to the documentation of this file.
1 // Copyright (C) 2013-2021 Internet Systems Consortium, Inc. ("ISC")
2 //
3 // This Source Code Form is subject to the terms of the Mozilla Public
4 // License, v. 2.0. If a copy of the MPL was not distributed with this
5 // file, You can obtain one at http://mozilla.org/MPL/2.0/.
6 
7 #ifndef D_CFG_MGR_H
8 #define D_CFG_MGR_H
9 
10 #include <cc/data.h>
11 #include <cc/cfg_to_element.h>
12 #include <cc/user_context.h>
13 #include <process/config_base.h>
14 #include <exceptions/exceptions.h>
15 
16 #include <stdint.h>
17 
18 #include <functional>
19 #include <list>
20 #include <string>
21 
22 namespace isc {
23 namespace process {
24 
26 typedef std::map<std::string, isc::data::ConstElementPtr> ElementMap;
27 
30 public:
31  DCfgMgrBaseError(const char* file, size_t line, const char* what) :
32  isc::Exception(file, line, what) { };
33 };
34 
108 class DCfgMgrBase {
109 public:
116  DCfgMgrBase(ConfigPtr context);
117 
119  virtual ~DCfgMgrBase();
120 
145  bool check_only = false,
146  const std::function<void()>& post_config_cb = nullptr);
147 
152  return (context_);
153  }
154 
165  virtual std::string getConfigSummary(const uint32_t selection) = 0;
166 
179  redactConfig(isc::data::ConstElementPtr const& config) const;
180 
181 protected:
188  virtual void setCfgDefaults(isc::data::ElementPtr mutable_config);
189 
199  virtual ConfigPtr createNewContext() = 0;
200 
202  void resetContext();
203 
209  void setContext(ConfigPtr& context);
210 
227  bool check_only);
228 
239  virtual std::list<std::list<std::string>> jsonPathsToRedact() const;
240 
241 private:
243  ConfigPtr context_;
244 };
245 
247 typedef boost::shared_ptr<DCfgMgrBase> DCfgMgrBasePtr;
248 
249 } // end of isc::process namespace
250 } // end of isc namespace
251 
252 #endif // D_CFG_MGR_H
boost::shared_ptr< DCfgMgrBase > DCfgMgrBasePtr
Defines a shared pointer to DCfgMgrBase.
Definition: d_cfg_mgr.h:247
virtual std::list< std::list< std::string > > jsonPathsToRedact() const
Return a list of all paths that contain passwords or secrets.
Definition: d_cfg_mgr.cc:69
boost::shared_ptr< Element > ElementPtr
Definition: data.h:20
isc::data::ConstElementPtr redactConfig(isc::data::ConstElementPtr const &config) const
Redact the configuration.
Definition: d_cfg_mgr.cc:61
std::map< std::string, isc::data::ConstElementPtr > ElementMap
Defines a map of ConstElementPtrs keyed by name.
Definition: d_cfg_mgr.h:26
Configuration Manager.
Definition: d_cfg_mgr.h:108
void setContext(ConfigPtr &context)
Update the current context.
Definition: d_cfg_mgr.cc:52
virtual std::string getConfigSummary(const uint32_t selection)=0
Returns configuration summary in the textual format.
void resetContext()
Replaces existing context with a new, empty context.
Definition: d_cfg_mgr.cc:46
Exception thrown if the configuration manager encounters an error.
Definition: d_cfg_mgr.h:29
virtual ConfigPtr createNewContext()=0
Abstract factory which creates a context instance.
boost::shared_ptr< const Element > ConstElementPtr
Definition: data.h:23
virtual const char * what() const
Returns a C-style character string of the cause of the exception.
isc::data::ConstElementPtr simpleParseConfig(isc::data::ConstElementPtr config, bool check_only=false, const std::function< void()> &post_config_cb=nullptr)
Acts as the receiver of new configurations.
Definition: d_cfg_mgr.cc:75
This is a base class for exceptions thrown from the DNS library module.
Defines the logger used by the top-level component of kea-dhcp-ddns.
DCfgMgrBaseError(const char *file, size_t line, const char *what)
Definition: d_cfg_mgr.h:31
virtual void setCfgDefaults(isc::data::ElementPtr mutable_config)
Adds default values to the given config.
Definition: d_cfg_mgr.cc:154
virtual ~DCfgMgrBase()
Destructor.
Definition: d_cfg_mgr.cc:42
virtual isc::data::ConstElementPtr parse(isc::data::ConstElementPtr config, bool check_only)
Parses actual configuration.
Definition: d_cfg_mgr.cc:158
DCfgMgrBase(ConfigPtr context)
Constructor.
Definition: d_cfg_mgr.cc:38
ConfigPtr & getContext()
Fetches the configuration context.
Definition: d_cfg_mgr.h:151
boost::shared_ptr< ConfigBase > ConfigPtr
Non-const pointer to the ConfigBase.
Definition: config_base.h:176