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);
66 AdjacencyLsa::wireEncode<ndn::encoding::EncoderTag>(ndn::EncodingImpl<ndn::encoding::EncoderTag>& encoder)
const;
69 AdjacencyLsa::wireEncode<ndn::encoding::EstimatorTag>(ndn::EncodingImpl<ndn::encoding::EstimatorTag>& encoder)
const;
74 if (m_wire.hasWire()) {
78 ndn::EncodingEstimator estimator;
81 ndn::EncodingBuffer buffer(estimatedSize, 0);
84 m_wire = buffer.block();
92 m_hasAdjacencies =
false;
93 m_adjacencies.clear();
98 std::stringstream error;
99 error <<
"Expected AdjacencyLsa Block, but Block is of a different type: #" 101 throw Error(error.str());
106 ndn::Block::element_const_iterator val = m_wire.elements_begin();
113 throw Error(
"Missing required LsaInfo field");
116 for (; val != m_wire.elements_end(); ++val) {
118 m_adjacencies.push_back(
Adjacency(*val));
119 m_hasAdjacencies =
true;
122 std::stringstream error;
123 error <<
"Expected Adjacency Block, but Block is of a different type: #" 125 throw Error(error.str());
133 os <<
"AdjacencyLsa(" 136 for (
const auto& adjacency : adjacencyLsa) {
137 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
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.