Kea  1.5.0
library_manager.h
Go to the documentation of this file.
1 // Copyright (C) 2013-2017 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 
71 
73 public:
87  LibraryManager(const std::string& name, int index,
88  const boost::shared_ptr<CalloutManager>& manager);
89 
97 
108  static bool validateLibrary(const std::string& name);
109 
121  bool loadLibrary();
122 
135  bool unloadLibrary();
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 
153  bool openLibrary();
154 
163  bool closeLibrary();
164 
177  bool checkVersion() const;
178 
185 
193  bool runLoad();
194 
202  bool runUnload();
203 
204 private:
212  LibraryManager(const std::string& name);
213 
214  // Member variables
215 
216  void* dl_handle_;
217  int index_;
218  boost::shared_ptr<CalloutManager> manager_;
220  std::string library_name_;
221 
222  ServerHooksPtr server_hooks_;
223 
224 };
225 
226 } // namespace hooks
227 } // namespace isc
228 
229 #endif // LIBRARY_MANAGER_H
bool unloadLibrary()
Unloads a library.
bool loadLibrary()
Loads a library.
boost::shared_ptr< ServerHooks > ServerHooksPtr
Definition: server_hooks.h:42
static bool validateLibrary(const std::string &name)
Validate library.
bool runUnload()
Run the unload function if present.
virtual const char * what() const
Returns a C-style character string of the cause of the exception.
std::string getName() const
Return library name.
bool checkVersion() const
Check library version.
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 runLoad()
Run the load function if present.
NoCalloutManager(const char *file, size_t line, const char *what)
bool openLibrary()
Open library.
bool closeLibrary()
Close library.
LibraryManager(const std::string &name, int index, const boost::shared_ptr< CalloutManager > &manager)
Constructor.