16#include <boost/shared_ptr.hpp>
17#include <boost/weak_ptr.hpp>
29HooksManager::HooksManager() : test_mode_(false) {
33 lm_collection_.reset(
new LibraryManagerCollection(libraries));
34 lm_collection_->loadLibraries(
false);
35 callout_manager_ = lm_collection_->getCalloutManager();
41HooksManager::getHooksManager() {
42 static HooksManager manager;
49HooksManager::calloutsPresentInternal(
int index) {
50 return (callout_manager_->calloutsPresent(index));
54HooksManager::calloutsPresent(
int index) {
55 return (getHooksManager().calloutsPresentInternal(index));
59HooksManager::commandHandlersPresentInternal(
const std::string& command_name) {
60 return (callout_manager_->commandHandlersPresent(command_name));
64HooksManager::commandHandlersPresent(
const std::string& command_name) {
65 return (getHooksManager().commandHandlersPresentInternal(command_name));
71HooksManager::callCalloutsInternal(
int index,
CalloutHandle& handle) {
72 callout_manager_->callCallouts(index, handle);
77 getHooksManager().callCalloutsInternal(index, handle);
81HooksManager::callCommandHandlersInternal(
const std::string& command_name,
83 callout_manager_->callCommandHandlers(command_name, handle);
87HooksManager::callCommandHandlers(
const std::string& command_name,
89 getHooksManager().callCommandHandlersInternal(command_name, handle);
98 bool multi_threading_enabled) {
103 ServerHooks::getServerHooks().getParkingLotsPtr()->clear();
106 boost::weak_ptr<LibraryManagerCollection> weak_lmc(lm_collection_);
109 lm_collection_.reset(
new LibraryManagerCollection(libraries));
113 if (!weak_lmc.expired()) {
114 isc_throw(LibrariesStillOpened,
"some libraries are still opened");
118 bool status = lm_collection_->loadLibraries(multi_threading_enabled);
122 callout_manager_ = lm_collection_->getCalloutManager();
126 static_cast<void>(unloadLibrariesInternal());
134 bool multi_threading_enabled) {
135 return (getHooksManager().loadLibrariesInternal(libraries,
136 multi_threading_enabled));
144HooksManager::unloadLibrariesInternal() {
149 ServerHooks::getServerHooks().getParkingLotsPtr()->clear();
152 boost::weak_ptr<LibraryManagerCollection> weak_lmc(lm_collection_);
155 HookLibsCollection libraries;
156 lm_collection_.reset(
new LibraryManagerCollection(libraries));
160 boost::shared_ptr<LibraryManagerCollection> still_here = weak_lmc.lock();
163 lm_collection_ = still_here;
168 lm_collection_->loadLibraries(
false);
171 callout_manager_ = lm_collection_->getCalloutManager();
177HooksManager::unloadLibraries() {
178 return (getHooksManager().unloadLibrariesInternal());
182HooksManager::prepareUnloadLibrariesInternal() {
187 static_cast<void>(lm_collection_->prepareUnloadLibraries());
191HooksManager::prepareUnloadLibraries() {
192 getHooksManager().prepareUnloadLibrariesInternal();
197boost::shared_ptr<CalloutHandle>
198HooksManager::createCalloutHandleInternal() {
199 return (boost::make_shared<CalloutHandle>(callout_manager_, lm_collection_));
202boost::shared_ptr<CalloutHandle>
203HooksManager::createCalloutHandle() {
204 return (getHooksManager().createCalloutHandleInternal());
209std::vector<std::string>
210HooksManager::getLibraryNamesInternal()
const {
211 return (lm_collection_->getLibraryNames());
215HooksManager::getLibraryInfoInternal()
const {
216 return (lm_collection_->getLibraryInfo());
219std::vector<std::string>
220HooksManager::getLibraryNames() {
221 return (getHooksManager().getLibraryNamesInternal());
225HooksManager::getLibraryInfo() {
226 return (getHooksManager().getLibraryInfoInternal());
232HooksManager::registerHook(
const std::string& name) {
233 return (ServerHooks::getServerHooks().registerHook(name));
239HooksManager::preCalloutsLibraryHandleInternal() {
240 return (callout_manager_->getPreLibraryHandle());
244HooksManager::preCalloutsLibraryHandle() {
245 return (getHooksManager().preCalloutsLibraryHandleInternal());
249HooksManager::postCalloutsLibraryHandleInternal() {
250 return (callout_manager_->getPostLibraryHandle());
254HooksManager::postCalloutsLibraryHandle() {
255 return (getHooksManager().postCalloutsLibraryHandleInternal());
260std::vector<std::string>
261HooksManager::validateLibraries(
const std::vector<std::string>& libraries,
262 bool multi_threading_enabled) {
263 return (LibraryManagerCollection::validateLibraries(libraries,
264 multi_threading_enabled));
270HooksManager::setTestMode(
bool mode) {
271 getHooksManager().test_mode_ = mode;
275HooksManager::getTestMode() {
276 return (getHooksManager().test_mode_);
Per-packet callout handle.
#define isc_throw(type, stream)
A shortcut macro to insert known values into exception arguments.
std::vector< HookLibInfo > HookLibsCollection
A storage for information about hook libraries.
Defines the logger used by the top-level component of kea-lfc.