fw: delete deprecated Strategy::getName in favor of getInstanceName
This commit also renames strategy_choice::Entry::getStrategyName
to getStrategyInstanceName.
refs #3868
Change-Id: I40301e744fc236918d6be1c1262eba952198e22f
diff --git a/daemon/fw/strategy.hpp b/daemon/fw/strategy.hpp
index c2949b2..1f34ce2 100644
--- a/daemon/fw/strategy.hpp
+++ b/daemon/fw/strategy.hpp
@@ -106,13 +106,6 @@
return m_name;
}
- DEPRECATED(
- const Name&
- getName() const)
- {
- return this->getInstanceName();
- }
-
public: // triggers
/** \brief trigger after Interest is received
*
diff --git a/daemon/mgmt/strategy-choice-manager.cpp b/daemon/mgmt/strategy-choice-manager.cpp
index cff7cef..6ed7826 100644
--- a/daemon/mgmt/strategy-choice-manager.cpp
+++ b/daemon/mgmt/strategy-choice-manager.cpp
@@ -88,9 +88,10 @@
StrategyChoiceManager::listChoices(const Name& topPrefix, const Interest& interest,
ndn::mgmt::StatusDatasetContext& context)
{
- for (auto&& i : m_table) {
+ for (const auto& i : m_table) {
ndn::nfd::StrategyChoice entry;
- entry.setName(i.getPrefix()).setStrategy(i.getStrategyName());
+ entry.setName(i.getPrefix())
+ .setStrategy(i.getStrategyInstanceName());
context.append(entry.wireEncode());
}
context.end();
diff --git a/daemon/table/strategy-choice-entry.cpp b/daemon/table/strategy-choice-entry.cpp
index f5d9551..b9e0b48 100644
--- a/daemon/table/strategy-choice-entry.cpp
+++ b/daemon/table/strategy-choice-entry.cpp
@@ -40,9 +40,9 @@
Entry::~Entry() = default;
const Name&
-Entry::getStrategyName() const
+Entry::getStrategyInstanceName() const
{
- return this->getStrategy().getName();
+ return this->getStrategy().getInstanceName();
}
void
diff --git a/daemon/table/strategy-choice-entry.hpp b/daemon/table/strategy-choice-entry.hpp
index 5d1497c..c6a1326 100644
--- a/daemon/table/strategy-choice-entry.hpp
+++ b/daemon/table/strategy-choice-entry.hpp
@@ -49,15 +49,21 @@
~Entry();
+ /** \return name prefix on which this strategy choice is applied
+ */
const Name&
getPrefix() const
{
return m_prefix;
}
+ /** \return strategy instance name
+ */
const Name&
- getStrategyName() const;
+ getStrategyInstanceName() const;
+ /** \return strategy instance
+ */
fw::Strategy&
getStrategy() const
{
@@ -78,7 +84,6 @@
fw::Strategy* m_strategyPtr;
name_tree::Entry* m_nameTreeEntry;
-
friend class name_tree::Entry;
};
diff --git a/daemon/table/strategy-choice.cpp b/daemon/table/strategy-choice.cpp
index 06acaae..b251a97 100644
--- a/daemon/table/strategy-choice.cpp
+++ b/daemon/table/strategy-choice.cpp
@@ -57,7 +57,7 @@
{
auto entry = make_unique<Entry>(Name());
entry->setStrategy(Strategy::create(strategyName, m_forwarder));
- NFD_LOG_INFO("setDefaultStrategy " << entry->getStrategyName());
+ NFD_LOG_INFO("setDefaultStrategy " << entry->getStrategyInstanceName());
// don't use .insert here, because it will invoke findEffectiveStrategy
// which expects an existing root entry
@@ -86,7 +86,7 @@
/// m_strategyInstances, install, getStrategy, hasStrategy should be eliminated.
BOOST_ASSERT(strategy != nullptr);
- Name strategyName = strategy->getName();
+ Name strategyName = strategy->getInstanceName();
// copying Name, so that strategyName remains available even if strategy is deallocated
bool isInserted = false;
@@ -142,13 +142,13 @@
Entry* entry = nte.getStrategyChoiceEntry();
Strategy* oldStrategy = nullptr;
if (entry != nullptr) {
- if (entry->getStrategyName() == strategy->getName()) {
- NFD_LOG_TRACE("insert(" << prefix << ") not changing " << strategy->getName());
+ if (entry->getStrategyInstanceName() == strategy->getInstanceName()) {
+ NFD_LOG_TRACE("insert(" << prefix << ") not changing " << strategy->getInstanceName());
return true;
}
oldStrategy = &entry->getStrategy();
- NFD_LOG_TRACE("insert(" << prefix << ") changing from " << oldStrategy->getName() <<
- " to " << strategy->getName());
+ NFD_LOG_TRACE("insert(" << prefix << ") changing from " << oldStrategy->getInstanceName() <<
+ " to " << strategy->getInstanceName());
}
else {
oldStrategy = &this->findEffectiveStrategy(prefix);
@@ -156,7 +156,7 @@
entry = newEntry.get();
nte.setStrategyChoiceEntry(std::move(newEntry));
++m_nItems;
- NFD_LOG_TRACE("insert(" << prefix << ") new entry " << strategy->getName());
+ NFD_LOG_TRACE("insert(" << prefix << ") new entry " << strategy->getInstanceName());
}
this->changeStrategy(*entry, *oldStrategy, *strategy);
@@ -207,7 +207,7 @@
return {false, Name()};
}
- return {true, entry->getStrategy().getName()};
+ return {true, entry->getStrategyInstanceName()};
}
template<typename K>
@@ -265,8 +265,8 @@
}
NFD_LOG_INFO("changeStrategy(" << entry.getPrefix() << ")"
- << " from " << oldStrategy.getName()
- << " to " << newStrategy.getName());
+ << " from " << oldStrategy.getInstanceName()
+ << " to " << newStrategy.getInstanceName());
// reset StrategyInfo on a portion of NameTree,
// where entry's effective strategy is covered by the changing StrategyChoice entry
diff --git a/tests/daemon/mgmt/strategy-choice-manager.t.cpp b/tests/daemon/mgmt/strategy-choice-manager.t.cpp
index 667dbf3..f1121ea 100644
--- a/tests/daemon/mgmt/strategy-choice-manager.t.cpp
+++ b/tests/daemon/mgmt/strategy-choice-manager.t.cpp
@@ -202,7 +202,7 @@
std::set<Name> actualNames, actualStrategies;
for (const auto& entry : m_strategyChoice) {
actualNames.insert(entry.getPrefix());
- actualStrategies.insert(entry.getStrategyName());
+ actualStrategies.insert(entry.getStrategyInstanceName());
}
std::uniform_int_distribution<uint64_t> dist;
diff --git a/tests/daemon/table/strategy-choice.t.cpp b/tests/daemon/table/strategy-choice.t.cpp
index ebcd9db..e827321 100644
--- a/tests/daemon/table/strategy-choice.t.cpp
+++ b/tests/daemon/table/strategy-choice.t.cpp
@@ -216,7 +216,7 @@
std::map<Name, Name> map; // namespace=>strategyName
for (StrategyChoice::const_iterator it = sc.begin(); it != sc.end(); ++it) {
- map[it->getPrefix()] = it->getStrategyName();
+ map[it->getPrefix()] = it->getStrategyInstanceName();
}
BOOST_CHECK_EQUAL(map.at("/"), strategyNameP);