Ashlesh Gawande | 0db4d4d | 2020-02-05 20:30:02 -0800 | [diff] [blame] | 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
Ashlesh Gawande | 57a8717 | 2020-05-09 19:47:06 -0700 | [diff] [blame] | 2 | /* |
Ashlesh Gawande | 5d93aa5 | 2020-06-13 18:57:45 -0700 | [diff] [blame^] | 3 | * Copyright (c) 2014-2021, The University of Memphis, |
Ashlesh Gawande | 0db4d4d | 2020-02-05 20:30:02 -0800 | [diff] [blame] | 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/>. |
Ashlesh Gawande | 57a8717 | 2020-05-09 19:47:06 -0700 | [diff] [blame] | 20 | */ |
Ashlesh Gawande | 0db4d4d | 2020-02-05 20:30:02 -0800 | [diff] [blame] | 21 | |
| 22 | #ifndef NLSR_LSA_COORDINATE_LSA_HPP |
| 23 | #define NLSR_LSA_COORDINATE_LSA_HPP |
| 24 | |
| 25 | #include "lsa.hpp" |
| 26 | |
| 27 | namespace nlsr { |
| 28 | |
| 29 | /*! |
| 30 | \brief Data abstraction for CoordinateLsa |
| 31 | CoordinateLsa := COORDINATE-LSA-TYPE TLV-LENGTH |
| 32 | Lsa |
| 33 | HyperbolicRadius |
| 34 | HyperbolicAngle+ |
| 35 | */ |
| 36 | class CoordinateLsa : public Lsa |
| 37 | { |
| 38 | public: |
| 39 | CoordinateLsa() = default; |
| 40 | |
Ashlesh Gawande | 57a8717 | 2020-05-09 19:47:06 -0700 | [diff] [blame] | 41 | CoordinateLsa(const ndn::Name& originRouter, uint64_t seqNo, |
Ashlesh Gawande | 0db4d4d | 2020-02-05 20:30:02 -0800 | [diff] [blame] | 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 | { |
Ashlesh Gawande | 57a8717 | 2020-05-09 19:47:06 -0700 | [diff] [blame] | 50 | return type(); |
| 51 | } |
| 52 | |
| 53 | static constexpr Lsa::Type |
| 54 | type() |
| 55 | { |
Ashlesh Gawande | 0db4d4d | 2020-02-05 20:30:02 -0800 | [diff] [blame] | 56 | return Lsa::Type::COORDINATE; |
| 57 | } |
| 58 | |
| 59 | double |
| 60 | getCorRadius() const |
| 61 | { |
| 62 | return m_hyperbolicRadius; |
| 63 | } |
| 64 | |
| 65 | void |
| 66 | setCorRadius(double cr) |
| 67 | { |
| 68 | m_wire.reset(); |
| 69 | m_hyperbolicRadius = cr; |
| 70 | } |
| 71 | |
| 72 | const std::vector<double> |
| 73 | getCorTheta() const |
| 74 | { |
| 75 | return m_hyperbolicAngles; |
| 76 | } |
| 77 | |
| 78 | void |
| 79 | setCorTheta(std::vector<double> ct) |
| 80 | { |
| 81 | m_wire.reset(); |
| 82 | m_hyperbolicAngles = ct; |
| 83 | } |
| 84 | |
| 85 | bool |
| 86 | isEqualContent(const CoordinateLsa& clsa) const; |
| 87 | |
| 88 | template<ndn::encoding::Tag TAG> |
| 89 | size_t |
| 90 | wireEncode(ndn::EncodingImpl<TAG>& block) const; |
| 91 | |
| 92 | const ndn::Block& |
Ashlesh Gawande | 57a8717 | 2020-05-09 19:47:06 -0700 | [diff] [blame] | 93 | wireEncode() const override; |
Ashlesh Gawande | 0db4d4d | 2020-02-05 20:30:02 -0800 | [diff] [blame] | 94 | |
| 95 | void |
| 96 | wireDecode(const ndn::Block& wire); |
| 97 | |
Ashlesh Gawande | 57a8717 | 2020-05-09 19:47:06 -0700 | [diff] [blame] | 98 | std::string |
| 99 | toString() const override; |
| 100 | |
Ashlesh Gawande | 5d93aa5 | 2020-06-13 18:57:45 -0700 | [diff] [blame^] | 101 | std::tuple<bool, std::list<ndn::Name>, std::list<ndn::Name>> |
| 102 | update(const std::shared_ptr<Lsa>& lsa) override; |
| 103 | |
Ashlesh Gawande | 0db4d4d | 2020-02-05 20:30:02 -0800 | [diff] [blame] | 104 | private: |
| 105 | double m_hyperbolicRadius = 0.0; |
| 106 | std::vector<double> m_hyperbolicAngles; |
Ashlesh Gawande | 0db4d4d | 2020-02-05 20:30:02 -0800 | [diff] [blame] | 107 | }; |
| 108 | |
| 109 | NDN_CXX_DECLARE_WIRE_ENCODE_INSTANTIATIONS(CoordinateLsa); |
| 110 | |
| 111 | std::ostream& |
| 112 | operator<<(std::ostream& os, const CoordinateLsa& lsa); |
| 113 | |
| 114 | } // namespace nlsr |
| 115 | |
| 116 | #endif // NLSR_LSA_COORDINATE_LSA_HPP |