Kea  2.1.7-git
config_ctl_info.h
Go to the documentation of this file.
1 // Copyright (C) 2018-2022 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 PROCESS_CONFIG_CTL_INFO_H
8 #define PROCESS_CONFIG_CTL_INFO_H
9 
10 #include <cc/cfg_to_element.h>
12 #include <util/optional.h>
13 
14 #include <boost/shared_ptr.hpp>
15 #include <stdint.h>
16 #include <vector>
17 
18 namespace isc {
19 namespace process {
20 
25 public:
28 
40  void setAccessString(const std::string& access_str, bool test_mode = false);
41 
45  std::string getAccessString() const {
46  return (access_str_);
47  }
48 
52  std::string redactedAccessString() const {
53  return(db::DatabaseConnection::redactedAccessString(access_params_));
54  }
55 
60  return (access_params_);
61  }
62 
71  bool getParameterValue(const std::string& name,
72  std::string& value) const;
73 
77  virtual isc::data::ElementPtr toElement() const;
78 
84  bool equals(const ConfigDbInfo& other) const;
85 
91  bool operator==(const ConfigDbInfo& other) const {
92  return (equals(other));
93  }
94 
100  bool operator!=(const ConfigDbInfo& other) const {
101  return (!equals(other));
102  }
103 
104 private:
106  std::string access_str_;
107 
110 };
111 
112 typedef std::vector<ConfigDbInfo> ConfigDbInfoList;
113 
142 public:
143 
146  : config_fetch_wait_time_(30, true) {};
147 
149  ConfigControlInfo(const ConfigControlInfo& other);
150 
157  void setConfigFetchWaitTime(const util::Optional<uint16_t>& config_fetch_wait_time) {
158  config_fetch_wait_time_ = config_fetch_wait_time;
159  }
160 
172  return (config_fetch_wait_time_);
173  }
174 
181  void addConfigDatabase(const std::string& access_str);
182 
189  const ConfigDbInfoList& getConfigDatabases() const {
190  return (db_infos_);
191  }
192 
197  const ConfigDbInfo& findConfigDb(const std::string& param_name,
198  const std::string& param_value);
199 
201  void clear();
202 
210  void merge(const ConfigControlInfo& other);
211 
215  virtual isc::data::ElementPtr toElement() const;
216 
220  static const ConfigDbInfo& EMPTY_DB();
221 
227  bool equals(const ConfigControlInfo& other) const;
228 
229 private:
230 
232  util::Optional<uint16_t> config_fetch_wait_time_;
233 
235  ConfigDbInfoList db_infos_;
236 };
237 
239 typedef boost::shared_ptr<ConfigControlInfo> ConfigControlInfoPtr;
240 
242 typedef boost::shared_ptr<const ConfigControlInfo> ConstConfigControlInfoPtr;
243 
244 } // namespace process
245 } // end namespace isc
246 
247 #endif // PROCESS_CONFIG_CTL_INFO_H
std::string getAccessString() const
Retrieves the database access string.
const util::Optional< uint16_t > & getConfigFetchWaitTime() const
Returns configured config-fetch-wait-time value.
std::string redactedAccessString() const
Retrieves the database access string with password redacted.
void setConfigFetchWaitTime(const util::Optional< uint16_t > &config_fetch_wait_time)
Sets new value of the config-fetch-wait-time.
virtual isc::data::ElementPtr toElement() const
Unparse a configuration object.
Embodies configuration information used during a server&#39;s configuration process.
boost::shared_ptr< Element > ElementPtr
Definition: data.h:24
bool getParameterValue(const std::string &name, std::string &value) const
Fetch the value of a given parameter.
bool equals(const ConfigDbInfo &other) const
Compares two objects for equality.
Abstract class for configuration Cfg_* classes.
void setAccessString(const std::string &access_str, bool test_mode=false)
Set the access string.
bool operator!=(const ConfigDbInfo &other) const
Compares two objects for inequality.
const db::DatabaseConnection::ParameterMap & getParameters() const
Retrieve the map of parameter values.
Defines the logger used by the top-level component of kea-lfc.
bool operator==(const ConfigDbInfo &other) const
Compares two objects for equality.
void merge(ElementPtr element, ConstElementPtr other)
Merges the data from other into element.
Definition: data.cc:1134
Provides configuration information used during a server&#39;s configuration process.
std::map< std::string, std::string > ParameterMap
Database configuration parameter map.
boost::shared_ptr< ConfigControlInfo > ConfigControlInfoPtr
Defines a pointer to a ConfigControlInfo.
const ConfigDbInfoList & getConfigDatabases() const
Retrieves the list of databases.
static std::string redactedAccessString(const ParameterMap &parameters)
Redact database access string.
std::vector< ConfigDbInfo > ConfigDbInfoList
boost::shared_ptr< const ConfigControlInfo > ConstConfigControlInfoPtr
Defines a pointer to a const ConfigControlInfo.