blob: d1f08de6ba65ee253aed4f3a0bead4d7cf06335b [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 Shidbe71732014-02-21 22:23:28 -07008
9namespace nfd {
10
Junxiao Shi7bb01512014-03-05 21:34:09 -070011using fw::Strategy;
12
Junxiao Shidbe71732014-02-21 22:23:28 -070013MeasurementsAccessor::MeasurementsAccessor(Measurements& measurements,
Junxiao Shi7bb01512014-03-05 21:34:09 -070014 StrategyChoice& strategyChoice,
15 Strategy* strategy)
Junxiao Shidbe71732014-02-21 22:23:28 -070016 : m_measurements(measurements)
Junxiao Shi7bb01512014-03-05 21:34:09 -070017 , m_strategyChoice(strategyChoice)
Junxiao Shidbe71732014-02-21 22:23:28 -070018 , m_strategy(strategy)
19{
20}
21
22MeasurementsAccessor::~MeasurementsAccessor()
23{
24}
25
26shared_ptr<measurements::Entry>
27MeasurementsAccessor::filter(const shared_ptr<measurements::Entry>& entry)
28{
29 if (!static_cast<bool>(entry)) {
30 return entry;
31 }
32
Junxiao Shi7bb01512014-03-05 21:34:09 -070033 Strategy& effectiveStrategy = m_strategyChoice.findEffectiveStrategy(*entry);
34 if (&effectiveStrategy == m_strategy) {
Junxiao Shidbe71732014-02-21 22:23:28 -070035 return entry;
36 }
37 return shared_ptr<measurements::Entry>();
38}
39
40} // namespace nfd