NS-3 based Named Data Networking (NDN) simulator
ndnSIM 2.5: NDN, CCN, CCNx, content centric networks
API Documentation
geo-tag.hpp
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright (c) 2013-2019 Regents of the University of California.
4  *
5  * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
6  *
7  * ndn-cxx library is free software: you can redistribute it and/or modify it under the
8  * terms of the GNU Lesser General Public License as published by the Free Software
9  * Foundation, either version 3 of the License, or (at your option) any later version.
10  *
11  * ndn-cxx library is distributed in the hope that it will be useful, but WITHOUT ANY
12  * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
13  * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
14  *
15  * You should have received copies of the GNU General Public License and GNU Lesser
16  * General Public License along with ndn-cxx, e.g., in COPYING.md file. If not, see
17  * <http://www.gnu.org/licenses/>.
18  *
19  * See AUTHORS.md for complete list of ndn-cxx authors and contributors.
20  */
21 
22 #ifndef NDN_CXX_LP_GEO_TAG_HPP
23 #define NDN_CXX_LP_GEO_TAG_HPP
24 
27 #include "ndn-cxx/tag.hpp"
28 
29 namespace ndn {
30 namespace lp {
31 
35 class GeoTag : public Tag
36 {
37 public:
38  static constexpr int
39  getTypeId() noexcept
40  {
41  return 0x60000001;
42  }
43 
44  GeoTag() = default;
45 
46  explicit
47  GeoTag(std::tuple<double, double, double> pos)
48  : m_pos(pos)
49  {
50  }
51 
52  explicit
53  GeoTag(const Block& block);
54 
58  template<encoding::Tag TAG>
59  size_t
60  wireEncode(EncodingImpl<TAG>& encoder) const;
61 
65  const Block&
66  wireEncode() const;
67 
71  void
72  wireDecode(const Block& wire);
73 
74 public: // get & set GeoTag
78  std::tuple<double, double, double>
79  getPos() const
80  {
81  return m_pos;
82  }
83 
87  GeoTag*
88  setPosX(std::tuple<double, double, double> pos)
89  {
90  m_pos = pos;
91  return this;
92  }
93 
94 private:
95  std::tuple<double, double, double> m_pos = {0.0, 0.0, 0.0};
96  mutable Block m_wire;
97 };
98 
99 } // namespace lp
100 } // namespace ndn
101 
102 #endif // NDN_CXX_LP_GEOTAG_HPP
Copyright (c) 2011-2015 Regents of the University of California.
std::tuple< double, double, double > getPos() const
Definition: geo-tag.hpp:79
Represents a TLV element of the NDN packet format.
Definition: block.hpp:44
static constexpr int getTypeId() noexcept
Definition: geo-tag.hpp:39
GeoTag()=default
void wireDecode(const Block &wire)
get GeoTag from wire format
Definition: geo-tag.cpp:71
const Block & wireEncode() const
encode GeoTag into wire format
Definition: geo-tag.cpp:53
represents a GeoTag header field
Definition: geo-tag.hpp:35
Base class for packet tags that can hold any arbitrary information.
Definition: tag.hpp:30
GeoTag * setPosX(std::tuple< double, double, double > pos)
set position x
Definition: geo-tag.hpp:88
GeoTag(std::tuple< double, double, double > pos)
Definition: geo-tag.hpp:47