Kea 3.1.1
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
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
32class 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
110 ManagerID id = 0);
111
118
131 static bool delBackend(const std::string& db_type,
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
167 return (pool_);
168 }
169
173 static bool haveInstance(std::string type);
174
181
186 io_service_ = io_service;
187 }
188
189protected:
190
193
195 static std::map<std::string, std::pair<LegalLogMgrFactory::Factory, LegalLogMgrFactory::DBVersion>> map_;
196
199};
200
201} // end of namespace isc::dhcp
202} // end of namespace isc
203
204#endif // LEGAL_LOG_MGR_FACTORY_H
std::map< std::string, std::string > ParameterMap
Database configuration parameter map.
static std::map< std::string, std::pair< LegalLogMgrFactory::Factory, LegalLogMgrFactory::DBVersion > > map_
A map holding registered backend factory functions.
static bool unregisterBackendFactory(const std::string &db_type, bool no_log=false)
Unregisters the backend factory function for a given backend type.
static void addBackend(db::DatabaseConnection::ParameterMap &parameters, ManagerID id=0)
Create an instance of a forensic log backend.
static void delAllBackends()
Removes all backends from the pool.
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.
static LegalLogMgrPool pool_
Pointer to the forensic log backends pool.
static isc::db::DatabaseConnection::ParameterMap getParameters(ManagerID id=0)
Gets the forensic backend manager parameters.
static void setIOService(isc::asiolink::IOServicePtr io_service)
Set the hook I/O service.
static void logRegistered()
Logs out all registered backends.
static bool delBackend(const std::string &db_type, db::DatabaseConnection::ParameterMap &parameters, bool if_unusable=false)
Delete a forensic backend manager.
static bool registeredFactory(const std::string &db_type)
Check if a backend store factory was registered.
static LegalLogMgrPtr & instance(ManagerID id=0)
Returns the forensic backend manager with specified ID.
static LegalLogMgrPool getPool()
Returns underlying forensic log backend pool.
static std::list< std::string > getDBVersions()
Return extended version info for registered backends.
static bool haveInstance(std::string type)
Returns true is respective backend store is present, false otherwise.
static void setParameters(isc::db::DatabaseConnection::ParameterMap parameters, ManagerID id=0)
Sets the forensic backend manager parameters.
static isc::asiolink::IOServicePtr getIOService()
Get the hook I/O service.
static isc::asiolink::IOServicePtr io_service_
The hook I/O service.
Defines the abstract class for backend stores.
boost::shared_ptr< LegalLogMgr > LegalLogMgrPtr
Defines a smart pointer to a LegalLogMgr.
std::map< ManagerID, std::pair< isc::db::DatabaseConnection::ParameterMap, LegalLogMgrPtr > > LegalLogMgrPool
LegalLogMgr pool.
uint64_t ManagerID
Manger ID used by hook libraries to retrieve respective LegalLogMgr instance.
Defines the logger used by the top-level component of kea-lfc.