NS-3 based Named Data Networking (NDN) simulator
ndnSIM 2.0: 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 #include "common.hpp"
31 
32 #include <boost/multi_index_container.hpp>
33 #include <boost/multi_index/sequenced_index.hpp>
34 #include <boost/multi_index/hashed_index.hpp>
35 
36 namespace nfd {
37 namespace cs {
38 namespace lru {
39 
41 {
42  bool
43  operator()(const iterator& a, const iterator& b) const
44  {
45  return *a < *b;
46  }
47 };
48 
49 typedef boost::multi_index_container<
50  iterator,
51  boost::multi_index::indexed_by<
52  boost::multi_index::sequenced<>,
53  boost::multi_index::ordered_unique<
54  boost::multi_index::identity<iterator>, EntryItComparator
55  >
56  >
57  > Queue;
58 
65 class LruPolicy : public Policy
66 {
67 public:
68  LruPolicy();
69 
70 public:
71  static const std::string POLICY_NAME;
72 
73 private:
74  virtual void
75  doAfterInsert(iterator i) DECL_OVERRIDE;
76 
77  virtual void
78  doAfterRefresh(iterator i) DECL_OVERRIDE;
79 
80  virtual void
81  doBeforeErase(iterator i) DECL_OVERRIDE;
82 
83  virtual void
84  doBeforeUse(iterator i) DECL_OVERRIDE;
85 
86  virtual void
87  evictEntries() DECL_OVERRIDE;
88 
89 private:
92  void
93  insertToQueue(iterator i, bool isNewEntry);
94 
95 private:
96  Queue m_queue;
97 };
98 
99 } // namespace lru
100 
101 using lru::LruPolicy;
102 
103 } // namespace cs
104 } // namespace nfd
105 
106 #endif // NFD_DAEMON_TABLE_CS_POLICY_LRU_HPP
#define DECL_OVERRIDE
expands to &#39;override&#39; if compiler supports this feature, otherwise expands to nothing ...
Definition: common.hpp:49
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:38
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
bool operator()(const iterator &a, const iterator &b) const
LRU cs replacement policy.
static const std::string POLICY_NAME