meta-info-lite.hpp
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
22 #ifndef NDN_META_INFO_LITE_HPP
23 #define NDN_META_INFO_LITE_HPP
24 
25 #include "common-lite.hpp"
26 #include "name-lite.hpp"
27 #include "../c/data-types.h"
28 
29 namespace ndn {
30 
35 class MetaInfoLite : private ndn_MetaInfo {
36 public:
40  MetaInfoLite();
41 
47  ndn_ContentType
48  getType() const { return type; }
49 
56  int
57  getOtherTypeCode() const { return otherTypeCode; }
58 
60  getFreshnessPeriod() const { return freshnessPeriod; }
61 
62  const NameLite::Component
63  getFinalBlockId() const { return NameLite::Component::downCast(finalBlockId); }
64 
71  void
72  setType(ndn_ContentType type) { this->type = type; }
73 
81  void
82  setOtherTypeCode(int otherTypeCode) { this->otherTypeCode = otherTypeCode; }
83 
84  void
85  setFreshnessPeriod(Milliseconds freshnessPeriod)
86  {
87  this->freshnessPeriod = freshnessPeriod;
88  }
89 
95  void
97  {
98  NameLite::Component::downCast(this->finalBlockId) = finalBlockId;
99  }
100 
106  static MetaInfoLite&
107  downCast(ndn_MetaInfo& metaInfo) { return *(MetaInfoLite*)&metaInfo; }
108 
109  static const MetaInfoLite&
110  downCast(const ndn_MetaInfo& metaInfo) { return *(MetaInfoLite*)&metaInfo; }
111 };
112 
113 }
114 
115 #endif
void setOtherTypeCode(int otherTypeCode)
Set the packet's content type code to use when the content type enum is ndn_ContentType_OTHER_CODE.
Definition: meta-info-lite.hpp:82
double Milliseconds
A time interval represented as the number of milliseconds.
Definition: common.hpp:112
Copyright (C) 2013-2016 Regents of the University of California.
Definition: common.hpp:36
int getOtherTypeCode() const
Get the content type code from the packet which is other than a recognized ContentType enum value...
Definition: meta-info-lite.hpp:57
A MetaInfoLite holds a type and other info to represent the meta info of a Data packet.
Definition: meta-info-lite.hpp:35
void setFinalBlockId(const NameLite::Component &finalBlockId)
Set the final block ID.
Definition: meta-info-lite.hpp:96
ndn_ContentType type
default is ndn_ContentType_BLOB.
Definition: data-types.h:79
MetaInfoLite()
Create a MetaInfoLite with default field values.
Definition: meta-info-lite.cpp:27
struct ndn_NameComponent finalBlockId
has a pointer to a pre-allocated buffer.
Definition: data-types.h:82
An ndn_MetaInfo struct holds the meta info which is signed inside the data packet.
Definition: data-types.h:77
A NameLite::Component holds a pointer to the component value.
Definition: name-lite.hpp:41
ndn_ContentType getType() const
Get the content type.
Definition: meta-info-lite.hpp:48
static Component & downCast(ndn_NameComponent &component)
Downcast the reference to the ndn_NameComponent struct to a NameLite::Component.
Definition: name-lite.hpp:390
void setType(ndn_ContentType type)
Set the content type.
Definition: meta-info-lite.hpp:72
static MetaInfoLite & downCast(ndn_MetaInfo &metaInfo)
Downcast the reference to the ndn_MetaInfo struct to a MetaInfoLite.
Definition: meta-info-lite.hpp:107
ndn_Milliseconds freshnessPeriod
-1 for none
Definition: data-types.h:81