table: don't share Strategy instance among StrategyChoice entries
For a Strategy type registered in the strategy registry,
a new instance is created for each StrategyChoice entry that uses it.
StrategyChoice::install is deprecated. An installed strategy instance
is still shared among StrategyChoice entries that use it. This will
be removed after unit tests switch to use the strategy registry.
refs #3868
Change-Id: Ibca685e6b6668f64fa1a503e3575867e8babdfe1
diff --git a/daemon/table/strategy-choice-entry.hpp b/daemon/table/strategy-choice-entry.hpp
index c63676b..5d1497c 100644
--- a/daemon/table/strategy-choice-entry.hpp
+++ b/daemon/table/strategy-choice-entry.hpp
@@ -47,6 +47,8 @@
public:
Entry(const Name& prefix);
+ ~Entry();
+
const Name&
getPrefix() const
{
@@ -59,19 +61,21 @@
fw::Strategy&
getStrategy() const
{
- BOOST_ASSERT(m_strategy != nullptr);
- return *m_strategy;
+ BOOST_ASSERT(m_strategyPtr != nullptr);
+ return *m_strategyPtr;
}
+ DEPRECATED(
void
- setStrategy(fw::Strategy& strategy)
- {
- m_strategy = &strategy;
- }
+ setStrategy(fw::Strategy& strategy));
+
+ void
+ setStrategy(unique_ptr<fw::Strategy> strategy);
private:
Name m_prefix;
- fw::Strategy* m_strategy;
+ unique_ptr<fw::Strategy> m_strategy;
+ fw::Strategy* m_strategyPtr;
name_tree::Entry* m_nameTreeEntry;