25 #include <ndn-cxx/util/concepts.hpp> 26 #include <ndn-cxx/encoding/block-helpers.hpp> 31 BOOST_CONCEPT_ASSERT((ndn::WireEncodable<CoordinateLsa>));
32 BOOST_CONCEPT_ASSERT((ndn::WireDecodable<CoordinateLsa>));
33 static_assert(std::is_base_of<ndn::tlv::Error, CoordinateLsa::Error>::value,
34 "CoordinateLsa::Error must inherit from tlv::Error");
37 : m_hyperbolicRadius(0.0)
46 template<ndn::encoding::Tag TAG>
50 size_t totalLength = 0;
52 for (
auto it = m_hyperbolicAngle.rbegin(); it != m_hyperbolicAngle.rend(); ++it) {
60 totalLength += block.prependVarNumber(totalLength);
71 if (m_wire.hasWire()) {
75 ndn::EncodingEstimator estimator;
78 ndn::EncodingBuffer buffer(estimatedSize, 0);
81 m_wire = buffer.block();
89 m_hyperbolicRadius = 0.0;
90 m_hyperbolicAngle.clear();
95 std::stringstream error;
96 error <<
"Expected CoordinateLsa Block, but Block is of a different type: #" 98 BOOST_THROW_EXCEPTION(
Error(error.str()));
103 ndn::Block::element_const_iterator val = m_wire.elements_begin();
110 BOOST_THROW_EXCEPTION(
Error(
"Missing required LsaInfo field"));
114 m_hyperbolicRadius = ndn::encoding::readDouble(*val);
118 BOOST_THROW_EXCEPTION(
Error(
"Missing required HyperbolicRadius field"));
121 for (; val != m_wire.elements_end(); ++val) {
123 m_hyperbolicAngle.push_back(ndn::encoding::readDouble(*val));
131 os <<
"CoordinateLsa(" 135 os <<
"HyperbolicAngles: ";
Data abstraction for CoordinateLsa.
NDN_CXX_DEFINE_WIRE_ENCODE_INSTANTIATIONS(AdjacencyLsa)
const LsaInfo & getLsaInfo() const
Copyright (c) 2014-2019, The University of Memphis, Regents of the University of California, Arizona Board of Regents.
const ndn::Block & wireEncode() const
Create a TLV encoding of this object.
const std::vector< double > getHyperbolicAngle() const
std::ostream & operator<<(std::ostream &os, const AdjacencyLsa &adjacencyLsa)
void wireDecode(const ndn::Block &wire)
Populate this object by decoding the one contained in the given block.
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.
double getHyperbolicRadius() const