Kea 2.7.5
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:
46 destroy();
47 }
48
73 static void create(const std::string& dbaccess);
74
80 static void destroy();
81
92 static void recreate(const std::string& dbaccess,
93 bool preserve_callbacks = true);
94
102 static TrackingLeaseMgr& instance();
103
107 static bool haveInstance();
108
114
116 typedef std::function<std::string ()> DBVersion;
117
130 static bool registerFactory(const std::string& db_type,
131 const Factory& factory,
132 bool no_log = false,
133 DBVersion db_version = DBVersion());
134
144 static bool deregisterFactory(const std::string& db_type,
145 bool no_log = false);
146
151 static bool registeredFactory(const std::string& db_type);
152
158 static void logRegistered();
159
161 static std::list<std::string> getDBVersions();
162
163private:
169 static TrackingLeaseMgrPtr& getLeaseMgrPtr();
170
172 static std::map<std::string, std::pair<Factory, DBVersion>> map_;
173};
174
175} // end of isc::dhcp namespace
176} // end of isc namespace
177
178#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.