NS-3 based Named Data Networking (NDN) simulator
ndnSIM 2.0: NDN, CCN, CCNx, content centric networks
API Documentation
cs-policy.hpp
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
26 #ifndef NFD_DAEMON_TABLE_CS_POLICY_HPP
27 #define NFD_DAEMON_TABLE_CS_POLICY_HPP
28 
29 #include "cs-internal.hpp"
30 #include "cs-entry-impl.hpp"
31 
32 namespace nfd {
33 namespace cs {
34 
35 class Cs;
36 
39 class Policy : noncopyable
40 {
41 public:
42  explicit
43  Policy(const std::string& policyName);
44 
45  virtual
46  ~Policy();
47 
48  const std::string&
49  getName() const;
50 
51 public:
54  Cs*
55  getCs() const;
56 
59  void
60  setCs(Cs *cs);
61 
64  size_t
65  getLimit() const;
66 
73  void
74  setLimit(size_t nMaxEntries);
75 
82 
89  void
91 
96  void
98 
102  void
104 
109  void
110  beforeUse(iterator i);
111 
112 protected:
121  virtual void
122  doAfterInsert(iterator i) = 0;
123 
129  virtual void
130  doAfterRefresh(iterator i) = 0;
131 
138  virtual void
139  doBeforeErase(iterator i) = 0;
140 
146  virtual void
147  doBeforeUse(iterator i) = 0;
148 
152  virtual void
153  evictEntries() = 0;
154 
155 protected:
156  DECLARE_SIGNAL_EMIT(beforeEvict)
157 
158 private:
159  std::string m_policyName;
160  size_t m_limit;
161  Cs* m_cs;
162 };
163 
164 inline const std::string&
165 Policy::getName() const
166 {
167  return m_policyName;
168 }
169 
170 inline Cs*
172 {
173  return m_cs;
174 }
175 
176 inline void
178 {
179  m_cs = cs;
180 }
181 
182 inline size_t
184 {
185  return m_limit;
186 }
187 
188 } // namespace cs
189 } // namespace nfd
190 
191 #endif // NFD_DAEMON_TABLE_CS_POLICY_HPP
void setCs(Cs *cs)
sets cs
Definition: cs-policy.hpp:177
virtual void evictEntries()=0
evicts zero or more entries
void setLimit(size_t nMaxEntries)
sets hard limit (in number of entries)
Definition: cs-policy.cpp:42
signal::Signal< Policy, iterator > beforeEvict
emits when an entry is being evicted
Definition: cs-policy.hpp:81
virtual void doAfterRefresh(iterator i)=0
invoked after an existing entry is refreshed by same Data
virtual void doBeforeUse(iterator i)=0
invoked before an entry is used to match a lookup
STL namespace.
virtual ~Policy()
Definition: cs-policy.cpp:37
Copyright (c) 2014-2015, Regents of the University of California, Arizona Board of Regents...
provides a lightweight signal / event system
Table::const_iterator iterator
Definition: cs-internal.hpp:41
represents a CS replacement policy
Definition: cs-policy.hpp:39
const std::string & getName() const
Definition: cs-policy.hpp:165
void beforeErase(iterator i)
invoked by CS before an entry is erased due to management command
Definition: cs-policy.cpp:65
Copyright (c) 2011-2015 Regents of the University of California.
Definition: ndn-common.hpp:38
void beforeUse(iterator i)
invoked by CS before an entry is used to match a lookup
Definition: cs-policy.cpp:72
virtual void doBeforeErase(iterator i)=0
invoked before an entry is erased due to management command
#define DECLARE_SIGNAL_EMIT(signalName)
(implementation detail) declares a &#39;emit_signalName&#39; method
Definition: signal-emit.hpp:59
size_t getLimit() const
gets hard limit (in number of entries)
Definition: cs-policy.hpp:183
represents the ContentStore
Definition: cs.hpp:65
void afterInsert(iterator i)
invoked by CS after a new entry is inserted
Definition: cs-policy.cpp:51
virtual void doAfterInsert(iterator i)=0
invoked after a new entry is created in CS
Cs * getCs() const
gets cs
Definition: cs-policy.hpp:171
Policy(const std::string &policyName)
Definition: cs-policy.cpp:32
void afterRefresh(iterator i)
invoked by CS after an existing entry is refreshed by same Data
Definition: cs-policy.cpp:58