blob: 94709f3f4c91b27c55098e672388cf320a0f778c [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
21#ifndef _CCNX_PIT_IMPL_H_
22#define _CCNX_PIT_IMPL_H_
23
24#include "ccnx-pit.h"
Alexander Afanasyeve3d126f2012-07-16 17:07:31 -070025
26#include "../../utils/trie-with-policy.h"
Alexander Afanasyev413c7f12012-07-10 17:35:16 -070027
28#include "ccnx-pit-entry-impl.h"
29
Alexander Afanasyev11f7bb42012-07-09 17:06:30 -070030#include "ns3/ccnx-name-components.h"
31
32namespace ns3 {
33
Alexander Afanasyev11f7bb42012-07-09 17:06:30 -070034/**
35 * \ingroup ccnx
36 * \brief Class implementing Pending Interests Table
37 */
Alexander Afanasyevbd6f3f42012-07-26 17:50:17 -070038template<class Policy>
Alexander Afanasyev11f7bb42012-07-09 17:06:30 -070039class CcnxPitImpl : public CcnxPit
Alexander Afanasyev36b45772012-07-10 16:57:42 -070040 , protected ndnSIM::trie_with_policy<CcnxNameComponents,
Alexander Afanasyevbd6f3f42012-07-26 17:50:17 -070041 ndnSIM::smart_pointer_payload_traits<CcnxPitEntryImpl< CcnxPitImpl< Policy > > >,
42 // ndnSIM::persistent_policy_traits
43 Policy
Alexander Afanasyev36b45772012-07-10 16:57:42 -070044 >
Alexander Afanasyev11f7bb42012-07-09 17:06:30 -070045{
46public:
Alexander Afanasyev36b45772012-07-10 16:57:42 -070047 typedef ndnSIM::trie_with_policy<CcnxNameComponents,
Alexander Afanasyevbd6f3f42012-07-26 17:50:17 -070048 ndnSIM::smart_pointer_payload_traits<CcnxPitEntryImpl< CcnxPitImpl< Policy > > >,
49 // ndnSIM::persistent_policy_traits
50 Policy
Alexander Afanasyev36b45772012-07-10 16:57:42 -070051 > super;
Alexander Afanasyevbd6f3f42012-07-26 17:50:17 -070052 typedef CcnxPitEntryImpl< CcnxPitImpl< Policy > > entry;
Alexander Afanasyev36b45772012-07-10 16:57:42 -070053
Alexander Afanasyev11f7bb42012-07-09 17:06:30 -070054 /**
55 * \brief Interface ID
56 *
57 * \return interface ID
58 */
59 static TypeId GetTypeId ();
60
61 /**
62 * \brief PIT constructor
63 */
64 CcnxPitImpl ();
65
66 /**
67 * \brief Destructor
68 */
69 virtual ~CcnxPitImpl ();
70
71 // inherited from CcnxPit
72 virtual Ptr<CcnxPitEntry>
Alexander Afanasyev30f60e32012-07-10 14:21:16 -070073 Lookup (const CcnxContentObjectHeader &header);
Alexander Afanasyev11f7bb42012-07-09 17:06:30 -070074
75 virtual Ptr<CcnxPitEntry>
76 Lookup (const CcnxInterestHeader &header);
77
Alexander Afanasyev11f7bb42012-07-09 17:06:30 -070078 virtual Ptr<CcnxPitEntry>
Alexander Afanasyev30f60e32012-07-10 14:21:16 -070079 Create (Ptr<const CcnxInterestHeader> header);
Alexander Afanasyev11f7bb42012-07-09 17:06:30 -070080
81 virtual void
82 MarkErased (Ptr<CcnxPitEntry> entry);
83
84 virtual void
85 Print (std::ostream &os) const;
Alexander Afanasyev1aa4bbc2012-07-09 17:17:25 -070086
Alexander Afanasyevf1e013f2012-07-11 17:59:40 -070087 virtual uint32_t
88 GetSize () const;
89
Alexander Afanasyev30f60e32012-07-10 14:21:16 -070090 virtual Ptr<CcnxPitEntry>
91 Begin ();
92
93 virtual Ptr<CcnxPitEntry>
94 End ();
95
96 virtual Ptr<CcnxPitEntry>
97 Next (Ptr<CcnxPitEntry>);
Alexander Afanasyev11f7bb42012-07-09 17:06:30 -070098
99protected:
Alexander Afanasyev413c7f12012-07-10 17:35:16 -0700100 void RescheduleCleaning ();
101 void CleanExpired ();
Alexander Afanasyev11f7bb42012-07-09 17:06:30 -0700102
103 // inherited from Object class
104 virtual void NotifyNewAggregate (); ///< @brief Even when object is aggregated to another Object
105 virtual void DoDispose (); ///< @brief Do cleanup
106
107private:
108 uint32_t
109 GetMaxSize () const;
110
111 void
112 SetMaxSize (uint32_t maxSize);
113
114private:
Alexander Afanasyev413c7f12012-07-10 17:35:16 -0700115 EventId m_cleanEvent;
Alexander Afanasyev11f7bb42012-07-09 17:06:30 -0700116 Ptr<CcnxFib> m_fib; ///< \brief Link to FIB table
Alexander Afanasyevf249a192012-07-18 16:52:51 -0700117 Ptr<CcnxForwardingStrategy> m_forwardingStrategy;
Alexander Afanasyev36b45772012-07-10 16:57:42 -0700118
119 // indexes
120 typedef
121 boost::intrusive::set<entry,
122 boost::intrusive::compare < TimestampIndex< entry > >,
123 boost::intrusive::member_hook< entry,
124 boost::intrusive::set_member_hook<>,
125 &entry::time_hook_>
Alexander Afanasyev413c7f12012-07-10 17:35:16 -0700126 > time_index;
127 time_index i_time;
Alexander Afanasyev36b45772012-07-10 16:57:42 -0700128
129 friend class CcnxPitEntryImpl< CcnxPitImpl >;
Alexander Afanasyev11f7bb42012-07-09 17:06:30 -0700130};
131
132} // namespace ns3
133
134#endif /* CCNX_PIT_IMPL_H */