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" |
| 27 | #include "ns3/ccnx-name-components.h" |
| 28 | |
| 29 | namespace ns3 { |
| 30 | |
| 31 | class CcnxPitEntryImpl : public CcnxPitEntry |
| 32 | { |
| 33 | public: |
| 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 | |
| 55 | private: |
| 56 | trie::iterator item_; |
| 57 | }; |
| 58 | |
| 59 | //////////////////////////////////////////////////////////////////////// |
| 60 | //////////////////////////////////////////////////////////////////////// |
| 61 | |
| 62 | /** |
| 63 | * \ingroup ccnx |
| 64 | * \brief Class implementing Pending Interests Table |
| 65 | */ |
| 66 | class CcnxPitImpl : public CcnxPit |
| 67 | , protected CcnxPitEntryImpl::trie |
| 68 | { |
| 69 | public: |
Alexander Afanasyev | 1aa4bbc | 2012-07-09 17:17:25 -0700 | [diff] [blame^] | 70 | typedef CcnxPitEntryImpl::trie super; |
| 71 | |
Alexander Afanasyev | 11f7bb4 | 2012-07-09 17:06:30 -0700 | [diff] [blame] | 72 | /** |
| 73 | * \brief Interface ID |
| 74 | * |
| 75 | * \return interface ID |
| 76 | */ |
| 77 | static TypeId GetTypeId (); |
| 78 | |
| 79 | /** |
| 80 | * \brief PIT constructor |
| 81 | */ |
| 82 | CcnxPitImpl (); |
| 83 | |
| 84 | /** |
| 85 | * \brief Destructor |
| 86 | */ |
| 87 | virtual ~CcnxPitImpl (); |
| 88 | |
| 89 | // inherited from CcnxPit |
| 90 | virtual Ptr<CcnxPitEntry> |
| 91 | Lookup (const CcnxContentObjectHeader &header) const; |
| 92 | |
| 93 | virtual Ptr<CcnxPitEntry> |
| 94 | Lookup (const CcnxInterestHeader &header); |
| 95 | |
| 96 | virtual bool |
| 97 | CheckIfDuplicate (Ptr<CcnxPitEntry> entry, const CcnxInterestHeader &header); |
| 98 | |
| 99 | virtual Ptr<CcnxPitEntry> |
| 100 | Create (const CcnxInterestHeader &header); |
| 101 | |
| 102 | virtual void |
| 103 | MarkErased (Ptr<CcnxPitEntry> entry); |
| 104 | |
| 105 | virtual void |
| 106 | Print (std::ostream &os) const; |
Alexander Afanasyev | 1aa4bbc | 2012-07-09 17:17:25 -0700 | [diff] [blame^] | 107 | |
| 108 | // /** |
| 109 | // * @brief Modify element in container |
| 110 | // */ |
| 111 | // template<typename Modifier> |
| 112 | // bool |
| 113 | // modify (Ptr<CcnxPitEntry> item, Modifier mod) |
| 114 | // { |
| 115 | // return super::modify (StaticCast<CcnxPitEntryImpl> (item)->to_iterator (), mod); |
| 116 | // } |
Alexander Afanasyev | 11f7bb4 | 2012-07-09 17:06:30 -0700 | [diff] [blame] | 117 | |
| 118 | protected: |
| 119 | // inherited from CcnxPit |
| 120 | virtual void DoCleanExpired (); |
| 121 | |
| 122 | // inherited from Object class |
| 123 | virtual void NotifyNewAggregate (); ///< @brief Even when object is aggregated to another Object |
| 124 | virtual void DoDispose (); ///< @brief Do cleanup |
| 125 | |
| 126 | private: |
| 127 | uint32_t |
| 128 | GetMaxSize () const; |
| 129 | |
| 130 | void |
| 131 | SetMaxSize (uint32_t maxSize); |
| 132 | |
| 133 | private: |
| 134 | Ptr<CcnxFib> m_fib; ///< \brief Link to FIB table |
| 135 | }; |
| 136 | |
| 137 | } // namespace ns3 |
| 138 | |
| 139 | #endif /* CCNX_PIT_IMPL_H */ |