blob: da3f4f3b3312e8b284e9152f62144f8a7525cffb [file] [log] [blame]
Alexander Afanasyev11f7bb42012-07-09 17:06:30 -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: Alexander Afanasyev <alexander.afanasyev@ucla.edu>
19 */
20
Alexander Afanasyev4aac5572012-08-09 10:49:55 -070021#include "ndn-pit-impl.h"
Alexander Afanasyeve3d126f2012-07-16 17:07:31 -070022
Alexander Afanasyev4aac5572012-08-09 10:49:55 -070023#include "ns3/ndn-interest-header.h"
24#include "ns3/ndn-content-object-header.h"
25#include "ns3/ndn-forwarding-strategy.h"
Alexander Afanasyeve3d126f2012-07-16 17:07:31 -070026
Alexander Afanasyevbd6f3f42012-07-26 17:50:17 -070027#include "../../utils/empty-policy.h"
28#include "../../utils/persistent-policy.h"
29#include "../../utils/random-policy.h"
30#include "../../utils/lru-policy.h"
31
Alexander Afanasyev11f7bb42012-07-09 17:06:30 -070032#include "ns3/log.h"
33#include "ns3/string.h"
34#include "ns3/uinteger.h"
35#include "ns3/simulator.h"
Alexander Afanasyev11f7bb42012-07-09 17:06:30 -070036
37#include <boost/lambda/bind.hpp>
38#include <boost/lambda/lambda.hpp>
39
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -070040NS_LOG_COMPONENT_DEFINE ("ndn.pit.PitImpl");
Alexander Afanasyev11f7bb42012-07-09 17:06:30 -070041
42using namespace boost::tuples;
43using namespace boost;
44namespace ll = boost::lambda;
Alexander Afanasyevbd6f3f42012-07-26 17:50:17 -070045
46#define NS_OBJECT_ENSURE_REGISTERED_TEMPL(type, templ) \
47 static struct X ## type ## templ ## RegistrationClass \
48 { \
49 X ## type ## templ ## RegistrationClass () { \
50 ns3::TypeId tid = type<templ>::GetTypeId (); \
51 tid.GetParent (); \
52 } \
53 } x_ ## type ## templ ## RegistrationVariable
Alexander Afanasyev11f7bb42012-07-09 17:06:30 -070054
55namespace ns3 {
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -070056namespace ndn {
57namespace pit {
Alexander Afanasyev11f7bb42012-07-09 17:06:30 -070058
Alexander Afanasyeve77db792012-08-09 11:10:58 -070059using namespace ndnSIM;
60
Alexander Afanasyevbd6f3f42012-07-26 17:50:17 -070061template<>
62TypeId
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -070063PitImpl<persistent_policy_traits>::GetTypeId ()
Alexander Afanasyevbd6f3f42012-07-26 17:50:17 -070064{
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -070065 static TypeId tid = TypeId ("ns3::ndn::pit::Persistent")
Alexander Afanasyev4aac5572012-08-09 10:49:55 -070066 .SetGroupName ("Ndn")
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -070067 .SetParent<Pit> ()
68 .AddConstructor< PitImpl< persistent_policy_traits > > ()
Alexander Afanasyevbd6f3f42012-07-26 17:50:17 -070069 .AddAttribute ("MaxSize",
70 "Set maximum number of entries in PIT. If 0, limit is not enforced",
71 StringValue ("0"),
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -070072 MakeUintegerAccessor (&PitImpl< persistent_policy_traits >::GetMaxSize,
73 &PitImpl< persistent_policy_traits >::SetMaxSize),
Alexander Afanasyevbd6f3f42012-07-26 17:50:17 -070074 MakeUintegerChecker<uint32_t> ())
75 ;
76
Alexander Afanasyev0a0dc392012-07-27 13:41:49 -070077 return tid;
Alexander Afanasyevbd6f3f42012-07-26 17:50:17 -070078}
79
80template<>
81TypeId
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -070082PitImpl<random_policy_traits>::GetTypeId ()
Alexander Afanasyevbd6f3f42012-07-26 17:50:17 -070083{
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -070084 static TypeId tid = TypeId ("ns3::ndn::pit::Random")
Alexander Afanasyev4aac5572012-08-09 10:49:55 -070085 .SetGroupName ("Ndn")
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -070086 .SetParent<Pit> ()
87 .AddConstructor< PitImpl< random_policy_traits > > ()
Alexander Afanasyevbd6f3f42012-07-26 17:50:17 -070088 .AddAttribute ("MaxSize",
89 "Set maximum number of entries in PIT. If 0, limit is not enforced",
90 StringValue ("0"),
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -070091 MakeUintegerAccessor (&PitImpl< random_policy_traits >::GetMaxSize,
92 &PitImpl< random_policy_traits >::SetMaxSize),
Alexander Afanasyevbd6f3f42012-07-26 17:50:17 -070093 MakeUintegerChecker<uint32_t> ())
94 ;
95
Alexander Afanasyev0a0dc392012-07-27 13:41:49 -070096 return tid;
Alexander Afanasyevbd6f3f42012-07-26 17:50:17 -070097}
98
99template<>
100TypeId
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -0700101PitImpl<lru_policy_traits>::GetTypeId ()
Alexander Afanasyevbd6f3f42012-07-26 17:50:17 -0700102{
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -0700103 static TypeId tid = TypeId ("ns3::ndn::pit::Lru")
Alexander Afanasyev4aac5572012-08-09 10:49:55 -0700104 .SetGroupName ("Ndn")
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -0700105 .SetParent<Pit> ()
106 .AddConstructor< PitImpl< lru_policy_traits > > ()
Alexander Afanasyevbd6f3f42012-07-26 17:50:17 -0700107 .AddAttribute ("MaxSize",
108 "Set maximum number of entries in PIT. If 0, limit is not enforced",
109 StringValue ("0"),
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -0700110 MakeUintegerAccessor (&PitImpl< lru_policy_traits >::GetMaxSize,
111 &PitImpl< lru_policy_traits >::SetMaxSize),
Alexander Afanasyevbd6f3f42012-07-26 17:50:17 -0700112 MakeUintegerChecker<uint32_t> ())
113 ;
114
Alexander Afanasyev0a0dc392012-07-27 13:41:49 -0700115 return tid;
Alexander Afanasyevbd6f3f42012-07-26 17:50:17 -0700116}
Alexander Afanasyev11f7bb42012-07-09 17:06:30 -0700117
Alexander Afanasyevbd6f3f42012-07-26 17:50:17 -0700118template<class Policy>
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -0700119PitImpl<Policy>::PitImpl ()
Alexander Afanasyev11f7bb42012-07-09 17:06:30 -0700120{
121}
122
Alexander Afanasyevbd6f3f42012-07-26 17:50:17 -0700123template<class Policy>
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -0700124PitImpl<Policy>::~PitImpl ()
Alexander Afanasyev11f7bb42012-07-09 17:06:30 -0700125{
126}
127
Alexander Afanasyevbd6f3f42012-07-26 17:50:17 -0700128template<class Policy>
Alexander Afanasyev11f7bb42012-07-09 17:06:30 -0700129uint32_t
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -0700130PitImpl<Policy>::GetMaxSize () const
Alexander Afanasyev11f7bb42012-07-09 17:06:30 -0700131{
Alexander Afanasyevbd6f3f42012-07-26 17:50:17 -0700132 return super::getPolicy ().get_max_size ();
Alexander Afanasyev11f7bb42012-07-09 17:06:30 -0700133}
134
Alexander Afanasyevbd6f3f42012-07-26 17:50:17 -0700135template<class Policy>
Alexander Afanasyev11f7bb42012-07-09 17:06:30 -0700136void
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -0700137PitImpl<Policy>::SetMaxSize (uint32_t maxSize)
Alexander Afanasyev11f7bb42012-07-09 17:06:30 -0700138{
Alexander Afanasyevbd6f3f42012-07-26 17:50:17 -0700139 super::getPolicy ().set_max_size (maxSize);
Alexander Afanasyev11f7bb42012-07-09 17:06:30 -0700140}
141
Alexander Afanasyevbd6f3f42012-07-26 17:50:17 -0700142template<class Policy>
Alexander Afanasyev11f7bb42012-07-09 17:06:30 -0700143void
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -0700144PitImpl<Policy>::NotifyNewAggregate ()
Alexander Afanasyev11f7bb42012-07-09 17:06:30 -0700145{
146 if (m_fib == 0)
147 {
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -0700148 m_fib = GetObject<Fib> ();
Alexander Afanasyev11f7bb42012-07-09 17:06:30 -0700149 }
Alexander Afanasyevf249a192012-07-18 16:52:51 -0700150 if (m_forwardingStrategy == 0)
151 {
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -0700152 m_forwardingStrategy = GetObject<ForwardingStrategy> ();
Alexander Afanasyevf249a192012-07-18 16:52:51 -0700153 }
154
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -0700155 Pit::NotifyNewAggregate ();
Alexander Afanasyev11f7bb42012-07-09 17:06:30 -0700156}
157
Alexander Afanasyevbd6f3f42012-07-26 17:50:17 -0700158template<class Policy>
Alexander Afanasyev11f7bb42012-07-09 17:06:30 -0700159void
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -0700160PitImpl<Policy>::DoDispose ()
Alexander Afanasyev11f7bb42012-07-09 17:06:30 -0700161{
Alexander Afanasyev413c7f12012-07-10 17:35:16 -0700162 super::clear ();
Alexander Afanasyevf249a192012-07-18 16:52:51 -0700163
164 m_forwardingStrategy = 0;
165 m_fib = 0;
166
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -0700167 Pit::DoDispose ();
Alexander Afanasyev413c7f12012-07-10 17:35:16 -0700168}
169
Alexander Afanasyevbd6f3f42012-07-26 17:50:17 -0700170template<class Policy>
171void
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -0700172PitImpl<Policy>::RescheduleCleaning ()
Alexander Afanasyevb18ae022012-09-03 21:46:36 -0700173{
174 // m_cleanEvent.Cancel ();
175 Simulator::Remove (m_cleanEvent); // slower, but better for memory
Alexander Afanasyev413c7f12012-07-10 17:35:16 -0700176 if (i_time.empty ())
Alexander Afanasyevf1e013f2012-07-11 17:59:40 -0700177 {
Alexander Afanasyevbd6f3f42012-07-26 17:50:17 -0700178 // NS_LOG_DEBUG ("No items in PIT");
Alexander Afanasyevf1e013f2012-07-11 17:59:40 -0700179 return;
180 }
Alexander Afanasyev413c7f12012-07-10 17:35:16 -0700181
Alexander Afanasyevf1e013f2012-07-11 17:59:40 -0700182 Time nextEvent = i_time.begin ()->GetExpireTime () - Simulator::Now ();
Alexander Afanasyevbd6f3f42012-07-26 17:50:17 -0700183 if (nextEvent <= 0) nextEvent = Seconds (0);
Alexander Afanasyevf1e013f2012-07-11 17:59:40 -0700184
Alexander Afanasyevbd6f3f42012-07-26 17:50:17 -0700185 // NS_LOG_DEBUG ("Schedule next cleaning in " <<
186 // nextEvent.ToDouble (Time::S) << "s (at " <<
187 // i_time.begin ()->GetExpireTime () << "s abs time");
188
Alexander Afanasyevf1e013f2012-07-11 17:59:40 -0700189 m_cleanEvent = Simulator::Schedule (nextEvent,
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -0700190 &PitImpl<Policy>::CleanExpired, this);
Alexander Afanasyev11f7bb42012-07-09 17:06:30 -0700191}
192
Alexander Afanasyevbd6f3f42012-07-26 17:50:17 -0700193template<class Policy>
Alexander Afanasyev11f7bb42012-07-09 17:06:30 -0700194void
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -0700195PitImpl<Policy>::CleanExpired ()
Alexander Afanasyev11f7bb42012-07-09 17:06:30 -0700196{
Alexander Afanasyev413c7f12012-07-10 17:35:16 -0700197 NS_LOG_LOGIC ("Cleaning PIT. Total: " << i_time.size ());
Alexander Afanasyev11f7bb42012-07-09 17:06:30 -0700198 Time now = Simulator::Now ();
199
Alexander Afanasyev413c7f12012-07-10 17:35:16 -0700200 // uint32_t count = 0;
201 while (!i_time.empty ())
202 {
Alexander Afanasyevbd6f3f42012-07-26 17:50:17 -0700203 typename time_index::iterator entry = i_time.begin ();
Alexander Afanasyev413c7f12012-07-10 17:35:16 -0700204 if (entry->GetExpireTime () <= now) // is the record stale?
205 {
Alexander Afanasyevf249a192012-07-18 16:52:51 -0700206 m_forwardingStrategy->WillErasePendingInterest (entry->to_iterator ()->payload ());
Alexander Afanasyev413c7f12012-07-10 17:35:16 -0700207 super::erase (entry->to_iterator ());
Alexander Afanasyevbd6f3f42012-07-26 17:50:17 -0700208 // count ++;
Alexander Afanasyev413c7f12012-07-10 17:35:16 -0700209 }
210 else
211 break; // nothing else to do. All later records will not be stale
212 }
213
Alexander Afanasyevbd6f3f42012-07-26 17:50:17 -0700214 if (super::getPolicy ().size ())
215 {
216 NS_LOG_DEBUG ("Size: " << super::getPolicy ().size ());
Alexander Afanasyev6b51b082012-07-27 16:28:34 -0700217 NS_LOG_DEBUG ("i_time size: " << i_time.size ());
Alexander Afanasyevbd6f3f42012-07-26 17:50:17 -0700218 }
Alexander Afanasyev413c7f12012-07-10 17:35:16 -0700219 RescheduleCleaning ();
Alexander Afanasyev11f7bb42012-07-09 17:06:30 -0700220}
221
Alexander Afanasyevbd6f3f42012-07-26 17:50:17 -0700222template<class Policy>
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -0700223Ptr<Entry>
224PitImpl<Policy>::Lookup (const ContentObjectHeader &header)
Alexander Afanasyev11f7bb42012-07-09 17:06:30 -0700225{
Alexander Afanasyev30f60e32012-07-10 14:21:16 -0700226 /// @todo use predicate to search with exclude filters
Alexander Afanasyevbd6f3f42012-07-26 17:50:17 -0700227 typename super::iterator item = super::longest_prefix_match (header.GetName ());
Alexander Afanasyev11f7bb42012-07-09 17:06:30 -0700228
Alexander Afanasyev30f60e32012-07-10 14:21:16 -0700229 if (item == super::end ())
230 return 0;
231 else
232 return item->payload (); // which could also be 0
Alexander Afanasyev11f7bb42012-07-09 17:06:30 -0700233}
234
Alexander Afanasyevbd6f3f42012-07-26 17:50:17 -0700235template<class Policy>
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -0700236Ptr<Entry>
237PitImpl<Policy>::Lookup (const InterestHeader &header)
Alexander Afanasyev11f7bb42012-07-09 17:06:30 -0700238{
Alexander Afanasyevbd6f3f42012-07-26 17:50:17 -0700239 // NS_LOG_FUNCTION (header.GetName ());
Alexander Afanasyev30f60e32012-07-10 14:21:16 -0700240 NS_ASSERT_MSG (m_fib != 0, "FIB should be set");
Alexander Afanasyevf249a192012-07-18 16:52:51 -0700241 NS_ASSERT_MSG (m_forwardingStrategy != 0, "Forwarding strategy should be set");
Alexander Afanasyev11f7bb42012-07-09 17:06:30 -0700242
Alexander Afanasyevbd6f3f42012-07-26 17:50:17 -0700243 typename super::iterator foundItem, lastItem;
Alexander Afanasyev30f60e32012-07-10 14:21:16 -0700244 bool reachLast;
245 boost::tie (foundItem, reachLast, lastItem) = super::getTrie ().find (header.GetName ());
Alexander Afanasyev11f7bb42012-07-09 17:06:30 -0700246
Alexander Afanasyev30f60e32012-07-10 14:21:16 -0700247 if (!reachLast || lastItem == super::end ())
248 return 0;
249 else
250 return lastItem->payload (); // which could also be 0
Alexander Afanasyev11f7bb42012-07-09 17:06:30 -0700251}
252
Alexander Afanasyevbd6f3f42012-07-26 17:50:17 -0700253template<class Policy>
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -0700254Ptr<Entry>
255PitImpl<Policy>::Create (Ptr<const InterestHeader> header)
Alexander Afanasyev11f7bb42012-07-09 17:06:30 -0700256{
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -0700257 Ptr<fib::Entry> fibEntry = m_fib->LongestPrefixMatch (*header);
Alexander Afanasyev3c5b6a72012-07-20 15:35:48 -0700258 if (fibEntry == 0)
259 return 0;
260
261 // NS_ASSERT_MSG (fibEntry != 0,
262 // "There should be at least default route set" <<
263 // " Prefix = "<< header->GetName() << ", NodeID == " << m_fib->GetObject<Node>()->GetId() << "\n" << *m_fib);
Alexander Afanasyev30f60e32012-07-10 14:21:16 -0700264
Alexander Afanasyev36b45772012-07-10 16:57:42 -0700265 Ptr< entry > newEntry = ns3::Create< entry > (boost::ref (*this), header, fibEntry);
Alexander Afanasyevbd6f3f42012-07-26 17:50:17 -0700266 std::pair< typename super::iterator, bool > result = super::insert (header->GetName (), newEntry);
Alexander Afanasyev30f60e32012-07-10 14:21:16 -0700267 if (result.first != super::end ())
268 {
269 if (result.second)
270 {
271 newEntry->SetTrie (result.first);
272 return newEntry;
273 }
274 else
275 {
276 // should we do anything?
277 // update payload? add new payload?
278 return result.first->payload ();
279 }
280 }
281 else
282 return 0;
Alexander Afanasyev11f7bb42012-07-09 17:06:30 -0700283}
284
285
Alexander Afanasyevbd6f3f42012-07-26 17:50:17 -0700286template<class Policy>
Alexander Afanasyev11f7bb42012-07-09 17:06:30 -0700287void
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -0700288PitImpl<Policy>::MarkErased (Ptr<Entry> item)
Alexander Afanasyev11f7bb42012-07-09 17:06:30 -0700289{
Alexander Afanasyev30f60e32012-07-10 14:21:16 -0700290 // entry->SetExpireTime (Simulator::Now () + m_PitEntryPruningTimout);
Alexander Afanasyev36b45772012-07-10 16:57:42 -0700291 super::erase (StaticCast< entry > (item)->to_iterator ());
Alexander Afanasyev11f7bb42012-07-09 17:06:30 -0700292}
293
294
Alexander Afanasyevbd6f3f42012-07-26 17:50:17 -0700295template<class Policy>
Alexander Afanasyev11f7bb42012-07-09 17:06:30 -0700296void
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -0700297PitImpl<Policy>::Print (std::ostream& os) const
Alexander Afanasyev11f7bb42012-07-09 17:06:30 -0700298{
Alexander Afanasyev30f60e32012-07-10 14:21:16 -0700299 // !!! unordered_set imposes "random" order of item in the same level !!!
Alexander Afanasyevbd6f3f42012-07-26 17:50:17 -0700300 typename super::parent_trie::const_recursive_iterator item (super::getTrie ()), end (0);
Alexander Afanasyev30f60e32012-07-10 14:21:16 -0700301 for (; item != end; item++)
302 {
303 if (item->payload () == 0) continue;
304
305 os << item->payload ()->GetPrefix () << "\t" << *item->payload () << "\n";
306 }
Alexander Afanasyev11f7bb42012-07-09 17:06:30 -0700307}
308
Alexander Afanasyevbd6f3f42012-07-26 17:50:17 -0700309template<class Policy>
Alexander Afanasyevf1e013f2012-07-11 17:59:40 -0700310uint32_t
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -0700311PitImpl<Policy>::GetSize () const
Alexander Afanasyevf1e013f2012-07-11 17:59:40 -0700312{
313 return super::getPolicy ().size ();
314}
315
Alexander Afanasyevbd6f3f42012-07-26 17:50:17 -0700316template<class Policy>
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -0700317Ptr<Entry>
318PitImpl<Policy>::Begin ()
Alexander Afanasyev30f60e32012-07-10 14:21:16 -0700319{
Alexander Afanasyevbd6f3f42012-07-26 17:50:17 -0700320 typename super::parent_trie::recursive_iterator item (super::getTrie ()), end (0);
Alexander Afanasyev30f60e32012-07-10 14:21:16 -0700321 for (; item != end; item++)
322 {
323 if (item->payload () == 0) continue;
324 break;
325 }
326
327 if (item == end)
328 return End ();
329 else
330 return item->payload ();
331}
332
Alexander Afanasyevbd6f3f42012-07-26 17:50:17 -0700333template<class Policy>
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -0700334Ptr<Entry>
335PitImpl<Policy>::End ()
Alexander Afanasyev30f60e32012-07-10 14:21:16 -0700336{
337 return 0;
338}
339
Alexander Afanasyevbd6f3f42012-07-26 17:50:17 -0700340template<class Policy>
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -0700341Ptr<Entry>
342PitImpl<Policy>::Next (Ptr<Entry> from)
Alexander Afanasyev30f60e32012-07-10 14:21:16 -0700343{
344 if (from == 0) return 0;
345
Alexander Afanasyevbd6f3f42012-07-26 17:50:17 -0700346 typename super::parent_trie::recursive_iterator
Alexander Afanasyev36b45772012-07-10 16:57:42 -0700347 item (*StaticCast< entry > (from)->to_iterator ()),
Alexander Afanasyev30f60e32012-07-10 14:21:16 -0700348 end (0);
349
350 for (item++; item != end; item++)
351 {
352 if (item->payload () == 0) continue;
353 break;
354 }
355
356 if (item == end)
357 return End ();
358 else
359 return item->payload ();
360}
361
362
Alexander Afanasyevbd6f3f42012-07-26 17:50:17 -0700363// explicit instantiation and registering
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -0700364template class PitImpl<persistent_policy_traits>;
365template class PitImpl<random_policy_traits>;
366template class PitImpl<lru_policy_traits>;
Alexander Afanasyevbd6f3f42012-07-26 17:50:17 -0700367
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -0700368NS_OBJECT_ENSURE_REGISTERED_TEMPL(PitImpl, persistent_policy_traits);
369NS_OBJECT_ENSURE_REGISTERED_TEMPL(PitImpl, random_policy_traits);
370NS_OBJECT_ENSURE_REGISTERED_TEMPL(PitImpl, lru_policy_traits);
Alexander Afanasyevbd6f3f42012-07-26 17:50:17 -0700371
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -0700372} // namespace pit
373} // namespace ndn
Alexander Afanasyev11f7bb42012-07-09 17:06:30 -0700374} // namespace ns3