Alexander Afanasyev | c169a81 | 2014-05-20 20:37:29 -0400 | [diff] [blame] | 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
Alexander Afanasyev | 04fa37a | 2014-03-19 18:06:22 -0700 | [diff] [blame] | 2 | /** |
Alexander Afanasyev | c169a81 | 2014-05-20 20:37:29 -0400 | [diff] [blame] | 3 | * Copyright (c) 2013-2014 Regents of the University of California. |
Alexander Afanasyev | dfa52c4 | 2014-04-24 21:10:11 -0700 | [diff] [blame] | 4 | * |
| 5 | * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions). |
Alexander Afanasyev | dfa52c4 | 2014-04-24 21:10:11 -0700 | [diff] [blame] | 6 | * |
Alexander Afanasyev | c169a81 | 2014-05-20 20:37:29 -0400 | [diff] [blame] | 7 | * ndn-cxx library is free software: you can redistribute it and/or modify it under the |
| 8 | * terms of the GNU Lesser General Public License as published by the Free Software |
| 9 | * Foundation, either version 3 of the License, or (at your option) any later version. |
| 10 | * |
| 11 | * ndn-cxx library is distributed in the hope that it will be useful, but WITHOUT ANY |
| 12 | * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A |
| 13 | * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. |
| 14 | * |
| 15 | * You should have received copies of the GNU General Public License and GNU Lesser |
| 16 | * General Public License along with ndn-cxx, e.g., in COPYING.md file. If not, see |
| 17 | * <http://www.gnu.org/licenses/>. |
| 18 | * |
| 19 | * See AUTHORS.md for complete list of ndn-cxx authors and contributors. |
Alexander Afanasyev | 04fa37a | 2014-03-19 18:06:22 -0700 | [diff] [blame] | 20 | */ |
| 21 | |
| 22 | #ifndef NDN_MANAGEMENT_NFD_FACE_STATUS_HPP |
| 23 | #define NDN_MANAGEMENT_NFD_FACE_STATUS_HPP |
| 24 | |
Junxiao Shi | 7b1ba1a | 2014-03-29 01:01:56 -0700 | [diff] [blame] | 25 | // This include must be kept as the first one, to ensure nfd-face-flags.hpp compiles on its own. |
Chengyu Fan | 36dca99 | 2014-09-25 13:42:03 -0600 | [diff] [blame] | 26 | #include "nfd-face-traits.hpp" |
Junxiao Shi | 7b1ba1a | 2014-03-29 01:01:56 -0700 | [diff] [blame] | 27 | |
Alexander Afanasyev | e63eaf6 | 2014-06-30 12:40:55 -0700 | [diff] [blame] | 28 | #include "../util/time.hpp" |
Alexander Afanasyev | 04fa37a | 2014-03-19 18:06:22 -0700 | [diff] [blame] | 29 | |
| 30 | namespace ndn { |
| 31 | namespace nfd { |
| 32 | |
Alexander Afanasyev | 4671bf7 | 2014-05-19 09:01:37 -0400 | [diff] [blame] | 33 | /** |
| 34 | * \ingroup management |
| 35 | * \brief represents Face status |
| 36 | * \sa http://redmine.named-data.net/projects/nfd/wiki/FaceMgmt#Face-Dataset |
Junxiao Shi | 7b1ba1a | 2014-03-29 01:01:56 -0700 | [diff] [blame] | 37 | */ |
Chengyu Fan | 36dca99 | 2014-09-25 13:42:03 -0600 | [diff] [blame] | 38 | class FaceStatus : public FaceTraits<FaceStatus> |
Alexander Afanasyev | 04fa37a | 2014-03-19 18:06:22 -0700 | [diff] [blame] | 39 | { |
| 40 | public: |
Junxiao Shi | 7b1ba1a | 2014-03-29 01:01:56 -0700 | [diff] [blame] | 41 | FaceStatus(); |
Alexander Afanasyev | 04fa37a | 2014-03-19 18:06:22 -0700 | [diff] [blame] | 42 | |
| 43 | explicit |
Chengyu Fan | 36dca99 | 2014-09-25 13:42:03 -0600 | [diff] [blame] | 44 | FaceStatus(const Block& block); |
Alexander Afanasyev | 04fa37a | 2014-03-19 18:06:22 -0700 | [diff] [blame] | 45 | |
Junxiao Shi | 7b1ba1a | 2014-03-29 01:01:56 -0700 | [diff] [blame] | 46 | /** \brief prepend FaceStatus to the encoder |
| 47 | */ |
| 48 | template<bool T> |
| 49 | size_t |
| 50 | wireEncode(EncodingImpl<T>& encoder) const; |
| 51 | |
| 52 | /** \brief encode FaceStatus |
| 53 | */ |
| 54 | const Block& |
| 55 | wireEncode() const; |
| 56 | |
| 57 | /** \brief decode FaceStatus |
| 58 | */ |
| 59 | void |
| 60 | wireDecode(const Block& wire); |
| 61 | |
| 62 | public: // getters & setters |
Alexander Afanasyev | e63eaf6 | 2014-06-30 12:40:55 -0700 | [diff] [blame] | 63 | bool |
| 64 | hasExpirationPeriod() const |
| 65 | { |
| 66 | return m_hasExpirationPeriod; |
| 67 | } |
| 68 | |
| 69 | const time::milliseconds& |
| 70 | getExpirationPeriod() const |
| 71 | { |
| 72 | BOOST_ASSERT(m_hasExpirationPeriod); |
| 73 | return m_expirationPeriod; |
| 74 | } |
| 75 | |
| 76 | FaceStatus& |
Chengyu Fan | 36dca99 | 2014-09-25 13:42:03 -0600 | [diff] [blame] | 77 | setExpirationPeriod(const time::milliseconds& expirationPeriod); |
Junxiao Shi | 7b1ba1a | 2014-03-29 01:01:56 -0700 | [diff] [blame] | 78 | |
| 79 | uint64_t |
| 80 | getNInInterests() const |
| 81 | { |
| 82 | return m_nInInterests; |
| 83 | } |
| 84 | |
| 85 | FaceStatus& |
Chengyu Fan | 36dca99 | 2014-09-25 13:42:03 -0600 | [diff] [blame] | 86 | setNInInterests(uint64_t nInInterests); |
Junxiao Shi | 7b1ba1a | 2014-03-29 01:01:56 -0700 | [diff] [blame] | 87 | |
| 88 | uint64_t |
| 89 | getNInDatas() const |
| 90 | { |
| 91 | return m_nInDatas; |
| 92 | } |
| 93 | |
| 94 | FaceStatus& |
Chengyu Fan | 36dca99 | 2014-09-25 13:42:03 -0600 | [diff] [blame] | 95 | setNInDatas(uint64_t nInDatas); |
Junxiao Shi | 7b1ba1a | 2014-03-29 01:01:56 -0700 | [diff] [blame] | 96 | |
| 97 | uint64_t |
| 98 | getNOutInterests() const |
| 99 | { |
| 100 | return m_nOutInterests; |
| 101 | } |
| 102 | |
| 103 | FaceStatus& |
Chengyu Fan | 36dca99 | 2014-09-25 13:42:03 -0600 | [diff] [blame] | 104 | setNOutInterests(uint64_t nOutInterests); |
Junxiao Shi | 7b1ba1a | 2014-03-29 01:01:56 -0700 | [diff] [blame] | 105 | |
| 106 | uint64_t |
| 107 | getNOutDatas() const |
| 108 | { |
| 109 | return m_nOutDatas; |
| 110 | } |
| 111 | |
| 112 | FaceStatus& |
Chengyu Fan | 36dca99 | 2014-09-25 13:42:03 -0600 | [diff] [blame] | 113 | setNOutDatas(uint64_t nOutDatas); |
Junxiao Shi | 7b1ba1a | 2014-03-29 01:01:56 -0700 | [diff] [blame] | 114 | |
Junxiao Shi | 13e637f | 2014-07-16 19:20:40 -0700 | [diff] [blame] | 115 | uint64_t |
| 116 | getNInBytes() const |
| 117 | { |
| 118 | return m_nInBytes; |
| 119 | } |
| 120 | |
| 121 | FaceStatus& |
Chengyu Fan | 36dca99 | 2014-09-25 13:42:03 -0600 | [diff] [blame] | 122 | setNInBytes(uint64_t nInBytes); |
Junxiao Shi | 13e637f | 2014-07-16 19:20:40 -0700 | [diff] [blame] | 123 | |
| 124 | uint64_t |
| 125 | getNOutBytes() const |
| 126 | { |
| 127 | return m_nOutBytes; |
| 128 | } |
| 129 | |
| 130 | FaceStatus& |
Chengyu Fan | 36dca99 | 2014-09-25 13:42:03 -0600 | [diff] [blame] | 131 | setNOutBytes(uint64_t nOutBytes); |
| 132 | |
| 133 | protected: |
| 134 | void |
| 135 | wireReset() const; |
Junxiao Shi | 13e637f | 2014-07-16 19:20:40 -0700 | [diff] [blame] | 136 | |
Alexander Afanasyev | 04fa37a | 2014-03-19 18:06:22 -0700 | [diff] [blame] | 137 | private: |
Alexander Afanasyev | e63eaf6 | 2014-06-30 12:40:55 -0700 | [diff] [blame] | 138 | time::milliseconds m_expirationPeriod; |
| 139 | bool m_hasExpirationPeriod; |
Junxiao Shi | 7b1ba1a | 2014-03-29 01:01:56 -0700 | [diff] [blame] | 140 | uint64_t m_nInInterests; |
| 141 | uint64_t m_nInDatas; |
| 142 | uint64_t m_nOutInterests; |
| 143 | uint64_t m_nOutDatas; |
Junxiao Shi | 13e637f | 2014-07-16 19:20:40 -0700 | [diff] [blame] | 144 | uint64_t m_nInBytes; |
| 145 | uint64_t m_nOutBytes; |
Alexander Afanasyev | 04fa37a | 2014-03-19 18:06:22 -0700 | [diff] [blame] | 146 | |
| 147 | mutable Block m_wire; |
| 148 | }; |
| 149 | |
Junxiao Shi | 13e637f | 2014-07-16 19:20:40 -0700 | [diff] [blame] | 150 | std::ostream& |
| 151 | operator<<(std::ostream& os, const FaceStatus& status); |
Alexander Afanasyev | 04fa37a | 2014-03-19 18:06:22 -0700 | [diff] [blame] | 152 | |
| 153 | } // namespace nfd |
| 154 | } // namespace ndn |
| 155 | |
Junxiao Shi | 7b1ba1a | 2014-03-29 01:01:56 -0700 | [diff] [blame] | 156 | #endif // NDN_MANAGEMENT_NFD_FACE_STATUS_HPP |