blob: 4b3a3835e5016cfd4995c4743e5fcc06ff11d4b0 [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 Afanasyev9a989702012-06-29 17:44:00 -070025#include "ccnx-content-store-impl.h"
Alexander Afanasyevd9fecdd2012-06-08 16:22:24 -070026
Alexander Afanasyevd9fecdd2012-06-08 16:22:24 -070027#include "ccnx.h"
28#include "ccnx-name-components-hash-helper.h"
Alexander Afanasyevd9fecdd2012-06-08 16:22:24 -070029
Alexander Afanasyevb0c43892012-06-13 00:52:58 -070030#include "../utils/trie.h"
Alexander Afanasyev9a989702012-06-29 17:44:00 -070031#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 Afanasyevb0c43892012-06-13 00:52:58 -070036
Alexander Afanasyevd9fecdd2012-06-08 16:22:24 -070037namespace ns3
38{
Alexander Afanasyevd9fecdd2012-06-08 16:22:24 -070039
40/**
41 * \ingroup ccnx
Alexander Afanasyev9a989702012-06-29 17:44:00 -070042 * \brief Content Store with LRU replacement policy
Alexander Afanasyevd9fecdd2012-06-08 16:22:24 -070043 */
Alexander Afanasyev9a989702012-06-29 17:44:00 -070044class 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 Afanasyevd9fecdd2012-06-08 16:22:24 -070053{
54public:
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 Afanasyev9a989702012-06-29 17:44:00 -070068private:
Alexander Afanasyevd9fecdd2012-06-08 16:22:24 -070069 void
70 SetMaxSize (uint32_t maxSize);
71
Alexander Afanasyevd9fecdd2012-06-08 16:22:24 -070072 uint32_t
73 GetMaxSize () const;
Alexander Afanasyev9a989702012-06-29 17:44:00 -070074};
Alexander Afanasyevd9fecdd2012-06-08 16:22:24 -070075
Alexander Afanasyev9a989702012-06-29 17:44:00 -070076
77/**
78 * \ingroup ccnx
79 * \brief Content Store with RANDOM replacement policy
80 */
81class 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{
91public:
92 /**
93 * \brief Interface ID
94 *
95 * \return interface ID
96 */
97 static TypeId GetTypeId ();
Alexander Afanasyevd9fecdd2012-06-08 16:22:24 -070098
99 /**
Alexander Afanasyev9a989702012-06-29 17:44:00 -0700100 * Default constructor
Alexander Afanasyevd9fecdd2012-06-08 16:22:24 -0700101 */
Alexander Afanasyev9a989702012-06-29 17:44:00 -0700102 CcnxContentStoreRandom ();
103 virtual ~CcnxContentStoreRandom ();
104
105private:
106 void
107 SetMaxSize (uint32_t maxSize);
108
109 uint32_t
110 GetMaxSize () const;
Alexander Afanasyevd9fecdd2012-06-08 16:22:24 -0700111};
112
Alexander Afanasyev9a989702012-06-29 17:44:00 -0700113/**
114 * \ingroup ccnx
115 * \brief Content Store with FIFO replacement policy
116 */
117class 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{
127public:
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
141private:
142 void
143 SetMaxSize (uint32_t maxSize);
144
145 uint32_t
146 GetMaxSize () const;
147};
148
149
Alexander Afanasyevd9fecdd2012-06-08 16:22:24 -0700150} //namespace ns3
151
Alexander Afanasyev480e4562012-06-29 17:46:47 -0700152#endif // CCNX_CONTENT_STORE_POLICIES_H