25 #include <ndn-cxx/util/concepts.hpp> 26 #include <ndn-cxx/encoding/block-helpers.hpp> 33 BOOST_CONCEPT_ASSERT((ndn::WireEncodable<CoordinateLsa>));
34 BOOST_CONCEPT_ASSERT((ndn::WireDecodable<CoordinateLsa>));
35 static_assert(std::is_base_of<ndn::tlv::Error, CoordinateLsa::Error>::value,
36 "CoordinateLsa::Error must inherit from tlv::Error");
39 : m_hyperbolicRadius(0.0)
48 template<ndn::encoding::Tag TAG>
52 size_t totalLength = 0;
54 for (
auto it = m_hyperbolicAngle.rbegin(); it != m_hyperbolicAngle.rend(); ++it) {
62 totalLength += block.prependVarNumber(totalLength);
73 if (m_wire.hasWire()) {
77 ndn::EncodingEstimator estimator;
80 ndn::EncodingBuffer buffer(estimatedSize, 0);
83 m_wire = buffer.block();
91 m_hyperbolicRadius = 0.0;
92 m_hyperbolicAngle.clear();
97 std::stringstream error;
98 error <<
"Expected CoordinateLsa Block, but Block is of a different type: #" 100 BOOST_THROW_EXCEPTION(
Error(error.str()));
105 ndn::Block::element_const_iterator val = m_wire.elements_begin();
112 std::cout <<
"Missing required LsaInfo field" << std::endl;
113 BOOST_THROW_EXCEPTION(
Error(
"Missing required LsaInfo field"));
121 std::cout <<
"Missing required HyperbolicRadius field" << std::endl;
122 BOOST_THROW_EXCEPTION(
Error(
"Missing required HyperbolicRadius field"));
125 for (; val != m_wire.elements_end(); ++val) {
135 os <<
"CoordinateLsa(" 139 os <<
"HyperbolicAngles: ";
size_t wireEncode(ndn::EncodingImpl< TAG > &block) const
Encodes LSA info using the method in TAG.
const LsaInfo & getLsaInfo() const
Data abstraction for CoordinateLsa.
double readDouble(const ndn::Block &block)
Read a double from a TLV element.
const ndn::Block & wireEncode() const
Create a TLV encoding of this object.
NDN_CXX_DEFINE_WIRE_ENCODE_INSTANTIATIONS(AdjacencyLsa)
size_t prependDouble(ndn::EncodingImpl< TAG > &encoder, uint32_t type, double value)
Prepend a TLV element containing a double.
const std::vector< double > getHyperbolicAngle() const
Copyright (c) 2014-2018, The University of Memphis, Regents of the University of California, Arizona Board of Regents.
double getHyperbolicRadius() 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.
void wireDecode(const ndn::Block &wire)
Populate this object by decoding the one contained in the given block.