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));
59 NFD_LOG_DEBUG(
"strategy-choice/set(" << prefix <<
"," << strategy <<
"): cannot-create " << 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");
76 const Name& prefix = parameters.getName();
79 m_table.
erase(parameters.getName());
88 for (
const auto& i : m_table) {
91 .setStrategy(i.getStrategyInstanceName());
int getStatusCode() const
get a status code for use in management command response
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
size_t wireEncode(EncodingImpl< TAG > &encoder) const
std::pair< bool, Name > get(const Name &prefix) const
get strategy Name of prefix
#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
const Name & getName() 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
size_t wireEncode(EncodingImpl< TAG > &encoder) const
Represents an absolute name.
std::function< void(const ControlResponse &resp)> CommandContinuation
a function to be called after ControlCommandHandler completes
provides ControlCommand authorization according to NFD configuration file
represents the Strategy Choice table
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)
const Name & getStrategy() const
void registerStatusDatasetHandler(const std::string &verb, const ndn::mgmt::StatusDatasetHandler &handler)
StrategyChoice & setName(const Name &name)