fw: pass parameters to Strategy subclass constructors
refs #3868
Change-Id: I1a09e7353c047d548065c4ed669d1f7993676428
diff --git a/daemon/fw/best-route-strategy.cpp b/daemon/fw/best-route-strategy.cpp
index b58ed88..ad70ab6 100644
--- a/daemon/fw/best-route-strategy.cpp
+++ b/daemon/fw/best-route-strategy.cpp
@@ -29,23 +29,14 @@
namespace nfd {
namespace fw {
-NFD_REGISTER_STRATEGY(BestRouteStrategy);
-
-BestRouteStrategy::BestRouteStrategy(Forwarder& forwarder, const Name& name)
- : Strategy(forwarder, name)
+BestRouteStrategyBase::BestRouteStrategyBase(Forwarder& forwarder)
+ : Strategy(forwarder)
{
}
-const Name&
-BestRouteStrategy::getStrategyName()
-{
- static Name strategyName("/localhost/nfd/strategy/best-route/%FD%01");
- return strategyName;
-}
-
void
-BestRouteStrategy::afterReceiveInterest(const Face& inFace, const Interest& interest,
- const shared_ptr<pit::Entry>& pitEntry)
+BestRouteStrategyBase::afterReceiveInterest(const Face& inFace, const Interest& interest,
+ const shared_ptr<pit::Entry>& pitEntry)
{
if (hasPendingOutRecords(*pitEntry)) {
// not a new Interest, don't forward
@@ -67,5 +58,24 @@
this->rejectPendingInterest(pitEntry);
}
+NFD_REGISTER_STRATEGY(BestRouteStrategy);
+
+BestRouteStrategy::BestRouteStrategy(Forwarder& forwarder, const Name& name)
+ : BestRouteStrategyBase(forwarder)
+{
+ ParsedInstanceName parsed = parseInstanceName(name);
+ if (!parsed.parameters.empty()) {
+ BOOST_THROW_EXCEPTION(std::invalid_argument("BestRouteStrategy does not accept parameters"));
+ }
+ this->setInstanceName(makeInstanceName(name, getStrategyName()));
+}
+
+const Name&
+BestRouteStrategy::getStrategyName()
+{
+ static Name strategyName("/localhost/nfd/strategy/best-route/%FD%01");
+ return strategyName;
+}
+
} // namespace fw
} // namespace nfd