state.hpp
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright (c) 2014-2020, The University of Memphis
4  *
5  * This file is part of PSync.
6  * See AUTHORS.md for complete list of PSync authors and contributors.
7  *
8  * PSync is free software: you can redistribute it and/or modify it under the terms
9  * of the GNU Lesser General Public License as published by the Free Software Foundation,
10  * either version 3 of the License, or (at your option) any later version.
11  *
12  * PSync is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
13  * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
14  * PURPOSE. See the GNU Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public License along with
17  * PSync, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
18  */
19 
20 #ifndef PSYNC_DETAIL_STATE_HPP
21 #define PSYNC_DETAIL_STATE_HPP
22 
23 #include <ndn-cxx/name.hpp>
24 
25 namespace psync {
26 namespace tlv {
27 
28 enum {
30 };
31 
32 } // namespace tlv
33 
34 namespace detail {
35 
36 class State
37 {
38 public:
39  State() = default;
40 
41  explicit
42  State(const ndn::Block& block);
43 
44  void
45  addContent(const ndn::Name& prefix);
46 
47  const std::vector<ndn::Name>&
48  getContent() const
49  {
50  return m_content;
51  }
52 
53  const ndn::Block&
54  wireEncode() const;
55 
56  template<ndn::encoding::Tag TAG>
57  size_t
58  wireEncode(ndn::EncodingImpl<TAG>& block) const;
59 
60  void
61  wireDecode(const ndn::Block& wire);
62 
63  std::vector<ndn::Name>::const_iterator
64  begin() const
65  {
66  return m_content.cbegin();
67  }
68 
69  std::vector<ndn::Name>::const_iterator
70  end() const
71  {
72  return m_content.cend();
73  }
74 
75 private:
76  std::vector<ndn::Name> m_content;
77  mutable ndn::Block m_wire;
78 };
79 
80 NDN_CXX_DECLARE_WIRE_ENCODE_INSTANTIATIONS(State);
81 
82 std::ostream&
83 operator<<(std::ostream& os, const State& State);
84 
85 } // namespace detail
86 } // namespace psync
87 
88 #endif // PSYNC_DETAIL_STATE_HPP
std::ostream & operator<<(std::ostream &os, const IBLT &iblt)
Definition: iblt.cpp:259
Definition: common.hpp:33
std::vector< ndn::Name >::const_iterator begin() const
Definition: state.hpp:64
std::vector< ndn::Name >::const_iterator end() const
Definition: state.hpp:70
const std::vector< ndn::Name > & getContent() const
Definition: state.hpp:48