Kea: cfg_db_access.h Source File

| Kea 3.0.3-git

cfg_db_access.h
Go to the documentation of this file.
1// Copyright (C) 2016-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 CFG_DBACCESS_H
8#define CFG_DBACCESS_H
9
10#include <cc/cfg_to_element.h>
11#include <database/database_connection.h>
12
13#include <boost/shared_ptr.hpp>
14#include <string>
15#include <list>
16
17namespace isc {
18namespace dhcp {
19
25 class CfgDbAccess {
26public:
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
107 void setExtendedInfoTablesEnabled(const bool enabled) {
108 extended_info_tables_enabled_ = enabled;
109 }
110
116 bool getExtendedInfoTablesEnabled() const {
117 return (extended_info_tables_enabled_);
118 }
119
122 void createManagers() const;
123
124protected:
125
129 std::string getAccessString(const std::string& access_string) const;
130
133 std::string appended_parameters_;
134
136 std::string lease_db_access_;
137
139 std::list<std::string> host_db_access_;
140
143 bool ip_reservations_unique_;
144
147 bool extended_info_tables_enabled_;
148};
149
151 typedef boost::shared_ptr<CfgDbAccess> CfgDbAccessPtr;
152
154 typedef boost::shared_ptr<const CfgDbAccess> ConstCfgDbAccessPtr;
155
157 struct CfgLeaseDbAccess : public CfgDbAccess, public isc::data::CfgToElement {
159 CfgLeaseDbAccess(const CfgDbAccess& super) : CfgDbAccess(super) { }
160
166 virtual isc::data::ElementPtr toElement() const {
167 return (db::DatabaseConnection::toElementDbAccessString(lease_db_access_));
168 }
169};
170
171 struct CfgHostDbAccess : public CfgDbAccess, public isc::data::CfgToElement {
173 CfgHostDbAccess(const CfgDbAccess& super) : CfgDbAccess(super) { }
174
180 virtual isc::data::ElementPtr toElement() const {
181 isc::data::ElementPtr result = isc::data::Element::createList();
182 for (const std::string& dbaccess : host_db_access_) {
183 isc::data::ElementPtr entry =
184 db::DatabaseConnection::toElementDbAccessString(dbaccess);
185 if (entry->size() > 0) {
186 result->add(entry);
187 }
188 }
189 return (result);
190 }
191};
192
193}
194}
195
196#endif // CFG_DBACCESS_H
cfg_to_element.h
isc::data::Element::createList
static ElementPtr createList(const Position &pos=ZERO_POSITION())
Creates an empty ListElement type ElementPtr.
Definition data.cc:349
isc::db::DatabaseConnection::toElementDbAccessString
static isc::data::ElementPtr toElementDbAccessString(const std::string &dbaccess)
Unparse an access string.
Definition database_connection.cc:279
isc::dhcp::CfgDbAccess::setLeaseDbAccessString
void setLeaseDbAccessString(const std::string &lease_db_access)
Sets lease database access string.
Definition cfg_db_access.h:48
isc::dhcp::CfgDbAccess::ip_reservations_unique_
bool ip_reservations_unique_
Holds the setting whether IP reservations should be unique or can be non-unique.
Definition cfg_db_access.h:143
isc::dhcp::CfgDbAccess::getAccessString
std::string getAccessString(const std::string &access_string) const
Returns lease or host database access string.
Definition cfg_db_access.cc:118
isc::dhcp::CfgDbAccess::createManagers
void createManagers() const
Creates instance of lease manager and host data sources according to the configuration specified.
Definition cfg_db_access.cc:59
isc::dhcp::CfgDbAccess::getHostDbAccessString
std::string getHostDbAccessString() const
Retrieves host database access string.
Definition cfg_db_access.cc:39
isc::dhcp::CfgDbAccess::getIPReservationsUnique
bool getIPReservationsUnique() const
Returns the setting indicating if the IP reservations are unique or can be non unique.
Definition cfg_db_access.h:99
isc::dhcp::CfgDbAccess::getExtendedInfoTablesEnabled
bool getExtendedInfoTablesEnabled() const
Returns the setting indicating if lease extended info tables are enabled.
Definition cfg_db_access.h:116
isc::dhcp::CfgDbAccess::host_db_access_
std::list< std::string > host_db_access_
Holds host database access strings.
Definition cfg_db_access.h:139
isc::dhcp::CfgDbAccess::appended_parameters_
std::string appended_parameters_
Parameters to be appended to the database access strings.
Definition cfg_db_access.h:133
isc::dhcp::CfgDbAccess::CfgDbAccess
CfgDbAccess()
Constructor.
Definition cfg_db_access.cc:26
isc::dhcp::CfgDbAccess::extended_info_tables_enabled_
bool extended_info_tables_enabled_
Holds the setting whether the lease extended info tables are enabled or disabled.
Definition cfg_db_access.h:147
isc::dhcp::CfgDbAccess::getHostDbAccessStringList
std::list< std::string > getHostDbAccessStringList() const
Retrieves host database access string.
Definition cfg_db_access.cc:48
isc::dhcp::CfgDbAccess::setIPReservationsUnique
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
isc::dhcp::CfgDbAccess::setHostDbAccessString
void setHostDbAccessString(const std::string &host_db_access, bool front=false)
Sets host database access string.
Definition cfg_db_access.h:62
isc::dhcp::CfgDbAccess::setAppendedParameters
void setAppendedParameters(const std::string &appended_parameters)
Sets parameters which will be appended to the database access strings.
Definition cfg_db_access.h:35
isc::dhcp::CfgDbAccess::setExtendedInfoTablesEnabled
void setExtendedInfoTablesEnabled(const bool enabled)
Modifies the setting whether the lease extended info tables are enabled.
Definition cfg_db_access.h:107
isc::dhcp::CfgDbAccess::lease_db_access_
std::string lease_db_access_
Holds lease database access string.
Definition cfg_db_access.h:136
isc::dhcp::CfgDbAccess::getLeaseDbAccessString
std::string getLeaseDbAccessString() const
Retrieves lease database access string.
Definition cfg_db_access.cc:33
database_connection.h
isc::data::ElementPtr
boost::shared_ptr< Element > ElementPtr
Definition data.h:29
isc::dhcp
Definition dhcp4/client_handler.cc:20
isc::dhcp::CfgDbAccessPtr
boost::shared_ptr< CfgDbAccess > CfgDbAccessPtr
A pointer to the CfgDbAccess.
Definition cfg_db_access.h:151
isc::dhcp::ConstCfgDbAccessPtr
boost::shared_ptr< const CfgDbAccess > ConstCfgDbAccessPtr
A pointer to the const CfgDbAccess.
Definition cfg_db_access.h:154
isc
Defines the logger used by the top-level component of kea-lfc.
Definition agent_parser.cc:148
isc::data::CfgToElement
Abstract class for configuration Cfg_* classes.
Definition cfg_to_element.h:29
isc::dhcp::CfgHostDbAccess::CfgHostDbAccess
CfgHostDbAccess(const CfgDbAccess &super)
Constructor.
Definition cfg_db_access.h:173
isc::dhcp::CfgHostDbAccess::toElement
virtual isc::data::ElementPtr toElement() const
Unparse.
Definition cfg_db_access.h:180
isc::dhcp::CfgLeaseDbAccess::toElement
virtual isc::data::ElementPtr toElement() const
Unparse.
Definition cfg_db_access.h:166
isc::dhcp::CfgLeaseDbAccess::CfgLeaseDbAccess
CfgLeaseDbAccess(const CfgDbAccess &super)
Constructor.
Definition cfg_db_access.h:159