blob: e5a7f33d4dfc97c7ed289dfcb291701f85274780 [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"
27#include "ns3/ccnx-name-components.h"
28
29namespace ns3 {
30
31class CcnxPitEntryImpl : public CcnxPitEntry
32{
33public:
34 typedef ndnSIM::trie_with_policy<
35 CcnxNameComponents,
36 ndnSIM::smart_pointer_payload_traits<CcnxPitEntryImpl>,
37 ndnSIM::empty_policy_traits
38 > trie;
39
40 CcnxPitEntryImpl (const Ptr<const CcnxNameComponents> &prefix, const Time &offsetTime, Ptr<CcnxFibEntry> fibEntry)
41 : CcnxPitEntry (prefix, offsetTime, fibEntry)
42 , item_ (0)
43 {
44 }
45
46 void
47 SetTrie (trie::iterator item)
48 {
49 item_ = item;
50 }
51
52 trie::iterator to_iterator () { return item_; }
53 trie::const_iterator to_iterator () const { return item_; }
54
55private:
56 trie::iterator item_;
57};
58
59////////////////////////////////////////////////////////////////////////
60////////////////////////////////////////////////////////////////////////
61
62/**
63 * \ingroup ccnx
64 * \brief Class implementing Pending Interests Table
65 */
66class CcnxPitImpl : public CcnxPit
67 , protected CcnxPitEntryImpl::trie
68{
69public:
70 /**
71 * \brief Interface ID
72 *
73 * \return interface ID
74 */
75 static TypeId GetTypeId ();
76
77 /**
78 * \brief PIT constructor
79 */
80 CcnxPitImpl ();
81
82 /**
83 * \brief Destructor
84 */
85 virtual ~CcnxPitImpl ();
86
87 // inherited from CcnxPit
88 virtual Ptr<CcnxPitEntry>
89 Lookup (const CcnxContentObjectHeader &header) const;
90
91 virtual Ptr<CcnxPitEntry>
92 Lookup (const CcnxInterestHeader &header);
93
94 virtual bool
95 CheckIfDuplicate (Ptr<CcnxPitEntry> entry, const CcnxInterestHeader &header);
96
97 virtual Ptr<CcnxPitEntry>
98 Create (const CcnxInterestHeader &header);
99
100 virtual void
101 MarkErased (Ptr<CcnxPitEntry> entry);
102
103 virtual void
104 Print (std::ostream &os) const;
105
106protected:
107 // inherited from CcnxPit
108 virtual void DoCleanExpired ();
109
110 // inherited from Object class
111 virtual void NotifyNewAggregate (); ///< @brief Even when object is aggregated to another Object
112 virtual void DoDispose (); ///< @brief Do cleanup
113
114private:
115 uint32_t
116 GetMaxSize () const;
117
118 void
119 SetMaxSize (uint32_t maxSize);
120
121private:
122 Ptr<CcnxFib> m_fib; ///< \brief Link to FIB table
123};
124
125} // namespace ns3
126
127#endif /* CCNX_PIT_IMPL_H */