Kea 3.0.0
lease_mgr_factory.h
Go to the documentation of this file.
1// Copyright (C) 2012-2025 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
41public:
43 destroy();
44 }
45
70 static void create(const std::string& dbaccess);
71
77 static void destroy();
78
89 static void recreate(const std::string& dbaccess,
90 bool preserve_callbacks = true);
91
99 static TrackingLeaseMgr& instance();
100
104 static bool haveInstance();
105
111
113 typedef std::function<std::string ()> DBVersion;
114
127 static bool registerFactory(const std::string& db_type,
128 const Factory& factory,
129 bool no_log = false,
130 DBVersion db_version = DBVersion());
131
141 static bool deregisterFactory(const std::string& db_type,
142 bool no_log = false);
143
148 static bool registeredFactory(const std::string& db_type);
149
155 static void logRegistered();
156
158 static std::list<std::string> getDBVersions();
159
160private:
166 static TrackingLeaseMgrPtr& getLeaseMgrPtr();
167
169 static std::map<std::string, std::pair<Factory, DBVersion>> map_;
170};
171
172} // end of isc::dhcp namespace
173} // end of isc namespace
174
175#endif // LEASE_MGR_FACTORY_H
Exception(const char *file, size_t line, const char *what)
Constructor for a given type for exceptions with file name and file line number.
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.
std::function< TrackingLeaseMgrPtr(const db::DatabaseConnection::ParameterMap &)> Factory
Type of lease mgr factory.
static void destroy()
Destroy lease manager.
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.
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.