blob: 277290a414cd41b8005b2e440a6e9381dff4f284 [file] [log] [blame]
Alexander Afanasyevd9fecdd2012-06-08 16:22:24 -07001/* -*- 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 Afanasyevd9fecdd2012-06-08 16:22:24 -070026#include "ccnx.h"
27#include "ccnx-name-components-hash-helper.h"
Alexander Afanasyevd9fecdd2012-06-08 16:22:24 -070028
Alexander Afanasyevb0c43892012-06-13 00:52:58 -070029#include "../utils/trie.h"
30
Alexander Afanasyevd9fecdd2012-06-08 16:22:24 -070031namespace ns3
32{
33/**
34 * \ingroup ccnx
Alexander Afanasyevb0c43892012-06-13 00:52:58 -070035 * \brief Typedef for content store container implemented as trie with configurable replacement policy
Alexander Afanasyevd9fecdd2012-06-08 16:22:24 -070036 */
Alexander Afanasyevb0c43892012-06-13 00:52:58 -070037typedef 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 Afanasyevd9fecdd2012-06-08 16:22:24 -070042
43/**
44 * \ingroup ccnx
45 * \brief NDN content store entry
46 */
47class CcnxContentStoreLru : public CcnxContentStore
48{
49public:
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
89private:
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 Afanasyevb0c43892012-06-13 00:52:58 -070096 CcnxContentStoreLruContainer m_contentStore;
Alexander Afanasyevd9fecdd2012-06-08 16:22:24 -070097};
98
99} //namespace ns3
100
101#endif // CCNX_CONTENT_STORE_LRU_H