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 | 65f1a71 | 2014-11-20 14:59:36 -0700 | [diff] [blame^] | 25 | #include "nfd-face-traits.hpp" // include this first, to ensure it compiles on its own. |
| 26 | #include "../encoding/block.hpp" |
Alexander Afanasyev | e63eaf6 | 2014-06-30 12:40:55 -0700 | [diff] [blame] | 27 | #include "../util/time.hpp" |
Alexander Afanasyev | 04fa37a | 2014-03-19 18:06:22 -0700 | [diff] [blame] | 28 | |
| 29 | namespace ndn { |
| 30 | namespace nfd { |
| 31 | |
Alexander Afanasyev | 4671bf7 | 2014-05-19 09:01:37 -0400 | [diff] [blame] | 32 | /** |
| 33 | * \ingroup management |
| 34 | * \brief represents Face status |
| 35 | * \sa http://redmine.named-data.net/projects/nfd/wiki/FaceMgmt#Face-Dataset |
Junxiao Shi | 7b1ba1a | 2014-03-29 01:01:56 -0700 | [diff] [blame] | 36 | */ |
Chengyu Fan | 36dca99 | 2014-09-25 13:42:03 -0600 | [diff] [blame] | 37 | class FaceStatus : public FaceTraits<FaceStatus> |
Alexander Afanasyev | 04fa37a | 2014-03-19 18:06:22 -0700 | [diff] [blame] | 38 | { |
| 39 | public: |
Junxiao Shi | 7b1ba1a | 2014-03-29 01:01:56 -0700 | [diff] [blame] | 40 | FaceStatus(); |
Alexander Afanasyev | 04fa37a | 2014-03-19 18:06:22 -0700 | [diff] [blame] | 41 | |
| 42 | explicit |
Chengyu Fan | 36dca99 | 2014-09-25 13:42:03 -0600 | [diff] [blame] | 43 | FaceStatus(const Block& block); |
Alexander Afanasyev | 04fa37a | 2014-03-19 18:06:22 -0700 | [diff] [blame] | 44 | |
Junxiao Shi | 7b1ba1a | 2014-03-29 01:01:56 -0700 | [diff] [blame] | 45 | /** \brief prepend FaceStatus to the encoder |
| 46 | */ |
| 47 | template<bool T> |
| 48 | size_t |
| 49 | wireEncode(EncodingImpl<T>& 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 |
Alexander Afanasyev | e63eaf6 | 2014-06-30 12:40:55 -0700 | [diff] [blame] | 62 | bool |
| 63 | hasExpirationPeriod() const |
| 64 | { |
| 65 | return m_hasExpirationPeriod; |
| 66 | } |
| 67 | |
| 68 | const time::milliseconds& |
| 69 | getExpirationPeriod() const |
| 70 | { |
| 71 | BOOST_ASSERT(m_hasExpirationPeriod); |
| 72 | return m_expirationPeriod; |
| 73 | } |
| 74 | |
| 75 | FaceStatus& |
Chengyu Fan | 36dca99 | 2014-09-25 13:42:03 -0600 | [diff] [blame] | 76 | setExpirationPeriod(const time::milliseconds& expirationPeriod); |
Junxiao Shi | 7b1ba1a | 2014-03-29 01:01:56 -0700 | [diff] [blame] | 77 | |
| 78 | uint64_t |
| 79 | getNInInterests() const |
| 80 | { |
| 81 | return m_nInInterests; |
| 82 | } |
| 83 | |
| 84 | FaceStatus& |
Chengyu Fan | 36dca99 | 2014-09-25 13:42:03 -0600 | [diff] [blame] | 85 | setNInInterests(uint64_t nInInterests); |
Junxiao Shi | 7b1ba1a | 2014-03-29 01:01:56 -0700 | [diff] [blame] | 86 | |
| 87 | uint64_t |
| 88 | getNInDatas() const |
| 89 | { |
| 90 | return m_nInDatas; |
| 91 | } |
| 92 | |
| 93 | FaceStatus& |
Chengyu Fan | 36dca99 | 2014-09-25 13:42:03 -0600 | [diff] [blame] | 94 | setNInDatas(uint64_t nInDatas); |
Junxiao Shi | 7b1ba1a | 2014-03-29 01:01:56 -0700 | [diff] [blame] | 95 | |
| 96 | uint64_t |
| 97 | getNOutInterests() const |
| 98 | { |
| 99 | return m_nOutInterests; |
| 100 | } |
| 101 | |
| 102 | FaceStatus& |
Chengyu Fan | 36dca99 | 2014-09-25 13:42:03 -0600 | [diff] [blame] | 103 | setNOutInterests(uint64_t nOutInterests); |
Junxiao Shi | 7b1ba1a | 2014-03-29 01:01:56 -0700 | [diff] [blame] | 104 | |
| 105 | uint64_t |
| 106 | getNOutDatas() const |
| 107 | { |
| 108 | return m_nOutDatas; |
| 109 | } |
| 110 | |
| 111 | FaceStatus& |
Chengyu Fan | 36dca99 | 2014-09-25 13:42:03 -0600 | [diff] [blame] | 112 | setNOutDatas(uint64_t nOutDatas); |
Junxiao Shi | 7b1ba1a | 2014-03-29 01:01:56 -0700 | [diff] [blame] | 113 | |
Junxiao Shi | 13e637f | 2014-07-16 19:20:40 -0700 | [diff] [blame] | 114 | uint64_t |
| 115 | getNInBytes() const |
| 116 | { |
| 117 | return m_nInBytes; |
| 118 | } |
| 119 | |
| 120 | FaceStatus& |
Chengyu Fan | 36dca99 | 2014-09-25 13:42:03 -0600 | [diff] [blame] | 121 | setNInBytes(uint64_t nInBytes); |
Junxiao Shi | 13e637f | 2014-07-16 19:20:40 -0700 | [diff] [blame] | 122 | |
| 123 | uint64_t |
| 124 | getNOutBytes() const |
| 125 | { |
| 126 | return m_nOutBytes; |
| 127 | } |
| 128 | |
| 129 | FaceStatus& |
Chengyu Fan | 36dca99 | 2014-09-25 13:42:03 -0600 | [diff] [blame] | 130 | setNOutBytes(uint64_t nOutBytes); |
| 131 | |
| 132 | protected: |
| 133 | void |
| 134 | wireReset() const; |
Junxiao Shi | 13e637f | 2014-07-16 19:20:40 -0700 | [diff] [blame] | 135 | |
Alexander Afanasyev | 04fa37a | 2014-03-19 18:06:22 -0700 | [diff] [blame] | 136 | private: |
Alexander Afanasyev | e63eaf6 | 2014-06-30 12:40:55 -0700 | [diff] [blame] | 137 | time::milliseconds m_expirationPeriod; |
| 138 | bool m_hasExpirationPeriod; |
Junxiao Shi | 7b1ba1a | 2014-03-29 01:01:56 -0700 | [diff] [blame] | 139 | uint64_t m_nInInterests; |
| 140 | uint64_t m_nInDatas; |
| 141 | uint64_t m_nOutInterests; |
| 142 | uint64_t m_nOutDatas; |
Junxiao Shi | 13e637f | 2014-07-16 19:20:40 -0700 | [diff] [blame] | 143 | uint64_t m_nInBytes; |
| 144 | uint64_t m_nOutBytes; |
Alexander Afanasyev | 04fa37a | 2014-03-19 18:06:22 -0700 | [diff] [blame] | 145 | |
| 146 | mutable Block m_wire; |
| 147 | }; |
| 148 | |
Junxiao Shi | 13e637f | 2014-07-16 19:20:40 -0700 | [diff] [blame] | 149 | std::ostream& |
| 150 | operator<<(std::ostream& os, const FaceStatus& status); |
Alexander Afanasyev | 04fa37a | 2014-03-19 18:06:22 -0700 | [diff] [blame] | 151 | |
| 152 | } // namespace nfd |
| 153 | } // namespace ndn |
| 154 | |
Junxiao Shi | 7b1ba1a | 2014-03-29 01:01:56 -0700 | [diff] [blame] | 155 | #endif // NDN_MANAGEMENT_NFD_FACE_STATUS_HPP |