table: Strategy Choice table
refs #1309
Change-Id: I6fd8efdfc98175a1cc39fdc3aa7175671596f470
diff --git a/daemon/fw/best-route-strategy.cpp b/daemon/fw/best-route-strategy.cpp
index d60411f..19458e9 100644
--- a/daemon/fw/best-route-strategy.cpp
+++ b/daemon/fw/best-route-strategy.cpp
@@ -10,7 +10,7 @@
namespace fw {
BestRouteStrategy::BestRouteStrategy(Forwarder& forwarder)
- : Strategy(forwarder)
+ : Strategy(forwarder, "ndn:/localhost/nfd/strategy/best-route")
{
}
diff --git a/daemon/fw/broadcast-strategy.cpp b/daemon/fw/broadcast-strategy.cpp
index 49d0ef6..4cc4e5f 100644
--- a/daemon/fw/broadcast-strategy.cpp
+++ b/daemon/fw/broadcast-strategy.cpp
@@ -10,7 +10,7 @@
namespace fw {
BroadcastStrategy::BroadcastStrategy(Forwarder& forwarder)
- : Strategy(forwarder)
+ : Strategy(forwarder, "ndn:/localhost/nfd/strategy/broadcast")
{
}
diff --git a/daemon/fw/forwarder.cpp b/daemon/fw/forwarder.cpp
index b32041e..6c9f3ce 100644
--- a/daemon/fw/forwarder.cpp
+++ b/daemon/fw/forwarder.cpp
@@ -20,6 +20,7 @@
, m_fib(m_nameTree)
, m_pit(m_nameTree)
, m_measurements(m_nameTree)
+ , m_strategyChoice(m_nameTree, make_shared<fw::BestRouteStrategy>(boost::ref(*this)))
{
m_strategy = make_shared<fw::BestRouteStrategy>(boost::ref(*this));
}
diff --git a/daemon/fw/forwarder.hpp b/daemon/fw/forwarder.hpp
index 726d8a0..7ab0849 100644
--- a/daemon/fw/forwarder.hpp
+++ b/daemon/fw/forwarder.hpp
@@ -14,6 +14,7 @@
#include "table/pit.hpp"
#include "table/cs.hpp"
#include "table/measurements.hpp"
+#include "table/strategy-choice.hpp"
#include "strategy.hpp"
namespace nfd {
@@ -72,6 +73,9 @@
Measurements&
getMeasurements();
+ StrategyChoice&
+ getStrategyChoice();
+
PUBLIC_WITH_TESTS_ELSE_PRIVATE: // pipelines
/** \brief incoming Interest pipeline
*/
@@ -133,11 +137,14 @@
private:
FaceTable m_faceTable;
- NameTree m_nameTree;
- Fib m_fib;
- Pit m_pit;
- Cs m_cs;
- Measurements m_measurements;
+ // tables
+ NameTree m_nameTree;
+ Fib m_fib;
+ Pit m_pit;
+ Cs m_cs;
+ Measurements m_measurements;
+ StrategyChoice m_strategyChoice;
+
/// the active strategy (only one strategy in mock)
shared_ptr<fw::Strategy> m_strategy;
@@ -207,6 +214,11 @@
return m_measurements;
}
+inline StrategyChoice&
+Forwarder::getStrategyChoice()
+{
+ return m_strategyChoice;
+}
} // namespace nfd
diff --git a/daemon/fw/ncc-strategy.cpp b/daemon/fw/ncc-strategy.cpp
index d08260c..101e847 100644
--- a/daemon/fw/ncc-strategy.cpp
+++ b/daemon/fw/ncc-strategy.cpp
@@ -10,7 +10,7 @@
namespace fw {
NccStrategy::NccStrategy(Forwarder& forwarder)
- : Strategy(forwarder)
+ : Strategy(forwarder, "ndn:/localhost/nfd/strategy/ncc")
{
}
diff --git a/daemon/fw/strategy.cpp b/daemon/fw/strategy.cpp
index 09268a8..fbb2b4a 100644
--- a/daemon/fw/strategy.cpp
+++ b/daemon/fw/strategy.cpp
@@ -13,8 +13,9 @@
NFD_LOG_INIT("Strategy");
-Strategy::Strategy(Forwarder& forwarder)
- : m_forwarder(forwarder)
+Strategy::Strategy(Forwarder& forwarder, const Name& name)
+ : m_name(name)
+ , m_forwarder(forwarder)
, m_measurements(m_forwarder.getMeasurements(), m_forwarder.getFib(), this)
{
}
diff --git a/daemon/fw/strategy.hpp b/daemon/fw/strategy.hpp
index edffdb3..df4c946 100644
--- a/daemon/fw/strategy.hpp
+++ b/daemon/fw/strategy.hpp
@@ -18,18 +18,20 @@
namespace fw {
-/** \class Strategy
- * \brief represents a forwarding strategy
+/** \brief represents a forwarding strategy
*/
-class Strategy
+class Strategy : public enable_shared_from_this<Strategy>, noncopyable
{
public:
- explicit
- Strategy(Forwarder& forwarder);
+ Strategy(Forwarder& forwarder, const Name& name);
virtual
~Strategy();
+ /// a Name that represent the Strategy program
+ const Name&
+ getName() const;
+
public: // triggers
/** \brief trigger after Interest is received
*
@@ -113,6 +115,8 @@
getMeasurements();
private:
+ Name m_name;
+
/** \brief reference to the forwarder
*
* Triggers can access forwarder indirectly via actions.
@@ -122,6 +126,12 @@
MeasurementsAccessor m_measurements;
};
+inline const Name&
+Strategy::getName() const
+{
+ return m_name;
+}
+
inline MeasurementsAccessor&
Strategy::getMeasurements()
{