Kea 2.7.4
lease_mgr_factory.h
Go to the documentation of this file.
1// Copyright (C) 2012-2024 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 LEASE_MGR_FACTORY_H
8#define LEASE_MGR_FACTORY_H
9
13
14#include <boost/scoped_ptr.hpp>
15
16#include <string>
17
18namespace isc {
19namespace dhcp {
20
25class NoLeaseManager : public Exception {
26public:
27 NoLeaseManager(const char* file, size_t line, const char* what) :
28 isc::Exception(file, line, what) {}
29};
30
44public:
69 static void create(const std::string& dbaccess);
70
76 static void destroy();
77
88 static void recreate(const std::string& dbaccess,
89 bool preserve_callbacks = true);
90
98 static TrackingLeaseMgr& instance();
99
103 static bool haveInstance();
104
110
112 typedef std::function<std::string ()> DBVersion;
113
126 static bool registerFactory(const std::string& db_type,
127 const Factory& factory,
128 bool no_log = false,
129 DBVersion db_version = DBVersion());
130
140 static bool deregisterFactory(const std::string& db_type,
141 bool no_log = false);
142
147 static bool registeredFactory(const std::string& db_type);
148
154 static void logRegistered();
155
157 static std::list<std::string> getDBVersions();
158
159private:
165 static TrackingLeaseMgrPtr& getLeaseMgrPtr();
166
168 static std::map<std::string, std::pair<Factory, DBVersion>> map_;
169};
170
171} // end of isc::dhcp namespace
172} // end of isc namespace
173
174#endif // LEASE_MGR_FACTORY_H
This is a base class for exceptions thrown from the DNS library module.
virtual const char * what() const
Returns a C-style character string of the cause of the exception.
std::map< std::string, std::string > ParameterMap
Database configuration parameter map.
Lease Manager Factory.
static void create(const std::string &dbaccess)
Create an instance of a lease manager.
static TrackingLeaseMgr & instance()
Return current lease manager.
static bool registerFactory(const std::string &db_type, const Factory &factory, bool no_log=false, DBVersion db_version=DBVersion())
Register a lease mgr factory.
static std::list< std::string > getDBVersions()
Return extended version info for registered backends.
static void destroy()
Destroy lease manager.
std::function< TrackingLeaseMgrPtr(const db::DatabaseConnection::ParameterMap &) Factory)
Type of lease mgr factory.
static bool registeredFactory(const std::string &db_type)
Check if a lease mgr factory was registered.
std::function< std::string()> DBVersion
Type of lease mgr version.
static bool haveInstance()
Indicates if the lease manager has been instantiated.
static bool deregisterFactory(const std::string &db_type, bool no_log=false)
Deregister a lease mgr factory.
static void logRegistered()
Logs out all registered backends.
static void recreate(const std::string &dbaccess, bool preserve_callbacks=true)
Recreate an instance of a lease manager with optionally preserving registered callbacks.
No lease manager exception.
NoLeaseManager(const char *file, size_t line, const char *what)
Introduces callbacks into the LeaseMgr.
std::unique_ptr< TrackingLeaseMgr > TrackingLeaseMgrPtr
TrackingLeaseMgr pointer.
Defines the logger used by the top-level component of kea-lfc.