blob: f29b568a4d15b50914abc313ffe725e00a8e87b8 [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
97 getNOutInterests() const
98 {
99 return m_nOutInterests;
100 }
101
102 FaceStatus&
Chengyu Fan36dca992014-09-25 13:42:03 -0600103 setNOutInterests(uint64_t nOutInterests);
Junxiao Shi7b1ba1a2014-03-29 01:01:56 -0700104
105 uint64_t
106 getNOutDatas() const
107 {
108 return m_nOutDatas;
109 }
110
111 FaceStatus&
Chengyu Fan36dca992014-09-25 13:42:03 -0600112 setNOutDatas(uint64_t nOutDatas);
Junxiao Shi7b1ba1a2014-03-29 01:01:56 -0700113
Junxiao Shi13e637f2014-07-16 19:20:40 -0700114 uint64_t
115 getNInBytes() const
116 {
117 return m_nInBytes;
118 }
119
120 FaceStatus&
Chengyu Fan36dca992014-09-25 13:42:03 -0600121 setNInBytes(uint64_t nInBytes);
Junxiao Shi13e637f2014-07-16 19:20:40 -0700122
123 uint64_t
124 getNOutBytes() const
125 {
126 return m_nOutBytes;
127 }
128
129 FaceStatus&
Chengyu Fan36dca992014-09-25 13:42:03 -0600130 setNOutBytes(uint64_t nOutBytes);
131
132protected:
133 void
134 wireReset() const;
Junxiao Shi13e637f2014-07-16 19:20:40 -0700135
Alexander Afanasyev04fa37a2014-03-19 18:06:22 -0700136private:
Alexander Afanasyeve63eaf62014-06-30 12:40:55 -0700137 time::milliseconds m_expirationPeriod;
138 bool m_hasExpirationPeriod;
Junxiao Shi7b1ba1a2014-03-29 01:01:56 -0700139 uint64_t m_nInInterests;
140 uint64_t m_nInDatas;
141 uint64_t m_nOutInterests;
142 uint64_t m_nOutDatas;
Junxiao Shi13e637f2014-07-16 19:20:40 -0700143 uint64_t m_nInBytes;
144 uint64_t m_nOutBytes;
Alexander Afanasyev04fa37a2014-03-19 18:06:22 -0700145
146 mutable Block m_wire;
147};
148
Junxiao Shi13e637f2014-07-16 19:20:40 -0700149std::ostream&
150operator<<(std::ostream& os, const FaceStatus& status);
Alexander Afanasyev04fa37a2014-03-19 18:06:22 -0700151
152} // namespace nfd
153} // namespace ndn
154
Junxiao Shi7b1ba1a2014-03-29 01:01:56 -0700155#endif // NDN_MANAGEMENT_NFD_FACE_STATUS_HPP