fw: move STRATEGY_NAME to getStrategyName static function
This avoids potential problems with static initialization order.
refs #3868
Change-Id: I13f0ff6c51c0a3bd43af7993233ff63a4bca9cf9
diff --git a/daemon/fw/access-strategy.cpp b/daemon/fw/access-strategy.cpp
index 45235d8..df92d1b 100644
--- a/daemon/fw/access-strategy.cpp
+++ b/daemon/fw/access-strategy.cpp
@@ -31,8 +31,6 @@
namespace fw {
NFD_LOG_INIT("AccessStrategy");
-
-const Name AccessStrategy::STRATEGY_NAME("ndn:/localhost/nfd/strategy/access/%FD%01");
NFD_REGISTER_STRATEGY(AccessStrategy);
AccessStrategy::AccessStrategy(Forwarder& forwarder, const Name& name)
@@ -42,6 +40,13 @@
{
}
+const Name&
+AccessStrategy::getStrategyName()
+{
+ static Name strategyName("/localhost/nfd/strategy/access/%FD%01");
+ return strategyName;
+}
+
void
AccessStrategy::afterReceiveInterest(const Face& inFace, const Interest& interest,
const shared_ptr<pit::Entry>& pitEntry)
diff --git a/daemon/fw/access-strategy.hpp b/daemon/fw/access-strategy.hpp
index a9a1150..31f2180 100644
--- a/daemon/fw/access-strategy.hpp
+++ b/daemon/fw/access-strategy.hpp
@@ -50,7 +50,10 @@
{
public:
explicit
- AccessStrategy(Forwarder& forwarder, const Name& name = STRATEGY_NAME);
+ AccessStrategy(Forwarder& forwarder, const Name& name = getStrategyName());
+
+ static const Name&
+ getStrategyName();
public: // triggers
virtual void
@@ -155,9 +158,6 @@
updateMeasurements(const Face& inFace, const Data& data,
const RttEstimator::Duration& rtt);
-public:
- static const Name STRATEGY_NAME;
-
private:
FaceInfoTable m_fit;
RetxSuppressionFixed m_retxSuppression;
diff --git a/daemon/fw/asf-strategy.cpp b/daemon/fw/asf-strategy.cpp
index acab918..cb2bca3 100644
--- a/daemon/fw/asf-strategy.cpp
+++ b/daemon/fw/asf-strategy.cpp
@@ -33,13 +33,11 @@
namespace asf {
NFD_LOG_INIT("AsfStrategy");
+NFD_REGISTER_STRATEGY(AsfStrategy);
-const Name AsfStrategy::STRATEGY_NAME("ndn:/localhost/nfd/strategy/asf/%FD%01");
const time::milliseconds AsfStrategy::RETX_SUPPRESSION_INITIAL(10);
const time::milliseconds AsfStrategy::RETX_SUPPRESSION_MAX(250);
-NFD_REGISTER_STRATEGY(AsfStrategy);
-
AsfStrategy::AsfStrategy(Forwarder& forwarder, const Name& name)
: Strategy(forwarder, name)
, m_measurements(getMeasurements())
@@ -50,6 +48,13 @@
{
}
+const Name&
+AsfStrategy::getStrategyName()
+{
+ static Name strategyName("/localhost/nfd/strategy/asf/%FD%01");
+ return strategyName;
+}
+
void
AsfStrategy::afterReceiveInterest(const Face& inFace, const Interest& interest,
const shared_ptr<pit::Entry>& pitEntry)
diff --git a/daemon/fw/asf-strategy.hpp b/daemon/fw/asf-strategy.hpp
index 8975d6b..eb1c65c 100644
--- a/daemon/fw/asf-strategy.hpp
+++ b/daemon/fw/asf-strategy.hpp
@@ -45,7 +45,10 @@
{
public:
explicit
- AsfStrategy(Forwarder& forwarder, const Name& name = STRATEGY_NAME);
+ AsfStrategy(Forwarder& forwarder, const Name& name = getStrategyName());
+
+ static const Name&
+ getStrategyName();
public: // triggers
virtual void
@@ -77,9 +80,6 @@
void
sendNoRouteNack(const Face& inFace, const Interest& interest, const shared_ptr<pit::Entry>& pitEntry);
-public:
- static const Name STRATEGY_NAME;
-
private:
AsfMeasurements m_measurements;
ProbingModule m_probing;
diff --git a/daemon/fw/best-route-strategy.cpp b/daemon/fw/best-route-strategy.cpp
index a8877e1..b58ed88 100644
--- a/daemon/fw/best-route-strategy.cpp
+++ b/daemon/fw/best-route-strategy.cpp
@@ -29,7 +29,6 @@
namespace nfd {
namespace fw {
-const Name BestRouteStrategy::STRATEGY_NAME("ndn:/localhost/nfd/strategy/best-route/%FD%01");
NFD_REGISTER_STRATEGY(BestRouteStrategy);
BestRouteStrategy::BestRouteStrategy(Forwarder& forwarder, const Name& name)
@@ -37,6 +36,13 @@
{
}
+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)
diff --git a/daemon/fw/best-route-strategy.hpp b/daemon/fw/best-route-strategy.hpp
index b24f62e..70d975d 100644
--- a/daemon/fw/best-route-strategy.hpp
+++ b/daemon/fw/best-route-strategy.hpp
@@ -46,14 +46,14 @@
{
public:
explicit
- BestRouteStrategy(Forwarder& forwarder, const Name& name = STRATEGY_NAME);
+ BestRouteStrategy(Forwarder& forwarder, const Name& name = getStrategyName());
+
+ static const Name&
+ getStrategyName();
virtual void
afterReceiveInterest(const Face& inFace, const Interest& interest,
const shared_ptr<pit::Entry>& pitEntry) override;
-
-public:
- static const Name STRATEGY_NAME;
};
} // namespace fw
diff --git a/daemon/fw/best-route-strategy2.cpp b/daemon/fw/best-route-strategy2.cpp
index 6bb1d42..9b53b4b 100644
--- a/daemon/fw/best-route-strategy2.cpp
+++ b/daemon/fw/best-route-strategy2.cpp
@@ -31,8 +31,6 @@
namespace fw {
NFD_LOG_INIT("BestRouteStrategy2");
-
-const Name BestRouteStrategy2::STRATEGY_NAME("ndn:/localhost/nfd/strategy/best-route/%FD%04");
NFD_REGISTER_STRATEGY(BestRouteStrategy2);
const time::milliseconds BestRouteStrategy2::RETX_SUPPRESSION_INITIAL(10);
@@ -46,6 +44,13 @@
{
}
+const Name&
+BestRouteStrategy2::getStrategyName()
+{
+ static Name strategyName("/localhost/nfd/strategy/best-route/%FD%04");
+ return strategyName;
+}
+
/** \brief determines whether a NextHop is eligible
* \param inFace incoming face of current Interest
* \param interest incoming Interest
diff --git a/daemon/fw/best-route-strategy2.hpp b/daemon/fw/best-route-strategy2.hpp
index a27664f..99fc19d 100644
--- a/daemon/fw/best-route-strategy2.hpp
+++ b/daemon/fw/best-route-strategy2.hpp
@@ -53,7 +53,10 @@
{
public:
explicit
- BestRouteStrategy2(Forwarder& forwarder, const Name& name = STRATEGY_NAME);
+ BestRouteStrategy2(Forwarder& forwarder, const Name& name = getStrategyName());
+
+ static const Name&
+ getStrategyName();
virtual void
afterReceiveInterest(const Face& inFace, const Interest& interest,
@@ -63,9 +66,6 @@
afterReceiveNack(const Face& inFace, const lp::Nack& nack,
const shared_ptr<pit::Entry>& pitEntry) override;
-public:
- static const Name STRATEGY_NAME;
-
PUBLIC_WITH_TESTS_ELSE_PRIVATE:
static const time::milliseconds RETX_SUPPRESSION_INITIAL;
static const time::milliseconds RETX_SUPPRESSION_MAX;
diff --git a/daemon/fw/client-control-strategy.cpp b/daemon/fw/client-control-strategy.cpp
index 37460f9..edb98cd 100644
--- a/daemon/fw/client-control-strategy.cpp
+++ b/daemon/fw/client-control-strategy.cpp
@@ -30,8 +30,6 @@
namespace fw {
NFD_LOG_INIT("ClientControlStrategy");
-
-const Name ClientControlStrategy::STRATEGY_NAME("ndn:/localhost/nfd/strategy/client-control/%FD%02");
NFD_REGISTER_STRATEGY(ClientControlStrategy);
ClientControlStrategy::ClientControlStrategy(Forwarder& forwarder, const Name& name)
@@ -39,6 +37,13 @@
{
}
+const Name&
+ClientControlStrategy::getStrategyName()
+{
+ static Name strategyName("/localhost/nfd/strategy/client-control/%FD%02");
+ return strategyName;
+}
+
void
ClientControlStrategy::afterReceiveInterest(const Face& inFace, const Interest& interest,
const shared_ptr<pit::Entry>& pitEntry)
diff --git a/daemon/fw/client-control-strategy.hpp b/daemon/fw/client-control-strategy.hpp
index 13ffd81..e18f15b 100644
--- a/daemon/fw/client-control-strategy.hpp
+++ b/daemon/fw/client-control-strategy.hpp
@@ -38,15 +38,15 @@
{
public:
explicit
- ClientControlStrategy(Forwarder& forwarder, const Name& name = STRATEGY_NAME);
+ ClientControlStrategy(Forwarder& forwarder, const Name& name = getStrategyName());
+
+ static const Name&
+ getStrategyName();
virtual void
afterReceiveInterest(const Face& inFace, const Interest& interest,
const shared_ptr<pit::Entry>& pitEntry) override;
-public:
- static const Name STRATEGY_NAME;
-
private:
bool m_isFirstUse = true;
};
diff --git a/daemon/fw/forwarder.cpp b/daemon/fw/forwarder.cpp
index 8efc522..76e4127 100644
--- a/daemon/fw/forwarder.cpp
+++ b/daemon/fw/forwarder.cpp
@@ -38,7 +38,7 @@
static Name
getDefaultStrategyName()
{
- return fw::BestRouteStrategy2::STRATEGY_NAME;
+ return fw::BestRouteStrategy2::getStrategyName();
}
Forwarder::Forwarder()
diff --git a/daemon/fw/multicast-strategy.cpp b/daemon/fw/multicast-strategy.cpp
index 3d6e8b2..3248684 100644
--- a/daemon/fw/multicast-strategy.cpp
+++ b/daemon/fw/multicast-strategy.cpp
@@ -29,7 +29,6 @@
namespace nfd {
namespace fw {
-const Name MulticastStrategy::STRATEGY_NAME("ndn:/localhost/nfd/strategy/multicast/%FD%01");
NFD_REGISTER_STRATEGY(MulticastStrategy);
MulticastStrategy::MulticastStrategy(Forwarder& forwarder, const Name& name)
@@ -37,6 +36,13 @@
{
}
+const Name&
+MulticastStrategy::getStrategyName()
+{
+ static Name strategyName("/localhost/nfd/strategy/multicast/%FD%01");
+ return strategyName;
+}
+
void
MulticastStrategy::afterReceiveInterest(const Face& inFace, const Interest& interest,
const shared_ptr<pit::Entry>& pitEntry)
diff --git a/daemon/fw/multicast-strategy.hpp b/daemon/fw/multicast-strategy.hpp
index 2ab3f8d..e656e45 100644
--- a/daemon/fw/multicast-strategy.hpp
+++ b/daemon/fw/multicast-strategy.hpp
@@ -36,14 +36,14 @@
class MulticastStrategy : public Strategy
{
public:
- MulticastStrategy(Forwarder& forwarder, const Name& name = STRATEGY_NAME);
+ MulticastStrategy(Forwarder& forwarder, const Name& name = getStrategyName());
+
+ static const Name&
+ getStrategyName();
virtual void
afterReceiveInterest(const Face& inFace, const Interest& interest,
const shared_ptr<pit::Entry>& pitEntry) override;
-
-public:
- static const Name STRATEGY_NAME;
};
} // namespace fw
diff --git a/daemon/fw/ncc-strategy.cpp b/daemon/fw/ncc-strategy.cpp
index 650182c..0c8b53a 100644
--- a/daemon/fw/ncc-strategy.cpp
+++ b/daemon/fw/ncc-strategy.cpp
@@ -30,17 +30,23 @@
namespace nfd {
namespace fw {
-const Name NccStrategy::STRATEGY_NAME("ndn:/localhost/nfd/strategy/ncc/%FD%01");
NFD_REGISTER_STRATEGY(NccStrategy);
+const time::microseconds NccStrategy::DEFER_FIRST_WITHOUT_BEST_FACE = time::microseconds(4000);
+const time::microseconds NccStrategy::DEFER_RANGE_WITHOUT_BEST_FACE = time::microseconds(75000);
+const time::nanoseconds NccStrategy::MEASUREMENTS_LIFETIME = time::seconds(16);
+
NccStrategy::NccStrategy(Forwarder& forwarder, const Name& name)
: Strategy(forwarder, name)
{
}
-const time::microseconds NccStrategy::DEFER_FIRST_WITHOUT_BEST_FACE = time::microseconds(4000);
-const time::microseconds NccStrategy::DEFER_RANGE_WITHOUT_BEST_FACE = time::microseconds(75000);
-const time::nanoseconds NccStrategy::MEASUREMENTS_LIFETIME = time::seconds(16);
+const Name&
+NccStrategy::getStrategyName()
+{
+ static Name strategyName("/localhost/nfd/strategy/ncc/%FD%01");
+ return strategyName;
+}
void
NccStrategy::afterReceiveInterest(const Face& inFace, const Interest& interest,
diff --git a/daemon/fw/ncc-strategy.hpp b/daemon/fw/ncc-strategy.hpp
index 9403dd5..7e63333 100644
--- a/daemon/fw/ncc-strategy.hpp
+++ b/daemon/fw/ncc-strategy.hpp
@@ -37,7 +37,10 @@
{
public:
explicit
- NccStrategy(Forwarder& forwarder, const Name& name = STRATEGY_NAME);
+ NccStrategy(Forwarder& forwarder, const Name& name = getStrategyName());
+
+ static const Name&
+ getStrategyName();
virtual void
afterReceiveInterest(const Face& inFace, const Interest& interest,
@@ -128,9 +131,6 @@
void
timeoutOnBestFace(weak_ptr<pit::Entry> pitEntryWeak);
-public:
- static const Name STRATEGY_NAME;
-
protected:
static const time::microseconds DEFER_FIRST_WITHOUT_BEST_FACE;
static const time::microseconds DEFER_RANGE_WITHOUT_BEST_FACE;
diff --git a/daemon/fw/strategy.hpp b/daemon/fw/strategy.hpp
index 0bc8d9e..187f7fe 100644
--- a/daemon/fw/strategy.hpp
+++ b/daemon/fw/strategy.hpp
@@ -45,7 +45,7 @@
*/
template<typename S>
static void
- registerType(const Name& strategyName = S::STRATEGY_NAME)
+ registerType(const Name& strategyName = S::getStrategyName())
{
Registry& registry = getRegistry();
BOOST_ASSERT(registry.count(strategyName) == 0);
@@ -81,13 +81,24 @@
* and should not keep a reference themselves.
* \param name the strategy Name.
* It's recommended to include a version number as the last component.
+ * \todo #3868 name contains version and parameters as instantiated.
*/
Strategy(Forwarder& forwarder, const Name& name);
virtual
~Strategy();
- /** \return a Name that represents the strategy program
+#ifdef DOXYGEN
+ /** \return a name that represents the strategy program
+ * \todo #3868 This name contains version as given in code,
+ * which may differ from instantiated version.
+ */
+ static const Name&
+ getStrategyName();
+#endif
+
+ /** \return a name that represents the strategy program
+ * \todo #3868 This name contains version and parameters as instantiated.
*/
const Name&
getName() const