ndn-cxx: NDN C++ Library 0.9.0-33-g832ea91d
Loading...
Searching...
No Matches
meta-info.hpp
Go to the documentation of this file.
1/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2/*
3 * Copyright (c) 2013-2024 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_META_INFO_HPP
23#define NDN_CXX_META_INFO_HPP
24
28#include "ndn-cxx/util/time.hpp"
29
30#include <list>
31#include <optional>
32
33namespace ndn {
34
39
62{
63public:
64 class Error : public tlv::Error
65 {
66 public:
68 };
69
71
75 explicit
76 MetaInfo(const Block& block);
77
78 template<encoding::Tag TAG>
79 size_t
80 wireEncode(EncodingImpl<TAG>& encoder) const;
81
82 const Block&
83 wireEncode() const;
84
85 void
86 wireDecode(const Block& wire);
87
88public: // getter/setter
94 uint32_t
95 getType() const noexcept
96 {
97 return m_type;
98 }
99
104 MetaInfo&
105 setType(uint32_t type);
106
115 getFreshnessPeriod() const noexcept;
116
121 MetaInfo&
122 setFreshnessPeriod(time::milliseconds freshnessPeriod);
123
127 const std::optional<name::Component>&
128 getFinalBlock() const noexcept
129 {
130 return m_finalBlockId;
131 }
132
136 MetaInfo&
137 setFinalBlock(std::optional<name::Component> finalBlockId);
138
139public: // app-defined MetaInfo items
146 const std::list<Block>&
147 getAppMetaInfo() const;
148
160 MetaInfo&
161 setAppMetaInfo(const std::list<Block>& info);
162
172 MetaInfo&
173 addAppMetaInfo(const Block& block);
174
183 bool
184 removeAppMetaInfo(uint32_t tlvType);
185
197 const Block*
198 findAppMetaInfo(uint32_t tlvType) const;
199
200private:
201 uint32_t m_type = tlv::ContentType_Blob;
202 uint64_t m_freshnessPeriod = DEFAULT_FRESHNESS_PERIOD.count();
203 std::optional<name::Component> m_finalBlockId;
204 std::list<Block> m_appMetaInfo;
205
206 mutable Block m_wire;
207};
208
210
211std::ostream&
212operator<<(std::ostream& os, const MetaInfo& info);
213
214} // namespace ndn
215
216#endif // NDN_CXX_META_INFO_HPP
Represents a TLV element of the NDN packet format.
Definition block.hpp:45
A MetaInfo holds the meta info which is signed inside the Data packet.
Definition meta-info.hpp:62
uint32_t getType() const noexcept
Return the value of ContentType.
Definition meta-info.hpp:95
void wireDecode(const Block &wire)
MetaInfo & setFinalBlock(std::optional< name::Component > finalBlockId)
Set the FinalBlockId.
Definition meta-info.cpp:66
MetaInfo & addAppMetaInfo(const Block &block)
Add an app-defined MetaInfo item.
Definition meta-info.cpp:93
MetaInfo & setAppMetaInfo(const std::list< Block > &info)
Set app-defined MetaInfo items.
Definition meta-info.cpp:80
MetaInfo & setType(uint32_t type)
Set the ContentType.
Definition meta-info.cpp:38
const Block & wireEncode() const
const Block * findAppMetaInfo(uint32_t tlvType) const
Find a first app-defined MetaInfo item of type tlvType.
const std::optional< name::Component > & getFinalBlock() const noexcept
Return the value of FinalBlockId.
time::milliseconds getFreshnessPeriod() const noexcept
Return the value of FreshnessPeriod.
Definition meta-info.cpp:46
MetaInfo & setFreshnessPeriod(time::milliseconds freshnessPeriod)
Set the FreshnessPeriod.
Definition meta-info.cpp:55
const std::list< Block > & getAppMetaInfo() const
Get all app-defined MetaInfo items.
Definition meta-info.cpp:74
bool removeAppMetaInfo(uint32_t tlvType)
Remove a first app-defined MetaInfo item with type tlvType.
Represents an error in TLV encoding or decoding.
Definition tlv.hpp:54
Error(const char *expectedType, uint32_t actualType)
Definition tlv.cpp:28
#define NDN_CXX_DECLARE_WIRE_ENCODE_INSTANTIATIONS(ClassName)
::boost::chrono::milliseconds milliseconds
Definition time.hpp:52
@ ContentType_Blob
payload
Definition tlv.hpp:145
Definition data.cpp:25
constexpr time::milliseconds DEFAULT_FRESHNESS_PERIOD
Default value of FreshnessPeriod.
Definition meta-info.hpp:38
std::ostream & operator<<(std::ostream &os, const Data &data)
Definition data.cpp:377
STL namespace.
uint32_t tlvType
TLV-TYPE of the field; 0 if field does not exist.
Definition packet.cpp:49
SignatureInfo info