blob: 4e37aad9bbfc931d1a398228750dae7049528477 [file] [log] [blame]
Minsheng Zhangcb6e05f2015-04-20 15:51:47 -05001/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2/**
Minsheng Zhangffe8bbb2016-03-10 13:40:37 -07003 * Copyright (c) 2014-2016, Regents of the University of California,
Minsheng Zhangcb6e05f2015-04-20 15:51:47 -05004 * Arizona Board of Regents,
5 * Colorado State University,
6 * University Pierre & Marie Curie, Sorbonne University,
7 * Washington University in St. Louis,
8 * Beijing Institute of Technology,
9 * The University of Memphis.
10 *
11 * This file is part of NFD (Named Data Networking Forwarding Daemon).
12 * See AUTHORS.md for complete list of NFD authors and contributors.
13 *
14 * NFD is free software: you can redistribute it and/or modify it under the terms
15 * of the GNU General Public License as published by the Free Software Foundation,
16 * either version 3 of the License, or (at your option) any later version.
17 *
18 * NFD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
19 * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
20 * PURPOSE. See the GNU General Public License for more details.
21 *
22 * You should have received a copy of the GNU General Public License along with
23 * NFD, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
24 */
25
26#include "cs-policy.hpp"
27#include "cs.hpp"
Junxiao Shi2af9ca32016-08-25 21:51:02 +000028#include "core/logger.hpp"
29
30NFD_LOG_INIT("CsPolicy");
Minsheng Zhangcb6e05f2015-04-20 15:51:47 -050031
32namespace nfd {
33namespace cs {
34
35Policy::Policy(const std::string& policyName)
36 : m_policyName(policyName)
37{
38}
39
Minsheng Zhangcb6e05f2015-04-20 15:51:47 -050040void
41Policy::setLimit(size_t nMaxEntries)
42{
Junxiao Shi2af9ca32016-08-25 21:51:02 +000043 NFD_LOG_INFO("setLimit " << nMaxEntries);
Minsheng Zhangcb6e05f2015-04-20 15:51:47 -050044 m_limit = nMaxEntries;
Minsheng Zhangcb6e05f2015-04-20 15:51:47 -050045 this->evictEntries();
46}
47
48void
49Policy::afterInsert(iterator i)
50{
51 BOOST_ASSERT(m_cs != nullptr);
52 this->doAfterInsert(i);
53}
54
55void
56Policy::afterRefresh(iterator i)
57{
58 BOOST_ASSERT(m_cs != nullptr);
59 this->doAfterRefresh(i);
60}
61
62void
63Policy::beforeErase(iterator i)
64{
65 BOOST_ASSERT(m_cs != nullptr);
66 this->doBeforeErase(i);
67}
68
69void
70Policy::beforeUse(iterator i)
71{
72 BOOST_ASSERT(m_cs != nullptr);
73 this->doBeforeUse(i);
74}
75
76} // namespace cs
77} // namespace nfd