NS-3 based Named Data Networking (NDN) simulator
ndnSIM 2.3: NDN, CCN, CCNx, content centric networks
API Documentation
cs-policy-lru.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_LRU_HPP
27 #define NFD_DAEMON_TABLE_CS_POLICY_LRU_HPP
28 
29 #include "cs-policy.hpp"
30 
31 #include <boost/multi_index_container.hpp>
32 #include <boost/multi_index/sequenced_index.hpp>
33 #include <boost/multi_index/hashed_index.hpp>
34 
35 namespace nfd {
36 namespace cs {
37 namespace lru {
38 
40 {
41  bool
42  operator()(const iterator& a, const iterator& b) const
43  {
44  return *a < *b;
45  }
46 };
47 
48 typedef boost::multi_index_container<
49  iterator,
50  boost::multi_index::indexed_by<
51  boost::multi_index::sequenced<>,
52  boost::multi_index::ordered_unique<
53  boost::multi_index::identity<iterator>, EntryItComparator
54  >
55  >
56  > Queue;
57 
64 class LruPolicy : public Policy
65 {
66 public:
67  LruPolicy();
68 
69 public:
70  static const std::string POLICY_NAME;
71 
72 private:
73  virtual void
74  doAfterInsert(iterator i) override;
75 
76  virtual void
77  doAfterRefresh(iterator i) override;
78 
79  virtual void
80  doBeforeErase(iterator i) override;
81 
82  virtual void
83  doBeforeUse(iterator i) override;
84 
85  virtual void
86  evictEntries() override;
87 
88 private:
91  void
92  insertToQueue(iterator i, bool isNewEntry);
93 
94 private:
95  Queue m_queue;
96 };
97 
98 } // namespace lru
99 
100 using lru::LruPolicy;
101 
102 } // namespace cs
103 } // namespace nfd
104 
105 #endif // NFD_DAEMON_TABLE_CS_POLICY_LRU_HPP
bool operator()(const iterator &a, const iterator &b) const
Table::const_iterator iterator
Definition: cs-internal.hpp:41
represents a CS replacement policy
Definition: cs-policy.hpp:39
Copyright (c) 2011-2015 Regents of the University of California.
Definition: ndn-common.hpp:40
boost::multi_index_container< iterator, boost::multi_index::indexed_by< boost::multi_index::sequenced<>, boost::multi_index::ordered_unique< boost::multi_index::identity< iterator >, EntryItComparator > > > Queue
LRU cs replacement policy.
static const std::string POLICY_NAME