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

Change-Id: I54f04820861bdc7b4e001949f1ba8d62f9a66786
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