Junxiao Shi | dbe7173 | 2014-02-21 22:23:28 -0700 | [diff] [blame] | 1 | /* -*- 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 | |
| 9 | namespace nfd { |
| 10 | |
| 11 | MeasurementsAccessor::MeasurementsAccessor(Measurements& measurements, |
| 12 | Fib& fib, fw::Strategy* strategy) |
| 13 | : m_measurements(measurements) |
| 14 | , m_fib(fib) |
| 15 | , m_strategy(strategy) |
| 16 | { |
| 17 | } |
| 18 | |
| 19 | MeasurementsAccessor::~MeasurementsAccessor() |
| 20 | { |
| 21 | } |
| 22 | |
| 23 | shared_ptr<measurements::Entry> |
| 24 | MeasurementsAccessor::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 |