data+interest+selectors+meta-info+signature: Implementing EqualityComparable concept

Change-Id: I54f04820861bdc7b4e001949f1ba8d62f9a66786
diff --git a/src/data.hpp b/src/data.hpp
index 9fd00ab..4d84933 100644
--- a/src/data.hpp
+++ b/src/data.hpp
@@ -1,7 +1,6 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
 /**
  * Copyright (C) 2013 Regents of the University of California.
- * @author: Jeff Thompson <jefft0@remap.ucla.edu>
  * See COPYING for copyright and distribution information.
  */
 
@@ -22,19 +21,25 @@
 class Data : public enable_shared_from_this<Data>
 {
 public:
-  struct Error : public std::runtime_error { Error(const std::string &what) : std::runtime_error(what) {} };
+  class Error : public std::runtime_error
+  {
+  public:
+    explicit
+    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.
    */
-  inline
   Data(const Name& name);
 
   /**
@@ -49,37 +54,36 @@
   /**
    * @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;
+  size_t
+  wireEncode(EncodingImpl<T>& block, bool unsignedPortion = false) const;
 
   /**
    * @brief Encode to a wire format
    */
-  inline const Block&
+  const Block&
   wireEncode() const;
 
   /**
    * @brief Decode from the wire format
    */
-  inline void
-  wireDecode(const Block &wire);
+  void
+  wireDecode(const Block& wire);
 
   /**
    * @brief Check if already has wire
    */
-  inline bool
+  bool
   hasWire() const;
 
   ////////////////////////////////////////////////////////////////////
 
-  inline const Name&
+  const Name&
   getName() const;
 
   /**
@@ -88,12 +92,12 @@
    * @param name The Name which is copied.
    * @return This Data so that you can chain calls to update values.
    */
-  inline void
+  void
   setName(const Name& name);
 
   //
 
-  inline const MetaInfo&
+  const MetaInfo&
   getMetaInfo() const;
 
   /**
@@ -101,7 +105,7 @@
    * @param metaInfo The MetaInfo which is copied.
    * @return This Data so that you can chain calls to update values.
    */
-  inline void
+  void
   setMetaInfo(const MetaInfo& metaInfo);
 
   //
@@ -111,26 +115,26 @@
   ///////////////////////////////////////////////////////////////
   // MetaInfo proxy methods
 
-  inline uint32_t
+  uint32_t
   getContentType() const;
 
-  inline void
+  void
   setContentType(uint32_t type);
 
   //
 
-  inline const time::milliseconds&
+  const time::milliseconds&
   getFreshnessPeriod() const;
 
-  inline void
+  void
   setFreshnessPeriod(const time::milliseconds& freshnessPeriod);
 
   //
 
-  inline const name::Component&
+  const name::Component&
   getFinalBlockId() const;
 
-  inline void
+  void
   setFinalBlockId(const name::Component& finalBlockId);
 
   //
@@ -144,7 +148,7 @@
    * To access content value, one can use value()/value_size() or
    * value_begin()/value_end() methods of the Block class
    */
-  inline const Block&
+  const Block&
   getContent() const;
 
   /**
@@ -152,29 +156,29 @@
    * @param content A vector whose contents are copied.
    * @return This Data so that you can chain calls to update values.
    */
-  inline void
+  void
   setContent(const uint8_t* content, size_t contentLength);
 
-  inline void
+  void
   setContent(const Block& content);
 
-  inline void
-  setContent(const ConstBufferPtr &contentValue);
+  void
+  setContent(const ConstBufferPtr& contentValue);
 
   //
 
-  inline const Signature&
+  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
+  void
   setSignature(const Signature& signature);
 
-  inline void
-  setSignatureValue(const Block &value);
+  void
+  setSignatureValue(const Block& value);
 
   ///////////////////////////////////////////////////////////////
 
@@ -184,17 +188,24 @@
   const nfd::LocalControlHeader&
   getLocalControlHeader() const;
 
-  inline uint64_t
+  uint64_t
   getIncomingFaceId() const;
 
-  inline void
+  void
   setIncomingFaceId(uint64_t incomingFaceId);
 
+public: // EqualityComparable concept
+  bool
+  operator==(const Data& other) const;
+
+  bool
+  operator!=(const Data& other) const;
+
 private:
   /**
    * @brief Clear the wire encoding.
    */
-  inline void
+  void
   onChanged();
 
 private:
@@ -228,7 +239,7 @@
 
 template<bool T>
 inline size_t
-Data::wireEncode(EncodingImpl<T> &block, bool unsignedPortion/* = false*/) const
+Data::wireEncode(EncodingImpl<T>& block, bool unsignedPortion/* = false*/) const
 {
   size_t total_len = 0;
 
@@ -271,7 +282,7 @@
   return total_len;
 }
 
-inline const Block &
+inline const Block&
 Data::wireEncode() const
 {
   if (m_wire.hasWire())
@@ -291,8 +302,8 @@
  * Decode the input using a particular wire format and update this Data.
  * @param input The input byte array to be decoded.
  */
-void
-Data::wireDecode(const Block &wire)
+inline void
+Data::wireDecode(const Block& wire)
 {
   m_wire = wire;
   m_wire.parse();
@@ -416,7 +427,7 @@
 }
 
 inline void
-Data::setContent(const ConstBufferPtr &contentValue)
+Data::setContent(const ConstBufferPtr& contentValue)
 {
   onChanged();
 
@@ -449,7 +460,7 @@
 }
 
 inline void
-Data::setSignatureValue(const Block &value)
+Data::setSignatureValue(const Block& value)
 {
   onChanged();
   m_signature.setValue(value);
@@ -493,8 +504,23 @@
   m_wire.reset();
 }
 
+inline bool
+Data::operator==(const Data& other) const
+{
+  return getName() == other.getName() &&
+    getMetaInfo() == other.getMetaInfo() &&
+    getContent() == other.getContent() &&
+    getSignature() == other.getSignature();
+}
+
+inline bool
+Data::operator!=(const Data& other) const
+{
+  return !(*this == other);
+}
+
 inline std::ostream&
-operator << (std::ostream &os, const Data &data)
+operator<<(std::ostream& os, const Data& data)
 {
   os << "Name: " << data.getName() << "\n";
   os << "MetaInfo: " << data.getMetaInfo() << "\n";
diff --git a/src/exclude.cpp b/src/exclude.cpp
index bc1f9d5..be9dcc1 100644
--- a/src/exclude.cpp
+++ b/src/exclude.cpp
@@ -15,7 +15,7 @@
 namespace ndn
 {
 
-Exclude::Exclude ()
+Exclude::Exclude()
 {
 }
 
@@ -25,17 +25,17 @@
 //
 // /f (false); /d (true); /b (false); / (true)
 //
-// lower_bound (/)  -> / (true) <-- excluded (equal)
-// lower_bound (/a) -> / (true) <-- excluded (any)
-// lower_bound (/b) -> /b (false) <--- excluded (equal)
-// lower_bound (/c) -> /b (false) <--- not excluded (not equal and no ANY)
-// lower_bound (/d) -> /d (true) <- excluded
-// lower_bound (/e) -> /d (true) <- excluded
+// lower_bound(/)  -> / (true) <-- excluded (equal)
+// lower_bound(/a) -> / (true) <-- excluded (any)
+// lower_bound(/b) -> /b (false) <--- excluded (equal)
+// lower_bound(/c) -> /b (false) <--- not excluded (not equal and no ANY)
+// lower_bound(/d) -> /d (true) <- excluded
+// lower_bound(/e) -> /d (true) <- excluded
 bool
-Exclude::isExcluded (const name::Component &comp) const
+Exclude::isExcluded(const name::Component& comp) const
 {
-  const_iterator lowerBound = m_exclude.lower_bound (comp);
-  if (lowerBound == end ())
+  const_iterator lowerBound = m_exclude.lower_bound(comp);
+  if (lowerBound == end())
     return false;
 
   if (lowerBound->second)
@@ -46,12 +46,12 @@
   return false;
 }
 
-Exclude &
-Exclude::excludeOne (const name::Component &comp)
+Exclude&
+Exclude::excludeOne(const name::Component& comp)
 {
-  if (!isExcluded (comp))
+  if (!isExcluded(comp))
     {
-      m_exclude.insert (std::make_pair (comp, false));
+      m_exclude.insert(std::make_pair(comp, false));
     }
   return *this;
 }
@@ -63,42 +63,42 @@
 //
 // /f0 (false); /d0 (true); /b0 (false); / (true)
 //
-// lower_bound (/)  -> / (true) <-- excluded (equal)
-// lower_bound (/a0) -> / (true) <-- excluded (any)
-// lower_bound (/b0) -> /b0 (false) <--- excluded (equal)
-// lower_bound (/c0) -> /b0 (false) <--- not excluded (not equal and no ANY)
-// lower_bound (/d0) -> /d0 (true) <- excluded
-// lower_bound (/e0) -> /d0 (true) <- excluded
+// lower_bound(/)  -> / (true) <-- excluded (equal)
+// lower_bound(/a0) -> / (true) <-- excluded (any)
+// lower_bound(/b0) -> /b0 (false) <--- excluded (equal)
+// lower_bound(/c0) -> /b0 (false) <--- not excluded (not equal and no ANY)
+// lower_bound(/d0) -> /d0 (true) <- excluded
+// lower_bound(/e0) -> /d0 (true) <- excluded
 
 
 // examples with desired outcomes
-// excludeRange (/, /f0) ->  ANY /f0
+// excludeRange(/, /f0) ->  ANY /f0
 //                          /f0 (false); / (true)
-// excludeRange (/, /f1) ->  ANY /f1
+// excludeRange(/, /f1) ->  ANY /f1
 //                          /f1 (false); / (true)
-// excludeRange (/a0, /e0) ->  ANY /f0
+// excludeRange(/a0, /e0) ->  ANY /f0
 //                          /f0 (false); / (true)
-// excludeRange (/a0, /e0) ->  ANY /f0
+// excludeRange(/a0, /e0) ->  ANY /f0
 //                          /f0 (false); / (true)
 
-// excludeRange (/b1, /c0) ->  ANY /b0 /b1 ANY /c0 /d0 ANY /f0
+// excludeRange(/b1, /c0) ->  ANY /b0 /b1 ANY /c0 /d0 ANY /f0
 //                          /f0 (false); /d0 (true); /c0 (false); /b1 (true); /b0 (false); / (true)
 
-Exclude &
-Exclude::excludeRange (const name::Component &from, const name::Component &to)
+Exclude&
+Exclude::excludeRange(const name::Component& from, const name::Component& to)
 {
   if (from >= to)
     {
-      throw Error ("Invalid exclude range [" +
-                   from.toEscapedString() + ", " +
-                   to.toEscapedString() +
-                   "] (for single name exclude use Exclude::excludeOne)");
+      throw Error("Invalid exclude range [" +
+                  from.toEscapedString() + ", " +
+                  to.toEscapedString() +
+                  "] (for single name exclude use Exclude::excludeOne)");
     }
 
-  iterator newFrom = m_exclude.lower_bound (from);
-  if (newFrom == end () || !newFrom->second /*without ANY*/)
+  iterator newFrom = m_exclude.lower_bound(from);
+  if (newFrom == end() || !newFrom->second /*without ANY*/)
     {
-      std::pair<iterator, bool> fromResult = m_exclude.insert (std::make_pair (from, true));
+      std::pair<iterator, bool> fromResult = m_exclude.insert(std::make_pair(from, true));
       newFrom = fromResult.first;
       if (!fromResult.second)
         {
@@ -109,10 +109,10 @@
   // else
   // nothing special if start of the range already exists with ANY flag set
 
-  iterator newTo = m_exclude.lower_bound (to); // !newTo cannot be end ()
+  iterator newTo = m_exclude.lower_bound(to); // !newTo cannot be end()
   if (newTo == newFrom || !newTo->second)
     {
-      std::pair<iterator, bool> toResult = m_exclude.insert (std::make_pair (to, false));
+      std::pair<iterator, bool> toResult = m_exclude.insert(std::make_pair(to, false));
       newTo = toResult.first;
       ++ newTo;
     }
@@ -121,18 +121,18 @@
       // nothing to do really
     }
 
-  m_exclude.erase (newTo, newFrom); // remove any intermediate node, since all of the are excluded
+  m_exclude.erase(newTo, newFrom); // remove any intermediate node, since all of the are excluded
 
   return *this;
 }
 
-Exclude &
-Exclude::excludeAfter (const name::Component &from)
+Exclude&
+Exclude::excludeAfter(const name::Component& from)
 {
-  iterator newFrom = m_exclude.lower_bound (from);
-  if (newFrom == end () || !newFrom->second /*without ANY*/)
+  iterator newFrom = m_exclude.lower_bound(from);
+  if (newFrom == end() || !newFrom->second /*without ANY*/)
     {
-      std::pair<iterator, bool> fromResult = m_exclude.insert (std::make_pair (from, true));
+      std::pair<iterator, bool> fromResult = m_exclude.insert(std::make_pair(from, true));
       newFrom = fromResult.first;
       if (!fromResult.second)
         {
@@ -143,9 +143,9 @@
   // else
   // nothing special if start of the range already exists with ANY flag set
 
-  if (newFrom != m_exclude.begin ())
+  if (newFrom != m_exclude.begin())
     {
-      m_exclude.erase (m_exclude.begin (), newFrom); // remove any intermediate node, since all of the are excluded
+      m_exclude.erase(m_exclude.begin(), newFrom); // remove any intermediate node, since all of the are excluded
     }
 
   return *this;
@@ -153,15 +153,15 @@
 
 
 std::ostream&
-operator << (std::ostream &os, const Exclude &exclude)
+operator<<(std::ostream& os, const Exclude& exclude)
 {
   bool empty = true;
-  for (Exclude::const_reverse_iterator i = exclude.rbegin (); i != exclude.rend (); i++)
+  for (Exclude::const_reverse_iterator i = exclude.rbegin(); i != exclude.rend(); i++)
     {
       if (!i->first.empty())
         {
           if (!empty) os << ",";
-          os << i->first.toEscapedString ();
+          os << i->first.toEscapedString();
           empty = false;
         }
       if (i->second)
diff --git a/src/exclude.hpp b/src/exclude.hpp
index 22dc929..c38e9f9 100644
--- a/src/exclude.hpp
+++ b/src/exclude.hpp
@@ -21,9 +21,16 @@
 class Exclude
 {
 public:
-  struct Error : public std::runtime_error { Error(const std::string &what) : std::runtime_error(what) {} };
+  class Error : public std::runtime_error
+  {
+  public:
+    explicit
+    Error(const std::string& what)
+      : std::runtime_error(what)
+    {
+    }
+  };
 
-  
   typedef std::map< name::Component, bool /*any*/, std::greater<name::Component> > exclude_type;
 
   typedef exclude_type::iterator iterator;
@@ -34,15 +41,15 @@
   /**
    * @brief Default constructor an empty exclude
    */
-  Exclude ();
+  Exclude();
 
   /**
    * @brief Fast encoding or block size estimation
    */
   template<bool T>
   inline size_t
-  wireEncode(EncodingImpl<T> &block) const;
-  
+  wireEncode(EncodingImpl<T>& block) const;
+
   /**
    * @brief Encode to a wire format
    */
@@ -52,9 +59,9 @@
   /**
    * @brief Decode from the wire format
    */
-  inline void 
-  wireDecode(const Block &wire);
-  
+  inline void
+  wireDecode(const Block& wire);
+
   ///////////////////////////////////////////////////////////////////////////////
 
 
@@ -63,15 +70,15 @@
    * @param comp Name component to check against exclude filter
    */
   bool
-  isExcluded (const name::Component &comp) const;
+  isExcluded(const name::Component& comp) const;
 
   /**
    * @brief Exclude specific name component
    * @param comp component to exclude
    * @returns *this to allow chaining
    */
-  Exclude &
-  excludeOne (const name::Component &comp);
+  Exclude&
+  excludeOne(const name::Component& comp);
 
   /**
    * @brief Exclude components from range [from, to]
@@ -79,24 +86,24 @@
    * @param to last element of the range
    * @returns *this to allow chaining
    */
-  Exclude &
-  excludeRange (const name::Component &from, const name::Component &to);
+  Exclude&
+  excludeRange(const name::Component& from, const name::Component& to);
 
   /**
    * @brief Exclude all components from range [/, to]
    * @param to last element of the range
    * @returns *this to allow chaining
    */
-  inline Exclude &
-  excludeBefore (const name::Component &to);
+  inline Exclude&
+  excludeBefore(const name::Component& to);
 
   /**
    * @brief Exclude all components from range [from, +Inf]
    * @param to last element of the range
    * @returns *this to allow chaining
    */
-  Exclude &
-  excludeAfter (const name::Component &from);
+  Exclude&
+  excludeAfter(const name::Component& from);
 
   /**
    * @brief Method to directly append exclude element
@@ -108,126 +115,126 @@
    * If there is an error with ranges (e.g., order of components is wrong) an exception is thrown
    */
   inline void
-  appendExclude (const name::Component &name, bool any);
+  appendExclude(const name::Component& name, bool any);
 
   /**
    * @brief Check if exclude filter is empty
    */
   inline bool
-  empty () const;
+  empty() const;
 
   /**
    * @brief Clear the exclude filter
    */
   inline void
   clear();
-  
+
   /**
    * @brief Get number of exclude terms
    */
   inline size_t
-  size () const;
+  size() const;
 
   /**
    * @brief Get begin iterator of the exclude terms
    */
   inline const_iterator
-  begin () const;
+  begin() const;
 
   /**
    * @brief Get end iterator of the exclude terms
    */
   inline const_iterator
-  end () const;
+  end() const;
 
   /**
    * @brief Get begin iterator of the exclude terms
    */
   inline const_reverse_iterator
-  rbegin () const;
+  rbegin() const;
 
   /**
    * @brief Get end iterator of the exclude terms
    */
   inline const_reverse_iterator
-  rend () const;
+  rend() const;
 
   /**
    * @brief Get escaped string representation (e.g., for use in URI) of the exclude filter
    */
   inline std::string
-  toUri () const;
+  toUri() const;
 
 private:
-  Exclude &
-  excludeRange (iterator fromLowerBound, iterator toLowerBound);
+  Exclude&
+  excludeRange(iterator fromLowerBound, iterator toLowerBound);
 
 private:
   exclude_type m_exclude;
 
-  mutable Block wire_;
+  mutable Block m_wire;
 };
 
 std::ostream&
-operator << (std::ostream &os, const Exclude &name);
+operator<<(std::ostream& os, const Exclude& name);
 
-inline Exclude &
-Exclude::excludeBefore (const name::Component &to)
+inline Exclude&
+Exclude::excludeBefore(const name::Component& to)
 {
-  return excludeRange (name::Component (), to);
+  return excludeRange(name::Component(), to);
 }
 
 inline void
-Exclude::appendExclude (const name::Component &name, bool any)
+Exclude::appendExclude(const name::Component& name, bool any)
 {
   m_exclude[name] = any;
 }
 
 inline bool
-Exclude::empty () const
+Exclude::empty() const
 {
-  return m_exclude.empty ();
+  return m_exclude.empty();
 }
 
 inline void
-Exclude::clear ()
+Exclude::clear()
 {
-  m_exclude.clear ();
+  m_exclude.clear();
 }
 
 
 inline size_t
-Exclude::size () const
+Exclude::size() const
 {
-  return m_exclude.size ();
+  return m_exclude.size();
 }
 
 inline Exclude::const_iterator
-Exclude::begin () const
+Exclude::begin() const
 {
-  return m_exclude.begin ();
+  return m_exclude.begin();
 }
 
 inline Exclude::const_iterator
-Exclude::end () const
+Exclude::end() const
 {
-  return m_exclude.end ();
+  return m_exclude.end();
 }
 
 inline Exclude::const_reverse_iterator
-Exclude::rbegin () const
+Exclude::rbegin() const
 {
-  return m_exclude.rbegin ();
+  return m_exclude.rbegin();
 }
 
 inline Exclude::const_reverse_iterator
-Exclude::rend () const
+Exclude::rend() const
 {
-  return m_exclude.rend ();
+  return m_exclude.rend();
 }
 
 inline std::string
-Exclude::toUri () const
+Exclude::toUri() const
 {
   std::ostringstream os;
   os << *this;
@@ -236,14 +243,14 @@
 
 template<bool T>
 inline size_t
-Exclude::wireEncode(EncodingImpl<T> &block) const
+Exclude::wireEncode(EncodingImpl<T>& block) const
 {
   size_t total_len = 0;
 
   // Exclude ::= EXCLUDE-TYPE TLV-LENGTH Any? (NameComponent (Any)?)+
   // Any     ::= ANY-TYPE TLV-LENGTH(=0)
-  
-  for (Exclude::const_iterator i = m_exclude.begin (); i != m_exclude.end (); i++)
+
+  for (Exclude::const_iterator i = m_exclude.begin(); i != m_exclude.end(); i++)
     {
       if (i->second)
         {
@@ -260,47 +267,47 @@
   return total_len;
 }
 
-inline const Block &
+inline const Block&
 Exclude::wireEncode() const
 {
-  if (wire_.hasWire())
-    return wire_;
+  if (m_wire.hasWire())
+    return m_wire;
 
   EncodingEstimator estimator;
   size_t estimatedSize = wireEncode(estimator);
-  
+
   EncodingBuffer buffer(estimatedSize, 0);
   wireEncode(buffer);
 
-  wire_ = buffer.block();
-  return wire_;
+  m_wire = buffer.block();
+  return m_wire;
 }
 
 inline void
-Exclude::wireDecode(const Block &wire) 
+Exclude::wireDecode(const Block& wire)
 {
-  wire_ = wire;
-  wire_.parse();
+  m_wire = wire;
+  m_wire.parse();
 
   // Exclude ::= EXCLUDE-TYPE TLV-LENGTH Any? (NameComponent (Any)?)+
   // Any     ::= ANY-TYPE TLV-LENGTH(=0)
-  
-  Block::element_const_iterator i = wire_.elements_begin();
+
+  Block::element_const_iterator i = m_wire.elements_begin();
   if (i->type() == Tlv::Any)
     {
       appendExclude(name::Component(), true);
       ++i;
     }
 
-  while (i != wire_.elements_end())
+  while (i != m_wire.elements_end())
     {
       if (i->type() != Tlv::NameComponent)
         throw Error("Incorrect format of Exclude filter");
 
-      name::Component excludedComponent (i->value(), i->value_size());
+      name::Component excludedComponent(i->value(), i->value_size());
       ++i;
 
-      if (i != wire_.elements_end())
+      if (i != m_wire.elements_end())
         {
           if (i->type() == Tlv::Any)
             {
diff --git a/src/interest.cpp b/src/interest.cpp
index 8734274..314bdca 100644
--- a/src/interest.cpp
+++ b/src/interest.cpp
@@ -26,7 +26,7 @@
 
 
 bool
-Interest::matchesName(const Name &name) const
+Interest::matchesName(const Name& name) const
 {
   if (name.size() < m_name.size())
     return false;
@@ -75,8 +75,8 @@
   return true;
 }
 
-std::ostream &
-operator << (std::ostream &os, const Interest &interest)
+std::ostream&
+operator<<(std::ostream& os, const Interest& interest)
 {
   os << interest.getName();
 
diff --git a/src/interest.hpp b/src/interest.hpp
index fc851e7..2e2b8af 100644
--- a/src/interest.hpp
+++ b/src/interest.hpp
@@ -115,7 +115,7 @@
    */
   template<bool T>
   inline size_t
-  wireEncode(EncodingImpl<T> &block) const;
+  wireEncode(EncodingImpl<T>& block) const;
 
   /**
    * @brief Encode to a wire format
@@ -127,7 +127,7 @@
    * @brief Decode from the wire format
    */
   inline void
-  wireDecode(const Block &wire);
+  wireDecode(const Block& wire);
 
   /**
    * @brief Check if already has wire
@@ -157,7 +157,7 @@
    * @return 1 if the name and interest selectors match, 0 otherwise.
    */
   bool
-  matchesName(const Name &name) const;
+  matchesName(const Name& name) const;
 
   /** @brief Determines whether this Interest can be satisfied by @p data.
    *
@@ -407,6 +407,19 @@
     return *this;
   }
 
+public: // EqualityComparable concept
+  bool
+  operator==(const Interest& other) const
+  {
+    return wireEncode() == other.wireEncode();
+  }
+
+  bool
+  operator!=(const Interest& other) const
+  {
+    return !(*this == other);
+  }
+
 private:
   Name m_name;
   Selectors m_selectors;
@@ -420,8 +433,8 @@
   friend class nfd::LocalControlHeader;
 };
 
-std::ostream &
-operator << (std::ostream &os, const Interest &interest);
+std::ostream&
+operator<<(std::ostream& os, const Interest& interest);
 
 inline std::string
 Interest::toUri() const
@@ -447,7 +460,7 @@
 
 template<bool T>
 inline size_t
-Interest::wireEncode(EncodingImpl<T> &block) const
+Interest::wireEncode(EncodingImpl<T>& block) const
 {
   size_t total_len = 0;
 
@@ -507,7 +520,7 @@
 }
 
 inline void
-Interest::wireDecode(const Block &wire)
+Interest::wireDecode(const Block& wire)
 {
   m_wire = wire;
   m_wire.parse();
diff --git a/src/key-locator.hpp b/src/key-locator.hpp
index 1c71489..a139bf7 100644
--- a/src/key-locator.hpp
+++ b/src/key-locator.hpp
@@ -15,7 +15,15 @@
 
 class KeyLocator {
 public:
-  struct Error : public std::runtime_error { Error(const std::string &what) : std::runtime_error(what) {} };
+  class Error : public std::runtime_error
+  {
+  public:
+    explicit
+    Error(const std::string& what)
+      : std::runtime_error(what)
+    {
+    }
+  };
 
   enum {
     KeyLocator_None = 65535, // just an arbitrarily large number (used only internally)
@@ -24,30 +32,28 @@
     KeyLocator_Unknown = 255
   };
 
-  inline
   KeyLocator()
     : m_type(KeyLocator_None)
   {
   }
 
-  inline
-  KeyLocator(const Name &name);
+  KeyLocator(const Name& name);
 
   ///////////////////////////////////////////////////////////////////////////////
 
   template<bool T>
   size_t
-  wireEncode(EncodingImpl<T> &block) const;
+  wireEncode(EncodingImpl<T>& block) const;
 
   const Block&
   wireEncode() const;
 
   void
-  wireDecode(const Block &wire);
+  wireDecode(const Block& wire);
 
   ///////////////////////////////////////////////////////////////////////////////
 
-  inline bool
+   bool
   empty() const
   {
     return m_type == KeyLocator_None;
@@ -61,11 +67,11 @@
   //
   // For now only Name type is actually supported
 
-  inline const Name&
+  const Name&
   getName() const;
 
-  inline void
-  setName(const Name &name);
+  void
+  setName(const Name& name);
 
 public: // EqualityComparable concept
   bool
@@ -82,7 +88,7 @@
 };
 
 inline
-KeyLocator::KeyLocator(const Name &name)
+KeyLocator::KeyLocator(const Name& name)
 {
   setName(name);
 }
@@ -111,15 +117,15 @@
     throw Error("Unsupported KeyLocator type");
   }
 
-  total_len += block.prependVarNumber (total_len);
-  total_len += block.prependVarNumber (Tlv::KeyLocator);
+  total_len += block.prependVarNumber(total_len);
+  total_len += block.prependVarNumber(Tlv::KeyLocator);
   return total_len;
 }
 
 inline const Block&
 KeyLocator::wireEncode() const
 {
-  if (m_wire.hasWire ())
+  if (m_wire.hasWire())
     return m_wire;
 
   EncodingEstimator estimator;
@@ -133,7 +139,7 @@
 }
 
 inline void
-KeyLocator::wireDecode(const Block &value)
+KeyLocator::wireDecode(const Block& value)
 {
   if (value.type() != Tlv::KeyLocator)
     throw Error("Unexpected TLV type during KeyLocator decoding");
@@ -162,8 +168,9 @@
 }
 
 inline void
-KeyLocator::setName(const Name &name)
+KeyLocator::setName(const Name& name)
 {
+  m_wire.reset();
   m_type = KeyLocator_Name;
   m_name = name;
 }
@@ -171,19 +178,7 @@
 inline bool
 KeyLocator::operator==(const KeyLocator& other) const
 {
-  if (this->getType() != other.getType()) {
-    return false;
-  }
-
-  switch (this->getType()) {
-    case KeyLocator_Name:
-      if (this->getName() != other.getName()) {
-        return false;
-      }
-      break;
-  }
-
-  return true;
+  return wireEncode() == other.wireEncode();
 }
 
 inline bool
diff --git a/src/meta-info.hpp b/src/meta-info.hpp
index 42875d8..8042f8b 100644
--- a/src/meta-info.hpp
+++ b/src/meta-info.hpp
@@ -1,7 +1,6 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
 /**
- * Copyright (C) 2013 Regents of the University of California.
- * @author: Jeff Thompson <jefft0@remap.ucla.edu>
+ * Copyright (C) 2013-2014 Regents of the University of California.
  * See COPYING for copyright and distribution information.
  */
 
@@ -36,13 +35,13 @@
 
   template<bool T>
   size_t
-  wireEncode(EncodingImpl<T> &block) const;
+  wireEncode(EncodingImpl<T>& block) const;
 
   const Block&
   wireEncode() const;
 
   void
-  wireDecode(const Block &wire);
+  wireDecode(const Block& wire);
 
   ///////////////////////////////////////////////////////////////////////////////
   // Getters/setters
@@ -89,6 +88,19 @@
     return *this;
   }
 
+public: // EqualityComparable concept
+  bool
+  operator==(const MetaInfo& other) const
+  {
+    return wireEncode() == other.wireEncode();
+  }
+
+  bool
+  operator!=(const MetaInfo& other) const
+  {
+    return !(*this == other);
+  }
+
 private:
   uint32_t m_type;
   time::milliseconds m_freshnessPeriod;
@@ -127,15 +139,15 @@
       total_len += prependNonNegativeIntegerBlock(blk, Tlv::ContentType, m_type);
     }
 
-  total_len += blk.prependVarNumber (total_len);
-  total_len += blk.prependVarNumber (Tlv::MetaInfo);
+  total_len += blk.prependVarNumber(total_len);
+  total_len += blk.prependVarNumber(Tlv::MetaInfo);
   return total_len;
 }
 
 inline const Block&
 MetaInfo::wireEncode() const
 {
-  if (m_wire.hasWire ())
+  if (m_wire.hasWire())
     return m_wire;
 
   EncodingEstimator estimator;
@@ -149,7 +161,7 @@
 }
 
 inline void
-MetaInfo::wireDecode(const Block &wire)
+MetaInfo::wireDecode(const Block& wire)
 {
   m_wire = wire;
   m_wire.parse();
@@ -192,7 +204,7 @@
 }
 
 inline std::ostream&
-operator << (std::ostream &os, const MetaInfo &info)
+operator<<(std::ostream& os, const MetaInfo& info)
 {
   // ContentType
   os << "ContentType: " << info.getType();
diff --git a/src/security/signature-sha256-with-rsa.hpp b/src/security/signature-sha256-with-rsa.hpp
index e04ef78..7e19a1e 100644
--- a/src/security/signature-sha256-with-rsa.hpp
+++ b/src/security/signature-sha256-with-rsa.hpp
@@ -19,44 +19,44 @@
 public:
   SignatureSha256WithRsa()
   {
-    info_ = Block(Tlv::SignatureInfo);
-    
-    type_ = Signature::Sha256WithRsa;
-    info_.push_back(nonNegativeIntegerBlock(Tlv::SignatureType, Tlv::SignatureSha256WithRsa));
-    info_.push_back(keyLocator_.wireEncode());
+    m_info = Block(Tlv::SignatureInfo);
+
+    m_type = Signature::Sha256WithRsa;
+    m_info.push_back(nonNegativeIntegerBlock(Tlv::SignatureType, Tlv::SignatureSha256WithRsa));
+    m_info.push_back(m_keyLocator.wireEncode());
   }
-  
-  SignatureSha256WithRsa(const Signature &signature)
+
+  SignatureSha256WithRsa(const Signature& signature)
     : Signature(signature)
   {
     if (getType() != Signature::Sha256WithRsa)
       throw Signature::Error("Incorrect signature type");
 
-    info_.parse();
-    Block::element_const_iterator i = info_.find(Tlv::KeyLocator);
-    if (i != info_.elements_end())
+    m_info.parse();
+    Block::element_const_iterator i = m_info.find(Tlv::KeyLocator);
+    if (i != m_info.elements_end())
       {
-        keyLocator_.wireDecode(*i);
+        m_keyLocator.wireDecode(*i);
       }
   }
-  
-  const KeyLocator& 
+
+  const KeyLocator&
   getKeyLocator() const
   {
-    return keyLocator_;
+    return m_keyLocator;
   }
 
-  void 
+  void
   setKeyLocator(const KeyLocator& keyLocator)
   {
-    keyLocator_ = keyLocator;
+    m_keyLocator = keyLocator;
 
-    info_.remove(ndn::Tlv::KeyLocator);
-    info_.push_back(keyLocator_.wireEncode());
+    m_info.remove(ndn::Tlv::KeyLocator);
+    m_info.push_back(m_keyLocator.wireEncode());
   }
 
 private:
-  KeyLocator keyLocator_;
+  KeyLocator m_keyLocator;
 };
 
 } // namespace ndn
diff --git a/src/security/signature-sha256.hpp b/src/security/signature-sha256.hpp
index 99b550d..11b7cdf 100644
--- a/src/security/signature-sha256.hpp
+++ b/src/security/signature-sha256.hpp
@@ -19,12 +19,12 @@
 public:
   SignatureSha256()
   {
-    info_ = Block(Tlv::SignatureInfo);
-    
-    type_ = Signature::Sha256;
-    info_.push_back(nonNegativeIntegerBlock(Tlv::SignatureType, Tlv::DigestSha256));
+    m_info = Block(Tlv::SignatureInfo);
+
+    m_type = Signature::Sha256;
+    m_info.push_back(nonNegativeIntegerBlock(Tlv::SignatureType, Tlv::DigestSha256));
   }
-  
+
   SignatureSha256(const Signature &signature)
     : Signature(signature)
   {
diff --git a/src/selectors.hpp b/src/selectors.hpp
index cb17036..dd37e56 100644
--- a/src/selectors.hpp
+++ b/src/selectors.hpp
@@ -1,7 +1,6 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
 /**
- * Copyright (C) 2013 Regents of the University of California.
- * @author: Jeff Thompson <jefft0@remap.ucla.edu>
+ * Copyright (C) 2013-2014 Regents of the University of California.
  * See COPYING for copyright and distribution information.
  */
 
@@ -56,7 +55,7 @@
    */
   template<bool T>
   size_t
-  wireEncode(EncodingImpl<T> &block) const;
+  wireEncode(EncodingImpl<T>& block) const;
 
   /**
    * @brief Encode to a wire format
@@ -68,7 +67,7 @@
    * @brief Decode the input from wire format
    */
   void
-  wireDecode(const Block &wire);
+  wireDecode(const Block& wire);
 
   ///////////////////////////////////////////////////////////////////////////////
   ///////////////////////////////////////////////////////////////////////////////
@@ -84,7 +83,7 @@
   setMinSuffixComponents(int minSuffixComponents)
   {
     m_minSuffixComponents = minSuffixComponents;
-    wire_.reset();
+    m_wire.reset();
     return *this;
   }
 
@@ -100,7 +99,7 @@
   setMaxSuffixComponents(int maxSuffixComponents)
   {
     m_maxSuffixComponents = maxSuffixComponents;
-    wire_.reset();
+    m_wire.reset();
     return *this;
   }
 
@@ -116,7 +115,7 @@
   setPublisherPublicKeyLocator(const KeyLocator& keyLocator)
   {
     m_publisherPublicKeyLocator = keyLocator;
-    wire_.reset();
+    m_wire.reset();
     return *this;
   }
 
@@ -132,7 +131,7 @@
   setExclude(const Exclude& exclude)
   {
     m_exclude = exclude;
-    wire_.reset();
+    m_wire.reset();
     return *this;
   }
 
@@ -148,7 +147,7 @@
   setChildSelector(int childSelector)
   {
     m_childSelector = childSelector;
-    wire_.reset();
+    m_wire.reset();
     return *this;
   }
 
@@ -164,10 +163,23 @@
   setMustBeFresh(bool mustBeFresh)
   {
     m_mustBeFresh = mustBeFresh;
-    wire_.reset();
+    m_wire.reset();
     return *this;
   }
 
+public: // EqualityComparable concept
+  bool
+  operator==(const Selectors& other) const
+  {
+    return wireEncode() == other.wireEncode();
+  }
+
+  bool
+  operator!=(const Selectors& other) const
+  {
+    return !(*this == other);
+  }
+
 private:
   int m_minSuffixComponents;
   int m_maxSuffixComponents;
@@ -176,7 +188,7 @@
   int m_childSelector;
   bool m_mustBeFresh;
 
-  mutable Block wire_;
+  mutable Block m_wire;
 };
 
 inline bool
@@ -193,7 +205,7 @@
 
 template<bool T>
 inline size_t
-Selectors::wireEncode(EncodingImpl<T> &block) const
+Selectors::wireEncode(EncodingImpl<T>& block) const
 {
   size_t total_len = 0;
 
@@ -250,11 +262,11 @@
   return total_len;
 }
 
-inline const Block &
+inline const Block&
 Selectors::wireEncode() const
 {
-  if (wire_.hasWire())
-    return wire_;
+  if (m_wire.hasWire())
+    return m_wire;
 
   EncodingEstimator estimator;
   size_t estimatedSize = wireEncode(estimator);
@@ -262,59 +274,59 @@
   EncodingBuffer buffer(estimatedSize, 0);
   wireEncode(buffer);
 
-  wire_ = buffer.block();
-  return wire_;
+  m_wire = buffer.block();
+  return m_wire;
 }
 
 inline void
-Selectors::wireDecode(const Block &wire)
+Selectors::wireDecode(const Block& wire)
 {
   if (wire.type() != Tlv::Selectors)
     throw Tlv::Error("Unexpected TLV type when decoding Selectors");
 
   *this = Selectors();
 
-  wire_ = wire;
-  wire_.parse();
+  m_wire = wire;
+  m_wire.parse();
 
   // MinSuffixComponents
-  Block::element_const_iterator val = wire_.find(Tlv::MinSuffixComponents);
-  if (val != wire_.elements_end())
+  Block::element_const_iterator val = m_wire.find(Tlv::MinSuffixComponents);
+  if (val != m_wire.elements_end())
     {
       m_minSuffixComponents = readNonNegativeInteger(*val);
     }
 
   // MaxSuffixComponents
-  val = wire_.find(Tlv::MaxSuffixComponents);
-  if (val != wire_.elements_end())
+  val = m_wire.find(Tlv::MaxSuffixComponents);
+  if (val != m_wire.elements_end())
     {
       m_maxSuffixComponents = readNonNegativeInteger(*val);
     }
 
   // PublisherPublicKeyLocator
-  val = wire_.find(Tlv::KeyLocator);
-  if (val != wire_.elements_end())
+  val = m_wire.find(Tlv::KeyLocator);
+  if (val != m_wire.elements_end())
     {
       m_publisherPublicKeyLocator.wireDecode(*val);
     }
 
   // Exclude
-  val = wire_.find(Tlv::Exclude);
-  if (val != wire_.elements_end())
+  val = m_wire.find(Tlv::Exclude);
+  if (val != m_wire.elements_end())
     {
       m_exclude.wireDecode(*val);
     }
 
   // ChildSelector
-  val = wire_.find(Tlv::ChildSelector);
-  if (val != wire_.elements_end())
+  val = m_wire.find(Tlv::ChildSelector);
+  if (val != m_wire.elements_end())
     {
       m_childSelector = readNonNegativeInteger(*val);
     }
 
   //MustBeFresh aka AnswerOriginKind
-  val = wire_.find(Tlv::MustBeFresh);
-  if (val != wire_.elements_end())
+  val = m_wire.find(Tlv::MustBeFresh);
+  if (val != m_wire.elements_end())
     {
       m_mustBeFresh = true;
     }
diff --git a/src/signature.hpp b/src/signature.hpp
index e38ad3e..8a20baa 100644
--- a/src/signature.hpp
+++ b/src/signature.hpp
@@ -1,7 +1,6 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
 /**
- * Copyright (C) 2013 Regents of the University of California.
- * @author: Jeff Thompson <jefft0@remap.ucla.edu>
+ * Copyright (C) 2013-2014 Regents of the University of California.
  * See COPYING for copyright and distribution information.
  */
 
@@ -15,84 +14,106 @@
  */
 class Signature {
 public:
-  struct Error : public std::runtime_error { Error(const std::string &what) : std::runtime_error(what) {} };
+  class Error : public std::runtime_error
+  {
+  public:
+    explicit
+    Error(const std::string& what)
+      : std::runtime_error(what)
+    {
+    }
+  };
 
   enum {
     Sha256 = 0,
     Sha256WithRsa = 1
   };
-  
+
   Signature()
-    : type_(-1)
+    : m_type(-1)
   {
   }
-  
-  Signature(const Block &info, const Block &value = Block())
-    : value_(value)
+
+  Signature(const Block& info, const Block& value = Block())
+    : m_value(value)
   {
     setInfo(info);
   }
 
   operator bool() const
   {
-    return type_ != -1;
+    return m_type != -1;
   }
 
   uint32_t
   getType() const
   {
-    return type_;
+    return m_type;
   }
-  
+
   const Block&
   getInfo() const
   {
-    info_.encode(); // will do nothing if wire already exists
-    return info_;
+    m_info.encode(); // will do nothing if wire already exists
+    return m_info;
   }
 
   void
-  setInfo(const Block &info)
+  setInfo(const Block& info)
   {
-    info_ = info;
-    if (info_.hasWire() || info_.hasValue())
+    m_info = info;
+    if (m_info.hasWire() || m_info.hasValue())
       {
-        info_.parse();
-        const Block &signatureType = info_.get(Tlv::SignatureType);
-        type_ = readNonNegativeInteger(signatureType);
+        m_info.parse();
+        const Block& signatureType = m_info.get(Tlv::SignatureType);
+        m_type = readNonNegativeInteger(signatureType);
       }
     else
       {
-        type_ = -1;
+        m_type = -1;
       }
-  }  
+  }
 
   const Block&
   getValue() const
   {
-    value_.encode(); // will do nothing if wire already exists
-    return value_;
+    m_value.encode(); // will do nothing if wire already exists
+    return m_value;
   }
 
   void
-  setValue(const Block &value)
+  setValue(const Block& value)
   {
-    value_ = value;
+    m_value = value;
   }
 
   void
   reset()
   {
-    type_ = -1;
-    info_.reset();
-    value_.reset();
+    m_type = -1;
+    m_info.reset();
+    m_value.reset();
+  }
+
+public: // EqualityComparable concept
+  bool
+  operator==(const Signature& other) const
+  {
+    return getInfo() == other.getInfo() &&
+      getValue() == other.getValue();
+  }
+
+  bool
+  operator!=(const Signature& other) const
+  {
+    return !(*this == other);
   }
 
 protected:
-  int32_t type_;
-  
-  mutable Block info_;
-  mutable Block value_;
+  int32_t m_type;
+
+  mutable Block m_info;
+  mutable Block m_value;
 };
 
 } // namespace ndn