Kea  1.9.9-git
cfg_db_access.h
Go to the documentation of this file.
1 // Copyright (C) 2016-2020 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 CFG_DBACCESS_H
8 #define CFG_DBACCESS_H
9 
10 #include <cc/cfg_to_element.h>
12 
13 #include <boost/shared_ptr.hpp>
14 #include <string>
15 #include <list>
16 
17 namespace isc {
18 namespace dhcp {
19 
25 class CfgDbAccess {
26 public:
28  CfgDbAccess();
29 
35  void setAppendedParameters(const std::string& appended_parameters) {
36  appended_parameters_ = appended_parameters;
37  }
38 
43  std::string getLeaseDbAccessString() const;
44 
48  void setLeaseDbAccessString(const std::string& lease_db_access) {
49  lease_db_access_ = lease_db_access;
50  }
51 
56  std::string getHostDbAccessString() const;
57 
62  void setHostDbAccessString(const std::string& host_db_access,
63  bool front = false) {
64  if (front) {
65  host_db_access_.push_front(host_db_access);
66  } else {
67  host_db_access_.push_back(host_db_access);
68  }
69  }
70 
75  std::list<std::string> getHostDbAccessStringList() const;
76 
90  void setIPReservationsUnique(const bool unique) {
91  ip_reservations_unique_ = unique;
92  }
93 
99  bool getIPReservationsUnique() const {
100  return (ip_reservations_unique_);
101  }
102 
105  void createManagers() const;
106 
107 protected:
108 
112  std::string getAccessString(const std::string& access_string) const;
113 
116  std::string appended_parameters_;
117 
119  std::string lease_db_access_;
120 
122  std::list<std::string> host_db_access_;
123 
127 };
128 
130 typedef boost::shared_ptr<CfgDbAccess> CfgDbAccessPtr;
131 
133 typedef boost::shared_ptr<const CfgDbAccess> ConstCfgDbAccessPtr;
134 
138  CfgLeaseDbAccess(const CfgDbAccess& super) : CfgDbAccess(super) { }
139 
147  }
148 };
149 
152  CfgHostDbAccess(const CfgDbAccess& super) : CfgDbAccess(super) { }
153 
161  for (const std::string& dbaccess : host_db_access_) {
162  isc::data::ElementPtr entry =
164  if (entry->size() > 0) {
165  result->add(entry);
166  }
167  }
168  return (result);
169  }
170 };
171 
172 }
173 }
174 
175 #endif // CFG_DBACCESS_H
std::list< std::string > host_db_access_
Holds host database access strings.
CfgHostDbAccess(const CfgDbAccess &super)
Constructor.
void setIPReservationsUnique(const bool unique)
Modifies the setting imposing whether the IP reservations are unique or can be non unique...
Definition: cfg_db_access.h:90
std::string getLeaseDbAccessString() const
Retrieves lease database access string.
bool getIPReservationsUnique() const
Returns the setting indicating if the IP reservations are unique or can be non unique.
Definition: cfg_db_access.h:99
boost::shared_ptr< Element > ElementPtr
Definition: data.h:20
std::list< std::string > getHostDbAccessStringList() const
Retrieves host database access string.
static ElementPtr createList(const Position &pos=ZERO_POSITION())
Creates an empty ListElement type ElementPtr.
Definition: data.cc:262
boost::shared_ptr< const CfgDbAccess > ConstCfgDbAccessPtr
A pointer to the const CfgDbAccess.
void setLeaseDbAccessString(const std::string &lease_db_access)
Sets lease database access string.
Definition: cfg_db_access.h:48
static isc::data::ElementPtr toElementDbAccessString(const std::string &dbaccess)
Unparse an access string.
boost::shared_ptr< CfgDbAccess > CfgDbAccessPtr
A pointer to the CfgDbAccess.
std::string lease_db_access_
Holds lease database access string.
std::string getHostDbAccessString() const
Retrieves host database access string.
Abstract class for configuration Cfg_* classes.
CfgLeaseDbAccess(const CfgDbAccess &super)
Constructor.
Holds access parameters and the configuration of the lease and hosts database connection.
Definition: cfg_db_access.h:25
bool ip_reservations_unique_
Holds the setting whether IP reservations should be unique or can be non-unique.
utility class for unparsing
std::string getAccessString(const std::string &access_string) const
Returns lease or host database access string.
Defines the logger used by the top-level component of kea-dhcp-ddns.
CfgDbAccess()
Constructor.
void createManagers() const
Creates instance of lease manager and host data sources according to the configuration specified...
virtual isc::data::ElementPtr toElement() const
Unparse.
void setHostDbAccessString(const std::string &host_db_access, bool front=false)
Sets host database access string.
Definition: cfg_db_access.h:62
std::string appended_parameters_
Parameters to be appended to the database access strings.
virtual isc::data::ElementPtr toElement() const
Unparse.
void setAppendedParameters(const std::string &appended_parameters)
Sets parameters which will be appended to the database access strings.
Definition: cfg_db_access.h:35