blob: 2f526046053af386cd9fcaa87c680c32a5b67af1 [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"
27#include "../../utils/empty-policy.h"
28#include "../../utils/persistent-policy.h"
Alexander Afanasyev413c7f12012-07-10 17:35:16 -070029
30#include "ccnx-pit-entry-impl.h"
31
Alexander Afanasyev11f7bb42012-07-09 17:06:30 -070032#include "ns3/ccnx-name-components.h"
33
34namespace ns3 {
35
Alexander Afanasyev11f7bb42012-07-09 17:06:30 -070036/**
37 * \ingroup ccnx
38 * \brief Class implementing Pending Interests Table
39 */
40class CcnxPitImpl : public CcnxPit
Alexander Afanasyev36b45772012-07-10 16:57:42 -070041 , protected ndnSIM::trie_with_policy<CcnxNameComponents,
42 ndnSIM::smart_pointer_payload_traits<CcnxPitEntryImpl< CcnxPitImpl > >,
43 ndnSIM::persistent_policy_traits
44 >
Alexander Afanasyev11f7bb42012-07-09 17:06:30 -070045{
46public:
Alexander Afanasyev36b45772012-07-10 16:57:42 -070047 typedef ndnSIM::trie_with_policy<CcnxNameComponents,
48 ndnSIM::smart_pointer_payload_traits<CcnxPitEntryImpl< CcnxPitImpl > >,
49 ndnSIM::persistent_policy_traits
50 > super;
51 typedef CcnxPitEntryImpl< CcnxPitImpl > entry;
52
Alexander Afanasyev11f7bb42012-07-09 17:06:30 -070053 /**
54 * \brief Interface ID
55 *
56 * \return interface ID
57 */
58 static TypeId GetTypeId ();
59
60 /**
61 * \brief PIT constructor
62 */
63 CcnxPitImpl ();
64
65 /**
66 * \brief Destructor
67 */
68 virtual ~CcnxPitImpl ();
69
70 // inherited from CcnxPit
71 virtual Ptr<CcnxPitEntry>
Alexander Afanasyev30f60e32012-07-10 14:21:16 -070072 Lookup (const CcnxContentObjectHeader &header);
Alexander Afanasyev11f7bb42012-07-09 17:06:30 -070073
74 virtual Ptr<CcnxPitEntry>
75 Lookup (const CcnxInterestHeader &header);
76
Alexander Afanasyev11f7bb42012-07-09 17:06:30 -070077 virtual Ptr<CcnxPitEntry>
Alexander Afanasyev30f60e32012-07-10 14:21:16 -070078 Create (Ptr<const CcnxInterestHeader> header);
Alexander Afanasyev11f7bb42012-07-09 17:06:30 -070079
80 virtual void
81 MarkErased (Ptr<CcnxPitEntry> entry);
82
83 virtual void
84 Print (std::ostream &os) const;
Alexander Afanasyev1aa4bbc2012-07-09 17:17:25 -070085
Alexander Afanasyevf1e013f2012-07-11 17:59:40 -070086 virtual uint32_t
87 GetSize () const;
88
Alexander Afanasyev30f60e32012-07-10 14:21:16 -070089 virtual Ptr<CcnxPitEntry>
90 Begin ();
91
92 virtual Ptr<CcnxPitEntry>
93 End ();
94
95 virtual Ptr<CcnxPitEntry>
96 Next (Ptr<CcnxPitEntry>);
Alexander Afanasyev11f7bb42012-07-09 17:06:30 -070097
98protected:
Alexander Afanasyev413c7f12012-07-10 17:35:16 -070099 void RescheduleCleaning ();
100 void CleanExpired ();
Alexander Afanasyev11f7bb42012-07-09 17:06:30 -0700101
102 // inherited from Object class
103 virtual void NotifyNewAggregate (); ///< @brief Even when object is aggregated to another Object
104 virtual void DoDispose (); ///< @brief Do cleanup
105
106private:
107 uint32_t
108 GetMaxSize () const;
109
110 void
111 SetMaxSize (uint32_t maxSize);
112
113private:
Alexander Afanasyev413c7f12012-07-10 17:35:16 -0700114 EventId m_cleanEvent;
Alexander Afanasyev11f7bb42012-07-09 17:06:30 -0700115 Ptr<CcnxFib> m_fib; ///< \brief Link to FIB table
Alexander Afanasyevf249a192012-07-18 16:52:51 -0700116 Ptr<CcnxForwardingStrategy> m_forwardingStrategy;
Alexander Afanasyev36b45772012-07-10 16:57:42 -0700117
118 // indexes
119 typedef
120 boost::intrusive::set<entry,
121 boost::intrusive::compare < TimestampIndex< entry > >,
122 boost::intrusive::member_hook< entry,
123 boost::intrusive::set_member_hook<>,
124 &entry::time_hook_>
Alexander Afanasyev413c7f12012-07-10 17:35:16 -0700125 > time_index;
126 time_index i_time;
Alexander Afanasyev36b45772012-07-10 16:57:42 -0700127
128 friend class CcnxPitEntryImpl< CcnxPitImpl >;
Alexander Afanasyev11f7bb42012-07-09 17:06:30 -0700129};
130
131} // namespace ns3
132
133#endif /* CCNX_PIT_IMPL_H */