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" |
| 25 | #include "../utils/trie-with-policy.h" |
| 26 | #include "../utils/empty-policy.h" |
Alexander Afanasyev | 30f60e3 | 2012-07-10 14:21:16 -0700 | [diff] [blame] | 27 | #include "../utils/persistent-policy.h" |
Alexander Afanasyev | 413c7f1 | 2012-07-10 17:35:16 -0700 | [diff] [blame] | 28 | |
| 29 | #include "ccnx-pit-entry-impl.h" |
| 30 | |
Alexander Afanasyev | 11f7bb4 | 2012-07-09 17:06:30 -0700 | [diff] [blame] | 31 | #include "ns3/ccnx-name-components.h" |
| 32 | |
| 33 | namespace ns3 { |
| 34 | |
Alexander Afanasyev | 11f7bb4 | 2012-07-09 17:06:30 -0700 | [diff] [blame] | 35 | /** |
| 36 | * \ingroup ccnx |
| 37 | * \brief Class implementing Pending Interests Table |
| 38 | */ |
| 39 | class CcnxPitImpl : public CcnxPit |
Alexander Afanasyev | 36b4577 | 2012-07-10 16:57:42 -0700 | [diff] [blame] | 40 | , protected ndnSIM::trie_with_policy<CcnxNameComponents, |
| 41 | ndnSIM::smart_pointer_payload_traits<CcnxPitEntryImpl< CcnxPitImpl > >, |
| 42 | ndnSIM::persistent_policy_traits |
| 43 | > |
Alexander Afanasyev | 11f7bb4 | 2012-07-09 17:06:30 -0700 | [diff] [blame] | 44 | { |
| 45 | public: |
Alexander Afanasyev | 36b4577 | 2012-07-10 16:57:42 -0700 | [diff] [blame] | 46 | 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 Afanasyev | 11f7bb4 | 2012-07-09 17:06:30 -0700 | [diff] [blame] | 52 | /** |
| 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 Afanasyev | 30f60e3 | 2012-07-10 14:21:16 -0700 | [diff] [blame] | 71 | Lookup (const CcnxContentObjectHeader &header); |
Alexander Afanasyev | 11f7bb4 | 2012-07-09 17:06:30 -0700 | [diff] [blame] | 72 | |
| 73 | virtual Ptr<CcnxPitEntry> |
| 74 | Lookup (const CcnxInterestHeader &header); |
| 75 | |
Alexander Afanasyev | 11f7bb4 | 2012-07-09 17:06:30 -0700 | [diff] [blame] | 76 | virtual Ptr<CcnxPitEntry> |
Alexander Afanasyev | 30f60e3 | 2012-07-10 14:21:16 -0700 | [diff] [blame] | 77 | Create (Ptr<const CcnxInterestHeader> header); |
Alexander Afanasyev | 11f7bb4 | 2012-07-09 17:06:30 -0700 | [diff] [blame] | 78 | |
| 79 | virtual void |
| 80 | MarkErased (Ptr<CcnxPitEntry> entry); |
| 81 | |
| 82 | virtual void |
| 83 | Print (std::ostream &os) const; |
Alexander Afanasyev | 1aa4bbc | 2012-07-09 17:17:25 -0700 | [diff] [blame] | 84 | |
Alexander Afanasyev | 30f60e3 | 2012-07-10 14:21:16 -0700 | [diff] [blame] | 85 | virtual Ptr<CcnxPitEntry> |
| 86 | Begin (); |
| 87 | |
| 88 | virtual Ptr<CcnxPitEntry> |
| 89 | End (); |
| 90 | |
| 91 | virtual Ptr<CcnxPitEntry> |
| 92 | Next (Ptr<CcnxPitEntry>); |
Alexander Afanasyev | 11f7bb4 | 2012-07-09 17:06:30 -0700 | [diff] [blame] | 93 | |
| 94 | protected: |
Alexander Afanasyev | 413c7f1 | 2012-07-10 17:35:16 -0700 | [diff] [blame] | 95 | void RescheduleCleaning (); |
| 96 | void CleanExpired (); |
Alexander Afanasyev | 11f7bb4 | 2012-07-09 17:06:30 -0700 | [diff] [blame] | 97 | |
| 98 | // inherited from Object class |
| 99 | virtual void NotifyNewAggregate (); ///< @brief Even when object is aggregated to another Object |
| 100 | virtual void DoDispose (); ///< @brief Do cleanup |
| 101 | |
| 102 | private: |
| 103 | uint32_t |
| 104 | GetMaxSize () const; |
| 105 | |
| 106 | void |
| 107 | SetMaxSize (uint32_t maxSize); |
| 108 | |
| 109 | private: |
Alexander Afanasyev | 413c7f1 | 2012-07-10 17:35:16 -0700 | [diff] [blame] | 110 | EventId m_cleanEvent; |
Alexander Afanasyev | 11f7bb4 | 2012-07-09 17:06:30 -0700 | [diff] [blame] | 111 | Ptr<CcnxFib> m_fib; ///< \brief Link to FIB table |
Alexander Afanasyev | 36b4577 | 2012-07-10 16:57:42 -0700 | [diff] [blame] | 112 | |
| 113 | // indexes |
| 114 | typedef |
| 115 | boost::intrusive::set<entry, |
| 116 | boost::intrusive::compare < TimestampIndex< entry > >, |
| 117 | boost::intrusive::member_hook< entry, |
| 118 | boost::intrusive::set_member_hook<>, |
| 119 | &entry::time_hook_> |
Alexander Afanasyev | 413c7f1 | 2012-07-10 17:35:16 -0700 | [diff] [blame] | 120 | > time_index; |
| 121 | time_index i_time; |
Alexander Afanasyev | 36b4577 | 2012-07-10 16:57:42 -0700 | [diff] [blame] | 122 | |
| 123 | friend class CcnxPitEntryImpl< CcnxPitImpl >; |
Alexander Afanasyev | 11f7bb4 | 2012-07-09 17:06:30 -0700 | [diff] [blame] | 124 | }; |
| 125 | |
| 126 | } // namespace ns3 |
| 127 | |
| 128 | #endif /* CCNX_PIT_IMPL_H */ |