table: attach unique_ptr<strategy_choice::Entry> onto NameTree
refs #3164
Change-Id: I5cce7e43dba77cdaaa07347ec7ffca13f242113c
diff --git a/daemon/mgmt/strategy-choice-manager.cpp b/daemon/mgmt/strategy-choice-manager.cpp
index a28e237..1f0c208 100644
--- a/daemon/mgmt/strategy-choice-manager.cpp
+++ b/daemon/mgmt/strategy-choice-manager.cpp
@@ -35,7 +35,7 @@
Dispatcher& dispatcher,
CommandValidator& validator)
: NfdManagerBase(dispatcher, validator, "strategy-choice")
- , m_strategyChoice(strategyChoice)
+ , m_table(strategyChoice)
{
registerCommandHandler<ndn::nfd::StrategyChoiceSetCommand>("set",
bind(&StrategyChoiceManager::setStrategy, this, _2, _3, _4, _5));
@@ -54,15 +54,15 @@
const Name& prefix = parameters.getName();
const Name& selectedStrategy = parameters.getStrategy();
- if (!m_strategyChoice.hasStrategy(selectedStrategy)) {
+ if (!m_table.hasStrategy(selectedStrategy)) {
NFD_LOG_DEBUG("strategy-choice result: FAIL reason: unknown-strategy: "
<< parameters.getStrategy());
return done(ControlResponse(504, "Unsupported strategy"));
}
- if (m_strategyChoice.insert(prefix, selectedStrategy)) {
+ if (m_table.insert(prefix, selectedStrategy)) {
NFD_LOG_DEBUG("strategy-choice result: SUCCESS");
- auto currentStrategyChoice = m_strategyChoice.get(prefix);
+ auto currentStrategyChoice = m_table.get(prefix);
BOOST_ASSERT(currentStrategyChoice.first);
parameters.setStrategy(currentStrategyChoice.second);
return done(ControlResponse(200, "OK").setBody(parameters.wireEncode()));
@@ -78,7 +78,7 @@
ControlParameters parameters,
const ndn::mgmt::CommandContinuation& done)
{
- m_strategyChoice.erase(parameters.getName());
+ m_table.erase(parameters.getName());
NFD_LOG_DEBUG("strategy-choice result: SUCCESS");
done(ControlResponse(200, "OK").setBody(parameters.wireEncode()));
@@ -88,7 +88,7 @@
StrategyChoiceManager::listChoices(const Name& topPrefix, const Interest& interest,
ndn::mgmt::StatusDatasetContext& context)
{
- for (auto&& i : m_strategyChoice) {
+ for (auto&& i : m_table) {
ndn::nfd::StrategyChoice entry;
entry.setName(i.getPrefix()).setStrategy(i.getStrategyName());
context.append(entry.wireEncode());
diff --git a/daemon/mgmt/strategy-choice-manager.hpp b/daemon/mgmt/strategy-choice-manager.hpp
index eff3418..9fd4ad3 100644
--- a/daemon/mgmt/strategy-choice-manager.hpp
+++ b/daemon/mgmt/strategy-choice-manager.hpp
@@ -30,7 +30,9 @@
namespace nfd {
+namespace strategy_choice {
class StrategyChoice;
+} // namespace strategy_choice
/**
* @brief implement the Strategy Choice Management of NFD Management Protocol.
@@ -39,7 +41,7 @@
class StrategyChoiceManager : public NfdManagerBase
{
public:
- StrategyChoiceManager(StrategyChoice& strategyChoice,
+ StrategyChoiceManager(strategy_choice::StrategyChoice& table,
Dispatcher& dispatcher,
CommandValidator& validator);
@@ -59,7 +61,7 @@
ndn::mgmt::StatusDatasetContext& context);
private:
- StrategyChoice& m_strategyChoice;
+ strategy_choice::StrategyChoice& m_table;
};
} // namespace nfd