Kea 2.7.4
base_command_mgr.h
Go to the documentation of this file.
1// Copyright (C) 2017-2023 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 BASE_COMMAND_MGR_H
8#define BASE_COMMAND_MGR_H
9
10#include <cc/data.h>
12#include <functional>
13#include <map>
14#include <string>
15
16namespace isc {
17namespace config {
18
21public:
22 InvalidCommandHandler(const char* file, size_t line, const char* what) :
23 isc::Exception(file, line, what) { };
24};
25
28public:
29 InvalidCommandName(const char* file, size_t line, const char* what) :
30 isc::Exception(file, line, what) { };
31};
32
73public:
74
82 typedef std::function<isc::data::ConstElementPtr (const std::string& name,
84
95 typedef std::function<isc::data::ConstElementPtr (const std::string& name,
96 const isc::data::ConstElementPtr& params,
98
104
106 virtual ~BaseCommandMgr() { };
107
125
130 void registerCommand(const std::string& cmd, CommandHandler handler);
131
142 void registerExtendedCommand(const std::string& cmd,
143 ExtendedCommandHandler handler);
144
148 void deregisterCommand(const std::string& cmd);
149
154 void deregisterAll();
155
159 // representation of the structure.
163 static std::string getHash(const isc::data::ConstElementPtr& config);
164
165protected:
166
183 handleCommand(const std::string& cmd_name,
184 const isc::data::ConstElementPtr& params,
185 const isc::data::ConstElementPtr& original_cmd);
186
191
193 typedef std::map<std::string, HandlersPair> HandlerContainer;
194
197
198private:
199
211 listCommandsHandler(const std::string& name,
212 const isc::data::ConstElementPtr& params);
213};
214
215} // end of namespace isc::config
216} // end of namespace isc
217
218#endif
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.
Commands Manager, responsible for processing external commands.
HandlerContainer handlers_
Container for command handlers.
virtual isc::data::ConstElementPtr processCommand(const isc::data::ConstElementPtr &cmd)
Triggers command processing.
std::function< isc::data::ConstElementPtr(const std::string &name, const isc::data::ConstElementPtr &params) CommandHandler)
Defines command handler type.
void registerCommand(const std::string &cmd, CommandHandler handler)
Registers specified command handler for a given command.
static std::string getHash(const isc::data::ConstElementPtr &config)
returns a hash of a given Element structure
std::function< isc::data::ConstElementPtr(const std::string &name, const isc::data::ConstElementPtr &params, const isc::data::ConstElementPtr &original) ExtendedCommandHandler)
Defines extended command handler type.
void deregisterAll()
Auxiliary method that removes all installed commands.
void registerExtendedCommand(const std::string &cmd, ExtendedCommandHandler handler)
Registers specified command handler for a given command.
virtual isc::data::ConstElementPtr handleCommand(const std::string &cmd_name, const isc::data::ConstElementPtr &params, const isc::data::ConstElementPtr &original_cmd)
Handles the command having a given name and arguments.
virtual ~BaseCommandMgr()
Destructor.
std::map< std::string, HandlersPair > HandlerContainer
Type of the container for command handlers.
void deregisterCommand(const std::string &cmd)
Deregisters specified command handler.
Exception indicating that the handler specified is not valid.
InvalidCommandHandler(const char *file, size_t line, const char *what)
Exception indicating that the command name is not valid.
InvalidCommandName(const char *file, size_t line, const char *what)
boost::shared_ptr< const Element > ConstElementPtr
Definition data.h:29
Defines the logger used by the top-level component of kea-lfc.