validity-period.hpp
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
23 #ifndef NDN_VALIDITY_PERIOD_HPP
24 #define NDN_VALIDITY_PERIOD_HPP
25 
26 #include "../common.hpp"
27 #include "../lite/security/validity-period-lite.hpp"
28 
29 namespace ndn {
30 
36 public:
40 
46  bool
47  hasPeriod() const { return validityPeriod_.hasPeriod(); }
48 
54  getNotBefore() const { return validityPeriod_.getNotBefore(); }
55 
61  getNotAfter() const { return validityPeriod_.getNotAfter(); }
62 
65  void
66  clear()
67  {
68  validityPeriod_.clear();
69  ++changeCount_;
70  }
71 
83  setPeriod
85  MillisecondsSince1970 notAfter)
86  {
87  validityPeriod_.setPeriod(notBefore, notAfter);
88  ++changeCount_;
89  return *this;
90  }
91 
97  bool
98  equals(const ValidityPeriod& other) const
99  {
100  return validityPeriod_.equals(other.validityPeriod_);
101  }
102 
109  bool
110  isValid(const MillisecondsSince1970& time) const
111  {
112  return validityPeriod_.isValid(time);
113  }
114 
119  uint64_t
120  getChangeCount() const { return changeCount_; }
121 
130  void
131  get(ValidityPeriodLite& validityPeriodLite) const
132  {
133  validityPeriodLite = validityPeriod_;
134  }
135 
140  void
141  set(const ValidityPeriodLite& validityPeriodLite)
142  {
143  validityPeriod_ = validityPeriodLite;
144  ++changeCount_;
145  }
146 
147 private:
148  ValidityPeriodLite validityPeriod_;
149  uint64_t changeCount_;
150 };
151 
152 }
153 
154 #endif
Copyright (C) 2013-2017 Regents of the University of California.
Definition: common.hpp:36
bool equals(const ValidityPeriodLite &other) const
Check if this is the same validity period as other.
Definition: validity-period-lite.cpp:53
ValidityPeriod()
Create a default ValidityPeriod where the period is not specified.
Definition: validity-period.hpp:39
void set(const ValidityPeriodLite &validityPeriodLite)
Clear this meta info, and set the values by copying from validityPeriodLite.
Definition: validity-period.hpp:141
void clear()
Reset to a default ValidityPeriod where the period is not specified.
Definition: validity-period.hpp:66
bool isValid(const MillisecondsSince1970 &time) const
Check if the time falls within the validity period.
Definition: validity-period.hpp:110
A ValidityPeriod is used in a Data packet's SignatureInfo and represents the begin and end times of a...
Definition: validity-period.hpp:35
bool equals(const ValidityPeriod &other) const
Check if this is the same validity period as other.
Definition: validity-period.hpp:98
ValidityPeriod & setPeriod(MillisecondsSince1970 notBefore, MillisecondsSince1970 notAfter)
Set the validity period.
Definition: validity-period.hpp:84
void clear()
Reset to a default ValidityPeriod where the period is not specified.
Definition: validity-period-lite.cpp:39
uint64_t getChangeCount() const
Get the change count, which is incremented each time this object is changed.
Definition: validity-period.hpp:120
double MillisecondsSince1970
The calendar time represented as the number of milliseconds since 1/1/1970.
Definition: common.hpp:117
bool isValid(ndn_MillisecondsSince1970 time) const
Check if the time falls within the validity period.
Definition: validity-period-lite.cpp:59
ValidityPeriodLite & setPeriod(ndn_MillisecondsSince1970 notBefore, ndn_MillisecondsSince1970 notAfter)
Set the validity period.
Definition: validity-period-lite.cpp:46
ndn_MillisecondsSince1970 getNotAfter() const
Get the end of the validity period range.
Definition: validity-period-lite.hpp:60
ndn_MillisecondsSince1970 getNotBefore() const
Get the beginning of the validity period range.
Definition: validity-period-lite.hpp:53
MillisecondsSince1970 getNotBefore() const
Get the beginning of the validity period range.
Definition: validity-period.hpp:54
bool hasPeriod() const
Check if the period has been set.
Definition: validity-period-lite.cpp:33
A ValidityPeriodLite is used in a Data packet's SignatureInfo and represents the begin and end times ...
Definition: validity-period-lite.hpp:33
MillisecondsSince1970 getNotAfter() const
Get the end of the validity period range.
Definition: validity-period.hpp:61
bool hasPeriod() const
Check if the period has been set.
Definition: validity-period.hpp:47