Kea  1.9.9-git
library_manager.h
Go to the documentation of this file.
1 // Copyright (C) 2013-2020 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 
74 public:
88  LibraryManager(const std::string& name, int index,
89  const boost::shared_ptr<CalloutManager>& manager);
90 
98 
109  static bool validateLibrary(const std::string& name);
110 
124  bool loadLibrary();
125 
135  bool prepareUnloadLibrary();
136 
140  std::string getName() const {
141  return (library_name_);
142  }
143 
144 protected:
145  // The following methods are protected as they are accessed in testing.
146 
159  bool unloadLibrary();
160 
167  bool openLibrary();
168 
177  bool closeLibrary();
178 
191  bool checkVersion() const;
192 
201  bool checkMultiThreadingCompatible() const;
202 
209 
217  bool runLoad();
218 
219 private:
227  LibraryManager(const std::string& name);
228 
229  // Member variables
230 
231  void* dl_handle_;
232  int index_;
233  boost::shared_ptr<CalloutManager> manager_;
235  std::string library_name_;
236 
237  ServerHooksPtr server_hooks_;
238 
239 };
240 
241 } // namespace hooks
242 } // namespace isc
243 
244 #endif // LIBRARY_MANAGER_H
bool unloadLibrary()
Unloads a library.
std::string getName() const
Return library name.
bool checkMultiThreadingCompatible() const
Check multi-threading compatibility.
bool loadLibrary()
Loads a library.
bool checkVersion() const
Check library version.
boost::shared_ptr< ServerHooks > ServerHooksPtr
Definition: server_hooks.h:42
static bool validateLibrary(const std::string &name)
Validate library.
virtual const char * what() const
Returns a C-style character string of the cause of the exception.
void registerStandardCallouts()
Register standard callouts.
This is a base class for exceptions thrown from the DNS library module.
Defines the logger used by the top-level component of kea-dhcp-ddns.
bool prepareUnloadLibrary()
Prepares library unloading.
bool runLoad()
Run the load function if present.
NoCalloutManager(const char *file, size_t line, const char *what)
bool openLibrary()
Open library.
No Callout Manager.
bool closeLibrary()
Close library.
LibraryManager(const std::string &name, int index, const boost::shared_ptr< CalloutManager > &manager)
Constructor.