Kea  1.5.0
d_cfg_mgr.h
Go to the documentation of this file.
1 // Copyright (C) 2013-2018 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 #include <functional>
16 
17 #include <stdint.h>
18 #include <string>
19 
20 namespace isc {
21 namespace process {
22 
24 typedef std::map<std::string, isc::data::ConstElementPtr> ElementMap;
25 
28 public:
29  DCfgMgrBaseError(const char* file, size_t line, const char* what) :
30  isc::Exception(file, line, what) { };
31 };
32 
106 class DCfgMgrBase {
107 public:
114  DCfgMgrBase(ConfigPtr context);
115 
117  virtual ~DCfgMgrBase();
118 
143  bool check_only = false,
144  const std::function<void()>& post_config_cb = nullptr);
145 
150  return (context_);
151  }
152 
163  virtual std::string getConfigSummary(const uint32_t selection) = 0;
164 
165 protected:
172  virtual void setCfgDefaults(isc::data::ElementPtr mutable_config);
173 
183  virtual ConfigPtr createNewContext() = 0;
184 
186  void resetContext();
187 
193  void setContext(ConfigPtr& context);
194 
211  bool check_only);
212 
213 private:
215  ConfigPtr context_;
216 };
217 
219 typedef boost::shared_ptr<DCfgMgrBase> DCfgMgrBasePtr;
220 
221 
222 }; // end of isc::process namespace
223 }; // end of isc namespace
224 
225 #endif // D_CFG_MGR_H
boost::shared_ptr< DCfgMgrBase > DCfgMgrBasePtr
Defines a shared pointer to DCfgMgrBase.
Definition: d_cfg_mgr.h:219
boost::shared_ptr< Element > ElementPtr
Definition: data.h:20
std::map< std::string, isc::data::ConstElementPtr > ElementMap
Defines a map of ConstElementPtrs keyed by name.
Definition: d_cfg_mgr.h:24
Configuration Manager.
Definition: d_cfg_mgr.h:106
void setContext(ConfigPtr &context)
Update the current context.
Definition: d_cfg_mgr.cc:50
virtual const char * what() const
Returns a C-style character string of the cause of the exception.
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:44
Exception thrown if the configuration manager encounters an error.
Definition: d_cfg_mgr.h:27
virtual ConfigPtr createNewContext()=0
Abstract factory which creates a context instance.
boost::shared_ptr< const Element > ConstElementPtr
Definition: data.h:23
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:59
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:29
virtual void setCfgDefaults(isc::data::ElementPtr mutable_config)
Adds default values to the given config.
Definition: d_cfg_mgr.cc:127
virtual ~DCfgMgrBase()
Destructor.
Definition: d_cfg_mgr.cc:40
virtual isc::data::ConstElementPtr parse(isc::data::ConstElementPtr config, bool check_only)
Parses actual configuration.
Definition: d_cfg_mgr.cc:131
DCfgMgrBase(ConfigPtr context)
Constructor.
Definition: d_cfg_mgr.cc:36
ConfigPtr & getContext()
Fetches the configuration context.
Definition: d_cfg_mgr.h:149
boost::shared_ptr< ConfigBase > ConfigPtr
Non-const pointer to the SrvConfig.
Definition: config_base.h:119