blob: 499957fd9a3622a23e074dc5e957ec73cdf7f746 [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 Afanasyev11f7bb42012-07-09 17:06:30 -070028#include "ns3/ccnx-name-components.h"
29
30namespace ns3 {
31
32class CcnxPitEntryImpl : public CcnxPitEntry
33{
34public:
35 typedef ndnSIM::trie_with_policy<
36 CcnxNameComponents,
37 ndnSIM::smart_pointer_payload_traits<CcnxPitEntryImpl>,
Alexander Afanasyev30f60e32012-07-10 14:21:16 -070038 ndnSIM::persistent_policy_traits
Alexander Afanasyev11f7bb42012-07-09 17:06:30 -070039 > trie;
40
Alexander Afanasyev30f60e32012-07-10 14:21:16 -070041 CcnxPitEntryImpl (Ptr<const CcnxInterestHeader> header,
42 Ptr<CcnxFibEntry> fibEntry)
43 : CcnxPitEntry (header, fibEntry)
Alexander Afanasyev11f7bb42012-07-09 17:06:30 -070044 , item_ (0)
45 {
46 }
47
48 void
49 SetTrie (trie::iterator item)
50 {
51 item_ = item;
52 }
53
54 trie::iterator to_iterator () { return item_; }
55 trie::const_iterator to_iterator () const { return item_; }
56
57private:
58 trie::iterator item_;
59};
60
61////////////////////////////////////////////////////////////////////////
62////////////////////////////////////////////////////////////////////////
63
64/**
65 * \ingroup ccnx
66 * \brief Class implementing Pending Interests Table
67 */
68class CcnxPitImpl : public CcnxPit
69 , protected CcnxPitEntryImpl::trie
70{
71public:
Alexander Afanasyev1aa4bbc2012-07-09 17:17:25 -070072 typedef CcnxPitEntryImpl::trie super;
73
Alexander Afanasyev11f7bb42012-07-09 17:06:30 -070074 /**
75 * \brief Interface ID
76 *
77 * \return interface ID
78 */
79 static TypeId GetTypeId ();
80
81 /**
82 * \brief PIT constructor
83 */
84 CcnxPitImpl ();
85
86 /**
87 * \brief Destructor
88 */
89 virtual ~CcnxPitImpl ();
90
91 // inherited from CcnxPit
92 virtual Ptr<CcnxPitEntry>
Alexander Afanasyev30f60e32012-07-10 14:21:16 -070093 Lookup (const CcnxContentObjectHeader &header);
Alexander Afanasyev11f7bb42012-07-09 17:06:30 -070094
95 virtual Ptr<CcnxPitEntry>
96 Lookup (const CcnxInterestHeader &header);
97
Alexander Afanasyev11f7bb42012-07-09 17:06:30 -070098 virtual Ptr<CcnxPitEntry>
Alexander Afanasyev30f60e32012-07-10 14:21:16 -070099 Create (Ptr<const CcnxInterestHeader> header);
Alexander Afanasyev11f7bb42012-07-09 17:06:30 -0700100
101 virtual void
102 MarkErased (Ptr<CcnxPitEntry> entry);
103
104 virtual void
105 Print (std::ostream &os) const;
Alexander Afanasyev1aa4bbc2012-07-09 17:17:25 -0700106
Alexander Afanasyev30f60e32012-07-10 14:21:16 -0700107 virtual Ptr<CcnxPitEntry>
108 Begin ();
109
110 virtual Ptr<CcnxPitEntry>
111 End ();
112
113 virtual Ptr<CcnxPitEntry>
114 Next (Ptr<CcnxPitEntry>);
Alexander Afanasyev11f7bb42012-07-09 17:06:30 -0700115
116protected:
117 // inherited from CcnxPit
118 virtual void DoCleanExpired ();
119
120 // inherited from Object class
121 virtual void NotifyNewAggregate (); ///< @brief Even when object is aggregated to another Object
122 virtual void DoDispose (); ///< @brief Do cleanup
123
124private:
125 uint32_t
126 GetMaxSize () const;
127
128 void
129 SetMaxSize (uint32_t maxSize);
130
131private:
132 Ptr<CcnxFib> m_fib; ///< \brief Link to FIB table
133};
134
135} // namespace ns3
136
137#endif /* CCNX_PIT_IMPL_H */