16 #include <boost/shared_ptr.hpp>
17 #include <boost/weak_ptr.hpp>
29 HooksManager::HooksManager() : test_mode_(false) {
33 lm_collection_.reset(
new LibraryManagerCollection(libraries));
34 lm_collection_->loadLibraries();
35 callout_manager_ = lm_collection_->getCalloutManager();
41 HooksManager::getHooksManager() {
42 static HooksManager manager;
49 HooksManager::calloutsPresentInternal(
int index) {
50 return (callout_manager_->calloutsPresent(index));
54 HooksManager::calloutsPresent(
int index) {
55 return (getHooksManager().calloutsPresentInternal(index));
59 HooksManager::commandHandlersPresentInternal(
const std::string& command_name) {
60 return (callout_manager_->commandHandlersPresent(command_name));
64 HooksManager::commandHandlersPresent(
const std::string& command_name) {
65 return (getHooksManager().commandHandlersPresentInternal(command_name));
71 HooksManager::callCalloutsInternal(
int index,
CalloutHandle& handle) {
72 callout_manager_->callCallouts(index, handle);
77 getHooksManager().callCalloutsInternal(index, handle);
81 HooksManager::callCommandHandlersInternal(
const std::string& command_name,
83 callout_manager_->callCommandHandlers(command_name, handle);
87 HooksManager::callCommandHandlers(
const std::string& command_name,
89 getHooksManager().callCommandHandlersInternal(command_name, handle);
102 ServerHooks::getServerHooks().getParkingLotsPtr()->clear();
105 boost::weak_ptr<LibraryManagerCollection> weak_lmc(lm_collection_);
108 lm_collection_.reset(
new LibraryManagerCollection(libraries));
112 if (!weak_lmc.expired()) {
113 isc_throw(LibrariesStillOpened,
"some libraries are still opened");
117 bool status = lm_collection_->loadLibraries();
121 callout_manager_ = lm_collection_->getCalloutManager();
125 static_cast<void>(unloadLibrariesInternal());
133 return (getHooksManager().loadLibrariesInternal(libraries));
141 HooksManager::unloadLibrariesInternal() {
146 ServerHooks::getServerHooks().getParkingLotsPtr()->clear();
149 boost::weak_ptr<LibraryManagerCollection> weak_lmc(lm_collection_);
153 lm_collection_.reset(
new LibraryManagerCollection(libraries));
157 boost::shared_ptr<LibraryManagerCollection> still_here = weak_lmc.lock();
160 lm_collection_ = still_here;
165 lm_collection_->loadLibraries();
168 callout_manager_ = lm_collection_->getCalloutManager();
174 HooksManager::unloadLibraries() {
175 return (getHooksManager().unloadLibrariesInternal());
179 HooksManager::prepareUnloadLibrariesInternal() {
184 static_cast<void>(lm_collection_->prepareUnloadLibraries());
188 HooksManager::prepareUnloadLibraries() {
189 getHooksManager().prepareUnloadLibrariesInternal();
194 boost::shared_ptr<CalloutHandle>
195 HooksManager::createCalloutHandleInternal() {
196 return (boost::make_shared<CalloutHandle>(callout_manager_, lm_collection_));
199 boost::shared_ptr<CalloutHandle>
200 HooksManager::createCalloutHandle() {
201 return (getHooksManager().createCalloutHandleInternal());
206 std::vector<std::string>
207 HooksManager::getLibraryNamesInternal()
const {
208 return (lm_collection_->getLibraryNames());
212 HooksManager::getLibraryInfoInternal()
const {
213 return (lm_collection_->getLibraryInfo());
216 std::vector<std::string>
217 HooksManager::getLibraryNames() {
218 return (getHooksManager().getLibraryNamesInternal());
222 HooksManager::getLibraryInfo() {
223 return (getHooksManager().getLibraryInfoInternal());
229 HooksManager::registerHook(
const std::string& name) {
230 return (ServerHooks::getServerHooks().registerHook(name));
236 HooksManager::preCalloutsLibraryHandleInternal() {
237 return (callout_manager_->getPreLibraryHandle());
241 HooksManager::preCalloutsLibraryHandle() {
242 return (getHooksManager().preCalloutsLibraryHandleInternal());
246 HooksManager::postCalloutsLibraryHandleInternal() {
247 return (callout_manager_->getPostLibraryHandle());
251 HooksManager::postCalloutsLibraryHandle() {
252 return (getHooksManager().postCalloutsLibraryHandleInternal());
257 std::vector<std::string>
258 HooksManager::validateLibraries(
const std::vector<std::string>& libraries) {
259 return (LibraryManagerCollection::validateLibraries(libraries));
265 HooksManager::setTestMode(
bool mode) {
266 getHooksManager().test_mode_ = mode;
270 HooksManager::getTestMode() {
271 return (getHooksManager().test_mode_);
std::vector< HookLibInfo > HookLibsCollection
A storage for information about hook libraries.
#define isc_throw(type, stream)
A shortcut macro to insert known values into exception arguments.
Per-packet callout handle.
Defines the logger used by the top-level component of kea-dhcp-ddns.