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-2022, 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::tlv {
26 
27 enum {
28  PSyncContent = 128
29 };
30 
31 } // namespace psync::tlv
32 
33 namespace psync::detail {
34 
35 class State
36 {
37 public:
38  State() = default;
39 
40  explicit
41  State(const ndn::Block& block);
42 
43  void
44  addContent(const ndn::Name& prefix);
45 
46  const std::vector<ndn::Name>&
47  getContent() const
48  {
49  return m_content;
50  }
51 
52  const ndn::Block&
53  wireEncode() const;
54 
55  template<ndn::encoding::Tag TAG>
56  size_t
57  wireEncode(ndn::EncodingImpl<TAG>& block) const;
58 
59  void
60  wireDecode(const ndn::Block& wire);
61 
62  std::vector<ndn::Name>::const_iterator
63  begin() const
64  {
65  return m_content.cbegin();
66  }
67 
68  std::vector<ndn::Name>::const_iterator
69  end() const
70  {
71  return m_content.cend();
72  }
73 
74 private:
75  std::vector<ndn::Name> m_content;
76  mutable ndn::Block m_wire;
77 };
78 
79 NDN_CXX_DECLARE_WIRE_ENCODE_INSTANTIATIONS(State);
80 
81 std::ostream&
82 operator<<(std::ostream& os, const State& State);
83 
84 } // namespace psync::detail
85 
86 #endif // PSYNC_DETAIL_STATE_HPP
const std::vector< ndn::Name > & getContent() const
Definition: state.hpp:47
void wireDecode(const ndn::Block &wire)
Definition: state.cpp:75
std::vector< ndn::Name >::const_iterator begin() const
Definition: state.hpp:63
std::vector< ndn::Name >::const_iterator end() const
Definition: state.hpp:69
void addContent(const ndn::Name &prefix)
Definition: state.cpp:33
const ndn::Block & wireEncode() const
Definition: state.cpp:40
std::ostream & operator<<(std::ostream &os, const IBLT &iblt)
Definition: iblt.cpp:158
@ PSyncContent
Definition: state.hpp:28