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