adjacency-lsa.hpp
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
22 #ifndef NLSR_TLV_ADJACENCY_LSA_HPP
23 #define NLSR_TLV_ADJACENCY_LSA_HPP
24 
25 #include "lsa-info.hpp"
26 #include "adjacency.hpp"
27 
28 #include <ndn-cxx/util/time.hpp>
29 #include <ndn-cxx/encoding/block.hpp>
30 #include <ndn-cxx/encoding/encoding-buffer.hpp>
31 #include <ndn-cxx/encoding/tlv.hpp>
32 #include <ndn-cxx/name.hpp>
33 
34 #include <list>
35 
36 namespace nlsr {
37 namespace tlv {
38 
49 {
50 public:
51  class Error : public ndn::tlv::Error
52  {
53  public:
54  explicit
55  Error(const std::string& what)
56  : ndn::tlv::Error(what)
57  {
58  }
59  };
60 
61  typedef std::list<Adjacency> AdjacencyList;
63 
64  AdjacencyLsa();
65 
66  explicit
67  AdjacencyLsa(const ndn::Block& block);
68 
69  const LsaInfo&
70  getLsaInfo() const
71  {
72  return m_lsaInfo;
73  }
74 
76  setLsaInfo(const LsaInfo& lsaInfo)
77  {
78  m_lsaInfo = lsaInfo;
79  m_wire.reset();
80  return *this;
81  }
82 
83  bool
85  {
86  return m_hasAdjacencies;
87  }
88 
89  const std::list<Adjacency>&
91  {
92  return m_adjacencies;
93  }
94 
96  addAdjacency(const Adjacency& adjacency)
97  {
98  m_adjacencies.push_back(adjacency);
99  m_wire.reset();
100  m_hasAdjacencies = true;
101  return *this;
102  }
103 
104  AdjacencyLsa&
106  {
107  m_adjacencies.clear();
108  m_hasAdjacencies = false;
109  return *this;
110  }
111 
121  template<ndn::encoding::Tag TAG>
122  size_t
123  wireEncode(ndn::EncodingImpl<TAG>& block) const;
124 
133  const ndn::Block&
134  wireEncode() const;
135 
139  void
140  wireDecode(const ndn::Block& wire);
141 
142  iterator
143  begin() const;
144 
145  iterator
146  end() const;
147 
148 private:
149  LsaInfo m_lsaInfo;
150  bool m_hasAdjacencies;
151  AdjacencyList m_adjacencies;
152 
153  mutable ndn::Block m_wire;
154 };
155 
158 {
159  return m_adjacencies.begin();
160 }
161 
164 {
165  return m_adjacencies.end();
166 }
167 
168 std::ostream&
169 operator<<(std::ostream& os, const AdjacencyLsa& adjacencyLsa);
170 
171 } // namespace tlv
172 } // namespace nlsr
173 
174 #endif // NLSR_TLV_ADJACENCY_LSA_HPP
Copyright (c) 2014-2017, The University of Memphis, Regents of the University of California, Arizona Board of Regents.
Definition: tlv-nlsr.hpp:27
iterator end() const
std::list< Adjacency > AdjacencyList
iterator begin() const
AdjacencyLsa & addAdjacency(const Adjacency &adjacency)
void wireDecode(const ndn::Block &wire)
Populate this object by decoding the one contained in the given block.
std::list< Adjacent >::const_iterator const_iterator
Error(const std::string &what)
const LsaInfo & getLsaInfo() const
bool hasAdjacencies() const
const std::list< Adjacency > & getAdjacencies() const
AdjacencyLsa & setLsaInfo(const LsaInfo &lsaInfo)
Data abstraction for LsaInfo.
Definition: lsa-info.hpp:47
Copyright (c) 2014-2017, The University of Memphis, Regents of the University of California, Arizona Board of Regents.
Data abstraction for AdjacencyLsa.
AdjacencyLsa & clearAdjacencies()
std::ostream & operator<<(std::ostream &os, const AdjacencyLsa &adjacencyLsa)
Data abstraction for Adjacency.
Definition: adjacency.hpp:44
const ndn::Block & wireEncode() const
Create a TLV encoding of this object.
AdjacencyList::const_iterator iterator