Alexander Afanasyev | 1a0fff6 | 2013-01-19 14:29:51 -0800 | [diff] [blame] | 1 | /* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil -*- */ |
| 2 | /* |
| 3 | * Copyright (c) 2013 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 NDN_FW_HOP_COUNT_TAG_H |
| 22 | #define NDN_FW_HOP_COUNT_TAG_H |
| 23 | |
| 24 | #include "ns3/tag.h" |
| 25 | |
| 26 | namespace ns3 { |
| 27 | namespace ndn { |
| 28 | |
| 29 | /** |
Alexander Afanasyev | 7920651 | 2013-07-27 16:49:12 -0700 | [diff] [blame] | 30 | * @ingroup ndn-fw |
Alexander Afanasyev | 1a0fff6 | 2013-01-19 14:29:51 -0800 | [diff] [blame] | 31 | * @brief Packet tag that is used to track hop count for Interest-Data pairs |
| 32 | */ |
Alexander Afanasyev | be55cf6 | 2014-12-20 17:51:09 -0800 | [diff] [blame] | 33 | class FwHopCountTag : public Tag { |
Alexander Afanasyev | 1a0fff6 | 2013-01-19 14:29:51 -0800 | [diff] [blame] | 34 | public: |
| 35 | static TypeId |
Alexander Afanasyev | be55cf6 | 2014-12-20 17:51:09 -0800 | [diff] [blame] | 36 | GetTypeId(void); |
Alexander Afanasyev | 1a0fff6 | 2013-01-19 14:29:51 -0800 | [diff] [blame] | 37 | |
| 38 | /** |
| 39 | * @brief Default constructor |
| 40 | */ |
Alexander Afanasyev | be55cf6 | 2014-12-20 17:51:09 -0800 | [diff] [blame] | 41 | FwHopCountTag() |
| 42 | : m_hopCount(0){}; |
Alexander Afanasyev | 1a0fff6 | 2013-01-19 14:29:51 -0800 | [diff] [blame] | 43 | |
| 44 | /** |
| 45 | * @brief Destructor |
| 46 | */ |
Alexander Afanasyev | be55cf6 | 2014-12-20 17:51:09 -0800 | [diff] [blame] | 47 | ~FwHopCountTag() |
| 48 | { |
| 49 | } |
Alexander Afanasyev | 1a0fff6 | 2013-01-19 14:29:51 -0800 | [diff] [blame] | 50 | |
| 51 | /** |
| 52 | * @brief Increment hop count |
| 53 | */ |
| 54 | void |
Alexander Afanasyev | be55cf6 | 2014-12-20 17:51:09 -0800 | [diff] [blame] | 55 | Increment() |
| 56 | { |
| 57 | m_hopCount++; |
| 58 | } |
Alexander Afanasyev | 1a0fff6 | 2013-01-19 14:29:51 -0800 | [diff] [blame] | 59 | |
| 60 | /** |
| 61 | * @brief Get value of hop count |
| 62 | */ |
| 63 | uint32_t |
Alexander Afanasyev | be55cf6 | 2014-12-20 17:51:09 -0800 | [diff] [blame] | 64 | Get() const |
| 65 | { |
| 66 | return m_hopCount; |
| 67 | } |
Alexander Afanasyev | 1a0fff6 | 2013-01-19 14:29:51 -0800 | [diff] [blame] | 68 | |
| 69 | //////////////////////////////////////////////////////// |
| 70 | // from ObjectBase |
| 71 | //////////////////////////////////////////////////////// |
| 72 | virtual TypeId |
Alexander Afanasyev | be55cf6 | 2014-12-20 17:51:09 -0800 | [diff] [blame] | 73 | GetInstanceTypeId() const; |
| 74 | |
Alexander Afanasyev | 1a0fff6 | 2013-01-19 14:29:51 -0800 | [diff] [blame] | 75 | //////////////////////////////////////////////////////// |
| 76 | // from Tag |
| 77 | //////////////////////////////////////////////////////// |
Alexander Afanasyev | be55cf6 | 2014-12-20 17:51:09 -0800 | [diff] [blame] | 78 | |
Alexander Afanasyev | 1a0fff6 | 2013-01-19 14:29:51 -0800 | [diff] [blame] | 79 | virtual uint32_t |
Alexander Afanasyev | be55cf6 | 2014-12-20 17:51:09 -0800 | [diff] [blame] | 80 | GetSerializedSize() const; |
Alexander Afanasyev | 1a0fff6 | 2013-01-19 14:29:51 -0800 | [diff] [blame] | 81 | |
| 82 | virtual void |
Alexander Afanasyev | be55cf6 | 2014-12-20 17:51:09 -0800 | [diff] [blame] | 83 | Serialize(TagBuffer i) const; |
Alexander Afanasyev | 1a0fff6 | 2013-01-19 14:29:51 -0800 | [diff] [blame] | 84 | |
| 85 | virtual void |
Alexander Afanasyev | be55cf6 | 2014-12-20 17:51:09 -0800 | [diff] [blame] | 86 | Deserialize(TagBuffer i); |
| 87 | |
| 88 | virtual void |
| 89 | Print(std::ostream& os) const; |
| 90 | |
Alexander Afanasyev | 1a0fff6 | 2013-01-19 14:29:51 -0800 | [diff] [blame] | 91 | private: |
| 92 | uint32_t m_hopCount; |
| 93 | }; |
| 94 | |
| 95 | } // namespace ndn |
| 96 | } // namespace ns3 |
| 97 | |
| 98 | #endif // NDN_FW_HOP_COUNT_TAG_H |