blob: 1051e65d50a673a11226ad3b3fd3f37931d5865d [file] [log] [blame]
Junxiao Shi7357ef22016-09-07 02:39:37 +00001/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2/**
Davide Pesavento7f20d6e2017-01-16 14:43:58 -05003 * Copyright (c) 2013-2017 Regents of the University of California.
Junxiao Shi7357ef22016-09-07 02:39:37 +00004 *
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 Pesavento7f20d6e2017-01-16 14:43:58 -050025#include "face-traits.hpp"
Junxiao Shi7357ef22016-09-07 02:39:37 +000026#include "../../util/time.hpp"
27
28namespace ndn {
29namespace nfd {
30
31/**
32 * \ingroup management
Davide Pesavento4ec7a5a2017-02-07 23:13:39 -050033 * \brief represents an item in NFD Face dataset
34 * \sa https://redmine.named-data.net/projects/nfd/wiki/FaceMgmt#Face-Dataset
Junxiao Shi7357ef22016-09-07 02:39:37 +000035 */
36class FaceStatus : public FaceTraits<FaceStatus>
37{
38public:
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
60public: // getters & setters
61 bool
62 hasExpirationPeriod() const
63 {
Davide Pesavento4ec7a5a2017-02-07 23:13:39 -050064 return !!m_expirationPeriod;
Junxiao Shi7357ef22016-09-07 02:39:37 +000065 }
66
Davide Pesavento4ec7a5a2017-02-07 23:13:39 -050067 time::milliseconds
Junxiao Shi7357ef22016-09-07 02:39:37 +000068 getExpirationPeriod() const
69 {
Davide Pesavento4ec7a5a2017-02-07 23:13:39 -050070 BOOST_ASSERT(hasExpirationPeriod());
71 return *m_expirationPeriod;
Junxiao Shi7357ef22016-09-07 02:39:37 +000072 }
73
74 FaceStatus&
Davide Pesavento4ec7a5a2017-02-07 23:13:39 -050075 setExpirationPeriod(time::milliseconds expirationPeriod);
Junxiao Shi7357ef22016-09-07 02:39:37 +000076
Davide Pesavento156c1ea2017-03-19 16:09:33 -040077 FaceStatus&
78 unsetExpirationPeriod();
79
Junxiao Shi7357ef22016-09-07 02:39:37 +000080 uint64_t
81 getNInInterests() const
82 {
83 return m_nInInterests;
84 }
85
86 FaceStatus&
87 setNInInterests(uint64_t nInInterests);
88
89 uint64_t
Junxiao Shi9a53d782017-04-04 20:09:57 +000090 getNInData() const
Junxiao Shi7357ef22016-09-07 02:39:37 +000091 {
Davide Pesavento4ec7a5a2017-02-07 23:13:39 -050092 return m_nInData;
Junxiao Shi7357ef22016-09-07 02:39:37 +000093 }
94
Junxiao Shi9a53d782017-04-04 20:09:57 +000095 DEPRECATED(
96 uint64_t
97 getNInDatas() const)
98 {
99 return getNInData();
100 }
101
Junxiao Shi7357ef22016-09-07 02:39:37 +0000102 FaceStatus&
Junxiao Shi9a53d782017-04-04 20:09:57 +0000103 setNInData(uint64_t nInData);
104
105 DEPRECATED(
106 FaceStatus&
107 setNInDatas(uint64_t nInData))
108 {
109 return setNInData(nInData);
110 }
Junxiao Shi7357ef22016-09-07 02:39:37 +0000111
112 uint64_t
113 getNInNacks() const
114 {
115 return m_nInNacks;
116 }
117
118 FaceStatus&
119 setNInNacks(uint64_t nInNacks);
120
121 uint64_t
122 getNOutInterests() const
123 {
124 return m_nOutInterests;
125 }
126
127 FaceStatus&
128 setNOutInterests(uint64_t nOutInterests);
129
130 uint64_t
Junxiao Shi9a53d782017-04-04 20:09:57 +0000131 getNOutData() const
Junxiao Shi7357ef22016-09-07 02:39:37 +0000132 {
Davide Pesavento4ec7a5a2017-02-07 23:13:39 -0500133 return m_nOutData;
Junxiao Shi7357ef22016-09-07 02:39:37 +0000134 }
135
Junxiao Shi9a53d782017-04-04 20:09:57 +0000136 DEPRECATED(
137 uint64_t
138 getNOutDatas() const)
139 {
140 return getNOutData();
141 }
142
Junxiao Shi7357ef22016-09-07 02:39:37 +0000143 FaceStatus&
Junxiao Shi9a53d782017-04-04 20:09:57 +0000144 setNOutData(uint64_t nOutData);
145
146 DEPRECATED(
147 FaceStatus&
148 setNOutDatas(uint64_t nOutData))
149 {
150 return setNOutData(nOutData);
151 }
Junxiao Shi7357ef22016-09-07 02:39:37 +0000152
153 uint64_t
154 getNOutNacks() const
155 {
156 return m_nOutNacks;
157 }
158
159 FaceStatus&
160 setNOutNacks(uint64_t nOutNacks);
161
162 uint64_t
163 getNInBytes() const
164 {
165 return m_nInBytes;
166 }
167
168 FaceStatus&
169 setNInBytes(uint64_t nInBytes);
170
171 uint64_t
172 getNOutBytes() const
173 {
174 return m_nOutBytes;
175 }
176
177 FaceStatus&
178 setNOutBytes(uint64_t nOutBytes);
179
Junxiao Shi7357ef22016-09-07 02:39:37 +0000180private:
Davide Pesavento4ec7a5a2017-02-07 23:13:39 -0500181 optional<time::milliseconds> m_expirationPeriod;
Junxiao Shi7357ef22016-09-07 02:39:37 +0000182 uint64_t m_nInInterests;
Davide Pesavento4ec7a5a2017-02-07 23:13:39 -0500183 uint64_t m_nInData;
Junxiao Shi7357ef22016-09-07 02:39:37 +0000184 uint64_t m_nInNacks;
185 uint64_t m_nOutInterests;
Davide Pesavento4ec7a5a2017-02-07 23:13:39 -0500186 uint64_t m_nOutData;
Junxiao Shi7357ef22016-09-07 02:39:37 +0000187 uint64_t m_nOutNacks;
188 uint64_t m_nInBytes;
189 uint64_t m_nOutBytes;
Junxiao Shi7357ef22016-09-07 02:39:37 +0000190};
191
Davide Pesavento4ec7a5a2017-02-07 23:13:39 -0500192bool
193operator==(const FaceStatus& a, const FaceStatus& b);
194
195inline bool
196operator!=(const FaceStatus& a, const FaceStatus& b)
197{
198 return !(a == b);
199}
200
Junxiao Shi7357ef22016-09-07 02:39:37 +0000201std::ostream&
202operator<<(std::ostream& os, const FaceStatus& status);
203
204} // namespace nfd
205} // namespace ndn
206
207#endif // NDN_MGMT_NFD_FACE_STATUS_HPP