blob: 521f3d313d5d4c9426976f4014a40f887a371436 [file] [log] [blame]
Alexander Afanasyevc169a812014-05-20 20:37:29 -04001/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
Alexander Afanasyev04fa37a2014-03-19 18:06:22 -07002/**
Alexander Afanasyev74633892015-02-08 18:08:46 -08003 * Copyright (c) 2013-2015 Regents of the University of California.
Alexander Afanasyevdfa52c42014-04-24 21:10:11 -07004 *
5 * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
Alexander Afanasyevdfa52c42014-04-24 21:10:11 -07006 *
Alexander Afanasyevc169a812014-05-20 20:37:29 -04007 * 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 Afanasyev04fa37a2014-03-19 18:06:22 -070020 */
21
22#ifndef NDN_MANAGEMENT_NFD_FACE_STATUS_HPP
23#define NDN_MANAGEMENT_NFD_FACE_STATUS_HPP
24
Junxiao Shi65f1a712014-11-20 14:59:36 -070025#include "nfd-face-traits.hpp" // include this first, to ensure it compiles on its own.
26#include "../encoding/block.hpp"
Alexander Afanasyeve63eaf62014-06-30 12:40:55 -070027#include "../util/time.hpp"
Alexander Afanasyev04fa37a2014-03-19 18:06:22 -070028
29namespace ndn {
30namespace nfd {
31
Alexander Afanasyev4671bf72014-05-19 09:01:37 -040032/**
33 * \ingroup management
34 * \brief represents Face status
35 * \sa http://redmine.named-data.net/projects/nfd/wiki/FaceMgmt#Face-Dataset
Junxiao Shi7b1ba1a2014-03-29 01:01:56 -070036 */
Chengyu Fan36dca992014-09-25 13:42:03 -060037class FaceStatus : public FaceTraits<FaceStatus>
Alexander Afanasyev04fa37a2014-03-19 18:06:22 -070038{
39public:
Junxiao Shi7b1ba1a2014-03-29 01:01:56 -070040 FaceStatus();
Alexander Afanasyev04fa37a2014-03-19 18:06:22 -070041
42 explicit
Chengyu Fan36dca992014-09-25 13:42:03 -060043 FaceStatus(const Block& block);
Alexander Afanasyev04fa37a2014-03-19 18:06:22 -070044
Junxiao Shi7b1ba1a2014-03-29 01:01:56 -070045 /** \brief prepend FaceStatus to the encoder
46 */
Alexander Afanasyev74633892015-02-08 18:08:46 -080047 template<encoding::Tag TAG>
Junxiao Shi7b1ba1a2014-03-29 01:01:56 -070048 size_t
Alexander Afanasyev74633892015-02-08 18:08:46 -080049 wireEncode(EncodingImpl<TAG>& encoder) const;
Junxiao Shi7b1ba1a2014-03-29 01:01:56 -070050
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
61public: // getters & setters
Alexander Afanasyeve63eaf62014-06-30 12:40:55 -070062 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 Fan36dca992014-09-25 13:42:03 -060076 setExpirationPeriod(const time::milliseconds& expirationPeriod);
Junxiao Shi7b1ba1a2014-03-29 01:01:56 -070077
78 uint64_t
79 getNInInterests() const
80 {
81 return m_nInInterests;
82 }
83
84 FaceStatus&
Chengyu Fan36dca992014-09-25 13:42:03 -060085 setNInInterests(uint64_t nInInterests);
Junxiao Shi7b1ba1a2014-03-29 01:01:56 -070086
87 uint64_t
88 getNInDatas() const
89 {
90 return m_nInDatas;
91 }
92
93 FaceStatus&
Chengyu Fan36dca992014-09-25 13:42:03 -060094 setNInDatas(uint64_t nInDatas);
Junxiao Shi7b1ba1a2014-03-29 01:01:56 -070095
96 uint64_t
Eric Newberry95bd96a2015-09-04 23:34:22 -070097 getNInNacks() const
98 {
99 return m_nInNacks;
100 }
101
102 FaceStatus&
103 setNInNacks(uint64_t nInNacks);
104
105 uint64_t
Junxiao Shi7b1ba1a2014-03-29 01:01:56 -0700106 getNOutInterests() const
107 {
108 return m_nOutInterests;
109 }
110
111 FaceStatus&
Chengyu Fan36dca992014-09-25 13:42:03 -0600112 setNOutInterests(uint64_t nOutInterests);
Junxiao Shi7b1ba1a2014-03-29 01:01:56 -0700113
114 uint64_t
115 getNOutDatas() const
116 {
117 return m_nOutDatas;
118 }
119
120 FaceStatus&
Chengyu Fan36dca992014-09-25 13:42:03 -0600121 setNOutDatas(uint64_t nOutDatas);
Junxiao Shi7b1ba1a2014-03-29 01:01:56 -0700122
Junxiao Shi13e637f2014-07-16 19:20:40 -0700123 uint64_t
Eric Newberry95bd96a2015-09-04 23:34:22 -0700124 getNOutNacks() const
125 {
126 return m_nOutNacks;
127 }
128
129 FaceStatus&
130 setNOutNacks(uint64_t nOutNacks);
131
132 uint64_t
Junxiao Shi13e637f2014-07-16 19:20:40 -0700133 getNInBytes() const
134 {
135 return m_nInBytes;
136 }
137
138 FaceStatus&
Chengyu Fan36dca992014-09-25 13:42:03 -0600139 setNInBytes(uint64_t nInBytes);
Junxiao Shi13e637f2014-07-16 19:20:40 -0700140
141 uint64_t
142 getNOutBytes() const
143 {
144 return m_nOutBytes;
145 }
146
147 FaceStatus&
Chengyu Fan36dca992014-09-25 13:42:03 -0600148 setNOutBytes(uint64_t nOutBytes);
149
150protected:
151 void
152 wireReset() const;
Junxiao Shi13e637f2014-07-16 19:20:40 -0700153
Alexander Afanasyev04fa37a2014-03-19 18:06:22 -0700154private:
Alexander Afanasyeve63eaf62014-06-30 12:40:55 -0700155 time::milliseconds m_expirationPeriod;
156 bool m_hasExpirationPeriod;
Junxiao Shi7b1ba1a2014-03-29 01:01:56 -0700157 uint64_t m_nInInterests;
158 uint64_t m_nInDatas;
Eric Newberry95bd96a2015-09-04 23:34:22 -0700159 uint64_t m_nInNacks;
Junxiao Shi7b1ba1a2014-03-29 01:01:56 -0700160 uint64_t m_nOutInterests;
161 uint64_t m_nOutDatas;
Eric Newberry95bd96a2015-09-04 23:34:22 -0700162 uint64_t m_nOutNacks;
Junxiao Shi13e637f2014-07-16 19:20:40 -0700163 uint64_t m_nInBytes;
164 uint64_t m_nOutBytes;
Alexander Afanasyev04fa37a2014-03-19 18:06:22 -0700165
166 mutable Block m_wire;
167};
168
Junxiao Shi13e637f2014-07-16 19:20:40 -0700169std::ostream&
170operator<<(std::ostream& os, const FaceStatus& status);
Alexander Afanasyev04fa37a2014-03-19 18:06:22 -0700171
172} // namespace nfd
173} // namespace ndn
174
Junxiao Shi7b1ba1a2014-03-29 01:01:56 -0700175#endif // NDN_MANAGEMENT_NFD_FACE_STATUS_HPP