NS-3 based Named Data Networking (NDN) simulator
ndnSIM 2.3: NDN, CCN, CCNx, content centric networks
API Documentation
meta-info.hpp
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
22 #ifndef NDN_META_INFO_HPP
23 #define NDN_META_INFO_HPP
24 
25 #include "common.hpp"
26 #include "encoding/block.hpp"
28 #include "util/time.hpp"
29 #include "name-component.hpp"
30 #include <list>
31 
32 namespace ndn {
33 
56 class MetaInfo
57 {
58 public:
59  class Error : public tlv::Error
60  {
61  public:
62  explicit
63  Error(const std::string& what)
64  : tlv::Error(what)
65  {
66  }
67  };
68 
69  MetaInfo();
70 
74  explicit
75  MetaInfo(const Block& block);
76 
77  template<encoding::Tag TAG>
78  size_t
79  wireEncode(EncodingImpl<TAG>& encoder) const;
80 
81  const Block&
82  wireEncode() const;
83 
84  void
85  wireDecode(const Block& wire);
86 
87 public: // getter/setter
88  uint32_t
89  getType() const;
90 
94  MetaInfo&
95  setType(uint32_t type);
96 
97  const time::milliseconds&
98  getFreshnessPeriod() const;
99 
100  MetaInfo&
101  setFreshnessPeriod(const time::milliseconds& freshnessPeriod);
102 
103  const name::Component&
104  getFinalBlockId() const;
105 
106  MetaInfo&
107  setFinalBlockId(const name::Component& finalBlockId);
108 
109 public: // app-defined MetaInfo items
118  const std::list<Block>&
119  getAppMetaInfo() const;
120 
134  MetaInfo&
135  setAppMetaInfo(const std::list<Block>& info);
136 
148  MetaInfo&
149  addAppMetaInfo(const Block& block);
150 
161  bool
162  removeAppMetaInfo(uint32_t tlvType);
163 
177  const Block*
178  findAppMetaInfo(uint32_t tlvType) const;
179 
180 public: // EqualityComparable concept
181  bool
182  operator==(const MetaInfo& other) const;
183 
184  bool
185  operator!=(const MetaInfo& other) const;
186 
187 private:
188  uint32_t m_type;
189  time::milliseconds m_freshnessPeriod;
190  name::Component m_finalBlockId;
191  std::list<Block> m_appMetaInfo;
192 
193  mutable Block m_wire;
194 };
195 
196 std::ostream&
197 operator<<(std::ostream& os, const MetaInfo& info);
198 
200 
201 inline uint32_t
203 {
204  return m_type;
205 }
206 
207 inline const time::milliseconds&
209 {
210  return m_freshnessPeriod;
211 }
212 
213 inline const name::Component&
215 {
216  return m_finalBlockId;
217 }
218 
219 inline bool
220 MetaInfo::operator==(const MetaInfo& other) const
221 {
222  return wireEncode() == other.wireEncode();
223 }
224 
225 inline bool
226 MetaInfo::operator!=(const MetaInfo& other) const
227 {
228  return !(*this == other);
229 }
230 
231 } // namespace ndn
232 
233 #endif // NDN_META_INFO_HPP
Copyright (c) 2011-2015 Regents of the University of California.
const Block * findAppMetaInfo(uint32_t tlvType) const
Find a first app-defined MetaInfo item of type tlvType.
Definition: meta-info.cpp:117
const time::milliseconds & getFreshnessPeriod() const
Definition: meta-info.hpp:208
Error(const std::string &what)
Definition: meta-info.hpp:63
std::ostream & operator<<(std::ostream &os, const Data &data)
Definition: data.cpp:320
Class representing a wire element of NDN-TLV packet format.
Definition: block.hpp:43
Copyright (c) 2013-2016 Regents of the University of California.
uint32_t getType() const
Definition: meta-info.hpp:202
MetaInfo & setFinalBlockId(const name::Component &finalBlockId)
Definition: meta-info.cpp:63
MetaInfo & setType(uint32_t type)
set ContentType
Definition: meta-info.cpp:47
bool removeAppMetaInfo(uint32_t tlvType)
Remove a first app-defined MetaInfo item with type tlvType.
Definition: meta-info.cpp:103
const Block & wireEncode() const
Definition: meta-info.cpp:176
An MetaInfo holds the meta info which is signed inside the data packet.
Definition: meta-info.hpp:56
MetaInfo & setFreshnessPeriod(const time::milliseconds &freshnessPeriod)
Definition: meta-info.cpp:55
const std::list< Block > & getAppMetaInfo() const
Get all app-defined MetaInfo items.
Definition: meta-info.cpp:71
bool operator!=(const MetaInfo &other) const
Definition: meta-info.hpp:226
size_t wireEncode(EncodingImpl< TAG > &encoder) const
Definition: meta-info.cpp:130
const name::Component & getFinalBlockId() const
Definition: meta-info.hpp:214
Component holds a read-only name component value.
bool operator==(const MetaInfo &other) const
Definition: meta-info.hpp:220
MetaInfo & setAppMetaInfo(const std::list< Block > &info)
Set app-defined MetaInfo items.
Definition: meta-info.cpp:77
MetaInfo & addAppMetaInfo(const Block &block)
Add an app-defined MetaInfo item.
Definition: meta-info.cpp:91
represents an error in TLV encoding or decoding
Definition: tlv.hpp:50
void wireDecode(const Block &wire)
Definition: meta-info.cpp:192