28 #include <ndn-cxx/mgmt/nfd/strategy-choice.hpp> 29 #include <boost/lexical_cast.hpp> 39 , m_table(strategyChoice)
41 registerCommandHandler<ndn::nfd::StrategyChoiceSetCommand>(
"set",
42 bind(&StrategyChoiceManager::setStrategy,
this, _4, _5));
43 registerCommandHandler<ndn::nfd::StrategyChoiceUnsetCommand>(
"unset",
44 bind(&StrategyChoiceManager::unsetStrategy,
this, _4, _5));
47 bind(&StrategyChoiceManager::listChoices,
this, _3));
57 StrategyChoice::InsertResult res = m_table.
insert(prefix, strategy);
59 NFD_LOG_DEBUG(
"strategy-choice/set(" << prefix <<
"," << strategy <<
"): cannot-create " << res);
60 return done(
ControlResponse(404, boost::lexical_cast<std::string>(res)));
63 NFD_LOG_DEBUG(
"strategy-choice/set(" << prefix <<
"," << strategy <<
"): OK");
64 bool hasEntry =
false;
66 std::tie(hasEntry, instanceName) = m_table.
get(prefix);
67 BOOST_ASSERT_MSG(hasEntry,
"StrategyChoice entry must exist after StrategyChoice::insert");
88 for (
const auto& i : m_table) {
91 .setStrategy(i.getStrategyInstanceName());
const Name & getStrategy() const
StrategyChoiceManager(strategy_choice::StrategyChoice &table, Dispatcher &dispatcher, CommandAuthenticator &authenticator)
represents parameters in a ControlCommand request or response
represents a dispatcher on server side of NFD Management protocol
void erase(const Name &prefix)
make prefix to inherit strategy from its parent
#define NFD_LOG_DEBUG(expression)
ControlParameters & setStrategy(const Name &strategy)
InsertResult insert(const Name &prefix, const Name &strategyName)
set strategy of prefix to be strategyName
size_t wireEncode(EncodingImpl< TAG > &encoder) const
mgmt::ControlResponse ControlResponse
Copyright (c) 2011-2015 Regents of the University of California.
void end()
end the response successfully after appending zero or more blocks
const Name & getName() const
Represents an absolute name.
std::function< void(const ControlResponse &resp)> CommandContinuation
a function to be called after ControlCommandHandler completes
std::pair< bool, Name > get(const Name &prefix) const
get strategy Name of prefix
provides ControlCommand authorization according to NFD configuration file
size_t wireEncode(EncodingImpl< TAG > &encoder) const
void append(const Block &block)
append a Block to the response
represents an item in NFD StrategyChoice dataset
provides a context for generating response to a StatusDataset request
a collection of common functions shared by all NFD managers, such as communicating with the dispatche...
#define NFD_LOG_INIT(name)
void registerStatusDatasetHandler(const std::string &verb, const ndn::mgmt::StatusDatasetHandler &handler)
StrategyChoice & setName(const Name &name)