blob: 5a00c18f26d2f6414898a5e6cad80a3500e187a5 [file] [log] [blame]
Junxiao Shidbe71732014-02-21 22:23:28 -07001/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2/**
3 * Copyright (C) 2014 Named Data Networking Project
4 * See COPYING for copyright and distribution information.
5 */
6
7#include "measurements-accessor.hpp"
8
9namespace nfd {
10
11MeasurementsAccessor::MeasurementsAccessor(Measurements& measurements,
12 Fib& fib, fw::Strategy* strategy)
13 : m_measurements(measurements)
14 , m_fib(fib)
15 , m_strategy(strategy)
16{
17}
18
19MeasurementsAccessor::~MeasurementsAccessor()
20{
21}
22
23shared_ptr<measurements::Entry>
24MeasurementsAccessor::filter(const shared_ptr<measurements::Entry>& entry)
25{
26 if (!static_cast<bool>(entry)) {
27 return entry;
28 }
29
30 shared_ptr<fib::Entry> fibEntry = m_fib.findLongestPrefixMatch(*entry);
31 BOOST_ASSERT(static_cast<bool>(fibEntry));
32 if (&fibEntry->getStrategy() == m_strategy) {
33 return entry;
34 }
35 return shared_ptr<measurements::Entry>();
36}
37
38} // namespace nfd