all: Refactoring work with time using boost::chrono
Now the library has two clocks: time::steady_clock and
time::system_clock, following (boost|std)::chrono. In addition to
standard now() method, the library contains several helpers to convert
to/from UnixTimestamp (microsecond resolution) and IsoString (optional
microsecond resolution). The IsoString conversions use
boost::posix_time routines, since boost::chrono supports extended IO
support only starting boost version 1.52 (Boost Chrono V2).
This commit breaks compatibility with previous API. All time-related
Data/Interest calls must explicitly use time units to specify
FreshnessPeriod/InterestLifetime.
Brief usage/conversion guide:
- creation of time units does not support double/float types. If
necessary to create time unit from double, ``ndn::duration<double>`` (for
seconds) needs to be used instead. In some cases, this would also
require ``ndn::duration_cast``, if the target is not ``ndn::nanoseconds``.
- ndn::getNow, ndn::ndn_getNowMilliseconds, ndn::time::now are all
removed in favor of the now() method in a specific clock:
* time::system_clock::now();
* time::steady_clock::now();
- When necessary to convert system_clock::TimePoint to unix timestamp,
``time::toUnixTimestamp`` can be used. This method return number of
milliseconds since UNIX epoch as ``ndn::time::milliseconds`` type.
Use count() method to obtain number as an integral value.
Change-Id: Icd688bc6766e008d60c3d2888173627874526e47
Refs: #1152
diff --git a/src/security/certificate.hpp b/src/security/certificate.hpp
index 35934d0..d27f7a4 100644
--- a/src/security/certificate.hpp
+++ b/src/security/certificate.hpp
@@ -35,16 +35,16 @@
* @param data The data packet with the content to decode.
*/
Certificate(const Data& data);
-
+
/**
* The virtual destructor.
*/
- virtual
+ virtual
~Certificate();
inline void
wireDecode(const Block &wire);
-
+
/**
* encode certificate info into content
*/
@@ -55,63 +55,63 @@
* Add a subject description.
* @param description The description to be added.
*/
- void
+ void
addSubjectDescription(const CertificateSubjectDescription& description) { subjectDescriptionList_.push_back(description); }
- const SubjectDescriptionList&
+ const SubjectDescriptionList&
getSubjectDescriptionList() const { return subjectDescriptionList_; }
-
- SubjectDescriptionList&
+
+ SubjectDescriptionList&
getSubjectDescriptionList() { return subjectDescriptionList_; }
-
+
/**
* Add a certificate extension.
* @param extension the extension to be added
*/
- void
+ void
addExtension(const CertificateExtension& extension) { extensionList_.push_back(extension); }
const ExtensionList&
getExtensionList() const { return extensionList_; }
-
+
ExtensionList&
getExtensionList() { return extensionList_; }
- void
- setNotBefore(const MillisecondsSince1970& notBefore) { notBefore_ = notBefore; }
+ void
+ setNotBefore(const time::system_clock::TimePoint& notBefore) { notBefore_ = notBefore; }
- MillisecondsSince1970&
+ time::system_clock::TimePoint&
getNotBefore() { return notBefore_; }
-
- const MillisecondsSince1970&
+
+ const time::system_clock::TimePoint&
getNotBefore() const { return notBefore_; }
void
- setNotAfter(const MillisecondsSince1970& notAfter) { notAfter_ = notAfter; }
+ setNotAfter(const time::system_clock::TimePoint& notAfter) { notAfter_ = notAfter; }
- MillisecondsSince1970&
+ time::system_clock::TimePoint&
getNotAfter() { return notAfter_; }
- const MillisecondsSince1970&
+ const time::system_clock::TimePoint&
getNotAfter() const { return notAfter_; }
void
setPublicKeyInfo(const PublicKey& key) { key_ = key; }
-
- PublicKey&
+
+ PublicKey&
getPublicKeyInfo() { return key_; }
- const PublicKey&
+ const PublicKey&
getPublicKeyInfo() const { return key_; }
- // virtual Name
+ // virtual Name
// getPublicKeyName() const = 0;
-
+
/**
* Check if the certificate is valid.
* @return True if the current time is earlier than notBefore.
*/
- bool
+ bool
isTooEarly();
/**
@@ -121,7 +121,7 @@
bool
isTooLate();
- void
+ void
printCertificate(std::ostream &os) const;
protected:
@@ -130,8 +130,8 @@
protected:
SubjectDescriptionList subjectDescriptionList_;
- MillisecondsSince1970 notBefore_;
- MillisecondsSince1970 notAfter_;
+ time::system_clock::TimePoint notBefore_;
+ time::system_clock::TimePoint notAfter_;
PublicKey key_;
ExtensionList extensionList_;
};