| Kea 3.0.2-git

library_manager.h
Go to the documentation of this file.
1// Copyright (C) 2013-2023 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 LIBRARY_MANAGER_H
8#define LIBRARY_MANAGER_H
9
10#include <exceptions/exceptions.h>
11#include <hooks/server_hooks.h>
12#include <boost/shared_ptr.hpp>
13
14#include <string>
15
16 namespace isc {
17 namespace hooks {
18
23 class NoCalloutManager : public Exception {
24 public:
25 NoCalloutManager(const char* file, size_t line, const char* what) :
26 isc::Exception(file, line, what) {}
27};
28
29 class CalloutManager;
30 class LibraryHandle;
31 class LibraryManager;
32
72
73 class LibraryManager {
74 public:
88 LibraryManager(const std::string& name, int index,
89 const boost::shared_ptr<CalloutManager>& manager);
90
97 ~LibraryManager();
98
111 static bool validateLibrary(const std::string& name,
112 bool multi_threading_enabled = false);
113
130 bool loadLibrary(bool multi_threading_enabled = false);
131
141 bool prepareUnloadLibrary();
142
146 std::string getName() const {
147 return (library_name_);
148 }
149
150 protected:
151 // The following methods are protected as they are accessed in testing.
152
165 bool unloadLibrary();
166
173 bool openLibrary();
174
183 bool closeLibrary();
184
197 bool checkVersion() const;
198
210 bool checkMultiThreadingCompatible(bool multi_threading_enabled) const;
211
217 void registerStandardCallouts();
218
226 bool runLoad();
227
228 private:
236 LibraryManager(const std::string& name);
237
238 // Member variables
239
240 void* dl_handle_;
241 int index_;
242 boost::shared_ptr<CalloutManager> manager_;
244 std::string library_name_;
245
246 ServerHooksPtr server_hooks_;
247
248};
249
250} // namespace hooks
251} // namespace isc
252
253#endif // LIBRARY_MANAGER_H
isc::Exception::Exception
Exception(const char *file, size_t line, const char *what)
Constructor for a given type for exceptions with file name and file line number.
Definition exceptions/exceptions.cc:17
isc::Exception::what
virtual const char * what() const
Returns a C-style character string of the cause of the exception.
Definition exceptions/exceptions.cc:32
isc::hooks::LibraryManager::LibraryManager
LibraryManager(const std::string &name, int index, const boost::shared_ptr< CalloutManager > &manager)
Constructor.
Definition library_manager.cc:33
isc::hooks::LibraryManager::unloadLibrary
bool unloadLibrary()
Unloads a library.
Definition library_manager.cc:385
isc::hooks::LibraryManager::validateLibrary
static bool validateLibrary(const std::string &name, bool multi_threading_enabled=false)
Validate library.
Definition library_manager.cc:416
isc::hooks::LibraryManager::openLibrary
bool openLibrary()
Open library.
Definition library_manager.cc:72
isc::hooks::LibraryManager::closeLibrary
bool closeLibrary()
Close library.
Definition library_manager.cc:88
isc::hooks::LibraryManager::~LibraryManager
~LibraryManager()
Destructor.
Definition library_manager.cc:57
isc::hooks::LibraryManager::checkMultiThreadingCompatible
bool checkMultiThreadingCompatible(bool multi_threading_enabled) const
Check multi-threading compatibility.
Definition library_manager.cc:142
isc::hooks::LibraryManager::getName
std::string getName() const
Return library name.
Definition library_manager.h:146
isc::hooks::LibraryManager::checkVersion
bool checkVersion() const
Check library version.
Definition library_manager.cc:109
isc::hooks::LibraryManager::registerStandardCallouts
void registerStandardCallouts()
Register standard callouts.
Definition library_manager.cc:176
isc::hooks::LibraryManager::runLoad
bool runLoad()
Run the load function if present.
Definition library_manager.cc:203
isc::hooks::LibraryManager::prepareUnloadLibrary
bool prepareUnloadLibrary()
Prepares library unloading.
Definition library_manager.cc:253
isc::hooks::LibraryManager::loadLibrary
bool loadLibrary(bool multi_threading_enabled=false)
Loads a library.
Definition library_manager.cc:323
isc::hooks::NoCalloutManager::NoCalloutManager
NoCalloutManager(const char *file, size_t line, const char *what)
Definition library_manager.h:25
exceptions.h
isc::hooks
Definition callout_handle.cc:21
isc::hooks::ServerHooksPtr
boost::shared_ptr< ServerHooks > ServerHooksPtr
Definition server_hooks.h:43
isc
Defines the logger used by the top-level component of kea-lfc.
Definition agent_parser.cc:148
server_hooks.h