common.hpp: time: Added typedef for Milliseconds and MillisecondsSince1970, and use instead of double where appropriate.
diff --git a/include/ndn-cpp/c/common.h b/include/ndn-cpp/c/common.h
index 89392bc..c1706d5 100644
--- a/include/ndn-cpp/c/common.h
+++ b/include/ndn-cpp/c/common.h
@@ -12,4 +12,22 @@
// TODO: Is stddef.h portable?
#include <stddef.h>
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * A time interval represented as the number of milliseconds.
+ */
+typedef double ndn_Milliseconds;
+
+/**
+ * The calendar time represented as the number of milliseconds since 1/1/1970.
+ */
+typedef double ndn_MillisecondsSince1970;
+
+#ifdef __cplusplus
+}
+#endif
+
#endif
diff --git a/include/ndn-cpp/common.hpp b/include/ndn-cpp/common.hpp
index f0bd736..1df861b 100644
--- a/include/ndn-cpp/common.hpp
+++ b/include/ndn-cpp/common.hpp
@@ -63,10 +63,17 @@
#endif
namespace ndn {
+
+/**
+ * A time interval represented as the number of milliseconds.
+ */
+typedef double Milliseconds;
-// TODO: Implement Time, used in certificates and DER encoding.
-typedef double Time;
-
+/**
+ * The calendar time represented as the number of milliseconds since 1/1/1970.
+ */
+typedef double MillisecondsSince1970;
+
/**
* Return the hex representation of the bytes in array.
* @param array The array of bytes.
diff --git a/include/ndn-cpp/data.hpp b/include/ndn-cpp/data.hpp
index a99e410..1cd00f6 100644
--- a/include/ndn-cpp/data.hpp
+++ b/include/ndn-cpp/data.hpp
@@ -83,7 +83,7 @@
void
set(const struct ndn_MetaInfo& metaInfoStruct);
- double
+ MillisecondsSince1970
getTimestampMilliseconds() const { return timestampMilliseconds_; }
ndn_ContentType
@@ -96,7 +96,7 @@
getFinalBlockID() const { return finalBlockID_; }
void
- setTimestampMilliseconds(double timestampMilliseconds) { timestampMilliseconds_ = timestampMilliseconds; }
+ setTimestampMilliseconds(MillisecondsSince1970 timestampMilliseconds) { timestampMilliseconds_ = timestampMilliseconds; }
void
setType(ndn_ContentType type) { type_ = type; }
@@ -117,7 +117,7 @@
}
private:
- double timestampMilliseconds_; /**< milliseconds since 1/1/1970. -1 for none */
+ MillisecondsSince1970 timestampMilliseconds_; /**< milliseconds since 1/1/1970. -1 for none */
ndn_ContentType type_; /**< default is ndn_ContentType_DATA. -1 for none */
int freshnessSeconds_; /**< -1 for none */
Name::Component finalBlockID_; /** size 0 for none */
diff --git a/include/ndn-cpp/interest.hpp b/include/ndn-cpp/interest.hpp
index 955d681..f05d575 100644
--- a/include/ndn-cpp/interest.hpp
+++ b/include/ndn-cpp/interest.hpp
@@ -134,7 +134,7 @@
public:
Interest(const Name& name, int minSuffixComponents, int maxSuffixComponents,
const PublisherPublicKeyDigest& publisherPublicKeyDigest, const Exclude& exclude, int childSelector, int answerOriginKind,
- int scope, double interestLifetimeMilliseconds, const std::vector<uint8_t>& nonce)
+ int scope, Milliseconds interestLifetimeMilliseconds, const std::vector<uint8_t>& nonce)
: name_(name), minSuffixComponents_(minSuffixComponents), maxSuffixComponents_(maxSuffixComponents),
publisherPublicKeyDigest_(publisherPublicKeyDigest), exclude_(exclude), childSelector_(childSelector),
answerOriginKind_(answerOriginKind), scope_(scope), interestLifetimeMilliseconds_(interestLifetimeMilliseconds),
@@ -144,14 +144,14 @@
Interest(const Name& name, int minSuffixComponents, int maxSuffixComponents,
const PublisherPublicKeyDigest& publisherPublicKeyDigest, const Exclude& exclude, int childSelector, int answerOriginKind,
- int scope, double interestLifetimeMilliseconds)
+ int scope, Milliseconds interestLifetimeMilliseconds)
: name_(name), minSuffixComponents_(minSuffixComponents), maxSuffixComponents_(maxSuffixComponents),
publisherPublicKeyDigest_(publisherPublicKeyDigest), exclude_(exclude), childSelector_(childSelector),
answerOriginKind_(answerOriginKind), scope_(scope), interestLifetimeMilliseconds_(interestLifetimeMilliseconds)
{
}
- Interest(const Name& name, double interestLifetimeMilliseconds)
+ Interest(const Name& name, Milliseconds interestLifetimeMilliseconds)
: name_(name)
{
construct();
@@ -228,7 +228,7 @@
int
getScope() const { return scope_; }
- double
+ Milliseconds
getInterestLifetimeMilliseconds() const { return interestLifetimeMilliseconds_; }
const Blob&
@@ -257,7 +257,7 @@
setScope(int value) { scope_ = value; }
void
- setInterestLifetimeMilliseconds(double value) { interestLifetimeMilliseconds_ = value; }
+ setInterestLifetimeMilliseconds(Milliseconds value) { interestLifetimeMilliseconds_ = value; }
void
setNonce(const std::vector<uint8_t>& value) { nonce_ = value; }
@@ -282,7 +282,7 @@
int childSelector_;
int answerOriginKind_;
int scope_;
- double interestLifetimeMilliseconds_;
+ Milliseconds interestLifetimeMilliseconds_;
Blob nonce_;
};
diff --git a/include/ndn-cpp/node.hpp b/include/ndn-cpp/node.hpp
index 882ecd8..1e4c001 100644
--- a/include/ndn-cpp/node.hpp
+++ b/include/ndn-cpp/node.hpp
@@ -172,11 +172,11 @@
/**
* If this interest is timed out, call onTimeout_ (if defined) and return true.
* @param parent The parent Node for the UpcallInfo.
- * @param nowMilliseconds The current time in milliseconds from gettimeofday.
+ * @param nowMilliseconds The current time in milliseconds from ndn_getNowMilliseconds.
* @return true if this interest timed out and the timeout callback was called, otherwise false.
*/
bool
- checkTimeout(Node *parent, double nowMilliseconds);
+ checkTimeout(Node *parent, MillisecondsSince1970 nowMilliseconds);
private:
ptr_lib::shared_ptr<const Interest> interest_;
@@ -188,7 +188,7 @@
uint64_t pendingInterestId_; /**< A unique identifier for this entry so it can be deleted */
const OnData onData_;
const OnTimeout onTimeout_;
- double timeoutTimeMilliseconds_; /**< The time when the interest times out in milliseconds according to gettimeofday, or -1 for no timeout. */
+ MillisecondsSince1970 timeoutTimeMilliseconds_; /**< The time when the interest times out in milliseconds according to ndn_getNowMilliseconds, or -1 for no timeout. */
};
class RegisteredPrefix {
diff --git a/include/ndn-cpp/security/certificate/certificate.hpp b/include/ndn-cpp/security/certificate/certificate.hpp
index 21745e2..bc6b355 100644
--- a/include/ndn-cpp/security/certificate/certificate.hpp
+++ b/include/ndn-cpp/security/certificate/certificate.hpp
@@ -61,21 +61,21 @@
addExtension(const CertificateExtension& extension) { extensionList_.push_back(extension); }
void
- setNotBefore(const Time& notBefore) { notBefore_ = notBefore; }
+ setNotBefore(const MillisecondsSince1970& notBefore) { notBefore_ = notBefore; }
- Time&
+ MillisecondsSince1970&
getNotBefore() { return notBefore_; }
- const Time&
+ const MillisecondsSince1970&
getNotBefore() const { return notBefore_; }
void
- setNotAfter(const Time& notAfter) { notAfter_ = notAfter; }
+ setNotAfter(const MillisecondsSince1970& notAfter) { notAfter_ = notAfter; }
- Time&
+ MillisecondsSince1970&
getNotAfter() { return notAfter_; }
- const Time&
+ const MillisecondsSince1970&
getNotAfter() const { return notAfter_; }
void
@@ -113,8 +113,8 @@
protected:
SubjectDescriptionList subjectDescriptionList_;
- Time notBefore_;
- Time notAfter_;
+ MillisecondsSince1970 notBefore_;
+ MillisecondsSince1970 notAfter_;
PublicKey key_;
ExtensionList extensionList_;
};
diff --git a/include/ndn-cpp/security/identity/basic-identity-storage.hpp b/include/ndn-cpp/security/identity/basic-identity-storage.hpp
index ee1a886..d841548 100644
--- a/include/ndn-cpp/security/identity/basic-identity-storage.hpp
+++ b/include/ndn-cpp/security/identity/basic-identity-storage.hpp
@@ -200,7 +200,7 @@
sqlite3 *database_;
#if 0
- Time lastUpdated_;
+ MillisecondsSince1970 lastUpdated_;
#endif
};
diff --git a/include/ndn-cpp/security/identity/identity-manager.hpp b/include/ndn-cpp/security/identity/identity-manager.hpp
index d31e214..1d6df04 100644
--- a/include/ndn-cpp/security/identity/identity-manager.hpp
+++ b/include/ndn-cpp/security/identity/identity-manager.hpp
@@ -106,7 +106,7 @@
* @return The name of generated identity certificate.
*/
Name
- createIdentityCertificate(const Name& keyName, const Name& signerCertificateName, const Time& notBefore, const Time& notAfter);
+ createIdentityCertificate(const Name& keyName, const Name& signerCertificateName, const MillisecondsSince1970& notBefore, const MillisecondsSince1970& notAfter);
/**
* Create an identity certificate for a public key supplied by the caller.
@@ -119,7 +119,7 @@
*/
ptr_lib::shared_ptr<IdentityCertificate>
createIdentityCertificate
- (const Name& keyName, const PublicKey& publickey, const Name& signerCertificateName, const Time& notBefore, const Time& notAfter);
+ (const Name& keyName, const PublicKey& publickey, const Name& signerCertificateName, const MillisecondsSince1970& notBefore, const MillisecondsSince1970& notAfter);
/**
* Add a certificate into the public key identity storage.