cs-policy.cpp
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
26 #include "cs-policy.hpp"
27 #include "cs.hpp"
28 #include "core/logger.hpp"
29 
30 NFD_LOG_INIT("CsPolicy");
31 
32 namespace nfd {
33 namespace cs {
34 
35 Policy::Policy(const std::string& policyName)
36  : m_policyName(policyName)
37 {
38 }
39 
40 void
41 Policy::setLimit(size_t nMaxEntries)
42 {
43  NFD_LOG_INFO("setLimit " << nMaxEntries);
44  m_limit = nMaxEntries;
45  this->evictEntries();
46 }
47 
48 void
50 {
51  BOOST_ASSERT(m_cs != nullptr);
52  this->doAfterInsert(i);
53 }
54 
55 void
57 {
58  BOOST_ASSERT(m_cs != nullptr);
59  this->doAfterRefresh(i);
60 }
61 
62 void
64 {
65  BOOST_ASSERT(m_cs != nullptr);
66  this->doBeforeErase(i);
67 }
68 
69 void
71 {
72  BOOST_ASSERT(m_cs != nullptr);
73  this->doBeforeUse(i);
74 }
75 
76 } // namespace cs
77 } // namespace nfd
Copyright (c) 2014-2016, Regents of the University of California, Arizona Board of Regents...
void beforeUse(iterator i)
invoked by CS before an entry is used to match a lookup
Definition: cs-policy.cpp:70
void beforeErase(iterator i)
invoked by CS before an entry is erased due to management command
Definition: cs-policy.cpp:63
void afterRefresh(iterator i)
invoked by CS after an existing entry is refreshed by same Data
Definition: cs-policy.cpp:56
void afterInsert(iterator i)
invoked by CS after a new entry is inserted
Definition: cs-policy.cpp:49
virtual void doBeforeErase(iterator i)=0
invoked before an entry is erased due to management command
virtual void doAfterRefresh(iterator i)=0
invoked after an existing entry is refreshed by same Data
Table::const_iterator iterator
Definition: cs-internal.hpp:41
#define NFD_LOG_INFO(expression)
Definition: logger.hpp:162
virtual void evictEntries()=0
evicts zero or more entries
Copyright (c) 2014-2015, Regents of the University of California, Arizona Board of Regents...
Definition: algorithm.hpp:32
virtual void doAfterInsert(iterator i)=0
invoked after a new entry is created in CS
#define NFD_LOG_INIT(name)
Definition: logger.hpp:122
virtual void doBeforeUse(iterator i)=0
invoked before an entry is used to match a lookup
void setLimit(size_t nMaxEntries)
sets hard limit (in number of entries)
Definition: cs-policy.cpp:41
Policy(const std::string &policyName)
Definition: cs-policy.cpp:35