Junxiao Shi | 7357ef2 | 2016-09-07 02:39:37 +0000 | [diff] [blame] | 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
Davide Pesavento | 88a0d81 | 2017-08-19 21:31:42 -0400 | [diff] [blame] | 2 | /* |
Eric Newberry | 07d05c9 | 2018-01-22 16:08:01 -0700 | [diff] [blame] | 3 | * Copyright (c) 2013-2018 Regents of the University of California. |
Junxiao Shi | 7357ef2 | 2016-09-07 02:39:37 +0000 | [diff] [blame] | 4 | * |
| 5 | * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions). |
| 6 | * |
| 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. |
| 20 | */ |
| 21 | |
| 22 | #ifndef NDN_MGMT_NFD_FACE_STATUS_HPP |
| 23 | #define NDN_MGMT_NFD_FACE_STATUS_HPP |
| 24 | |
Davide Pesavento | 7f20d6e | 2017-01-16 14:43:58 -0500 | [diff] [blame] | 25 | #include "face-traits.hpp" |
Junxiao Shi | 7357ef2 | 2016-09-07 02:39:37 +0000 | [diff] [blame] | 26 | #include "../../util/time.hpp" |
| 27 | |
| 28 | namespace ndn { |
| 29 | namespace nfd { |
| 30 | |
| 31 | /** |
| 32 | * \ingroup management |
Davide Pesavento | 4ec7a5a | 2017-02-07 23:13:39 -0500 | [diff] [blame] | 33 | * \brief represents an item in NFD Face dataset |
| 34 | * \sa https://redmine.named-data.net/projects/nfd/wiki/FaceMgmt#Face-Dataset |
Junxiao Shi | 7357ef2 | 2016-09-07 02:39:37 +0000 | [diff] [blame] | 35 | */ |
| 36 | class FaceStatus : public FaceTraits<FaceStatus> |
| 37 | { |
| 38 | public: |
| 39 | FaceStatus(); |
| 40 | |
| 41 | explicit |
| 42 | FaceStatus(const Block& block); |
| 43 | |
| 44 | /** \brief prepend FaceStatus to the encoder |
| 45 | */ |
| 46 | template<encoding::Tag TAG> |
| 47 | size_t |
| 48 | wireEncode(EncodingImpl<TAG>& encoder) const; |
| 49 | |
| 50 | /** \brief encode FaceStatus |
| 51 | */ |
| 52 | const Block& |
| 53 | wireEncode() const; |
| 54 | |
| 55 | /** \brief decode FaceStatus |
| 56 | */ |
| 57 | void |
| 58 | wireDecode(const Block& wire); |
| 59 | |
| 60 | public: // getters & setters |
| 61 | bool |
| 62 | hasExpirationPeriod() const |
| 63 | { |
Davide Pesavento | 4ec7a5a | 2017-02-07 23:13:39 -0500 | [diff] [blame] | 64 | return !!m_expirationPeriod; |
Junxiao Shi | 7357ef2 | 2016-09-07 02:39:37 +0000 | [diff] [blame] | 65 | } |
| 66 | |
Davide Pesavento | 4ec7a5a | 2017-02-07 23:13:39 -0500 | [diff] [blame] | 67 | time::milliseconds |
Junxiao Shi | 7357ef2 | 2016-09-07 02:39:37 +0000 | [diff] [blame] | 68 | getExpirationPeriod() const |
| 69 | { |
Davide Pesavento | 4ec7a5a | 2017-02-07 23:13:39 -0500 | [diff] [blame] | 70 | BOOST_ASSERT(hasExpirationPeriod()); |
| 71 | return *m_expirationPeriod; |
Junxiao Shi | 7357ef2 | 2016-09-07 02:39:37 +0000 | [diff] [blame] | 72 | } |
| 73 | |
| 74 | FaceStatus& |
Davide Pesavento | 4ec7a5a | 2017-02-07 23:13:39 -0500 | [diff] [blame] | 75 | setExpirationPeriod(time::milliseconds expirationPeriod); |
Junxiao Shi | 7357ef2 | 2016-09-07 02:39:37 +0000 | [diff] [blame] | 76 | |
Davide Pesavento | 156c1ea | 2017-03-19 16:09:33 -0400 | [diff] [blame] | 77 | FaceStatus& |
| 78 | unsetExpirationPeriod(); |
| 79 | |
Eric Newberry | 07d05c9 | 2018-01-22 16:08:01 -0700 | [diff] [blame] | 80 | time::nanoseconds |
| 81 | getBaseCongestionMarkingInterval() const |
| 82 | { |
| 83 | return m_baseCongestionMarkingInterval; |
| 84 | } |
| 85 | |
| 86 | FaceStatus& |
| 87 | setBaseCongestionMarkingInterval(time::nanoseconds interval); |
| 88 | |
| 89 | /** \brief get default congestion threshold (measured in bytes) |
| 90 | */ |
| 91 | uint64_t |
| 92 | getDefaultCongestionThreshold() const |
| 93 | { |
| 94 | return m_defaultCongestionThreshold; |
| 95 | } |
| 96 | |
| 97 | /** \brief set default congestion threshold (measured in bytes) |
| 98 | */ |
| 99 | FaceStatus& |
| 100 | setDefaultCongestionThreshold(uint64_t threshold); |
| 101 | |
Junxiao Shi | 7357ef2 | 2016-09-07 02:39:37 +0000 | [diff] [blame] | 102 | uint64_t |
| 103 | getNInInterests() const |
| 104 | { |
| 105 | return m_nInInterests; |
| 106 | } |
| 107 | |
| 108 | FaceStatus& |
| 109 | setNInInterests(uint64_t nInInterests); |
| 110 | |
| 111 | uint64_t |
Junxiao Shi | 9a53d78 | 2017-04-04 20:09:57 +0000 | [diff] [blame] | 112 | getNInData() const |
Junxiao Shi | 7357ef2 | 2016-09-07 02:39:37 +0000 | [diff] [blame] | 113 | { |
Davide Pesavento | 4ec7a5a | 2017-02-07 23:13:39 -0500 | [diff] [blame] | 114 | return m_nInData; |
Junxiao Shi | 7357ef2 | 2016-09-07 02:39:37 +0000 | [diff] [blame] | 115 | } |
| 116 | |
| 117 | FaceStatus& |
Junxiao Shi | 9a53d78 | 2017-04-04 20:09:57 +0000 | [diff] [blame] | 118 | setNInData(uint64_t nInData); |
| 119 | |
Junxiao Shi | 7357ef2 | 2016-09-07 02:39:37 +0000 | [diff] [blame] | 120 | uint64_t |
| 121 | getNInNacks() const |
| 122 | { |
| 123 | return m_nInNacks; |
| 124 | } |
| 125 | |
| 126 | FaceStatus& |
| 127 | setNInNacks(uint64_t nInNacks); |
| 128 | |
| 129 | uint64_t |
| 130 | getNOutInterests() const |
| 131 | { |
| 132 | return m_nOutInterests; |
| 133 | } |
| 134 | |
| 135 | FaceStatus& |
| 136 | setNOutInterests(uint64_t nOutInterests); |
| 137 | |
| 138 | uint64_t |
Junxiao Shi | 9a53d78 | 2017-04-04 20:09:57 +0000 | [diff] [blame] | 139 | getNOutData() const |
Junxiao Shi | 7357ef2 | 2016-09-07 02:39:37 +0000 | [diff] [blame] | 140 | { |
Davide Pesavento | 4ec7a5a | 2017-02-07 23:13:39 -0500 | [diff] [blame] | 141 | return m_nOutData; |
Junxiao Shi | 7357ef2 | 2016-09-07 02:39:37 +0000 | [diff] [blame] | 142 | } |
| 143 | |
| 144 | FaceStatus& |
Junxiao Shi | 9a53d78 | 2017-04-04 20:09:57 +0000 | [diff] [blame] | 145 | setNOutData(uint64_t nOutData); |
| 146 | |
Junxiao Shi | 7357ef2 | 2016-09-07 02:39:37 +0000 | [diff] [blame] | 147 | uint64_t |
| 148 | getNOutNacks() const |
| 149 | { |
| 150 | return m_nOutNacks; |
| 151 | } |
| 152 | |
| 153 | FaceStatus& |
| 154 | setNOutNacks(uint64_t nOutNacks); |
| 155 | |
| 156 | uint64_t |
| 157 | getNInBytes() const |
| 158 | { |
| 159 | return m_nInBytes; |
| 160 | } |
| 161 | |
| 162 | FaceStatus& |
| 163 | setNInBytes(uint64_t nInBytes); |
| 164 | |
| 165 | uint64_t |
| 166 | getNOutBytes() const |
| 167 | { |
| 168 | return m_nOutBytes; |
| 169 | } |
| 170 | |
| 171 | FaceStatus& |
| 172 | setNOutBytes(uint64_t nOutBytes); |
| 173 | |
Junxiao Shi | 7357ef2 | 2016-09-07 02:39:37 +0000 | [diff] [blame] | 174 | private: |
Davide Pesavento | 4ec7a5a | 2017-02-07 23:13:39 -0500 | [diff] [blame] | 175 | optional<time::milliseconds> m_expirationPeriod; |
Eric Newberry | 07d05c9 | 2018-01-22 16:08:01 -0700 | [diff] [blame] | 176 | time::nanoseconds m_baseCongestionMarkingInterval; |
| 177 | uint64_t m_defaultCongestionThreshold; |
Junxiao Shi | 7357ef2 | 2016-09-07 02:39:37 +0000 | [diff] [blame] | 178 | uint64_t m_nInInterests; |
Davide Pesavento | 4ec7a5a | 2017-02-07 23:13:39 -0500 | [diff] [blame] | 179 | uint64_t m_nInData; |
Junxiao Shi | 7357ef2 | 2016-09-07 02:39:37 +0000 | [diff] [blame] | 180 | uint64_t m_nInNacks; |
| 181 | uint64_t m_nOutInterests; |
Davide Pesavento | 4ec7a5a | 2017-02-07 23:13:39 -0500 | [diff] [blame] | 182 | uint64_t m_nOutData; |
Junxiao Shi | 7357ef2 | 2016-09-07 02:39:37 +0000 | [diff] [blame] | 183 | uint64_t m_nOutNacks; |
| 184 | uint64_t m_nInBytes; |
| 185 | uint64_t m_nOutBytes; |
Junxiao Shi | 7357ef2 | 2016-09-07 02:39:37 +0000 | [diff] [blame] | 186 | }; |
| 187 | |
Davide Pesavento | 88a0d81 | 2017-08-19 21:31:42 -0400 | [diff] [blame] | 188 | NDN_CXX_DECLARE_WIRE_ENCODE_INSTANTIATIONS(FaceStatus); |
| 189 | |
Davide Pesavento | 4ec7a5a | 2017-02-07 23:13:39 -0500 | [diff] [blame] | 190 | bool |
| 191 | operator==(const FaceStatus& a, const FaceStatus& b); |
| 192 | |
| 193 | inline bool |
| 194 | operator!=(const FaceStatus& a, const FaceStatus& b) |
| 195 | { |
| 196 | return !(a == b); |
| 197 | } |
| 198 | |
Junxiao Shi | 7357ef2 | 2016-09-07 02:39:37 +0000 | [diff] [blame] | 199 | std::ostream& |
| 200 | operator<<(std::ostream& os, const FaceStatus& status); |
| 201 | |
| 202 | } // namespace nfd |
| 203 | } // namespace ndn |
| 204 | |
| 205 | #endif // NDN_MGMT_NFD_FACE_STATUS_HPP |