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 | dbe7173 | 2014-02-21 22:23:28 -0700 | [diff] [blame] | 8 | |
| 9 | namespace nfd { |
| 10 | |
Junxiao Shi | 7bb0151 | 2014-03-05 21:34:09 -0700 | [diff] [blame] | 11 | using fw::Strategy; |
| 12 | |
Junxiao Shi | dbe7173 | 2014-02-21 22:23:28 -0700 | [diff] [blame] | 13 | MeasurementsAccessor::MeasurementsAccessor(Measurements& measurements, |
Junxiao Shi | 7bb0151 | 2014-03-05 21:34:09 -0700 | [diff] [blame] | 14 | StrategyChoice& strategyChoice, |
| 15 | Strategy* strategy) |
Junxiao Shi | dbe7173 | 2014-02-21 22:23:28 -0700 | [diff] [blame] | 16 | : m_measurements(measurements) |
Junxiao Shi | 7bb0151 | 2014-03-05 21:34:09 -0700 | [diff] [blame] | 17 | , m_strategyChoice(strategyChoice) |
Junxiao Shi | dbe7173 | 2014-02-21 22:23:28 -0700 | [diff] [blame] | 18 | , m_strategy(strategy) |
| 19 | { |
| 20 | } |
| 21 | |
| 22 | MeasurementsAccessor::~MeasurementsAccessor() |
| 23 | { |
| 24 | } |
| 25 | |
| 26 | shared_ptr<measurements::Entry> |
| 27 | MeasurementsAccessor::filter(const shared_ptr<measurements::Entry>& entry) |
| 28 | { |
| 29 | if (!static_cast<bool>(entry)) { |
| 30 | return entry; |
| 31 | } |
| 32 | |
Junxiao Shi | 7bb0151 | 2014-03-05 21:34:09 -0700 | [diff] [blame] | 33 | Strategy& effectiveStrategy = m_strategyChoice.findEffectiveStrategy(*entry); |
| 34 | if (&effectiveStrategy == m_strategy) { |
Junxiao Shi | dbe7173 | 2014-02-21 22:23:28 -0700 | [diff] [blame] | 35 | return entry; |
| 36 | } |
| 37 | return shared_ptr<measurements::Entry>(); |
| 38 | } |
| 39 | |
| 40 | } // namespace nfd |