All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Pages
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 
31  class Signature;
32 
38 public:
42 
54  MillisecondsSince1970 notAfter)
55  {
56  validityPeriod_.setPeriod(notBefore, notAfter);
57  }
58 
64  bool
65  hasPeriod() const { return validityPeriod_.hasPeriod(); }
66 
72  getNotBefore() const { return validityPeriod_.getNotBefore(); }
73 
79  getNotAfter() const { return validityPeriod_.getNotAfter(); }
80 
83  void
85  {
86  validityPeriod_.clear();
87  ++changeCount_;
88  }
89 
101  setPeriod
103  MillisecondsSince1970 notAfter)
104  {
105  validityPeriod_.setPeriod(notBefore, notAfter);
106  ++changeCount_;
107  return *this;
108  }
109 
115  bool
116  equals(const ValidityPeriod& other) const
117  {
118  return validityPeriod_.equals(other.validityPeriod_);
119  }
120 
128  bool
129  isValid(MillisecondsSince1970 time = -1.0) const;
130 
142  static bool
143  canGetFromSignature(const Signature* signature);
144 
152  static ValidityPeriod&
153  getFromSignature(Signature* signature);
154 
155  static const ValidityPeriod&
156  getFromSignature(const Signature* signature)
157  {
158  return getFromSignature(const_cast<Signature*>(signature));
159  }
160 
165  uint64_t
166  getChangeCount() const { return changeCount_; }
167 
176  void
177  get(ValidityPeriodLite& validityPeriodLite) const
178  {
179  validityPeriodLite = validityPeriod_;
180  }
181 
186  void
187  set(const ValidityPeriodLite& validityPeriodLite)
188  {
189  validityPeriod_ = validityPeriodLite;
190  ++changeCount_;
191  }
192 
193 private:
194  ValidityPeriodLite validityPeriod_;
195  uint64_t changeCount_;
196 };
197 
198 }
199 
200 #endif
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:41
static ValidityPeriod & getFromSignature(Signature *signature)
If the signature is a type that has a ValidityPeriod, then return it.
Definition: validity-period.cpp:51
bool isValid(MillisecondsSince1970 time=-1.0) const
Check if the time falls within the validity period.
Definition: validity-period.cpp:34
void set(const ValidityPeriodLite &validityPeriodLite)
Clear this meta info, and set the values by copying from validityPeriodLite.
Definition: validity-period.hpp:187
void clear()
Reset to a default ValidityPeriod where the period is not specified.
Definition: validity-period.hpp:84
A ValidityPeriod is used in a Data packet's SignatureInfo and represents the begin and end times of a...
Definition: validity-period.hpp:37
A Signature is an abstract base class providing methods to work with the signature information in a D...
Definition: signature.hpp:35
bool equals(const ValidityPeriod &other) const
Check if this is the same validity period as other.
Definition: validity-period.hpp:116
ValidityPeriod & setPeriod(MillisecondsSince1970 notBefore, MillisecondsSince1970 notAfter)
Set the validity period.
Definition: validity-period.hpp:102
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:166
double MillisecondsSince1970
The calendar time represented as the number of milliseconds since 1/1/1970.
Definition: common.hpp:119
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:72
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:79
static bool canGetFromSignature(const Signature *signature)
If the signature is a type that has a ValidityPeriod (so that getFromSignature will succeed)...
Definition: validity-period.cpp:44
bool hasPeriod() const
Check if the period has been set.
Definition: validity-period.hpp:65