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/data.hpp b/src/data.hpp
index 5130b03..9fd00ab 100644
--- a/src/data.hpp
+++ b/src/data.hpp
@@ -18,18 +18,18 @@
 #include "management/nfd-local-control-header.hpp"
 
 namespace ndn {
-  
+
 class Data : public enable_shared_from_this<Data>
 {
 public:
   struct Error : public std::runtime_error { Error(const std::string &what) : std::runtime_error(what) {} };
-  
+
   /**
    * @brief Create an empty Data object
    */
   inline
   Data();
-  
+
   /**
    * @brief Create a new Data object with the given name
    * @param name A reference to the name which is copied.
@@ -45,20 +45,20 @@
   {
     wireDecode(wire);
   }
-  
+
   /**
    * @brief The destructor
    */
   inline
   ~Data();
-  
+
   /**
    * @brief Fast encoding or block size estimation
    */
   template<bool T>
   inline size_t
   wireEncode(EncodingImpl<T> &block, bool unsignedPortion = false) const;
-  
+
   /**
    * @brief Encode to a wire format
    */
@@ -68,7 +68,7 @@
   /**
    * @brief Decode from the wire format
    */
-  inline void 
+  inline void
   wireDecode(const Block &wire);
 
   /**
@@ -76,12 +76,12 @@
    */
   inline bool
   hasWire() const;
-  
-  ////////////////////////////////////////////////////////////////////  
-  
-  inline const Name& 
+
+  ////////////////////////////////////////////////////////////////////
+
+  inline const Name&
   getName() const;
-  
+
   /**
    * @brief Set name to a copy of the given Name.
    *
@@ -92,10 +92,10 @@
   setName(const Name& name);
 
   //
-  
-  inline const MetaInfo& 
+
+  inline const MetaInfo&
   getMetaInfo() const;
-  
+
   /**
    * @brief Set metaInfo to a copy of the given MetaInfo.
    * @param metaInfo The MetaInfo which is copied.
@@ -105,25 +105,25 @@
   setMetaInfo(const MetaInfo& metaInfo);
 
   //
-  
+
   ///////////////////////////////////////////////////////////////
   ///////////////////////////////////////////////////////////////
   ///////////////////////////////////////////////////////////////
   // MetaInfo proxy methods
 
-  inline uint32_t 
+  inline uint32_t
   getContentType() const;
-  
-  inline void 
+
+  inline void
   setContentType(uint32_t type);
 
   //
-  
-  inline Milliseconds 
+
+  inline const time::milliseconds&
   getFreshnessPeriod() const;
-  
-  inline void 
-  setFreshnessPeriod(Milliseconds freshnessPeriod);
+
+  inline void
+  setFreshnessPeriod(const time::milliseconds& freshnessPeriod);
 
   //
 
@@ -137,14 +137,14 @@
   ///////////////////////////////////////////////////////////////
   ///////////////////////////////////////////////////////////////
   ///////////////////////////////////////////////////////////////
-  
+
   /**
    * @brief Get content Block
    *
    * To access content value, one can use value()/value_size() or
    * value_begin()/value_end() methods of the Block class
    */
-  inline const Block& 
+  inline const Block&
   getContent() const;
 
   /**
@@ -162,17 +162,17 @@
   setContent(const ConstBufferPtr &contentValue);
 
   //
-  
+
   inline const Signature&
   getSignature() const;
-  
+
   /**
    * @brief Set the signature to a copy of the given signature.
    * @param signature The signature object which is cloned.
    */
   inline void
   setSignature(const Signature& signature);
-  
+
   inline void
   setSignatureValue(const Block &value);
 
@@ -183,18 +183,18 @@
 
   const nfd::LocalControlHeader&
   getLocalControlHeader() const;
-  
+
   inline uint64_t
   getIncomingFaceId() const;
 
   inline void
   setIncomingFaceId(uint64_t incomingFaceId);
-  
+
 private:
   /**
    * @brief Clear the wire encoding.
    */
-  inline void 
+  inline void
   onChanged();
 
 private:
@@ -253,10 +253,10 @@
 
   // SignatureInfo
   total_len += prependBlock(block, m_signature.getInfo());
-  
+
   // Content
   total_len += prependBlock(block, getContent());
-  
+
   // MetaInfo
   total_len += getMetaInfo().wireEncode(block);
 
@@ -279,16 +279,16 @@
 
   EncodingEstimator estimator;
   size_t estimatedSize = wireEncode(estimator);
-  
+
   EncodingBuffer buffer(estimatedSize, 0);
   wireEncode(buffer);
 
   const_cast<Data*>(this)->wireDecode(buffer.block());
   return m_wire;
 }
-  
+
 /**
- * Decode the input using a particular wire format and update this Data. 
+ * Decode the input using a particular wire format and update this Data.
  * @param input The input byte array to be decoded.
  */
 void
@@ -302,7 +302,7 @@
   //            MetaInfo
   //            Content
   //            Signature
-    
+
   // Name
   m_name.wireDecode(m_wire.get(Tlv::Name));
 
@@ -315,10 +315,10 @@
   ///////////////
   // Signature //
   ///////////////
-  
+
   // SignatureInfo
   m_signature.setInfo(m_wire.get(Tlv::SignatureInfo));
-  
+
   // SignatureValue
   Block::element_const_iterator val = m_wire.find(Tlv::SignatureValue);
   if (val != m_wire.elements_end())
@@ -331,53 +331,53 @@
   return m_wire.hasWire();
 }
 
-inline const Name& 
+inline const Name&
 Data::getName() const
 {
   return m_name;
 }
-  
+
 inline void
 Data::setName(const Name& name)
-{ 
+{
   onChanged();
-  m_name = name; 
+  m_name = name;
 }
-  
-inline const MetaInfo& 
+
+inline const MetaInfo&
 Data::getMetaInfo() const
 {
   return m_metaInfo;
 }
-  
+
 inline void
-Data::setMetaInfo(const MetaInfo& metaInfo) 
-{ 
+Data::setMetaInfo(const MetaInfo& metaInfo)
+{
   onChanged();
-  m_metaInfo = metaInfo; 
+  m_metaInfo = metaInfo;
 }
 
-inline uint32_t 
+inline uint32_t
 Data::getContentType() const
 {
   return m_metaInfo.getType();
 }
-  
-inline void 
+
+inline void
 Data::setContentType(uint32_t type)
 {
   onChanged();
   m_metaInfo.setType(type);
 }
-  
-inline Milliseconds 
+
+inline const time::milliseconds&
 Data::getFreshnessPeriod() const
 {
   return m_metaInfo.getFreshnessPeriod();
 }
-  
-inline void 
-Data::setFreshnessPeriod(Milliseconds freshnessPeriod)
+
+inline void
+Data::setFreshnessPeriod(const time::milliseconds& freshnessPeriod)
 {
   onChanged();
   m_metaInfo.setFreshnessPeriod(freshnessPeriod);
@@ -396,7 +396,7 @@
   m_metaInfo.setFinalBlockId(finalBlockId);
 }
 
-inline const Block& 
+inline const Block&
 Data::getContent() const
 {
   if (m_content.empty())
@@ -408,7 +408,7 @@
 }
 
 inline void
-Data::setContent(const uint8_t* content, size_t contentLength) 
+Data::setContent(const uint8_t* content, size_t contentLength)
 {
   onChanged();
 
@@ -422,9 +422,9 @@
 
   m_content = Block(Tlv::Content, contentValue); // not real a wire encoding yet
 }
-  
+
 inline void
-Data::setContent(const Block& content) 
+Data::setContent(const Block& content)
 {
   onChanged();
 
@@ -440,9 +440,9 @@
 {
   return m_signature;
 }
-  
+
 inline void
-Data::setSignature(const Signature& signature) 
+Data::setSignature(const Signature& signature)
 {
   onChanged();
   m_signature = signature;
@@ -482,14 +482,14 @@
   // ! do not reset Data's wire !
 }
 
-inline void 
+inline void
 Data::onChanged()
 {
   // The values have changed, so the wire format is invalidated
 
   // !!!Note!!! Signature is not invalidated and it is responsibility of
   // the application to do proper re-signing if necessary
-  
+
   m_wire.reset();
 }