table: make name_tree::Node the sole owner of name_tree::Entry
This commit also improves name_tree::Entry test coverage.
refs #3687
Change-Id: I92375f29fbebab82c67da7dff2ea7a2952ba2cca
diff --git a/daemon/table/strategy-choice-entry.hpp b/daemon/table/strategy-choice-entry.hpp
index 3a21731..c63676b 100644
--- a/daemon/table/strategy-choice-entry.hpp
+++ b/daemon/table/strategy-choice-entry.hpp
@@ -33,11 +33,10 @@
namespace fw {
class Strategy;
} // namespace fw
+
namespace name_tree {
-class NameTree;
class Entry;
} // namespace name_tree
-using name_tree::NameTree;
namespace strategy_choice {
@@ -49,46 +48,36 @@
Entry(const Name& prefix);
const Name&
- getPrefix() const;
+ getPrefix() const
+ {
+ return m_prefix;
+ }
const Name&
getStrategyName() const;
fw::Strategy&
- getStrategy() const;
+ getStrategy() const
+ {
+ BOOST_ASSERT(m_strategy != nullptr);
+ return *m_strategy;
+ }
void
- setStrategy(fw::Strategy& strategy);
+ setStrategy(fw::Strategy& strategy)
+ {
+ m_strategy = &strategy;
+ }
private:
Name m_prefix;
fw::Strategy* m_strategy;
- weak_ptr<name_tree::Entry> m_nameTreeEntry;
- friend class nfd::NameTree;
- friend class nfd::name_tree::Entry;
+ name_tree::Entry* m_nameTreeEntry;
+
+ friend class name_tree::Entry;
};
-
-inline const Name&
-Entry::getPrefix() const
-{
- return m_prefix;
-}
-
-inline fw::Strategy&
-Entry::getStrategy() const
-{
- BOOST_ASSERT(m_strategy != nullptr);
- return *m_strategy;
-}
-
-inline void
-Entry::setStrategy(fw::Strategy& strategy)
-{
- m_strategy = &strategy;
-}
-
} // namespace strategy_choice
} // namespace nfd