25 #include <ndn-cxx/util/concepts.hpp> 26 #include <ndn-cxx/encoding/block-helpers.hpp> 31 BOOST_CONCEPT_ASSERT((ndn::WireEncodable<AdjacencyLsa>));
32 BOOST_CONCEPT_ASSERT((ndn::WireDecodable<AdjacencyLsa>));
33 static_assert(std::is_base_of<ndn::tlv::Error, AdjacencyLsa::Error>::value,
34 "AdjacencyLsa::Error must inherit from tlv::Error");
37 : m_hasAdjacencies(false)
46 template<ndn::encoding::Tag TAG>
50 size_t totalLength = 0;
52 for (std::list<Adjacency>::const_reverse_iterator it = m_adjacencies.rbegin();
53 it != m_adjacencies.rend(); ++it) {
54 totalLength += it->wireEncode(block);
59 totalLength += block.prependVarNumber(totalLength);
70 if (m_wire.hasWire()) {
74 ndn::EncodingEstimator estimator;
77 ndn::EncodingBuffer buffer(estimatedSize, 0);
80 m_wire = buffer.block();
88 m_hasAdjacencies =
false;
89 m_adjacencies.clear();
94 BOOST_THROW_EXCEPTION(
Error(
"Expected AdjacencyLsa Block, but Block is of a different type: #" +
95 ndn::to_string(m_wire.type())));
100 ndn::Block::element_const_iterator val = m_wire.elements_begin();
107 BOOST_THROW_EXCEPTION(
Error(
"Missing required LsaInfo field"));
110 for (; val != m_wire.elements_end(); ++val) {
112 m_adjacencies.push_back(
Adjacency(*val));
113 m_hasAdjacencies =
true;
116 BOOST_THROW_EXCEPTION(
Error(
"Expected Adjacency Block, but Block is of a different type: #" +
117 ndn::to_string(m_wire.type())));
125 os <<
"AdjacencyLsa(" 128 for (
const auto& adjacency : adjacencyLsa) {
129 os <<
", " << adjacency;
size_t wireEncode(ndn::EncodingImpl< TAG > &block) const
Encodes LSA info using the method in TAG.
void wireDecode(const ndn::Block &wire)
Populate this object by decoding the one contained in the given block.
const LsaInfo & getLsaInfo() const
NDN_CXX_DEFINE_WIRE_ENCODE_INSTANTIATIONS(AdjacencyLsa)
Copyright (c) 2014-2018, The University of Memphis, Regents of the University of California, Arizona Board of Regents.
Data abstraction for AdjacencyLsa.
std::ostream & operator<<(std::ostream &os, const AdjacencyLsa &adjacencyLsa)
const ndn::Block & wireEncode() const
Create a TLV encoding of this object.
void wireDecode(const ndn::Block &wire)
Populate this object by decoding the one contained in the given block.