Junxiao Shi | 7357ef2 | 2016-09-07 02:39:37 +0000 | [diff] [blame] | 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
| 2 | /** |
Davide Pesavento | 7f20d6e | 2017-01-16 14:43:58 -0500 | [diff] [blame] | 3 | * Copyright (c) 2013-2017 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 | |
| 77 | uint64_t |
| 78 | getNInInterests() const |
| 79 | { |
| 80 | return m_nInInterests; |
| 81 | } |
| 82 | |
| 83 | FaceStatus& |
| 84 | setNInInterests(uint64_t nInInterests); |
| 85 | |
| 86 | uint64_t |
| 87 | getNInDatas() const |
| 88 | { |
Davide Pesavento | 4ec7a5a | 2017-02-07 23:13:39 -0500 | [diff] [blame] | 89 | return m_nInData; |
Junxiao Shi | 7357ef2 | 2016-09-07 02:39:37 +0000 | [diff] [blame] | 90 | } |
| 91 | |
| 92 | FaceStatus& |
Davide Pesavento | 4ec7a5a | 2017-02-07 23:13:39 -0500 | [diff] [blame] | 93 | setNInDatas(uint64_t nInData); |
Junxiao Shi | 7357ef2 | 2016-09-07 02:39:37 +0000 | [diff] [blame] | 94 | |
| 95 | uint64_t |
| 96 | getNInNacks() const |
| 97 | { |
| 98 | return m_nInNacks; |
| 99 | } |
| 100 | |
| 101 | FaceStatus& |
| 102 | setNInNacks(uint64_t nInNacks); |
| 103 | |
| 104 | uint64_t |
| 105 | getNOutInterests() const |
| 106 | { |
| 107 | return m_nOutInterests; |
| 108 | } |
| 109 | |
| 110 | FaceStatus& |
| 111 | setNOutInterests(uint64_t nOutInterests); |
| 112 | |
| 113 | uint64_t |
| 114 | getNOutDatas() const |
| 115 | { |
Davide Pesavento | 4ec7a5a | 2017-02-07 23:13:39 -0500 | [diff] [blame] | 116 | return m_nOutData; |
Junxiao Shi | 7357ef2 | 2016-09-07 02:39:37 +0000 | [diff] [blame] | 117 | } |
| 118 | |
| 119 | FaceStatus& |
Davide Pesavento | 4ec7a5a | 2017-02-07 23:13:39 -0500 | [diff] [blame] | 120 | setNOutDatas(uint64_t nOutData); |
Junxiao Shi | 7357ef2 | 2016-09-07 02:39:37 +0000 | [diff] [blame] | 121 | |
| 122 | uint64_t |
| 123 | getNOutNacks() const |
| 124 | { |
| 125 | return m_nOutNacks; |
| 126 | } |
| 127 | |
| 128 | FaceStatus& |
| 129 | setNOutNacks(uint64_t nOutNacks); |
| 130 | |
| 131 | uint64_t |
| 132 | getNInBytes() const |
| 133 | { |
| 134 | return m_nInBytes; |
| 135 | } |
| 136 | |
| 137 | FaceStatus& |
| 138 | setNInBytes(uint64_t nInBytes); |
| 139 | |
| 140 | uint64_t |
| 141 | getNOutBytes() const |
| 142 | { |
| 143 | return m_nOutBytes; |
| 144 | } |
| 145 | |
| 146 | FaceStatus& |
| 147 | setNOutBytes(uint64_t nOutBytes); |
| 148 | |
Junxiao Shi | 7357ef2 | 2016-09-07 02:39:37 +0000 | [diff] [blame] | 149 | private: |
Davide Pesavento | 4ec7a5a | 2017-02-07 23:13:39 -0500 | [diff] [blame] | 150 | optional<time::milliseconds> m_expirationPeriod; |
Junxiao Shi | 7357ef2 | 2016-09-07 02:39:37 +0000 | [diff] [blame] | 151 | uint64_t m_nInInterests; |
Davide Pesavento | 4ec7a5a | 2017-02-07 23:13:39 -0500 | [diff] [blame] | 152 | uint64_t m_nInData; |
Junxiao Shi | 7357ef2 | 2016-09-07 02:39:37 +0000 | [diff] [blame] | 153 | uint64_t m_nInNacks; |
| 154 | uint64_t m_nOutInterests; |
Davide Pesavento | 4ec7a5a | 2017-02-07 23:13:39 -0500 | [diff] [blame] | 155 | uint64_t m_nOutData; |
Junxiao Shi | 7357ef2 | 2016-09-07 02:39:37 +0000 | [diff] [blame] | 156 | uint64_t m_nOutNacks; |
| 157 | uint64_t m_nInBytes; |
| 158 | uint64_t m_nOutBytes; |
Junxiao Shi | 7357ef2 | 2016-09-07 02:39:37 +0000 | [diff] [blame] | 159 | }; |
| 160 | |
Davide Pesavento | 4ec7a5a | 2017-02-07 23:13:39 -0500 | [diff] [blame] | 161 | bool |
| 162 | operator==(const FaceStatus& a, const FaceStatus& b); |
| 163 | |
| 164 | inline bool |
| 165 | operator!=(const FaceStatus& a, const FaceStatus& b) |
| 166 | { |
| 167 | return !(a == b); |
| 168 | } |
| 169 | |
Junxiao Shi | 7357ef2 | 2016-09-07 02:39:37 +0000 | [diff] [blame] | 170 | std::ostream& |
| 171 | operator<<(std::ostream& os, const FaceStatus& status); |
| 172 | |
| 173 | } // namespace nfd |
| 174 | } // namespace ndn |
| 175 | |
| 176 | #endif // NDN_MGMT_NFD_FACE_STATUS_HPP |