26 #ifndef NFD_DAEMON_MGMT_MANAGER_BASE_HPP 27 #define NFD_DAEMON_MGMT_MANAGER_BASE_HPP 31 #include <ndn-cxx/mgmt/dispatcher.hpp> 32 #include <ndn-cxx/mgmt/nfd/control-command.hpp> 33 #include <ndn-cxx/mgmt/nfd/control-parameters.hpp> 34 #include <ndn-cxx/mgmt/nfd/control-response.hpp> 38 using ndn::mgmt::Dispatcher;
39 using ndn::nfd::ControlCommand;
40 using ndn::nfd::ControlParameters;
41 using ndn::nfd::ControlResponse;
50 class Error :
public std::runtime_error
53 using std::runtime_error::runtime_error;
69 ManagerBase(
const std::string& module, Dispatcher& dispatcher);
71 ManagerBase(
const std::string& module, Dispatcher& dispatcher,
77 const Name& prefix,
const Interest& interest,
78 const ControlParameters& parameters,
79 const ndn::mgmt::CommandContinuation done)>;
81 template<
typename Command>
88 const ndn::mgmt::StatusDatasetHandler& handler);
90 ndn::mgmt::PostNotification
103 extractRequester(
const Interest& interest, ndn::mgmt::AcceptContinuation accept);
109 virtual ndn::mgmt::Authorization
110 makeAuthorization(
const std::string& verb);
119 validateParameters(
const ControlCommand& command,
120 const ndn::mgmt::ControlParameters& parameters);
126 handleCommand(shared_ptr<ControlCommand> command,
128 const Name& prefix,
const Interest& interest,
129 const ndn::mgmt::ControlParameters& params,
130 ndn::mgmt::CommandContinuation done);
139 makeRelPrefix(
const std::string& verb)
141 return PartialName(m_module).append(verb);
145 std::string m_module;
146 Dispatcher& m_dispatcher;
150 template<
typename Command>
155 auto command = make_shared<Command>();
157 m_dispatcher.addControlCommand<ControlParameters>(
159 makeAuthorization(verb),
160 bind(&ManagerBase::validateParameters, std::cref(*command), _1),
161 bind(&ManagerBase::handleCommand, command, handler, _1, _2, _3, _4));
166 #endif // NFD_DAEMON_MGMT_MANAGER_BASE_HPP void registerStatusDatasetHandler(const std::string &verb, const ndn::mgmt::StatusDatasetHandler &handler)
std::function< void(const ControlCommand &command, const Name &prefix, const Interest &interest, const ControlParameters ¶meters, const ndn::mgmt::CommandContinuation done)> ControlCommandHandler
#define PUBLIC_WITH_TESTS_ELSE_PROTECTED
void registerCommandHandler(const std::string &verb, const ControlCommandHandler &handler)
ManagerBase(const std::string &module, Dispatcher &dispatcher)
Provides ControlCommand authorization according to NFD configuration file.
A collection of common functions shared by all NFD managers, such as communicating with the dispatche...
const std::string & getModule() const
Copyright (c) 2014-2015, Regents of the University of California, Arizona Board of Regents...
ndn::mgmt::PostNotification registerNotificationStream(const std::string &verb)
void extractRequester(const Interest &interest, ndn::mgmt::AcceptContinuation accept)
Extracts the requester from a ControlCommand request.
#define PUBLIC_WITH_TESTS_ELSE_PRIVATE