fw: refactor Strategy registry
Strategy registry is moved into Strategy class.
Strategy instantiation logic is implemented in Strategy::create.
These are in preparation of supporting Strategy parameters.
refs #3868
Change-Id: If36a08ad25a00a7008a5eccc8cfe4f6c63638676
diff --git a/daemon/fw/forwarder.cpp b/daemon/fw/forwarder.cpp
index 7e0df65..7482cf4 100644
--- a/daemon/fw/forwarder.cpp
+++ b/daemon/fw/forwarder.cpp
@@ -25,8 +25,9 @@
#include "forwarder.hpp"
#include "algorithm.hpp"
-#include "core/logger.hpp"
+#include "best-route-strategy2.hpp"
#include "strategy.hpp"
+#include "core/logger.hpp"
#include "table/cleanup.hpp"
#include <ndn-cxx/lp/tags.hpp>
@@ -34,15 +35,19 @@
NFD_LOG_INIT("Forwarder");
+static Name
+getDefaultStrategyName()
+{
+ return fw::BestRouteStrategy2::STRATEGY_NAME;
+}
+
Forwarder::Forwarder()
: m_unsolicitedDataPolicy(new fw::DefaultUnsolicitedDataPolicy())
, m_fib(m_nameTree)
, m_pit(m_nameTree)
, m_measurements(m_nameTree)
- , m_strategyChoice(m_nameTree, fw::makeDefaultStrategy(*this))
+ , m_strategyChoice(*this)
{
- fw::installStrategies(*this);
-
m_faceTable.afterAdd.connect([this] (Face& face) {
face.afterReceiveInterest.connect(
[this, &face] (const Interest& interest) {
@@ -61,6 +66,9 @@
m_faceTable.beforeRemove.connect([this] (Face& face) {
cleanupOnFaceRemoval(m_nameTree, m_fib, m_pit, face);
});
+
+ m_strategyChoice.setDefaultStrategy(getDefaultStrategyName());
+ m_strategyChoice.installFromRegistry();
}
Forwarder::~Forwarder() = default;