Kea: library_manager_collection.h Source File

| Kea 3.2.0-git

library_manager_collection.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_COLLECTION_H
8#define LIBRARY_MANAGER_COLLECTION_H
9
10#include <exceptions/exceptions.h>
11
12#include <boost/shared_ptr.hpp>
13#include <hooks/libinfo.h>
14
15#include <vector>
16
17namespace isc {
18namespace hooks {
19
24 class LoadLibrariesNotCalled : public Exception {
25public:
26 LoadLibrariesNotCalled(const char* file, size_t line, const char* what) :
27 isc::Exception(file, line, what) {}
28};
29
30
31// Forward declarations
32class CalloutManager;
33class LibraryManager;
34
69
70 class LibraryManagerCollection {
71public:
77 LibraryManagerCollection(const HookLibsCollection& libraries);
78
82 ~LibraryManagerCollection() {
83 static_cast<void>(unloadLibraries());
84 }
85
98 bool loadLibraries(bool multi_threading_enabled = false);
99
110 boost::shared_ptr<CalloutManager> getCalloutManager() const;
111
117 std::vector<std::string> getLibraryNames() const {
118 return (library_names_);
119 }
120
125 HookLibsCollection getLibraryInfo() const {
126 return (library_info_);
127 }
128
135 int getLoadedLibraryCount() const;
136
149 static std::vector<std::string> validateLibraries(const std::vector<std::string>& libraries,
150 bool multi_threading_enabled = false);
151
163 bool prepareUnloadLibraries();
164
165protected:
170 void unloadLibraries();
171
172private:
173
175 std::vector<std::string> library_names_;
176
178 std::vector<boost::shared_ptr<LibraryManager> > lib_managers_;
179
182 HookLibsCollection library_info_;
183
185 boost::shared_ptr<CalloutManager> callout_manager_;
186};
187
188} // namespace hooks
189} // namespace isc
190
191
192#endif // LIBRARY_MANAGER_COLLECTION_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::LibraryManagerCollection::getLibraryNames
std::vector< std::string > getLibraryNames() const
Get library names.
Definition library_manager_collection.h:117
isc::hooks::LibraryManagerCollection::~LibraryManagerCollection
~LibraryManagerCollection()
Destructor.
Definition library_manager_collection.h:82
isc::hooks::LibraryManagerCollection::unloadLibraries
void unloadLibraries()
Unload libraries.
Definition library_manager_collection.cc:107
isc::hooks::LibraryManagerCollection::getLibraryInfo
HookLibsCollection getLibraryInfo() const
Returns library info.
Definition library_manager_collection.h:125
isc::hooks::LibraryManagerCollection::LibraryManagerCollection
LibraryManagerCollection(const HookLibsCollection &libraries)
Constructor.
Definition library_manager_collection.cc:41
isc::hooks::LibraryManagerCollection::getCalloutManager
boost::shared_ptr< CalloutManager > getCalloutManager() const
Get callout manager.
Definition library_manager_collection.cc:30
isc::hooks::LibraryManagerCollection::prepareUnloadLibraries
bool prepareUnloadLibraries()
Prepare libaries unloading.
Definition library_manager_collection.cc:122
isc::hooks::LibraryManagerCollection::getLoadedLibraryCount
int getLoadedLibraryCount() const
Get number of loaded libraries.
Definition library_manager_collection.cc:133
isc::hooks::LibraryManagerCollection::validateLibraries
static std::vector< std::string > validateLibraries(const std::vector< std::string > &libraries, bool multi_threading_enabled=false)
Validate libraries.
Definition library_manager_collection.cc:139
isc::hooks::LibraryManagerCollection::loadLibraries
bool loadLibraries(bool multi_threading_enabled=false)
Load libraries.
Definition library_manager_collection.cc:53
isc::hooks::LoadLibrariesNotCalled::LoadLibrariesNotCalled
LoadLibrariesNotCalled(const char *file, size_t line, const char *what)
Definition library_manager_collection.h:26
exceptions.h
libinfo.h
isc::hooks
Definition callout_handle.cc:21
isc::hooks::HookLibsCollection
std::vector< HookLibInfo > HookLibsCollection
A storage for information about hook libraries.
Definition libinfo.h:51
isc
Defines the logger used by the top-level component of kea-lfc.
Definition check_exists_add.cc:18