Kea  1.5.0
cfg_db_access.h
Go to the documentation of this file.
1 // Copyright (C) 2016-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 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 
79  void createManagers() const;
80 
81 protected:
82 
86  std::string getAccessString(const std::string& access_string) const;
87 
90  std::string appended_parameters_;
91 
93  std::string lease_db_access_;
94 
96  std::list<std::string> host_db_access_;
97 
98 };
99 
101 typedef boost::shared_ptr<CfgDbAccess> CfgDbAccessPtr;
102 
104 typedef boost::shared_ptr<const CfgDbAccess> ConstCfgDbAccessPtr;
105 
109  CfgLeaseDbAccess(const CfgDbAccess& super) : CfgDbAccess(super) { }
110 
118  }
119 };
120 
123  CfgHostDbAccess(const CfgDbAccess& super) : CfgDbAccess(super) { }
124 
132  for (const std::string& dbaccess : host_db_access_) {
133  isc::data::ElementPtr entry =
135  if (entry->size() > 0) {
136  result->add(entry);
137  }
138  }
139  return (result);
140  }
141 };
142 
143 }
144 }
145 
146 #endif // CFG_DBACCESS_H
isc::db::DatabaseConnection::toElementDbAccessString
static isc::data::ElementPtr toElementDbAccessString(const std::string &dbaccess)
Unparse an access string.
Definition: database_connection.cc:211
isc::dhcp::CfgDbAccess::CfgDbAccess
CfgDbAccess()
Constructor.
Definition: cfg_db_access.cc:24
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::data::CfgToElement
Abstract class for configuration Cfg_* classes.
Definition: cfg_to_element.h:29
isc::dhcp::CfgLeaseDbAccess
utility class for unparsing
Definition: cfg_db_access.h:107
isc::dhcp::CfgDbAccess::getLeaseDbAccessString
std::string getLeaseDbAccessString() const
Retrieves lease database access string.
Definition: cfg_db_access.cc:30
isc::dhcp::CfgHostDbAccess::CfgHostDbAccess
CfgHostDbAccess(const CfgDbAccess &super)
Constructor.
Definition: cfg_db_access.h:123
isc
Defines the logger used by the top-level component of kea-dhcp-ddns.
Definition: agent_parser.cc:144
isc::dhcp::CfgDbAccess::appended_parameters_
std::string appended_parameters_
Parameters to be appended to the database access strings.
Definition: cfg_db_access.h:90
isc::dhcp::CfgDbAccess::getHostDbAccessString
std::string getHostDbAccessString() const
Retrieves host database access string.
Definition: cfg_db_access.cc:36
isc::dhcp::CfgLeaseDbAccess::CfgLeaseDbAccess
CfgLeaseDbAccess(const CfgDbAccess &super)
Constructor.
Definition: cfg_db_access.h:109
isc::dhcp::CfgDbAccess::getHostDbAccessStringList
std::list< std::string > getHostDbAccessStringList() const
Retrieves host database access string.
Definition: cfg_db_access.cc:45
isc::data::Element::createList
static ElementPtr createList(const Position &pos=ZERO_POSITION())
Creates an empty ListElement type ElementPtr.
Definition: data.cc:263
cfg_to_element.h
database_connection.h
isc::dhcp::ConstCfgDbAccessPtr
boost::shared_ptr< const CfgDbAccess > ConstCfgDbAccessPtr
A pointer to the const CfgDbAccess.
Definition: cfg_db_access.h:104
isc::dhcp::CfgDbAccess::host_db_access_
std::list< std::string > host_db_access_
Holds host database access strings.
Definition: cfg_db_access.h:96
isc::dhcp::CfgDbAccess::lease_db_access_
std::string lease_db_access_
Holds lease database access string.
Definition: cfg_db_access.h:93
isc::dhcp::CfgHostDbAccess
Definition: cfg_db_access.h:121
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:73
isc::data::ElementPtr
boost::shared_ptr< Element > ElementPtr
Definition: data.h:20
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:56
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::CfgHostDbAccess::toElement
virtual isc::data::ElementPtr toElement() const
Unparse.
Definition: cfg_db_access.h:130
isc::dhcp::CfgLeaseDbAccess::toElement
virtual isc::data::ElementPtr toElement() const
Unparse.
Definition: cfg_db_access.h:116
isc::dhcp::CfgDbAccessPtr
boost::shared_ptr< CfgDbAccess > CfgDbAccessPtr
A pointer to the CfgDbAccess.
Definition: cfg_db_access.h:101
isc::dhcp::CfgDbAccess
Holds access parameters and the configuration of the lease and hosts database connection.
Definition: cfg_db_access.h:25
isc::dhcp::CfgDbAccess::setLeaseDbAccessString
void setLeaseDbAccessString(const std::string &lease_db_access)
Sets lease database access string.
Definition: cfg_db_access.h:48