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