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 | * |
| 18 | * Author: Ilya Moiseenko <iliamo@cs.ucla.edu> |
| 19 | */ |
| 20 | |
| 21 | #ifndef CCNX_CONTENT_STORE_LRU_H |
| 22 | #define CCNX_CONTENT_STORE_LRU_H |
| 23 | |
| 24 | #include "ccnx-content-store.h" |
| 25 | |
Alexander Afanasyev | d9fecdd | 2012-06-08 16:22:24 -0700 | [diff] [blame] | 26 | #include "ccnx.h" |
| 27 | #include "ccnx-name-components-hash-helper.h" |
Alexander Afanasyev | d9fecdd | 2012-06-08 16:22:24 -0700 | [diff] [blame] | 28 | |
Alexander Afanasyev | b0c4389 | 2012-06-13 00:52:58 -0700 | [diff] [blame] | 29 | #include "../utils/trie.h" |
| 30 | |
Alexander Afanasyev | d9fecdd | 2012-06-08 16:22:24 -0700 | [diff] [blame] | 31 | namespace ns3 |
| 32 | { |
| 33 | /** |
| 34 | * \ingroup ccnx |
Alexander Afanasyev | b0c4389 | 2012-06-13 00:52:58 -0700 | [diff] [blame] | 35 | * \brief Typedef for content store container implemented as trie with configurable replacement policy |
Alexander Afanasyev | d9fecdd | 2012-06-08 16:22:24 -0700 | [diff] [blame] | 36 | */ |
Alexander Afanasyev | b0c4389 | 2012-06-13 00:52:58 -0700 | [diff] [blame] | 37 | typedef indexed_trie<CcnxNameComponents, |
| 38 | CcnxContentStoreEntry, smart_pointer_payload_traits<CcnxContentStoreEntry>, |
| 39 | lru_policy_traits<CcnxNameComponents, |
| 40 | CcnxContentStoreEntry, |
| 41 | smart_pointer_payload_traits<CcnxContentStoreEntry> > > CcnxContentStoreLruContainer; |
Alexander Afanasyev | d9fecdd | 2012-06-08 16:22:24 -0700 | [diff] [blame] | 42 | |
| 43 | /** |
| 44 | * \ingroup ccnx |
| 45 | * \brief NDN content store entry |
| 46 | */ |
| 47 | class CcnxContentStoreLru : public CcnxContentStore |
| 48 | { |
| 49 | public: |
| 50 | /** |
| 51 | * \brief Interface ID |
| 52 | * |
| 53 | * \return interface ID |
| 54 | */ |
| 55 | static TypeId GetTypeId (); |
| 56 | |
| 57 | /** |
| 58 | * Default constructor |
| 59 | */ |
| 60 | CcnxContentStoreLru (); |
| 61 | virtual ~CcnxContentStoreLru (); |
| 62 | |
| 63 | /** |
| 64 | * \brief Set maximum size of content store |
| 65 | * |
| 66 | * \param size size in packets |
| 67 | */ |
| 68 | void |
| 69 | SetMaxSize (uint32_t maxSize); |
| 70 | |
| 71 | /** |
| 72 | * \brief Get maximum size of content store |
| 73 | * |
| 74 | * \returns size in packets |
| 75 | */ |
| 76 | uint32_t |
| 77 | GetMaxSize () const; |
| 78 | |
| 79 | // from CcnxContentStore |
| 80 | virtual boost::tuple<Ptr<Packet>, Ptr<const CcnxContentObjectHeader>, Ptr<const Packet> > |
| 81 | Lookup (Ptr<const CcnxInterestHeader> interest); |
| 82 | |
| 83 | virtual bool |
| 84 | Add (Ptr<CcnxContentObjectHeader> header, Ptr<const Packet> packet); |
| 85 | |
| 86 | virtual void |
| 87 | Print () const; |
| 88 | |
| 89 | private: |
| 90 | size_t m_maxSize; ///< \brief maximum number of entries in cache |
| 91 | |
| 92 | /** |
| 93 | * \brief Content store implemented as a Boost.MultiIndex container |
| 94 | * \internal |
| 95 | */ |
Alexander Afanasyev | b0c4389 | 2012-06-13 00:52:58 -0700 | [diff] [blame] | 96 | CcnxContentStoreLruContainer m_contentStore; |
Alexander Afanasyev | d9fecdd | 2012-06-08 16:22:24 -0700 | [diff] [blame] | 97 | }; |
| 98 | |
| 99 | } //namespace ns3 |
| 100 | |
| 101 | #endif // CCNX_CONTENT_STORE_LRU_H |