bug+codestyle: Fix compile bugs and adjust code style

Change-Id: I008bb538441c099fa25b8b967fbf23ffce13a220
diff --git a/src/profile.cpp b/src/profile.cpp
index e6044fa..cd69849 100644
--- a/src/profile.cpp
+++ b/src/profile.cpp
@@ -8,15 +8,18 @@
  * Author: Yingdi Yu <yingdi@cs.ucla.edu>
  */
 
-#include "profile.h"
+#include "profile.hpp"
 #include "logging.h"
 
-using namespace ndn;
-
-INIT_LOGGER("Profile");
-
 namespace chronos{
 
+using std::vector;
+using std::string;
+using std::map;
+
+using ndn::IdentityCertificate;
+using ndn::CertificateSubjectDescription;
+
 const std::string Profile::OID_NAME("2.5.4.41");
 const std::string Profile::OID_ORG("2.5.4.11");
 const std::string Profile::OID_GROUP("2.5.4.1");
@@ -28,29 +31,30 @@
 {
   Name keyName = IdentityCertificate::certificateNameToPublicKeyName(identityCertificate.getName());
 
-  m_entries[std::string("IDENTITY")] = keyName.getPrefix(-1).toUri();
+  m_entries[string("IDENTITY")] = keyName.getPrefix(-1).toUri();
 
-  const std::vector<CertificateSubjectDescription>& subList = identityCertificate.getSubjectDescriptionList();
-  std::vector<CertificateSubjectDescription>::const_iterator it = subList.begin();
-  for(; it != subList.end(); it++)
-    {
-      const std::string oidStr = it->getOidString();
-      std::string valueStr = it->getValue();
-      if(oidStr == OID_NAME)
-        m_entries["name"] = valueStr;
-      else if(oidStr == OID_ORG)
-        m_entries["institution"] = valueStr;
-      else if(oidStr == OID_GROUP)
-        m_entries["group"] = valueStr;
-      else if(oidStr == OID_HOMEPAGE)
-        m_entries["homepage"] = valueStr;
-      else if(oidStr == OID_ADVISOR)
-        m_entries["advisor"] = valueStr;
-      else if(oidStr == OID_EMAIL)
-        m_entries["email"] = valueStr;
-      else
-        m_entries[oidStr] = valueStr;
-    }
+  const vector<CertificateSubjectDescription>& subList =
+    identityCertificate.getSubjectDescriptionList();
+
+  for (vector<CertificateSubjectDescription>::const_iterator it = subList.begin();
+       it != subList.end(); it++) {
+    const string oidStr = it->getOidString();
+    string valueStr = it->getValue();
+    if (oidStr == OID_NAME)
+      m_entries["name"] = valueStr;
+    else if (oidStr == OID_ORG)
+      m_entries["institution"] = valueStr;
+    else if (oidStr == OID_GROUP)
+      m_entries["group"] = valueStr;
+    else if (oidStr == OID_HOMEPAGE)
+      m_entries["homepage"] = valueStr;
+    else if (oidStr == OID_ADVISOR)
+      m_entries["advisor"] = valueStr;
+    else if (oidStr == OID_EMAIL)
+      m_entries["email"] = valueStr;
+    else
+      m_entries[oidStr] = valueStr;
+  }
 }
 
 Profile::Profile(const Name& identityName)
@@ -59,8 +63,8 @@
 }
 
 Profile::Profile(const Name& identityName,
-                 const std::string& name,
-                 const std::string& institution)
+                 const string& name,
+                 const string& institution)
 {
   m_entries["IDENTITY"] = identityName.toUri();
   m_entries["name"] = name;
@@ -69,7 +73,8 @@
 
 Profile::Profile(const Profile& profile)
   : m_entries(profile.m_entries)
-{}
+{
+}
 
 void
 Profile::encode(std::ostream& os) const
@@ -87,29 +92,50 @@
   profileMsg >> (*this);
 }
 
-Chronos::ProfileMsg&
-operator << (Chronos::ProfileMsg& profileMsg, const Profile& profile)
+bool
+Profile::operator==(const Profile& profile) const
 {
-  std::map<std::string, std::string>::const_iterator it = profile.begin();
-  for(; it != profile.end(); it++)
-    {
-      Chronos::ProfileMsg::ProfileEntry* profileEntry = profileMsg.add_entry();
-      profileEntry->set_oid(it->first);
-      profileEntry->set_data(it->second);
-    }
+  if (m_entries.size() != profile.m_entries.size())
+    return false;
+
+  for(map<string, string>::const_iterator it = m_entries.begin(); it != m_entries.end(); it++) {
+    map<string, string>::const_iterator found = profile.m_entries.find(it->first);
+    if (found == profile.m_entries.end())
+      return false;
+    if (found->second != it->second)
+      return false;
+  }
+
+  return true;
+}
+
+bool
+Profile::operator!=(const Profile& profile) const
+{
+  return !(*this == profile);
+}
+
+Chronos::ProfileMsg&
+operator<<(Chronos::ProfileMsg& profileMsg, const Profile& profile)
+{
+;
+  for (map<string, string>::const_iterator it = profile.begin(); it != profile.end(); it++) {
+    Chronos::ProfileMsg::ProfileEntry* profileEntry = profileMsg.add_entry();
+    profileEntry->set_oid(it->first);
+    profileEntry->set_data(it->second);
+  }
   return profileMsg;
 }
 
 Chronos::ProfileMsg&
-operator >> (Chronos::ProfileMsg& profileMsg, Profile& profile)
+operator>>(Chronos::ProfileMsg& profileMsg, Profile& profile)
 {
-  for(int i = 0; i < profileMsg.entry_size(); i++)
-    {
-      const Chronos::ProfileMsg::ProfileEntry& profileEntry = profileMsg.entry(i);
-      profile[profileEntry.oid()] = profileEntry.data();
-    }
+  for (int i = 0; i < profileMsg.entry_size(); i++) {
+    const Chronos::ProfileMsg::ProfileEntry& profileEntry = profileMsg.entry(i);
+    profile[profileEntry.oid()] = profileEntry.data();
+  }
 
   return profileMsg;
 }
 
-}//chronos
+} // namespace chronos