Alexander Afanasyev | 11f7bb4 | 2012-07-09 17:06:30 -0700 | [diff] [blame] | 1 | /* -*- 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 Afanasyev | e3d126f | 2012-07-16 17:07:31 -0700 | [diff] [blame] | 25 | |
| 26 | #include "../../utils/trie-with-policy.h" |
Alexander Afanasyev | 413c7f1 | 2012-07-10 17:35:16 -0700 | [diff] [blame] | 27 | |
| 28 | #include "ccnx-pit-entry-impl.h" |
| 29 | |
Alexander Afanasyev | 11f7bb4 | 2012-07-09 17:06:30 -0700 | [diff] [blame] | 30 | #include "ns3/ccnx-name-components.h" |
| 31 | |
| 32 | namespace ns3 { |
| 33 | |
Alexander Afanasyev | 11f7bb4 | 2012-07-09 17:06:30 -0700 | [diff] [blame] | 34 | /** |
| 35 | * \ingroup ccnx |
| 36 | * \brief Class implementing Pending Interests Table |
| 37 | */ |
Alexander Afanasyev | bd6f3f4 | 2012-07-26 17:50:17 -0700 | [diff] [blame] | 38 | template<class Policy> |
Alexander Afanasyev | 11f7bb4 | 2012-07-09 17:06:30 -0700 | [diff] [blame] | 39 | class CcnxPitImpl : public CcnxPit |
Alexander Afanasyev | 36b4577 | 2012-07-10 16:57:42 -0700 | [diff] [blame] | 40 | , protected ndnSIM::trie_with_policy<CcnxNameComponents, |
Alexander Afanasyev | bd6f3f4 | 2012-07-26 17:50:17 -0700 | [diff] [blame] | 41 | ndnSIM::smart_pointer_payload_traits<CcnxPitEntryImpl< CcnxPitImpl< Policy > > >, |
| 42 | // ndnSIM::persistent_policy_traits |
| 43 | Policy |
Alexander Afanasyev | 36b4577 | 2012-07-10 16:57:42 -0700 | [diff] [blame] | 44 | > |
Alexander Afanasyev | 11f7bb4 | 2012-07-09 17:06:30 -0700 | [diff] [blame] | 45 | { |
| 46 | public: |
Alexander Afanasyev | 36b4577 | 2012-07-10 16:57:42 -0700 | [diff] [blame] | 47 | typedef ndnSIM::trie_with_policy<CcnxNameComponents, |
Alexander Afanasyev | bd6f3f4 | 2012-07-26 17:50:17 -0700 | [diff] [blame] | 48 | ndnSIM::smart_pointer_payload_traits<CcnxPitEntryImpl< CcnxPitImpl< Policy > > >, |
| 49 | // ndnSIM::persistent_policy_traits |
| 50 | Policy |
Alexander Afanasyev | 36b4577 | 2012-07-10 16:57:42 -0700 | [diff] [blame] | 51 | > super; |
Alexander Afanasyev | bd6f3f4 | 2012-07-26 17:50:17 -0700 | [diff] [blame] | 52 | typedef CcnxPitEntryImpl< CcnxPitImpl< Policy > > entry; |
Alexander Afanasyev | 36b4577 | 2012-07-10 16:57:42 -0700 | [diff] [blame] | 53 | |
Alexander Afanasyev | 11f7bb4 | 2012-07-09 17:06:30 -0700 | [diff] [blame] | 54 | /** |
| 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 Afanasyev | 30f60e3 | 2012-07-10 14:21:16 -0700 | [diff] [blame] | 73 | Lookup (const CcnxContentObjectHeader &header); |
Alexander Afanasyev | 11f7bb4 | 2012-07-09 17:06:30 -0700 | [diff] [blame] | 74 | |
| 75 | virtual Ptr<CcnxPitEntry> |
| 76 | Lookup (const CcnxInterestHeader &header); |
| 77 | |
Alexander Afanasyev | 11f7bb4 | 2012-07-09 17:06:30 -0700 | [diff] [blame] | 78 | virtual Ptr<CcnxPitEntry> |
Alexander Afanasyev | 30f60e3 | 2012-07-10 14:21:16 -0700 | [diff] [blame] | 79 | Create (Ptr<const CcnxInterestHeader> header); |
Alexander Afanasyev | 11f7bb4 | 2012-07-09 17:06:30 -0700 | [diff] [blame] | 80 | |
| 81 | virtual void |
| 82 | MarkErased (Ptr<CcnxPitEntry> entry); |
| 83 | |
| 84 | virtual void |
| 85 | Print (std::ostream &os) const; |
Alexander Afanasyev | 1aa4bbc | 2012-07-09 17:17:25 -0700 | [diff] [blame] | 86 | |
Alexander Afanasyev | f1e013f | 2012-07-11 17:59:40 -0700 | [diff] [blame] | 87 | virtual uint32_t |
| 88 | GetSize () const; |
| 89 | |
Alexander Afanasyev | 30f60e3 | 2012-07-10 14:21:16 -0700 | [diff] [blame] | 90 | virtual Ptr<CcnxPitEntry> |
| 91 | Begin (); |
| 92 | |
| 93 | virtual Ptr<CcnxPitEntry> |
| 94 | End (); |
| 95 | |
| 96 | virtual Ptr<CcnxPitEntry> |
| 97 | Next (Ptr<CcnxPitEntry>); |
Alexander Afanasyev | 11f7bb4 | 2012-07-09 17:06:30 -0700 | [diff] [blame] | 98 | |
| 99 | protected: |
Alexander Afanasyev | 413c7f1 | 2012-07-10 17:35:16 -0700 | [diff] [blame] | 100 | void RescheduleCleaning (); |
| 101 | void CleanExpired (); |
Alexander Afanasyev | 11f7bb4 | 2012-07-09 17:06:30 -0700 | [diff] [blame] | 102 | |
| 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 | |
| 107 | private: |
| 108 | uint32_t |
| 109 | GetMaxSize () const; |
| 110 | |
| 111 | void |
| 112 | SetMaxSize (uint32_t maxSize); |
| 113 | |
| 114 | private: |
Alexander Afanasyev | 413c7f1 | 2012-07-10 17:35:16 -0700 | [diff] [blame] | 115 | EventId m_cleanEvent; |
Alexander Afanasyev | 11f7bb4 | 2012-07-09 17:06:30 -0700 | [diff] [blame] | 116 | Ptr<CcnxFib> m_fib; ///< \brief Link to FIB table |
Alexander Afanasyev | f249a19 | 2012-07-18 16:52:51 -0700 | [diff] [blame] | 117 | Ptr<CcnxForwardingStrategy> m_forwardingStrategy; |
Alexander Afanasyev | 36b4577 | 2012-07-10 16:57:42 -0700 | [diff] [blame] | 118 | |
| 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 Afanasyev | 413c7f1 | 2012-07-10 17:35:16 -0700 | [diff] [blame] | 126 | > time_index; |
| 127 | time_index i_time; |
Alexander Afanasyev | 36b4577 | 2012-07-10 16:57:42 -0700 | [diff] [blame] | 128 | |
| 129 | friend class CcnxPitEntryImpl< CcnxPitImpl >; |
Alexander Afanasyev | 11f7bb4 | 2012-07-09 17:06:30 -0700 | [diff] [blame] | 130 | }; |
| 131 | |
| 132 | } // namespace ns3 |
| 133 | |
| 134 | #endif /* CCNX_PIT_IMPL_H */ |