blob: 123ed8559f7a86d8a0638aef10f83f7a047fc067 [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"
25#include "../utils/trie-with-policy.h"
26#include "../utils/empty-policy.h"
Alexander Afanasyev30f60e32012-07-10 14:21:16 -070027#include "../utils/persistent-policy.h"
Alexander Afanasyev413c7f12012-07-10 17:35:16 -070028
29#include "ccnx-pit-entry-impl.h"
30
Alexander Afanasyev11f7bb42012-07-09 17:06:30 -070031#include "ns3/ccnx-name-components.h"
32
33namespace ns3 {
34
Alexander Afanasyev11f7bb42012-07-09 17:06:30 -070035/**
36 * \ingroup ccnx
37 * \brief Class implementing Pending Interests Table
38 */
39class CcnxPitImpl : public CcnxPit
Alexander Afanasyev36b45772012-07-10 16:57:42 -070040 , protected ndnSIM::trie_with_policy<CcnxNameComponents,
41 ndnSIM::smart_pointer_payload_traits<CcnxPitEntryImpl< CcnxPitImpl > >,
42 ndnSIM::persistent_policy_traits
43 >
Alexander Afanasyev11f7bb42012-07-09 17:06:30 -070044{
45public:
Alexander Afanasyev36b45772012-07-10 16:57:42 -070046 typedef ndnSIM::trie_with_policy<CcnxNameComponents,
47 ndnSIM::smart_pointer_payload_traits<CcnxPitEntryImpl< CcnxPitImpl > >,
48 ndnSIM::persistent_policy_traits
49 > super;
50 typedef CcnxPitEntryImpl< CcnxPitImpl > entry;
51
Alexander Afanasyev11f7bb42012-07-09 17:06:30 -070052 /**
53 * \brief Interface ID
54 *
55 * \return interface ID
56 */
57 static TypeId GetTypeId ();
58
59 /**
60 * \brief PIT constructor
61 */
62 CcnxPitImpl ();
63
64 /**
65 * \brief Destructor
66 */
67 virtual ~CcnxPitImpl ();
68
69 // inherited from CcnxPit
70 virtual Ptr<CcnxPitEntry>
Alexander Afanasyev30f60e32012-07-10 14:21:16 -070071 Lookup (const CcnxContentObjectHeader &header);
Alexander Afanasyev11f7bb42012-07-09 17:06:30 -070072
73 virtual Ptr<CcnxPitEntry>
74 Lookup (const CcnxInterestHeader &header);
75
Alexander Afanasyev11f7bb42012-07-09 17:06:30 -070076 virtual Ptr<CcnxPitEntry>
Alexander Afanasyev30f60e32012-07-10 14:21:16 -070077 Create (Ptr<const CcnxInterestHeader> header);
Alexander Afanasyev11f7bb42012-07-09 17:06:30 -070078
79 virtual void
80 MarkErased (Ptr<CcnxPitEntry> entry);
81
82 virtual void
83 Print (std::ostream &os) const;
Alexander Afanasyev1aa4bbc2012-07-09 17:17:25 -070084
Alexander Afanasyevf1e013f2012-07-11 17:59:40 -070085 virtual uint32_t
86 GetSize () const;
87
Alexander Afanasyev30f60e32012-07-10 14:21:16 -070088 virtual Ptr<CcnxPitEntry>
89 Begin ();
90
91 virtual Ptr<CcnxPitEntry>
92 End ();
93
94 virtual Ptr<CcnxPitEntry>
95 Next (Ptr<CcnxPitEntry>);
Alexander Afanasyev11f7bb42012-07-09 17:06:30 -070096
97protected:
Alexander Afanasyev413c7f12012-07-10 17:35:16 -070098 void RescheduleCleaning ();
99 void CleanExpired ();
Alexander Afanasyev11f7bb42012-07-09 17:06:30 -0700100
101 // inherited from Object class
102 virtual void NotifyNewAggregate (); ///< @brief Even when object is aggregated to another Object
103 virtual void DoDispose (); ///< @brief Do cleanup
104
105private:
106 uint32_t
107 GetMaxSize () const;
108
109 void
110 SetMaxSize (uint32_t maxSize);
111
112private:
Alexander Afanasyev413c7f12012-07-10 17:35:16 -0700113 EventId m_cleanEvent;
Alexander Afanasyev11f7bb42012-07-09 17:06:30 -0700114 Ptr<CcnxFib> m_fib; ///< \brief Link to FIB table
Alexander Afanasyev36b45772012-07-10 16:57:42 -0700115
116 // indexes
117 typedef
118 boost::intrusive::set<entry,
119 boost::intrusive::compare < TimestampIndex< entry > >,
120 boost::intrusive::member_hook< entry,
121 boost::intrusive::set_member_hook<>,
122 &entry::time_hook_>
Alexander Afanasyev413c7f12012-07-10 17:35:16 -0700123 > time_index;
124 time_index i_time;
Alexander Afanasyev36b45772012-07-10 16:57:42 -0700125
126 friend class CcnxPitEntryImpl< CcnxPitImpl >;
Alexander Afanasyev11f7bb42012-07-09 17:06:30 -0700127};
128
129} // namespace ns3
130
131#endif /* CCNX_PIT_IMPL_H */