35ServerHooks::ServerHooks() {
47 int index = hooks_.size();
48 pair<HookCollection::iterator, bool> result =
49 hooks_.insert(make_pair(name, index));
78 inverse_hooks_[index] = name;
87ServerHooks::initialize() {
91 inverse_hooks_.clear();
102 ", actual = " << create <<
104 ", actual = " << destroy);
127 InverseHookCollection::const_iterator i = inverse_hooks_.find(index);
128 if (i == inverse_hooks_.end()) {
141 HookCollection::const_iterator i = hooks_.find(name);
142 if (i == hooks_.end()) {
152 auto i = hooks_.find(name);
153 return ((i == hooks_.end()) ? -1 : i->second);
161 vector<string> names;
162 for (
auto const& i : hooks_) {
163 names.push_back(i.first);
184 return (parking_lots_);
189 return (parking_lots_->getParkingLotPtr(hook_index));
200 std::string hook_name = std::string(
"$") + command_name;
202 std::replace(hook_name.begin(), hook_name.end(),
'-',
'_');
208 if (!hook_name.empty() && hook_name.front() ==
'$') {
209 std::string command_name = hook_name.substr(1);
210 std::replace(command_name.begin(), command_name.end(),
'_',
'-');
211 return (command_name);
A generic exception that is thrown when an unexpected error condition occurs.
Collection of parking lots for various hook points.
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
ParkingLotsPtr getParkingLotsPtr() const
Returns pointer to all parking lots.
int findIndex(const std::string &name) const
Find hook index.
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.
int registerHook(const std::string &name)
Register a hook.
std::vector< std::string > getHookNames() const
Get hook names.
std::string getName(int index) const
Get hook name.
#define isc_throw(type, stream)
A shortcut macro to insert known values into exception arguments.
#define LOG_WARN(LOGGER, MESSAGE)
Macro to conveniently test warn output and log it.
boost::shared_ptr< ParkingLots > ParkingLotsPtr
Type of the pointer to the parking lots.
const isc::log::MessageID HOOKS_HOOK_LIST_RESET
boost::shared_ptr< ServerHooks > ServerHooksPtr
isc::log::Logger hooks_logger("hooks")
Hooks Logger.
boost::shared_ptr< ParkingLot > ParkingLotPtr
Type of the pointer to the parking lot.
Defines the logger used by the top-level component of kea-lfc.