Alexander Afanasyev | 2b4c947 | 2012-08-09 15:00:38 -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: Alexander Afanasyev <alexander.afanasyev@ucla.edu> |
| 19 | */ |
| 20 | |
| 21 | #include "content-store-impl.h" |
Alexander Afanasyev | 2b4c947 | 2012-08-09 15:00:38 -0700 | [diff] [blame] | 22 | |
Alexander Afanasyev | 1a2df6a | 2012-08-17 13:21:51 -0700 | [diff] [blame] | 23 | #include "../../utils/trie/random-policy.h" |
| 24 | #include "../../utils/trie/lru-policy.h" |
| 25 | #include "../../utils/trie/fifo-policy.h" |
Alexander Afanasyev | 41824bd | 2013-01-23 23:57:59 -0800 | [diff] [blame] | 26 | #include "../../utils/trie/lfu-policy.h" |
Alexander Afanasyev | e091bea | 2014-02-14 15:27:25 -0800 | [diff] [blame] | 27 | #include "../../utils/trie/multi-policy.h" |
| 28 | #include "../../utils/trie/aggregate-stats-policy.h" |
Alexander Afanasyev | 2b4c947 | 2012-08-09 15:00:38 -0700 | [diff] [blame] | 29 | |
Alexander Afanasyev | 2b4c947 | 2012-08-09 15:00:38 -0700 | [diff] [blame] | 30 | #define NS_OBJECT_ENSURE_REGISTERED_TEMPL(type, templ) \ |
| 31 | static struct X ## type ## templ ## RegistrationClass \ |
| 32 | { \ |
| 33 | X ## type ## templ ## RegistrationClass () { \ |
| 34 | ns3::TypeId tid = type<templ>::GetTypeId (); \ |
| 35 | tid.GetParent (); \ |
| 36 | } \ |
| 37 | } x_ ## type ## templ ## RegistrationVariable |
| 38 | |
| 39 | namespace ns3 { |
| 40 | namespace ndn { |
| 41 | |
| 42 | using namespace ndnSIM; |
| 43 | |
| 44 | namespace cs { |
| 45 | |
Alexander Afanasyev | 2b4c947 | 2012-08-09 15:00:38 -0700 | [diff] [blame] | 46 | // explicit instantiation and registering |
Alexander Afanasyev | 1cd79ae | 2012-10-05 22:42:12 -0700 | [diff] [blame] | 47 | /** |
| 48 | * @brief ContentStore with LRU cache replacement policy |
| 49 | **/ |
Alexander Afanasyev | 2b4c947 | 2012-08-09 15:00:38 -0700 | [diff] [blame] | 50 | template class ContentStoreImpl<lru_policy_traits>; |
Alexander Afanasyev | 1cd79ae | 2012-10-05 22:42:12 -0700 | [diff] [blame] | 51 | |
| 52 | /** |
| 53 | * @brief ContentStore with random cache replacement policy |
| 54 | **/ |
Alexander Afanasyev | 2b4c947 | 2012-08-09 15:00:38 -0700 | [diff] [blame] | 55 | template class ContentStoreImpl<random_policy_traits>; |
Alexander Afanasyev | 1cd79ae | 2012-10-05 22:42:12 -0700 | [diff] [blame] | 56 | |
| 57 | /** |
| 58 | * @brief ContentStore with FIFO cache replacement policy |
| 59 | **/ |
Alexander Afanasyev | 2b4c947 | 2012-08-09 15:00:38 -0700 | [diff] [blame] | 60 | template class ContentStoreImpl<fifo_policy_traits>; |
| 61 | |
Alexander Afanasyev | 41824bd | 2013-01-23 23:57:59 -0800 | [diff] [blame] | 62 | /** |
| 63 | * @brief ContentStore with Least Frequently Used (LFU) cache replacement policy |
| 64 | **/ |
| 65 | template class ContentStoreImpl<lfu_policy_traits>; |
| 66 | |
Alexander Afanasyev | 2b4c947 | 2012-08-09 15:00:38 -0700 | [diff] [blame] | 67 | NS_OBJECT_ENSURE_REGISTERED_TEMPL(ContentStoreImpl, lru_policy_traits); |
| 68 | NS_OBJECT_ENSURE_REGISTERED_TEMPL(ContentStoreImpl, random_policy_traits); |
| 69 | NS_OBJECT_ENSURE_REGISTERED_TEMPL(ContentStoreImpl, fifo_policy_traits); |
Alexander Afanasyev | 41824bd | 2013-01-23 23:57:59 -0800 | [diff] [blame] | 70 | NS_OBJECT_ENSURE_REGISTERED_TEMPL(ContentStoreImpl, lfu_policy_traits); |
| 71 | |
Alexander Afanasyev | e091bea | 2014-02-14 15:27:25 -0800 | [diff] [blame] | 72 | |
| 73 | typedef multi_policy_traits< boost::mpl::vector2< lru_policy_traits, |
| 74 | aggregate_stats_policy_traits > > LruWithCountsTraits; |
| 75 | typedef multi_policy_traits< boost::mpl::vector2< random_policy_traits, |
| 76 | aggregate_stats_policy_traits > > RandomWithCountsTraits; |
| 77 | typedef multi_policy_traits< boost::mpl::vector2< fifo_policy_traits, |
| 78 | aggregate_stats_policy_traits > > FifoWithCountsTraits; |
| 79 | typedef multi_policy_traits< boost::mpl::vector2< lfu_policy_traits, |
| 80 | aggregate_stats_policy_traits > > LfuWithCountsTraits; |
| 81 | |
| 82 | template class ContentStoreImpl<LruWithCountsTraits>; |
| 83 | NS_OBJECT_ENSURE_REGISTERED_TEMPL(ContentStoreImpl, LruWithCountsTraits); |
| 84 | |
| 85 | template class ContentStoreImpl<RandomWithCountsTraits>; |
| 86 | NS_OBJECT_ENSURE_REGISTERED_TEMPL(ContentStoreImpl, RandomWithCountsTraits); |
| 87 | |
| 88 | template class ContentStoreImpl<FifoWithCountsTraits>; |
| 89 | NS_OBJECT_ENSURE_REGISTERED_TEMPL(ContentStoreImpl, FifoWithCountsTraits); |
| 90 | |
| 91 | template class ContentStoreImpl<LfuWithCountsTraits>; |
| 92 | NS_OBJECT_ENSURE_REGISTERED_TEMPL(ContentStoreImpl, LfuWithCountsTraits); |
| 93 | |
Alexander Afanasyev | e095f0f | 2012-11-21 17:43:32 -0800 | [diff] [blame] | 94 | #ifdef DOXYGEN |
| 95 | // /** |
| 96 | // * \brief Content Store implementing LRU cache replacement policy |
| 97 | // */ |
| 98 | class Lru : public ContentStoreImpl<lru_policy_traits> { }; |
| 99 | |
| 100 | /** |
| 101 | * \brief Content Store implementing FIFO cache replacement policy |
| 102 | */ |
| 103 | class Fifo : public ContentStoreImpl<fifo_policy_traits> { }; |
| 104 | |
| 105 | /** |
| 106 | * \brief Content Store implementing Random cache replacement policy |
| 107 | */ |
| 108 | class Random : public ContentStoreImpl<random_policy_traits> { }; |
Alexander Afanasyev | 41824bd | 2013-01-23 23:57:59 -0800 | [diff] [blame] | 109 | |
| 110 | /** |
| 111 | * \brief Content Store implementing Least Frequently Used cache replacement policy |
| 112 | */ |
| 113 | class Lfu : public ContentStoreImpl<lfu_policy_traits> { }; |
Alexander Afanasyev | e095f0f | 2012-11-21 17:43:32 -0800 | [diff] [blame] | 114 | #endif |
| 115 | |
Alexander Afanasyev | 2b4c947 | 2012-08-09 15:00:38 -0700 | [diff] [blame] | 116 | |
| 117 | } // namespace cs |
| 118 | } // namespace ndn |
| 119 | } // namespace ns3 |