ndn-cxx: NDN C++ Library 0.9.0-33-g832ea91d
Loading...
Searching...
No Matches
face-status.hpp
Go to the documentation of this file.
1/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2/*
3 * Copyright (c) 2013-2023 Regents of the University of California.
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_CXX_MGMT_NFD_FACE_STATUS_HPP
23#define NDN_CXX_MGMT_NFD_FACE_STATUS_HPP
24
26#include "ndn-cxx/util/time.hpp"
27
28#include <optional>
29
30namespace ndn::nfd {
31
37class FaceStatus : public FaceTraits<FaceStatus>
38{
39public:
41
42 explicit
43 FaceStatus(const Block& block);
44
47 template<encoding::Tag TAG>
48 size_t
49 wireEncode(EncodingImpl<TAG>& encoder) const;
50
53 const Block&
54 wireEncode() const;
55
58 void
59 wireDecode(const Block& wire);
60
61public: // getters & setters
62 bool
64 {
65 return !!m_expirationPeriod;
66 }
67
70 {
71 BOOST_ASSERT(hasExpirationPeriod());
72 return *m_expirationPeriod;
73 }
74
77
80
81 bool
83 {
84 return !!m_baseCongestionMarkingInterval;
85 }
86
89 {
91 return *m_baseCongestionMarkingInterval;
92 }
93
96
99
100 bool
102 {
103 return !!m_defaultCongestionThreshold;
104 }
105
108 uint64_t
110 {
111 BOOST_ASSERT(hasDefaultCongestionThreshold());
112 return *m_defaultCongestionThreshold;
113 }
114
118 setDefaultCongestionThreshold(uint64_t threshold);
119
122
123 bool
124 hasMtu() const
125 {
126 return !!m_mtu;
127 }
128
133 uint64_t
134 getMtu() const
135 {
136 BOOST_ASSERT(hasMtu());
137 return *m_mtu;
138 }
139
145 setMtu(uint64_t mtu);
146
148 unsetMtu();
149
150 uint64_t
152 {
153 return m_nInInterests;
154 }
155
157 setNInInterests(uint64_t nInInterests);
158
159 uint64_t
161 {
162 return m_nInData;
163 }
164
166 setNInData(uint64_t nInData);
167
168 uint64_t
170 {
171 return m_nInNacks;
172 }
173
175 setNInNacks(uint64_t nInNacks);
176
177 uint64_t
179 {
180 return m_nOutInterests;
181 }
182
184 setNOutInterests(uint64_t nOutInterests);
185
186 uint64_t
188 {
189 return m_nOutData;
190 }
191
193 setNOutData(uint64_t nOutData);
194
195 uint64_t
197 {
198 return m_nOutNacks;
199 }
200
202 setNOutNacks(uint64_t nOutNacks);
203
204 uint64_t
206 {
207 return m_nInBytes;
208 }
209
211 setNInBytes(uint64_t nInBytes);
212
213 uint64_t
215 {
216 return m_nOutBytes;
217 }
218
220 setNOutBytes(uint64_t nOutBytes);
221
222private:
223 std::optional<time::milliseconds> m_expirationPeriod;
224 std::optional<time::nanoseconds> m_baseCongestionMarkingInterval;
225 std::optional<uint64_t> m_defaultCongestionThreshold;
226 std::optional<uint64_t> m_mtu;
227 uint64_t m_nInInterests = 0;
228 uint64_t m_nInData = 0;
229 uint64_t m_nInNacks = 0;
230 uint64_t m_nOutInterests = 0;
231 uint64_t m_nOutData = 0;
232 uint64_t m_nOutNacks = 0;
233 uint64_t m_nInBytes = 0;
234 uint64_t m_nOutBytes = 0;
235};
236
238
239bool
240operator==(const FaceStatus& a, const FaceStatus& b);
241
242inline bool
244{
245 return !(a == b);
246}
247
248std::ostream&
249operator<<(std::ostream& os, const FaceStatus& status);
250
251} // namespace ndn::nfd
252
253#endif // NDN_CXX_MGMT_NFD_FACE_STATUS_HPP
Represents a TLV element of the NDN packet format.
Definition block.hpp:45
Represents an item in NFD Face dataset.
FaceStatus & setNOutInterests(uint64_t nOutInterests)
const Block & wireEncode() const
Encode FaceStatus.
FaceStatus & unsetExpirationPeriod()
FaceStatus & setNOutData(uint64_t nOutData)
FaceStatus & unsetDefaultCongestionThreshold()
FaceStatus & setNOutBytes(uint64_t nOutBytes)
uint64_t getNOutInterests() const
FaceStatus & setNInInterests(uint64_t nInInterests)
FaceStatus & setNOutNacks(uint64_t nOutNacks)
uint64_t getNInData() const
uint64_t getNInBytes() const
void wireDecode(const Block &wire)
Decode FaceStatus.
uint64_t getNOutData() const
FaceStatus & setNInData(uint64_t nInData)
FaceStatus & setExpirationPeriod(time::milliseconds expirationPeriod)
FaceStatus & unsetMtu()
uint64_t getDefaultCongestionThreshold() const
Get default congestion threshold (measured in bytes).
bool hasBaseCongestionMarkingInterval() const
time::nanoseconds getBaseCongestionMarkingInterval() const
uint64_t getNInInterests() const
uint64_t getNInNacks() const
FaceStatus & setNInNacks(uint64_t nInNacks)
FaceStatus & setNInBytes(uint64_t nInBytes)
FaceStatus & setMtu(uint64_t mtu)
Set MTU (measured in bytes).
bool hasExpirationPeriod() const
uint64_t getMtu() const
Get MTU (measured in bytes).
FaceStatus & setDefaultCongestionThreshold(uint64_t threshold)
Set default congestion threshold (measured in bytes).
bool hasDefaultCongestionThreshold() const
FaceStatus & setBaseCongestionMarkingInterval(time::nanoseconds interval)
uint64_t getNOutBytes() const
FaceStatus & unsetBaseCongestionMarkingInterval()
time::milliseconds getExpirationPeriod() const
uint64_t getNOutNacks() const
Provides getters and setters for face information fields.
#define NDN_CXX_DECLARE_WIRE_ENCODE_INSTANTIATIONS(ClassName)
Contains classes and functions related to the NFD Management protocol.
bool operator!=(const ChannelStatus &a, const ChannelStatus &b)
std::ostream & operator<<(std::ostream &os, FaceScope faceScope)
bool operator==(const ChannelStatus &a, const ChannelStatus &b)
::boost::chrono::milliseconds milliseconds
Definition time.hpp:52
::boost::chrono::nanoseconds nanoseconds
Definition time.hpp:54