table: MeasurementsAccessor for strategy
refs #1276
Change-Id: Idec8f615c726f51612236a55a7532fabeb81a32d
diff --git a/daemon/table/measurements-accessor.cpp b/daemon/table/measurements-accessor.cpp
new file mode 100644
index 0000000..5a00c18
--- /dev/null
+++ b/daemon/table/measurements-accessor.cpp
@@ -0,0 +1,38 @@
+/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
+/**
+ * Copyright (C) 2014 Named Data Networking Project
+ * See COPYING for copyright and distribution information.
+ */
+
+#include "measurements-accessor.hpp"
+
+namespace nfd {
+
+MeasurementsAccessor::MeasurementsAccessor(Measurements& measurements,
+ Fib& fib, fw::Strategy* strategy)
+ : m_measurements(measurements)
+ , m_fib(fib)
+ , m_strategy(strategy)
+{
+}
+
+MeasurementsAccessor::~MeasurementsAccessor()
+{
+}
+
+shared_ptr<measurements::Entry>
+MeasurementsAccessor::filter(const shared_ptr<measurements::Entry>& entry)
+{
+ if (!static_cast<bool>(entry)) {
+ return entry;
+ }
+
+ shared_ptr<fib::Entry> fibEntry = m_fib.findLongestPrefixMatch(*entry);
+ BOOST_ASSERT(static_cast<bool>(fibEntry));
+ if (&fibEntry->getStrategy() == m_strategy) {
+ return entry;
+ }
+ return shared_ptr<measurements::Entry>();
+}
+
+} // namespace nfd