Alexander Afanasyev | d9fecdd | 2012-06-08 16:22:24 -0700 | [diff] [blame] | 1 | /* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */ |
| 2 | /* |
| 3 | * Copyright (c) 2011 University of California, Los Angeles |
| 4 | * |
| 5 | * This program is free software; you can redistribute it and/or modify |
| 6 | * it under the terms of the GNU General Public License version 2 as |
| 7 | * published by the Free Software Foundation; |
| 8 | * |
| 9 | * This program is distributed in the hope that it will be useful, |
| 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 12 | * GNU General Public License for more details. |
| 13 | * |
| 14 | * You should have received a copy of the GNU General Public License |
| 15 | * along with this program; if not, write to the Free Software |
| 16 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
| 17 | * |
Alexander Afanasyev | 9a98970 | 2012-06-29 17:44:00 -0700 | [diff] [blame] | 18 | * Author: Alexander Afanasyev <alexander.afanasyev@ucla.edu> |
| 19 | * Ilya Moiseenko <iliamo@cs.ucla.edu> |
Alexander Afanasyev | d9fecdd | 2012-06-08 16:22:24 -0700 | [diff] [blame] | 20 | */ |
| 21 | |
Alexander Afanasyev | 480e456 | 2012-06-29 17:46:47 -0700 | [diff] [blame^] | 22 | #ifndef CCNX_CONTENT_STORE_POLICIES_H |
| 23 | #define CCNX_CONTENT_STORE_POLICIES_H |
Alexander Afanasyev | d9fecdd | 2012-06-08 16:22:24 -0700 | [diff] [blame] | 24 | |
Alexander Afanasyev | 9a98970 | 2012-06-29 17:44:00 -0700 | [diff] [blame] | 25 | #include "ccnx-content-store-impl.h" |
Alexander Afanasyev | d9fecdd | 2012-06-08 16:22:24 -0700 | [diff] [blame] | 26 | |
Alexander Afanasyev | d9fecdd | 2012-06-08 16:22:24 -0700 | [diff] [blame] | 27 | #include "ccnx.h" |
| 28 | #include "ccnx-name-components-hash-helper.h" |
Alexander Afanasyev | d9fecdd | 2012-06-08 16:22:24 -0700 | [diff] [blame] | 29 | |
Alexander Afanasyev | b0c4389 | 2012-06-13 00:52:58 -0700 | [diff] [blame] | 30 | #include "../utils/trie.h" |
Alexander Afanasyev | 9a98970 | 2012-06-29 17:44:00 -0700 | [diff] [blame] | 31 | #include "../utils/trie-with-policy.h" |
| 32 | |
| 33 | #include "../utils/lru-policy.h" |
| 34 | #include "../utils/random-policy.h" |
| 35 | #include "../utils/fifo-policy.h" |
Alexander Afanasyev | b0c4389 | 2012-06-13 00:52:58 -0700 | [diff] [blame] | 36 | |
Alexander Afanasyev | d9fecdd | 2012-06-08 16:22:24 -0700 | [diff] [blame] | 37 | namespace ns3 |
| 38 | { |
Alexander Afanasyev | d9fecdd | 2012-06-08 16:22:24 -0700 | [diff] [blame] | 39 | |
| 40 | /** |
| 41 | * \ingroup ccnx |
Alexander Afanasyev | 9a98970 | 2012-06-29 17:44:00 -0700 | [diff] [blame] | 42 | * \brief Content Store with LRU replacement policy |
Alexander Afanasyev | d9fecdd | 2012-06-08 16:22:24 -0700 | [diff] [blame] | 43 | */ |
Alexander Afanasyev | 9a98970 | 2012-06-29 17:44:00 -0700 | [diff] [blame] | 44 | class CcnxContentStoreLru : |
| 45 | public CcnxContentStoreImpl< |
| 46 | trie_with_policy<CcnxNameComponents, |
| 47 | CcnxContentStoreEntry, |
| 48 | smart_pointer_payload_traits<CcnxContentStoreEntry>, |
| 49 | lru_policy_traits<CcnxNameComponents, |
| 50 | CcnxContentStoreEntry, |
| 51 | smart_pointer_payload_traits<CcnxContentStoreEntry> > > |
| 52 | > |
Alexander Afanasyev | d9fecdd | 2012-06-08 16:22:24 -0700 | [diff] [blame] | 53 | { |
| 54 | public: |
| 55 | /** |
| 56 | * \brief Interface ID |
| 57 | * |
| 58 | * \return interface ID |
| 59 | */ |
| 60 | static TypeId GetTypeId (); |
| 61 | |
| 62 | /** |
| 63 | * Default constructor |
| 64 | */ |
| 65 | CcnxContentStoreLru (); |
| 66 | virtual ~CcnxContentStoreLru (); |
| 67 | |
Alexander Afanasyev | 9a98970 | 2012-06-29 17:44:00 -0700 | [diff] [blame] | 68 | private: |
Alexander Afanasyev | d9fecdd | 2012-06-08 16:22:24 -0700 | [diff] [blame] | 69 | void |
| 70 | SetMaxSize (uint32_t maxSize); |
| 71 | |
Alexander Afanasyev | d9fecdd | 2012-06-08 16:22:24 -0700 | [diff] [blame] | 72 | uint32_t |
| 73 | GetMaxSize () const; |
Alexander Afanasyev | 9a98970 | 2012-06-29 17:44:00 -0700 | [diff] [blame] | 74 | }; |
Alexander Afanasyev | d9fecdd | 2012-06-08 16:22:24 -0700 | [diff] [blame] | 75 | |
Alexander Afanasyev | 9a98970 | 2012-06-29 17:44:00 -0700 | [diff] [blame] | 76 | |
| 77 | /** |
| 78 | * \ingroup ccnx |
| 79 | * \brief Content Store with RANDOM replacement policy |
| 80 | */ |
| 81 | class CcnxContentStoreRandom : |
| 82 | public CcnxContentStoreImpl< |
| 83 | trie_with_policy<CcnxNameComponents, |
| 84 | CcnxContentStoreEntry, |
| 85 | smart_pointer_payload_traits<CcnxContentStoreEntry>, |
| 86 | random_policy_traits<CcnxNameComponents, |
| 87 | CcnxContentStoreEntry, |
| 88 | smart_pointer_payload_traits<CcnxContentStoreEntry> > > |
| 89 | > |
| 90 | { |
| 91 | public: |
| 92 | /** |
| 93 | * \brief Interface ID |
| 94 | * |
| 95 | * \return interface ID |
| 96 | */ |
| 97 | static TypeId GetTypeId (); |
Alexander Afanasyev | d9fecdd | 2012-06-08 16:22:24 -0700 | [diff] [blame] | 98 | |
| 99 | /** |
Alexander Afanasyev | 9a98970 | 2012-06-29 17:44:00 -0700 | [diff] [blame] | 100 | * Default constructor |
Alexander Afanasyev | d9fecdd | 2012-06-08 16:22:24 -0700 | [diff] [blame] | 101 | */ |
Alexander Afanasyev | 9a98970 | 2012-06-29 17:44:00 -0700 | [diff] [blame] | 102 | CcnxContentStoreRandom (); |
| 103 | virtual ~CcnxContentStoreRandom (); |
| 104 | |
| 105 | private: |
| 106 | void |
| 107 | SetMaxSize (uint32_t maxSize); |
| 108 | |
| 109 | uint32_t |
| 110 | GetMaxSize () const; |
Alexander Afanasyev | d9fecdd | 2012-06-08 16:22:24 -0700 | [diff] [blame] | 111 | }; |
| 112 | |
Alexander Afanasyev | 9a98970 | 2012-06-29 17:44:00 -0700 | [diff] [blame] | 113 | /** |
| 114 | * \ingroup ccnx |
| 115 | * \brief Content Store with FIFO replacement policy |
| 116 | */ |
| 117 | class CcnxContentStoreFifo : |
| 118 | public CcnxContentStoreImpl< |
| 119 | trie_with_policy<CcnxNameComponents, |
| 120 | CcnxContentStoreEntry, |
| 121 | smart_pointer_payload_traits<CcnxContentStoreEntry>, |
| 122 | fifo_policy_traits<CcnxNameComponents, |
| 123 | CcnxContentStoreEntry, |
| 124 | smart_pointer_payload_traits<CcnxContentStoreEntry> > > |
| 125 | > |
| 126 | { |
| 127 | public: |
| 128 | /** |
| 129 | * \brief Interface ID |
| 130 | * |
| 131 | * \return interface ID |
| 132 | */ |
| 133 | static TypeId GetTypeId (); |
| 134 | |
| 135 | /** |
| 136 | * Default constructor |
| 137 | */ |
| 138 | CcnxContentStoreFifo (); |
| 139 | virtual ~CcnxContentStoreFifo (); |
| 140 | |
| 141 | private: |
| 142 | void |
| 143 | SetMaxSize (uint32_t maxSize); |
| 144 | |
| 145 | uint32_t |
| 146 | GetMaxSize () const; |
| 147 | }; |
| 148 | |
| 149 | |
Alexander Afanasyev | d9fecdd | 2012-06-08 16:22:24 -0700 | [diff] [blame] | 150 | } //namespace ns3 |
| 151 | |
Alexander Afanasyev | 480e456 | 2012-06-29 17:46:47 -0700 | [diff] [blame^] | 152 | #endif // CCNX_CONTENT_STORE_POLICIES_H |