28 #include <ndn-cxx/management/nfd-strategy-choice.hpp> 37 :
ManagerBase(dispatcher, validator,
"strategy-choice")
38 , m_strategyChoice(strategyChoice)
40 registerCommandHandler<ndn::nfd::StrategyChoiceSetCommand>(
"set",
41 bind(&StrategyChoiceManager::setStrategy,
this, _2, _3, _4, _5));
42 registerCommandHandler<ndn::nfd::StrategyChoiceUnsetCommand>(
"unset",
43 bind(&StrategyChoiceManager::unsetStrategy,
this, _2, _3, _4, _5));
46 bind(&StrategyChoiceManager::listChoices,
this, _1, _2, _3));
50 StrategyChoiceManager::setStrategy(
const Name& topPrefix,
const Interest& interest,
57 if (!m_strategyChoice.
hasStrategy(selectedStrategy)) {
58 NFD_LOG_DEBUG(
"strategy-choice result: FAIL reason: unknown-strategy: " 63 if (m_strategyChoice.
insert(prefix, selectedStrategy)) {
65 auto currentStrategyChoice = m_strategyChoice.
get(prefix);
66 BOOST_ASSERT(currentStrategyChoice.first);
67 parameters.
setStrategy(currentStrategyChoice.second);
71 NFD_LOG_DEBUG(
"strategy-choice result: FAIL reason: not-installed");
77 StrategyChoiceManager::unsetStrategy(
const Name& topPrefix,
const Interest& interest,
88 StrategyChoiceManager::listChoices(
const Name& topPrefix,
const Interest& interest,
91 for (
auto&& i : m_strategyChoice) {
93 entry.
setName(i.getPrefix()).setStrategy(i.getStrategyName());
a collection of common functions shared by all NFD managers, such as communicating with the dispatche...
#define NFD_LOG_DEBUG(expression)
represents the Strategy Choice table
represents parameters in a ControlCommand request or response
bool hasStrategy(const Name &strategyName, bool isExact=false) const
determines if a strategy is installed
represents a dispatcher on server side of NFD Management protocol
bool insert(const Name &prefix, const Name &strategyName)
set strategy of prefix to be strategyName
size_t wireEncode(EncodingImpl< TAG > &encoder) const
std::pair< bool, Name > get(const Name &prefix) const
get strategy Name of prefix
represents an Interest packet
ControlParameters & setStrategy(const Name &strategy)
StrategyChoiceManager(StrategyChoice &strategyChoice, Dispatcher &dispatcher, CommandValidator &validator)
const Name & getName() const
ndn::mgmt::ControlResponse ControlResponse
Copyright (c) 2011-2015 Regents of the University of California.
void erase(const Name &prefix)
make prefix to inherit strategy from its parent
void end()
end the response successfully after appending zero or more blocks
size_t wireEncode(EncodingImpl< TAG > &encoder) const
Name abstraction to represent an absolute name.
std::function< void(const ControlResponse &resp)> CommandContinuation
a function to be called after ControlCommandHandler completes
#define NFD_LOG_INIT(name)
void append(const Block &block)
append a Block to the response
represents NFD StrategyChoice dataset
provides a context for generating response to a StatusDataset request
const Name & getStrategy() const
void registerStatusDatasetHandler(const std::string &verb, const ndn::mgmt::StatusDatasetHandler &handler)
StrategyChoice & setName(const Name &name)