28 const ndn::time::system_clock::time_point& timepoint,
29 double radius, std::vector<double> angles)
30 :
Lsa(originRouter, seqNo, timepoint)
31 , m_hyperbolicRadius(radius)
32 , m_hyperbolicAngles(angles)
41 template<ndn::encoding::Tag TAG>
45 size_t totalLength = 0;
47 for (
auto it = m_hyperbolicAngles.rbegin(); it != m_hyperbolicAngles.rend(); ++it) {
55 totalLength += block.prependVarNumber(totalLength);
70 ndn::EncodingEstimator estimator;
73 ndn::EncodingBuffer buffer(estimatedSize, 0);
92 auto val =
m_wire.elements_begin();
99 NDN_THROW(
Error(
"Missing required Lsa field"));
103 m_hyperbolicRadius = ndn::encoding::readDouble(*val);
107 NDN_THROW(
Error(
"Missing required HyperbolicRadius field"));
110 std::vector<double> angles;
111 for (; val !=
m_wire.elements_end(); ++val) {
113 angles.push_back(ndn::encoding::readDouble(*val));
116 NDN_THROW(
Error(
"Missing required HyperbolicAngle field"));
119 m_hyperbolicAngles = angles;
123 CoordinateLsa::print(std::ostream& os)
const
125 os <<
" Hyperbolic Radius : " << m_hyperbolicRadius <<
"\n";
127 for (
const auto& value : m_hyperbolicAngles) {
128 os <<
" Hyperbolic Theta " << i++ <<
" : " << value <<
"\n";
132 std::tuple<bool, std::list<ndn::Name>, std::list<ndn::Name>>
135 auto clsa = std::static_pointer_cast<CoordinateLsa>(lsa);
136 if (*
this != *clsa) {
137 m_hyperbolicRadius = clsa->getRadius();
138 m_hyperbolicAngles.clear();
139 for (
const auto& angle : clsa->getTheta()) {
140 m_hyperbolicAngles.push_back(angle);
142 return {
true, std::list<ndn::Name>{}, std::list<ndn::Name>{}};
144 return {
false, std::list<ndn::Name>{}, std::list<ndn::Name>{}};
Represents an LSA of hyperbolic coordinates of the origin router.
const ndn::Block & wireEncode() const override
void wireDecode(const ndn::Block &wire)
std::tuple< bool, std::list< ndn::Name >, std::list< ndn::Name > > update(const std::shared_ptr< Lsa > &lsa) override
Represents a Link State Announcement (LSA).
virtual const ndn::Block & wireEncode() const =0
void wireDecode(const ndn::Block &wire)
Copyright (c) 2014-2020, The University of Memphis, Regents of the University of California.
NDN_CXX_DEFINE_WIRE_ENCODE_INSTANTIATIONS(Adjacent)