blob: 97a913b0a888c5b459e104c8c780bafeeb76aa20 [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"
Junxiao Shi2d9bdc82014-03-02 20:55:42 -07008#include "fw/strategy.hpp"
Junxiao Shidbe71732014-02-21 22:23:28 -07009
10namespace nfd {
11
12MeasurementsAccessor::MeasurementsAccessor(Measurements& measurements,
13 Fib& fib, fw::Strategy* strategy)
14 : m_measurements(measurements)
15 , m_fib(fib)
16 , m_strategy(strategy)
17{
18}
19
20MeasurementsAccessor::~MeasurementsAccessor()
21{
22}
23
24shared_ptr<measurements::Entry>
25MeasurementsAccessor::filter(const shared_ptr<measurements::Entry>& entry)
26{
27 if (!static_cast<bool>(entry)) {
28 return entry;
29 }
30
31 shared_ptr<fib::Entry> fibEntry = m_fib.findLongestPrefixMatch(*entry);
32 BOOST_ASSERT(static_cast<bool>(fibEntry));
33 if (&fibEntry->getStrategy() == m_strategy) {
34 return entry;
35 }
36 return shared_ptr<measurements::Entry>();
37}
38
39} // namespace nfd