blob: cb8ee10d7f2a82a4c3314e97e13e7b4a2a59543c [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 *
Alexander Afanasyev9a989702012-06-29 17:44:00 -070018 * Author: Alexander Afanasyev <alexander.afanasyev@ucla.edu>
19 * Ilya Moiseenko <iliamo@cs.ucla.edu>
Alexander Afanasyevd9fecdd2012-06-08 16:22:24 -070020 */
21
Alexander Afanasyev480e4562012-06-29 17:46:47 -070022#ifndef CCNX_CONTENT_STORE_POLICIES_H
23#define CCNX_CONTENT_STORE_POLICIES_H
Alexander Afanasyevd9fecdd2012-06-08 16:22:24 -070024
Alexander Afanasyev9e96e362012-07-02 23:04:39 -070025// #include "ns3/ccnx.h"
Alexander Afanasyevd9fecdd2012-06-08 16:22:24 -070026
Alexander Afanasyev9e96e362012-07-02 23:04:39 -070027#include "ccnx-content-store-impl.h"
Alexander Afanasyevd9fecdd2012-06-08 16:22:24 -070028
Alexander Afanasyeve3d126f2012-07-16 17:07:31 -070029#include "../../utils/trie.h"
30#include "../../utils/trie-with-policy.h"
Alexander Afanasyev9a989702012-06-29 17:44:00 -070031
Alexander Afanasyeve3d126f2012-07-16 17:07:31 -070032#include "../../utils/lru-policy.h"
33#include "../../utils/random-policy.h"
34#include "../../utils/fifo-policy.h"
Alexander Afanasyevb0c43892012-06-13 00:52:58 -070035
Alexander Afanasyevd9fecdd2012-06-08 16:22:24 -070036namespace ns3
37{
Alexander Afanasyevd9fecdd2012-06-08 16:22:24 -070038
39/**
40 * \ingroup ccnx
Alexander Afanasyev9a989702012-06-29 17:44:00 -070041 * \brief Content Store with LRU replacement policy
Alexander Afanasyevd9fecdd2012-06-08 16:22:24 -070042 */
Alexander Afanasyev9a989702012-06-29 17:44:00 -070043class CcnxContentStoreLru :
44 public CcnxContentStoreImpl<
Alexander Afanasyev30cb1172012-07-06 10:47:39 -070045 ndnSIM::trie_with_policy<CcnxNameComponents,
46 ndnSIM::smart_pointer_payload_traits<CcnxContentStoreEntry>,
47 ndnSIM::lru_policy_traits >
Alexander Afanasyev9a989702012-06-29 17:44:00 -070048 >
Alexander Afanasyevd9fecdd2012-06-08 16:22:24 -070049{
50public:
51 /**
52 * \brief Interface ID
53 *
54 * \return interface ID
55 */
56 static TypeId GetTypeId ();
57
58 /**
59 * Default constructor
60 */
61 CcnxContentStoreLru ();
62 virtual ~CcnxContentStoreLru ();
63
Alexander Afanasyev9a989702012-06-29 17:44:00 -070064private:
Alexander Afanasyevd9fecdd2012-06-08 16:22:24 -070065 void
66 SetMaxSize (uint32_t maxSize);
67
Alexander Afanasyevd9fecdd2012-06-08 16:22:24 -070068 uint32_t
69 GetMaxSize () const;
Alexander Afanasyev9a989702012-06-29 17:44:00 -070070};
Alexander Afanasyevd9fecdd2012-06-08 16:22:24 -070071
Alexander Afanasyev9a989702012-06-29 17:44:00 -070072
73/**
74 * \ingroup ccnx
75 * \brief Content Store with RANDOM replacement policy
76 */
77class CcnxContentStoreRandom :
78 public CcnxContentStoreImpl<
Alexander Afanasyev30cb1172012-07-06 10:47:39 -070079 ndnSIM::trie_with_policy<CcnxNameComponents,
80 ndnSIM::smart_pointer_payload_traits<CcnxContentStoreEntry>,
81 ndnSIM::random_policy_traits >
Alexander Afanasyev9a989702012-06-29 17:44:00 -070082 >
83{
84public:
85 /**
86 * \brief Interface ID
87 *
88 * \return interface ID
89 */
90 static TypeId GetTypeId ();
Alexander Afanasyevd9fecdd2012-06-08 16:22:24 -070091
92 /**
Alexander Afanasyev9a989702012-06-29 17:44:00 -070093 * Default constructor
Alexander Afanasyevd9fecdd2012-06-08 16:22:24 -070094 */
Alexander Afanasyev9a989702012-06-29 17:44:00 -070095 CcnxContentStoreRandom ();
96 virtual ~CcnxContentStoreRandom ();
97
98private:
99 void
100 SetMaxSize (uint32_t maxSize);
101
102 uint32_t
103 GetMaxSize () const;
Alexander Afanasyevd9fecdd2012-06-08 16:22:24 -0700104};
105
Alexander Afanasyev9a989702012-06-29 17:44:00 -0700106/**
107 * \ingroup ccnx
108 * \brief Content Store with FIFO replacement policy
109 */
110class CcnxContentStoreFifo :
111 public CcnxContentStoreImpl<
Alexander Afanasyev30cb1172012-07-06 10:47:39 -0700112 ndnSIM::trie_with_policy<CcnxNameComponents,
113 ndnSIM::smart_pointer_payload_traits<CcnxContentStoreEntry>,
114 ndnSIM::fifo_policy_traits >
Alexander Afanasyev9a989702012-06-29 17:44:00 -0700115 >
116{
117public:
118 /**
119 * \brief Interface ID
120 *
121 * \return interface ID
122 */
123 static TypeId GetTypeId ();
124
125 /**
126 * Default constructor
127 */
128 CcnxContentStoreFifo ();
129 virtual ~CcnxContentStoreFifo ();
130
131private:
132 void
133 SetMaxSize (uint32_t maxSize);
134
135 uint32_t
136 GetMaxSize () const;
137};
138
139
Alexander Afanasyevd9fecdd2012-06-08 16:22:24 -0700140} //namespace ns3
141
Alexander Afanasyev480e4562012-06-29 17:46:47 -0700142#endif // CCNX_CONTENT_STORE_POLICIES_H