26 #ifndef NFD_CORE_MANAGER_BASE_HPP 27 #define NFD_CORE_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-response.hpp> 34 #include <ndn-cxx/mgmt/nfd/control-parameters.hpp> 38 using ndn::mgmt::Dispatcher;
40 using ndn::nfd::ControlCommand;
41 using ndn::nfd::ControlResponse;
42 using ndn::nfd::ControlParameters;
51 class Error :
public std::runtime_error
56 :
std::runtime_error(what)
62 ManagerBase(Dispatcher& dispatcher,
const std::string& module);
75 typedef function<void(
const ControlCommand& command,
76 const Name& prefix,
const Interest& interest,
77 const ControlParameters& parameters,
80 template<
typename Command>
83 const ControlCommandHandler& handler);
87 const ndn::mgmt::StatusDatasetHandler& handler);
89 ndn::mgmt::PostNotification
103 ndn::mgmt::AcceptContinuation accept);
109 virtual ndn::mgmt::Authorization
110 makeAuthorization(
const std::string& verb) = 0;
120 validateParameters(
const nfd::ControlCommand& command,
121 const ndn::mgmt::ControlParameters& parameters);
126 handleCommand(shared_ptr<nfd::ControlCommand> command,
127 const ControlCommandHandler& handler,
128 const Name& prefix,
const Interest& interest,
129 const ndn::mgmt::ControlParameters& params,
130 ndn::mgmt::CommandContinuation done);
141 makeRelPrefix(
const std::string& verb);
144 Dispatcher& m_dispatcher;
145 std::string m_module;
149 ManagerBase::makeRelPrefix(
const std::string& verb)
151 return PartialName(m_module).append(verb);
154 template<
typename Command>
159 auto command = make_shared<Command>();
161 m_dispatcher.addControlCommand<ControlParameters>(
163 makeAuthorization(verb),
164 bind(&ManagerBase::validateParameters, cref(*command), _1),
165 bind(&ManagerBase::handleCommand, command, handler, _1, _2, _3, _4));
170 #endif // NFD_CORE_MANAGER_BASE_HPP void registerStatusDatasetHandler(const std::string &verb, const ndn::mgmt::StatusDatasetHandler &handler)
ManagerBase(Dispatcher &dispatcher, const std::string &module)
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)
Error(const std::string &what)
a collection of common functions shared by all NFD managers and RIB manager, such as communicating wi...
Copyright (c) 2014-2015, Regents of the University of California, Arizona Board of Regents...
const std::string & getModule() const
ndn::mgmt::PostNotification registerNotificationStream(const std::string &verb)
void extractRequester(const Interest &interest, ndn::mgmt::AcceptContinuation accept)
extract a requester from a ControlCommand request
#define PUBLIC_WITH_TESTS_ELSE_PRIVATE