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 "../../encoding/block.hpp" |
| 27 | #include "../../util/time.hpp" |
| 28 | |
| 29 | namespace ndn { |
| 30 | namespace nfd { |
| 31 | |
| 32 | /** |
| 33 | * \ingroup management |
Davide Pesavento | 4ec7a5a | 2017-02-07 23:13:39 -0500 | [diff] [blame^] | 34 | * \brief represents an item in NFD Face dataset |
| 35 | * \sa https://redmine.named-data.net/projects/nfd/wiki/FaceMgmt#Face-Dataset |
Junxiao Shi | 7357ef2 | 2016-09-07 02:39:37 +0000 | [diff] [blame] | 36 | */ |
| 37 | class FaceStatus : public FaceTraits<FaceStatus> |
| 38 | { |
| 39 | public: |
| 40 | FaceStatus(); |
| 41 | |
| 42 | explicit |
| 43 | FaceStatus(const Block& block); |
| 44 | |
| 45 | /** \brief prepend FaceStatus to the encoder |
| 46 | */ |
| 47 | template<encoding::Tag TAG> |
| 48 | size_t |
| 49 | wireEncode(EncodingImpl<TAG>& encoder) const; |
| 50 | |
| 51 | /** \brief encode FaceStatus |
| 52 | */ |
| 53 | const Block& |
| 54 | wireEncode() const; |
| 55 | |
| 56 | /** \brief decode FaceStatus |
| 57 | */ |
| 58 | void |
| 59 | wireDecode(const Block& wire); |
| 60 | |
| 61 | public: // getters & setters |
| 62 | bool |
| 63 | hasExpirationPeriod() const |
| 64 | { |
Davide Pesavento | 4ec7a5a | 2017-02-07 23:13:39 -0500 | [diff] [blame^] | 65 | return !!m_expirationPeriod; |
Junxiao Shi | 7357ef2 | 2016-09-07 02:39:37 +0000 | [diff] [blame] | 66 | } |
| 67 | |
Davide Pesavento | 4ec7a5a | 2017-02-07 23:13:39 -0500 | [diff] [blame^] | 68 | time::milliseconds |
Junxiao Shi | 7357ef2 | 2016-09-07 02:39:37 +0000 | [diff] [blame] | 69 | getExpirationPeriod() const |
| 70 | { |
Davide Pesavento | 4ec7a5a | 2017-02-07 23:13:39 -0500 | [diff] [blame^] | 71 | BOOST_ASSERT(hasExpirationPeriod()); |
| 72 | return *m_expirationPeriod; |
Junxiao Shi | 7357ef2 | 2016-09-07 02:39:37 +0000 | [diff] [blame] | 73 | } |
| 74 | |
| 75 | FaceStatus& |
Davide Pesavento | 4ec7a5a | 2017-02-07 23:13:39 -0500 | [diff] [blame^] | 76 | setExpirationPeriod(time::milliseconds expirationPeriod); |
Junxiao Shi | 7357ef2 | 2016-09-07 02:39:37 +0000 | [diff] [blame] | 77 | |
| 78 | uint64_t |
| 79 | getNInInterests() const |
| 80 | { |
| 81 | return m_nInInterests; |
| 82 | } |
| 83 | |
| 84 | FaceStatus& |
| 85 | setNInInterests(uint64_t nInInterests); |
| 86 | |
| 87 | uint64_t |
| 88 | getNInDatas() const |
| 89 | { |
Davide Pesavento | 4ec7a5a | 2017-02-07 23:13:39 -0500 | [diff] [blame^] | 90 | return m_nInData; |
Junxiao Shi | 7357ef2 | 2016-09-07 02:39:37 +0000 | [diff] [blame] | 91 | } |
| 92 | |
| 93 | FaceStatus& |
Davide Pesavento | 4ec7a5a | 2017-02-07 23:13:39 -0500 | [diff] [blame^] | 94 | setNInDatas(uint64_t nInData); |
Junxiao Shi | 7357ef2 | 2016-09-07 02:39:37 +0000 | [diff] [blame] | 95 | |
| 96 | uint64_t |
| 97 | getNInNacks() const |
| 98 | { |
| 99 | return m_nInNacks; |
| 100 | } |
| 101 | |
| 102 | FaceStatus& |
| 103 | setNInNacks(uint64_t nInNacks); |
| 104 | |
| 105 | uint64_t |
| 106 | getNOutInterests() const |
| 107 | { |
| 108 | return m_nOutInterests; |
| 109 | } |
| 110 | |
| 111 | FaceStatus& |
| 112 | setNOutInterests(uint64_t nOutInterests); |
| 113 | |
| 114 | uint64_t |
| 115 | getNOutDatas() const |
| 116 | { |
Davide Pesavento | 4ec7a5a | 2017-02-07 23:13:39 -0500 | [diff] [blame^] | 117 | return m_nOutData; |
Junxiao Shi | 7357ef2 | 2016-09-07 02:39:37 +0000 | [diff] [blame] | 118 | } |
| 119 | |
| 120 | FaceStatus& |
Davide Pesavento | 4ec7a5a | 2017-02-07 23:13:39 -0500 | [diff] [blame^] | 121 | setNOutDatas(uint64_t nOutData); |
Junxiao Shi | 7357ef2 | 2016-09-07 02:39:37 +0000 | [diff] [blame] | 122 | |
| 123 | uint64_t |
| 124 | getNOutNacks() const |
| 125 | { |
| 126 | return m_nOutNacks; |
| 127 | } |
| 128 | |
| 129 | FaceStatus& |
| 130 | setNOutNacks(uint64_t nOutNacks); |
| 131 | |
| 132 | uint64_t |
| 133 | getNInBytes() const |
| 134 | { |
| 135 | return m_nInBytes; |
| 136 | } |
| 137 | |
| 138 | FaceStatus& |
| 139 | setNInBytes(uint64_t nInBytes); |
| 140 | |
| 141 | uint64_t |
| 142 | getNOutBytes() const |
| 143 | { |
| 144 | return m_nOutBytes; |
| 145 | } |
| 146 | |
| 147 | FaceStatus& |
| 148 | setNOutBytes(uint64_t nOutBytes); |
| 149 | |
| 150 | protected: |
| 151 | void |
Davide Pesavento | 7f20d6e | 2017-01-16 14:43:58 -0500 | [diff] [blame] | 152 | wireReset() const override; |
Junxiao Shi | 7357ef2 | 2016-09-07 02:39:37 +0000 | [diff] [blame] | 153 | |
| 154 | private: |
Davide Pesavento | 4ec7a5a | 2017-02-07 23:13:39 -0500 | [diff] [blame^] | 155 | optional<time::milliseconds> m_expirationPeriod; |
Junxiao Shi | 7357ef2 | 2016-09-07 02:39:37 +0000 | [diff] [blame] | 156 | uint64_t m_nInInterests; |
Davide Pesavento | 4ec7a5a | 2017-02-07 23:13:39 -0500 | [diff] [blame^] | 157 | uint64_t m_nInData; |
Junxiao Shi | 7357ef2 | 2016-09-07 02:39:37 +0000 | [diff] [blame] | 158 | uint64_t m_nInNacks; |
| 159 | uint64_t m_nOutInterests; |
Davide Pesavento | 4ec7a5a | 2017-02-07 23:13:39 -0500 | [diff] [blame^] | 160 | uint64_t m_nOutData; |
Junxiao Shi | 7357ef2 | 2016-09-07 02:39:37 +0000 | [diff] [blame] | 161 | uint64_t m_nOutNacks; |
| 162 | uint64_t m_nInBytes; |
| 163 | uint64_t m_nOutBytes; |
Junxiao Shi | 7357ef2 | 2016-09-07 02:39:37 +0000 | [diff] [blame] | 164 | |
| 165 | mutable Block m_wire; |
| 166 | }; |
| 167 | |
Davide Pesavento | 4ec7a5a | 2017-02-07 23:13:39 -0500 | [diff] [blame^] | 168 | bool |
| 169 | operator==(const FaceStatus& a, const FaceStatus& b); |
| 170 | |
| 171 | inline bool |
| 172 | operator!=(const FaceStatus& a, const FaceStatus& b) |
| 173 | { |
| 174 | return !(a == b); |
| 175 | } |
| 176 | |
Junxiao Shi | 7357ef2 | 2016-09-07 02:39:37 +0000 | [diff] [blame] | 177 | std::ostream& |
| 178 | operator<<(std::ostream& os, const FaceStatus& status); |
| 179 | |
| 180 | } // namespace nfd |
| 181 | } // namespace ndn |
| 182 | |
| 183 | #endif // NDN_MGMT_NFD_FACE_STATUS_HPP |