blob: 237b3f1cce18f26795723255f4f4ba9e6d1d69fe [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 Afanasyevc169a812014-05-20 20:37:29 -04003 * Copyright (c) 2013-2014 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 Shi7b1ba1a2014-03-29 01:01:56 -070025// This include must be kept as the first one, to ensure nfd-face-flags.hpp compiles on its own.
Chengyu Fan36dca992014-09-25 13:42:03 -060026#include "nfd-face-traits.hpp"
Junxiao Shi7b1ba1a2014-03-29 01:01:56 -070027
Alexander Afanasyeve63eaf62014-06-30 12:40:55 -070028#include "../util/time.hpp"
Alexander Afanasyev04fa37a2014-03-19 18:06:22 -070029
30namespace ndn {
31namespace nfd {
32
Alexander Afanasyev4671bf72014-05-19 09:01:37 -040033/**
34 * \ingroup management
35 * \brief represents Face status
36 * \sa http://redmine.named-data.net/projects/nfd/wiki/FaceMgmt#Face-Dataset
Junxiao Shi7b1ba1a2014-03-29 01:01:56 -070037 */
Chengyu Fan36dca992014-09-25 13:42:03 -060038class FaceStatus : public FaceTraits<FaceStatus>
Alexander Afanasyev04fa37a2014-03-19 18:06:22 -070039{
40public:
Junxiao Shi7b1ba1a2014-03-29 01:01:56 -070041 FaceStatus();
Alexander Afanasyev04fa37a2014-03-19 18:06:22 -070042
43 explicit
Chengyu Fan36dca992014-09-25 13:42:03 -060044 FaceStatus(const Block& block);
Alexander Afanasyev04fa37a2014-03-19 18:06:22 -070045
Junxiao Shi7b1ba1a2014-03-29 01:01:56 -070046 /** \brief prepend FaceStatus to the encoder
47 */
48 template<bool T>
49 size_t
50 wireEncode(EncodingImpl<T>& encoder) const;
51
52 /** \brief encode FaceStatus
53 */
54 const Block&
55 wireEncode() const;
56
57 /** \brief decode FaceStatus
58 */
59 void
60 wireDecode(const Block& wire);
61
62public: // getters & setters
Alexander Afanasyeve63eaf62014-06-30 12:40:55 -070063 bool
64 hasExpirationPeriod() const
65 {
66 return m_hasExpirationPeriod;
67 }
68
69 const time::milliseconds&
70 getExpirationPeriod() const
71 {
72 BOOST_ASSERT(m_hasExpirationPeriod);
73 return m_expirationPeriod;
74 }
75
76 FaceStatus&
Chengyu Fan36dca992014-09-25 13:42:03 -060077 setExpirationPeriod(const time::milliseconds& expirationPeriod);
Junxiao Shi7b1ba1a2014-03-29 01:01:56 -070078
79 uint64_t
80 getNInInterests() const
81 {
82 return m_nInInterests;
83 }
84
85 FaceStatus&
Chengyu Fan36dca992014-09-25 13:42:03 -060086 setNInInterests(uint64_t nInInterests);
Junxiao Shi7b1ba1a2014-03-29 01:01:56 -070087
88 uint64_t
89 getNInDatas() const
90 {
91 return m_nInDatas;
92 }
93
94 FaceStatus&
Chengyu Fan36dca992014-09-25 13:42:03 -060095 setNInDatas(uint64_t nInDatas);
Junxiao Shi7b1ba1a2014-03-29 01:01:56 -070096
97 uint64_t
98 getNOutInterests() const
99 {
100 return m_nOutInterests;
101 }
102
103 FaceStatus&
Chengyu Fan36dca992014-09-25 13:42:03 -0600104 setNOutInterests(uint64_t nOutInterests);
Junxiao Shi7b1ba1a2014-03-29 01:01:56 -0700105
106 uint64_t
107 getNOutDatas() const
108 {
109 return m_nOutDatas;
110 }
111
112 FaceStatus&
Chengyu Fan36dca992014-09-25 13:42:03 -0600113 setNOutDatas(uint64_t nOutDatas);
Junxiao Shi7b1ba1a2014-03-29 01:01:56 -0700114
Junxiao Shi13e637f2014-07-16 19:20:40 -0700115 uint64_t
116 getNInBytes() const
117 {
118 return m_nInBytes;
119 }
120
121 FaceStatus&
Chengyu Fan36dca992014-09-25 13:42:03 -0600122 setNInBytes(uint64_t nInBytes);
Junxiao Shi13e637f2014-07-16 19:20:40 -0700123
124 uint64_t
125 getNOutBytes() const
126 {
127 return m_nOutBytes;
128 }
129
130 FaceStatus&
Chengyu Fan36dca992014-09-25 13:42:03 -0600131 setNOutBytes(uint64_t nOutBytes);
132
133protected:
134 void
135 wireReset() const;
Junxiao Shi13e637f2014-07-16 19:20:40 -0700136
Alexander Afanasyev04fa37a2014-03-19 18:06:22 -0700137private:
Alexander Afanasyeve63eaf62014-06-30 12:40:55 -0700138 time::milliseconds m_expirationPeriod;
139 bool m_hasExpirationPeriod;
Junxiao Shi7b1ba1a2014-03-29 01:01:56 -0700140 uint64_t m_nInInterests;
141 uint64_t m_nInDatas;
142 uint64_t m_nOutInterests;
143 uint64_t m_nOutDatas;
Junxiao Shi13e637f2014-07-16 19:20:40 -0700144 uint64_t m_nInBytes;
145 uint64_t m_nOutBytes;
Alexander Afanasyev04fa37a2014-03-19 18:06:22 -0700146
147 mutable Block m_wire;
148};
149
Junxiao Shi13e637f2014-07-16 19:20:40 -0700150std::ostream&
151operator<<(std::ostream& os, const FaceStatus& status);
Alexander Afanasyev04fa37a2014-03-19 18:06:22 -0700152
153} // namespace nfd
154} // namespace ndn
155
Junxiao Shi7b1ba1a2014-03-29 01:01:56 -0700156#endif // NDN_MANAGEMENT_NFD_FACE_STATUS_HPP