Kea 2.5.8
server_hooks.h
Go to the documentation of this file.
1// Copyright (C) 2013-2018 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 SERVER_HOOKS_H
8#define SERVER_HOOKS_H
9
11#include <hooks/parking_lots.h>
12
13#include <boost/noncopyable.hpp>
14#include <boost/shared_ptr.hpp>
15
16#include <map>
17#include <string>
18#include <vector>
19
20namespace isc {
21namespace hooks {
22
27class DuplicateHook : public Exception {
28public:
29 DuplicateHook(const char* file, size_t line, const char* what) :
30 isc::Exception(file, line, what) {}
31};
32
36class NoSuchHook : public Exception {
37public:
38 NoSuchHook(const char* file, size_t line, const char* what) :
39 isc::Exception(file, line, what) {}
40};
41
42class ServerHooks;
43typedef boost::shared_ptr<ServerHooks> ServerHooksPtr;
44
61
62class ServerHooks : public boost::noncopyable {
63public:
64
66 static const int CONTEXT_CREATE = 0;
67 static const int CONTEXT_DESTROY = 1;
68
78 void reset();
79
92 int registerHook(const std::string& name);
93
104 std::string getName(int index) const;
105
115 int getIndex(const std::string& name) const;
116
126 int findIndex(const std::string& name) const;
127
133 int getCount() const {
134 return (hooks_.size());
135 }
136
142 std::vector<std::string> getHookNames() const;
143
149 static ServerHooks& getServerHooks();
150
155
160
166 ParkingLotPtr getParkingLotPtr(const int hook_index);
167
173 ParkingLotPtr getParkingLotPtr(const std::string& hook_name);
174
193 static std::string commandToHookName(const std::string& command_name);
194
203 static std::string hookToCommandName(const std::string& hook_name);
204
205private:
219 ServerHooks();
220
229 void initialize();
230
232 typedef std::map<std::string, int> HookCollection;
233 typedef std::map<int, std::string> InverseHookCollection;
234
237 HookCollection hooks_;
238 InverseHookCollection inverse_hooks_;
239
240 ParkingLotsPtr parking_lots_;
241};
242
243} // namespace util
244} // namespace isc
245
246#endif // SERVER_HOOKS_H
This is a base class for exceptions thrown from the DNS library module.
virtual const char * what() const
Returns a C-style character string of the cause of the exception.
DuplicateHook(const char *file, size_t line, const char *what)
Definition: server_hooks.h:29
NoSuchHook(const char *file, size_t line, const char *what)
Definition: server_hooks.h:38
Server hook collection.
Definition: server_hooks.h:62
static ServerHooksPtr getServerHooksPtr()
Returns pointer to ServerHooks object.
ParkingLotPtr getParkingLotPtr(const int hook_index)
Returns pointer to the ParkingLot for the specified hook index.
int getIndex(const std::string &name) const
Get hook index.
static ServerHooks & getServerHooks()
Return ServerHooks object.
static const int CONTEXT_DESTROY
Definition: server_hooks.h:67
ParkingLotsPtr getParkingLotsPtr() const
Returns pointer to all parking lots.
int findIndex(const std::string &name) const
Find hook index.
int getCount() const
Return number of hooks.
Definition: server_hooks.h:133
void reset()
Reset to Initial State.
static std::string hookToCommandName(const std::string &hook_name)
Returns command name for a specified hook name.
static std::string commandToHookName(const std::string &command_name)
Generates hook point name for the given control command name.
static const int CONTEXT_CREATE
Index numbers for pre-defined hooks.
Definition: server_hooks.h:66
int registerHook(const std::string &name)
Register a hook.
Definition: server_hooks.cc:44
std::vector< std::string > getHookNames() const
Get hook names.
std::string getName(int index) const
Get hook name.
boost::shared_ptr< ParkingLots > ParkingLotsPtr
Type of the pointer to the parking lots.
Definition: parking_lots.h:421
boost::shared_ptr< ServerHooks > ServerHooksPtr
Definition: server_hooks.h:43
boost::shared_ptr< ParkingLot > ParkingLotPtr
Type of the pointer to the parking lot.
Definition: parking_lots.h:294
Defines the logger used by the top-level component of kea-lfc.