lsdb-status.hpp
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright (c) 2014-2018, The University of Memphis,
4  * Regents of the University of California,
5  * Arizona Board of Regents.
6  *
7  * This file is part of NLSR (Named-data Link State Routing).
8  * See AUTHORS.md for complete list of NLSR authors and contributors.
9  *
10  * NLSR is free software: you can redistribute it and/or modify it under the terms
11  * of the GNU General Public License as published by the Free Software Foundation,
12  * either version 3 of the License, or (at your option) any later version.
13  *
14  * NLSR is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
15  * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
16  * PURPOSE. See the GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License along with
19  * NLSR, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
20  */
21 
22 #ifndef NLSR_TLV_LSDB_STATUS_HPP
23 #define NLSR_TLV_LSDB_STATUS_HPP
24 
25 #include "adjacency-lsa.hpp"
26 #include "coordinate-lsa.hpp"
27 #include "name-lsa.hpp"
28 
29 #include <ndn-cxx/util/time.hpp>
30 #include <ndn-cxx/encoding/block.hpp>
31 #include <ndn-cxx/encoding/encoding-buffer.hpp>
32 #include <ndn-cxx/encoding/tlv.hpp>
33 #include <ndn-cxx/name.hpp>
34 
35 #include <list>
36 
37 namespace nlsr {
38 namespace tlv {
39 
50 {
51 public:
52  class Error : public ndn::tlv::Error
53  {
54  public:
55  explicit
56  Error(const std::string& what)
57  : ndn::tlv::Error(what)
58  {
59  }
60  };
61 
62  typedef std::list<AdjacencyLsa> AdjacencyLsaList;
63  typedef std::list<CoordinateLsa> CoordinateLsaList;
64  typedef std::list<NameLsa> NameLsaList;
65 
66  LsdbStatus();
67 
68  explicit
69  LsdbStatus(const ndn::Block& block);
70 
71  const std::list<AdjacencyLsa>&
73  {
74  return m_adjacencyLsas;
75  }
76 
77  LsdbStatus&
78  addAdjacencyLsa(const AdjacencyLsa& adjacencyLsa);
79 
80  LsdbStatus&
82 
83  bool
85  {
86  return m_hasAdjacencyLsas;
87  }
88 
89  const std::list<CoordinateLsa>&
91  {
92  return m_coordinateLsas;
93  }
94 
95  LsdbStatus&
96  addCoordinateLsa(const CoordinateLsa& coordinateLsa);
97 
98  LsdbStatus&
100 
101  bool
103  {
104  return m_hasCoordinateLsas;
105  }
106 
107  const std::list<NameLsa>&
108  getNameLsas() const
109  {
110  return m_nameLsas;
111  }
112 
113  LsdbStatus&
114  addNameLsa(const NameLsa& nameLsa);
115 
116  LsdbStatus&
117  clearNameLsas();
118 
119  bool
121  {
122  return m_hasNameLsas;
123  }
124 
135  template<ndn::encoding::Tag TAG>
136  size_t
137  wireEncode(ndn::EncodingImpl<TAG>& block) const;
138 
147  const ndn::Block&
148  wireEncode() const;
149 
153  void
154  wireDecode(const ndn::Block& wire);
155 
156 private:
157  AdjacencyLsaList m_adjacencyLsas;
158  CoordinateLsaList m_coordinateLsas;
159  NameLsaList m_nameLsas;
160 
161  bool m_hasAdjacencyLsas;
162  bool m_hasCoordinateLsas;
163  bool m_hasNameLsas;
164 
165  mutable ndn::Block m_wire;
166 };
167 
169 
170 std::ostream&
171 operator<<(std::ostream& os, const LsdbStatus& lsdbStatus);
172 
173 } // namespace tlv
174 } // namespace nlsr
175 
176 #endif // NLSR_TLV_LSDB_STATUS_HPP
std::list< AdjacencyLsa > AdjacencyLsaList
Definition: lsdb-status.hpp:62
Definition: tlv-nlsr.hpp:27
LsdbStatus & clearAdjacencyLsas()
Definition: lsdb-status.cpp:58
void wireDecode(const ndn::Block &wire)
Populate this object by decoding the one contained in the given block.
const std::list< CoordinateLsa > & getCoordinateLsas() const
Definition: lsdb-status.hpp:90
Data abstraction for CoordinateLsa.
const ndn::Block & wireEncode() const
Create a TLV encoding of this object.
LsdbStatus & clearNameLsas()
Definition: lsdb-status.cpp:92
std::list< NameLsa > NameLsaList
Definition: lsdb-status.hpp:64
LsdbStatus & addCoordinateLsa(const CoordinateLsa &coordinateLsa)
Definition: lsdb-status.cpp:66
LsdbStatus & clearCoordinateLsas()
Definition: lsdb-status.cpp:75
LsdbStatus & addAdjacencyLsa(const AdjacencyLsa &adjacencyLsa)
Definition: lsdb-status.cpp:49
Data abstraction for NameLsa.
Definition: name-lsa.hpp:47
std::list< CoordinateLsa > CoordinateLsaList
Definition: lsdb-status.hpp:63
const std::list< AdjacencyLsa > & getAdjacencyLsas() const
Definition: lsdb-status.hpp:72
Copyright (c) 2014-2019, The University of Memphis, Regents of the University of California, Arizona Board of Regents.
Data abstraction for AdjacencyLsa.
Data abstraction for LsdbStatus.
Definition: lsdb-status.hpp:49
LsdbStatus & addNameLsa(const NameLsa &nameLsa)
Definition: lsdb-status.cpp:83
std::ostream & operator<<(std::ostream &os, const AdjacencyLsa &adjacencyLsa)
const std::list< NameLsa > & getNameLsas() const
NDN_CXX_DECLARE_WIRE_ENCODE_INSTANTIATIONS(AdjacencyLsa)
Error(const std::string &what)
Definition: lsdb-status.hpp:56