Kea: legal_log_mgr_factory.h Source File

| Kea 3.2.0-git

legal_log_mgr_factory.h
Go to the documentation of this file.
1// Copyright (C) 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 LEGAL_LOG_MGR_FACTORY_H
8#define LEGAL_LOG_MGR_FACTORY_H
9
10#include <database/database_connection.h>
11#include <dhcpsrv/legal_log_mgr.h>
12#include <exceptions/exceptions.h>
13#include <boost/noncopyable.hpp>
14#include <boost/scoped_ptr.hpp>
15
16#include <functional>
17#include <map>
18#include <string>
19
20namespace isc {
21namespace dhcp {
22
32 class LegalLogMgrFactory : public boost::noncopyable {
33private:
34
39 typedef std::function<LegalLogMgrPtr (const db::DatabaseConnection::ParameterMap&)> Factory;
40
42 typedef std::function<std::string ()> DBVersion;
43
44public:
45
58 bool static registerBackendFactory(const std::string& db_type,
59 const Factory& factory,
60 bool no_log = false,
61 DBVersion db_version = DBVersion());
62
69 bool static unregisterBackendFactory(const std::string& db_type,
70 bool no_log = false);
71
87 static void addBackend(db::DatabaseConnection::ParameterMap& parameters, ManagerID id = 0);
88
90 static void delAllBackends();
91
95 static void delAllBackends(const std::string& db_type);
96
102 static LegalLogMgrPtr& instance(ManagerID id = 0);
103
109 static void setParameters(isc::db::DatabaseConnection::ParameterMap parameters,
110 ManagerID id = 0);
111
117 static isc::db::DatabaseConnection::ParameterMap getParameters(ManagerID id = 0);
118
131 static bool delBackend(const std::string& db_type,
132 db::DatabaseConnection::ParameterMap& parameters,
133 bool if_unusable = false);
134
146 static bool delBackend(ManagerID id,
147 bool if_unusable = false);
148
153 static bool registeredFactory(const std::string& db_type);
154
160 static void logRegistered();
161
163 static std::list<std::string> getDBVersions();
164
166 static LegalLogMgrPool getPool() {
167 return (pool_);
168 }
169
173 static bool haveInstance(std::string type);
174
178 static isc::asiolink::IOServicePtr getIOService() {
179 return (io_service_);
180 }
181
185 static void setIOService(isc::asiolink::IOServicePtr io_service) {
186 io_service_ = io_service;
187 }
188
189protected:
190
192 static isc::asiolink::IOServicePtr io_service_;
193
195 static std::map<std::string, std::pair<LegalLogMgrFactory::Factory, LegalLogMgrFactory::DBVersion>> map_;
196
198 static LegalLogMgrPool pool_;
199};
200
201} // end of namespace isc::dhcp
202} // end of namespace isc
203
204#endif // LEGAL_LOG_MGR_FACTORY_H
isc::db::DatabaseConnection::ParameterMap
std::map< std::string, std::string > ParameterMap
Database configuration parameter map.
Definition database_connection.h:137
isc::dhcp::LegalLogMgrFactory
Backend Store Factory.
Definition legal_log_mgr_factory.h:32
isc::dhcp::LegalLogMgrFactory::map_
static std::map< std::string, std::pair< LegalLogMgrFactory::Factory, LegalLogMgrFactory::DBVersion > > map_
A map holding registered backend factory functions.
Definition legal_log_mgr_factory.h:195
isc::dhcp::LegalLogMgrFactory::unregisterBackendFactory
static bool unregisterBackendFactory(const std::string &db_type, bool no_log=false)
Unregisters the backend factory function for a given backend type.
Definition legal_log_mgr_factory.cc:53
isc::dhcp::LegalLogMgrFactory::addBackend
static void addBackend(db::DatabaseConnection::ParameterMap &parameters, ManagerID id=0)
Create an instance of a forensic log backend.
Definition legal_log_mgr_factory.cc:72
isc::dhcp::LegalLogMgrFactory::delAllBackends
static void delAllBackends()
Removes all backends from the pool.
Definition legal_log_mgr_factory.cc:125
isc::dhcp::LegalLogMgrFactory::registerBackendFactory
static bool registerBackendFactory(const std::string &db_type, const Factory &factory, bool no_log=false, DBVersion db_version=DBVersion())
Registers new backend factory function for a given backend type.
Definition legal_log_mgr_factory.cc:23
isc::dhcp::LegalLogMgrFactory::pool_
static LegalLogMgrPool pool_
Pointer to the forensic log backends pool.
Definition legal_log_mgr_factory.h:198
isc::dhcp::LegalLogMgrFactory::getParameters
static isc::db::DatabaseConnection::ParameterMap getParameters(ManagerID id=0)
Gets the forensic backend manager parameters.
Definition legal_log_mgr_factory.cc:174
isc::dhcp::LegalLogMgrFactory::setIOService
static void setIOService(isc::asiolink::IOServicePtr io_service)
Set the hook I/O service.
Definition legal_log_mgr_factory.h:185
isc::dhcp::LegalLogMgrFactory::logRegistered
static void logRegistered()
Logs out all registered backends.
Definition legal_log_mgr_factory.cc:231
isc::dhcp::LegalLogMgrFactory::delBackend
static bool delBackend(const std::string &db_type, db::DatabaseConnection::ParameterMap &parameters, bool if_unusable=false)
Delete a forensic backend manager.
Definition legal_log_mgr_factory.cc:183
isc::dhcp::LegalLogMgrFactory::registeredFactory
static bool registeredFactory(const std::string &db_type)
Check if a backend store factory was registered.
Definition legal_log_mgr_factory.cc:225
isc::dhcp::LegalLogMgrFactory::instance
static LegalLogMgrPtr & instance(ManagerID id=0)
Returns the forensic backend manager with specified ID.
Definition legal_log_mgr_factory.cc:143
isc::dhcp::LegalLogMgrFactory::getPool
static LegalLogMgrPool getPool()
Returns underlying forensic log backend pool.
Definition legal_log_mgr_factory.h:166
isc::dhcp::LegalLogMgrFactory::getDBVersions
static std::list< std::string > getDBVersions()
Return extended version info for registered backends.
Definition legal_log_mgr_factory.cc:246
isc::dhcp::LegalLogMgrFactory::haveInstance
static bool haveInstance(std::string type)
Returns true is respective backend store is present, false otherwise.
Definition legal_log_mgr_factory.cc:259
isc::dhcp::LegalLogMgrFactory::setParameters
static void setParameters(isc::db::DatabaseConnection::ParameterMap parameters, ManagerID id=0)
Sets the forensic backend manager parameters.
Definition legal_log_mgr_factory.cc:162
isc::dhcp::LegalLogMgrFactory::getIOService
static isc::asiolink::IOServicePtr getIOService()
Get the hook I/O service.
Definition legal_log_mgr_factory.h:178
isc::dhcp::LegalLogMgrFactory::io_service_
static isc::asiolink::IOServicePtr io_service_
The hook I/O service.
Definition legal_log_mgr_factory.h:192
database_connection.h
exceptions.h
legal_log_mgr.h
Defines the abstract class for backend stores.
isc::asiolink::IOServicePtr
boost::shared_ptr< IOService > IOServicePtr
Defines a smart pointer to an IOService instance.
Definition io_service.h:35
isc::dhcp
Definition dhcp4/client_handler.cc:20
isc::dhcp::LegalLogMgrPtr
boost::shared_ptr< LegalLogMgr > LegalLogMgrPtr
Defines a smart pointer to a LegalLogMgr.
Definition legal_log_mgr.h:36
isc::dhcp::LegalLogMgrPool
std::map< ManagerID, std::pair< isc::db::DatabaseConnection::ParameterMap, LegalLogMgrPtr > > LegalLogMgrPool
LegalLogMgr pool.
Definition legal_log_mgr.h:389
isc::dhcp::ManagerID
uint64_t ManagerID
Manger ID used by hook libraries to retrieve respective LegalLogMgr instance.
Definition legal_log_mgr.h:386
isc
Defines the logger used by the top-level component of kea-lfc.
Definition check_exists_add.cc:18