Kea  2.3.2-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 
144  simpleParseConfig(isc::data::ConstElementPtr config,
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
boost::shared_ptr< Element > ElementPtr
Definition: data.h:24
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
virtual const char * what() const
Returns a C-style character string of the cause of the exception.
Exception thrown if the configuration manager encounters an error.
Definition: d_cfg_mgr.h:29
boost::shared_ptr< const Element > ConstElementPtr
Definition: data.h:27
ConstElementPtr redactConfig(ConstElementPtr const &element, list< string > const &json_path)
Redact a configuration.
This is a base class for exceptions thrown from the DNS library module.
Defines the logger used by the top-level component of kea-lfc.
DCfgMgrBaseError(const char *file, size_t line, const char *what)
Definition: d_cfg_mgr.h:31
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