25 #include <ndn-cxx/util/concepts.hpp> 26 #include <ndn-cxx/encoding/block-helpers.hpp> 31 BOOST_CONCEPT_ASSERT((ndn::WireEncodable<LsdbStatus>));
32 BOOST_CONCEPT_ASSERT((ndn::WireDecodable<LsdbStatus>));
33 static_assert(std::is_base_of<ndn::tlv::Error, LsdbStatus::Error>::value,
34 "LsdbStatus::Error must inherit from tlv::Error");
37 : m_hasAdjacencyLsas(false)
38 , m_hasCoordinateLsas(false)
39 , m_hasNameLsas(false)
48 template<ndn::encoding::Tag TAG>
52 size_t totalLength = 0;
54 for (std::list<NameLsa>::const_reverse_iterator it = m_nameLsas.rbegin();
55 it != m_nameLsas.rend(); ++it) {
56 totalLength += it->wireEncode(block);
59 for (std::list<CoordinateLsa>::const_reverse_iterator it = m_coordinateLsas.rbegin();
60 it != m_coordinateLsas.rend(); ++it) {
61 totalLength += it->wireEncode(block);
64 for (std::list<AdjacencyLsa>::const_reverse_iterator it = m_adjacencyLsas.rbegin();
65 it != m_adjacencyLsas.rend(); ++it) {
66 totalLength += it->wireEncode(block);
69 totalLength += block.prependVarNumber(totalLength);
76 LsdbStatus::wireEncode<ndn::encoding::EncoderTag>(ndn::EncodingImpl<ndn::encoding::EncoderTag>& block)
const;
79 LsdbStatus::wireEncode<ndn::encoding::EstimatorTag>(ndn::EncodingImpl<ndn::encoding::EstimatorTag>& block)
const;
84 if (m_wire.hasWire()) {
88 ndn::EncodingEstimator estimator;
91 ndn::EncodingBuffer buffer(estimatedSize, 0);
94 m_wire = buffer.block();
102 m_adjacencyLsas.clear();
103 m_coordinateLsas.clear();
106 m_hasAdjacencyLsas =
false;
107 m_hasCoordinateLsas =
false;
108 m_hasNameLsas =
false;
113 std::stringstream error;
114 error <<
"Expected LsdbStatus Block, but Block is of a different type: #" 116 throw Error(error.str());
121 ndn::Block::element_const_iterator val = m_wire.elements_begin();
125 m_hasAdjacencyLsas =
true;
130 m_hasCoordinateLsas =
true;
134 m_nameLsas.push_back(
NameLsa(*val));
135 m_hasNameLsas =
true;
138 if (val != m_wire.elements_end()) {
139 std::stringstream error;
140 error <<
"Expected the end of elements, but Block is of a different type: #" 142 throw Error(error.str());
175 for (
const auto& nameLsa : lsdbStatus.
getNameLsas()) {
void wireDecode(const ndn::Block &wire)
Populate this object by decoding the one contained in the given block.
const std::list< CoordinateLsa > & getCoordinateLsas() const
const ndn::Block & wireEncode() const
Create a TLV encoding of this object.
const std::list< AdjacencyLsa > & getAdjacencyLsas() const
Copyright (c) 2014-2017, The University of Memphis, Regents of the University of California, Arizona Board of Regents.
Data abstraction for LsdbStatus.
std::ostream & operator<<(std::ostream &os, const AdjacencyLsa &adjacencyLsa)
const std::list< NameLsa > & getNameLsas() const