blob: abeea2c1bfd13a0e7187d2262def60ee845942ed [file] [log] [blame]
Ashlesh Gawande0db4d4d2020-02-05 20:30:02 -08001/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2/**
3 * Copyright (c) 2014-2020, The University of Memphis,
4 * Regents of the University of California,
5 * Arizona Board of Regents.
6 *
7 * This file is part of NLSR (Named-data Link State Routing).
8 * See AUTHORS.md for complete list of NLSR authors and contributors.
9 *
10 * NLSR is free software: you can redistribute it and/or modify it under the terms
11 * of the GNU General Public License as published by the Free Software Foundation,
12 * either version 3 of the License, or (at your option) any later version.
13 *
14 * NLSR is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
15 * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
16 * PURPOSE. See the GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License along with
19 * NLSR, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
20 **/
21
22#ifndef NLSR_LSA_COORDINATE_LSA_HPP
23#define NLSR_LSA_COORDINATE_LSA_HPP
24
25#include "lsa.hpp"
26
27namespace nlsr {
28
29/*!
30 \brief Data abstraction for CoordinateLsa
31 CoordinateLsa := COORDINATE-LSA-TYPE TLV-LENGTH
32 Lsa
33 HyperbolicRadius
34 HyperbolicAngle+
35 */
36class CoordinateLsa : public Lsa
37{
38public:
39 CoordinateLsa() = default;
40
41 CoordinateLsa(const ndn::Name& originRouter, uint32_t seqNo,
42 const ndn::time::system_clock::TimePoint& timepoint,
43 double radius, std::vector<double> angles);
44
45 CoordinateLsa(const ndn::Block& block);
46
47 Lsa::Type
48 getType() const override
49 {
50 return Lsa::Type::COORDINATE;
51 }
52
53 double
54 getCorRadius() const
55 {
56 return m_hyperbolicRadius;
57 }
58
59 void
60 setCorRadius(double cr)
61 {
62 m_wire.reset();
63 m_hyperbolicRadius = cr;
64 }
65
66 const std::vector<double>
67 getCorTheta() const
68 {
69 return m_hyperbolicAngles;
70 }
71
72 void
73 setCorTheta(std::vector<double> ct)
74 {
75 m_wire.reset();
76 m_hyperbolicAngles = ct;
77 }
78
79 bool
80 isEqualContent(const CoordinateLsa& clsa) const;
81
82 template<ndn::encoding::Tag TAG>
83 size_t
84 wireEncode(ndn::EncodingImpl<TAG>& block) const;
85
86 const ndn::Block&
87 wireEncode() const;
88
89 void
90 wireDecode(const ndn::Block& wire);
91
92private:
93 double m_hyperbolicRadius = 0.0;
94 std::vector<double> m_hyperbolicAngles;
95
96 mutable ndn::Block m_wire;
97};
98
99NDN_CXX_DECLARE_WIRE_ENCODE_INSTANTIATIONS(CoordinateLsa);
100
101std::ostream&
102operator<<(std::ostream& os, const CoordinateLsa& lsa);
103
104} // namespace nlsr
105
106#endif // NLSR_LSA_COORDINATE_LSA_HPP