blob: b5b00f2ab6ed51bf1e443fa76b532c01ade4d641 [file] [log] [blame]
Alexander Afanasyev60a7b622014-12-20 17:04:07 -08001/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2/**
3 * Copyright (c) 2011-2015 Regents of the University of California.
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -07004 *
Alexander Afanasyev60a7b622014-12-20 17:04:07 -08005 * This file is part of ndnSIM. See AUTHORS for complete list of ndnSIM authors and
6 * contributors.
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -07007 *
Alexander Afanasyev60a7b622014-12-20 17:04:07 -08008 * ndnSIM is free software: you can redistribute it and/or modify it under the terms
9 * of the GNU General Public License as published by the Free Software Foundation,
10 * either version 3 of the License, or (at your option) any later version.
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -070011 *
Alexander Afanasyev60a7b622014-12-20 17:04:07 -080012 * ndnSIM is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
13 * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
14 * PURPOSE. See the GNU General Public License for more details.
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -070015 *
Alexander Afanasyev60a7b622014-12-20 17:04:07 -080016 * You should have received a copy of the GNU General Public License along with
17 * ndnSIM, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
18 **/
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -070019
Alexander Afanasyev0c395372014-12-20 15:54:02 -080020#include "content-store-impl.hpp"
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -070021
Alexander Afanasyev0c395372014-12-20 15:54:02 -080022#include "../../utils/trie/random-policy.hpp"
23#include "../../utils/trie/lru-policy.hpp"
24#include "../../utils/trie/fifo-policy.hpp"
25#include "../../utils/trie/lfu-policy.hpp"
26#include "../../utils/trie/multi-policy.hpp"
27#include "../../utils/trie/aggregate-stats-policy.hpp"
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -070028
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080029#define NS_OBJECT_ENSURE_REGISTERED_TEMPL(type, templ) \
30 static struct X##type##templ##RegistrationClass { \
31 X##type##templ##RegistrationClass() \
32 { \
33 ns3::TypeId tid = type<templ>::GetTypeId(); \
34 tid.GetParent(); \
35 } \
36 } x_##type##templ##RegistrationVariable
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -070037
38namespace ns3 {
39namespace ndn {
40
41using namespace ndnSIM;
42
43namespace cs {
44
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -070045// explicit instantiation and registering
Alexander Afanasyev1cd79ae2012-10-05 22:42:12 -070046/**
47 * @brief ContentStore with LRU cache replacement policy
48 **/
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -070049template class ContentStoreImpl<lru_policy_traits>;
Alexander Afanasyev1cd79ae2012-10-05 22:42:12 -070050
51/**
52 * @brief ContentStore with random cache replacement policy
53 **/
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -070054template class ContentStoreImpl<random_policy_traits>;
Alexander Afanasyev1cd79ae2012-10-05 22:42:12 -070055
56/**
57 * @brief ContentStore with FIFO cache replacement policy
58 **/
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -070059template class ContentStoreImpl<fifo_policy_traits>;
60
Alexander Afanasyev41824bd2013-01-23 23:57:59 -080061/**
62 * @brief ContentStore with Least Frequently Used (LFU) cache replacement policy
63 **/
64template class ContentStoreImpl<lfu_policy_traits>;
65
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -070066NS_OBJECT_ENSURE_REGISTERED_TEMPL(ContentStoreImpl, lru_policy_traits);
67NS_OBJECT_ENSURE_REGISTERED_TEMPL(ContentStoreImpl, random_policy_traits);
68NS_OBJECT_ENSURE_REGISTERED_TEMPL(ContentStoreImpl, fifo_policy_traits);
Alexander Afanasyev41824bd2013-01-23 23:57:59 -080069NS_OBJECT_ENSURE_REGISTERED_TEMPL(ContentStoreImpl, lfu_policy_traits);
70
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080071typedef multi_policy_traits<boost::mpl::vector2<lru_policy_traits, aggregate_stats_policy_traits>>
72 LruWithCountsTraits;
73typedef multi_policy_traits<boost::mpl::vector2<random_policy_traits,
74 aggregate_stats_policy_traits>>
75 RandomWithCountsTraits;
76typedef multi_policy_traits<boost::mpl::vector2<fifo_policy_traits, aggregate_stats_policy_traits>>
77 FifoWithCountsTraits;
78typedef multi_policy_traits<boost::mpl::vector2<lfu_policy_traits, aggregate_stats_policy_traits>>
79 LfuWithCountsTraits;
Alexander Afanasyeve091bea2014-02-14 15:27:25 -080080
81template class ContentStoreImpl<LruWithCountsTraits>;
82NS_OBJECT_ENSURE_REGISTERED_TEMPL(ContentStoreImpl, LruWithCountsTraits);
83
84template class ContentStoreImpl<RandomWithCountsTraits>;
85NS_OBJECT_ENSURE_REGISTERED_TEMPL(ContentStoreImpl, RandomWithCountsTraits);
86
87template class ContentStoreImpl<FifoWithCountsTraits>;
88NS_OBJECT_ENSURE_REGISTERED_TEMPL(ContentStoreImpl, FifoWithCountsTraits);
89
90template class ContentStoreImpl<LfuWithCountsTraits>;
91NS_OBJECT_ENSURE_REGISTERED_TEMPL(ContentStoreImpl, LfuWithCountsTraits);
92
Alexander Afanasyeve095f0f2012-11-21 17:43:32 -080093#ifdef DOXYGEN
94// /**
95// * \brief Content Store implementing LRU cache replacement policy
96// */
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080097class Lru : public ContentStoreImpl<lru_policy_traits> {
98};
Alexander Afanasyeve095f0f2012-11-21 17:43:32 -080099
100/**
101 * \brief Content Store implementing FIFO cache replacement policy
102 */
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -0800103class Fifo : public ContentStoreImpl<fifo_policy_traits> {
104};
Alexander Afanasyeve095f0f2012-11-21 17:43:32 -0800105
106/**
107 * \brief Content Store implementing Random cache replacement policy
108 */
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -0800109class Random : public ContentStoreImpl<random_policy_traits> {
110};
Alexander Afanasyev41824bd2013-01-23 23:57:59 -0800111
112/**
113 * \brief Content Store implementing Least Frequently Used cache replacement policy
114 */
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -0800115class Lfu : public ContentStoreImpl<lfu_policy_traits> {
116};
Alexander Afanasyeve095f0f2012-11-21 17:43:32 -0800117#endif
118
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -0700119} // namespace cs
120} // namespace ndn
121} // namespace ns3