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 
42  ndn_ContentType
43  getType() const { return type; }
44 
46  getFreshnessPeriod() const { return freshnessPeriod; }
47 
49  getFinalBlockId() const { return NameLite::Component::downCast(finalBlockId); }
50 
51  void
52  setType(ndn_ContentType type) { this->type = type; }
53 
54  void
55  setFreshnessPeriod(Milliseconds freshnessPeriod)
56  {
57  this->freshnessPeriod = freshnessPeriod;
58  }
59 
65  void
67  {
68  NameLite::Component::downCast(this->finalBlockId) = finalBlockId;
69  }
70 
76  static MetaInfoLite&
77  downCast(ndn_MetaInfo& metaInfo) { return *(MetaInfoLite*)&metaInfo; }
78 
79  static const MetaInfoLite&
80  downCast(const ndn_MetaInfo& metaInfo) { return *(MetaInfoLite*)&metaInfo; }
81 };
82 
83 }
84 
85 #endif
double Milliseconds
A time interval represented as the number of milliseconds.
Definition: common.hpp:111
Copyright (C) 2013-2016 Regents of the University of California.
Definition: common.hpp:35
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:66
ndn_ContentType type
default is ndn_ContentType_DATA.
Definition: data-types.h:73
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:75
An ndn_MetaInfo struct holds the meta info which is signed inside the data packet.
Definition: data-types.h:71
A NameLite::Component holds a pointer to the component value.
Definition: name-lite.hpp:39
static Component & downCast(ndn_NameComponent &component)
Downcast the reference to the ndn_NameComponent struct to a NameLite::Component.
Definition: name-lite.hpp:220
static MetaInfoLite & downCast(ndn_MetaInfo &metaInfo)
Downcast the reference to the ndn_MetaInfo struct to a MetaInfoLite.
Definition: meta-info-lite.hpp:77
ndn_Milliseconds freshnessPeriod
-1 for none
Definition: data-types.h:74