lsa: change type variable to enum class

Change-Id: I7fba951649771700ce6ccc4be7fb400546607e96
refs: #4340
diff --git a/src/common.hpp b/src/common.hpp
index 93b3e87..3337520 100644
--- a/src/common.hpp
+++ b/src/common.hpp
@@ -56,8 +56,6 @@
    static constexpr bool value = true;
 };
 
-using IsLsaNew = std::function<bool(const ndn::Name&, const std::string&, const uint64_t&)>;
-
 } // namespace nlsr
 
 #endif // NLSR_COMMON_HPP
diff --git a/src/communication/sync-logic-handler.cpp b/src/communication/sync-logic-handler.cpp
index 95b656c..d87f4fc 100644
--- a/src/communication/sync-logic-handler.cpp
+++ b/src/communication/sync-logic-handler.cpp
@@ -118,20 +118,21 @@
   // A router should not try to fetch its own LSA
   if (originRouter != m_confParam.getRouterPrefix()) {
 
-    std::string lsaType = updateName.get(updateName.size()-1).toUri();
+    Lsa::Type lsaType;
+    std::istringstream(updateName.get(updateName.size()-1).toUri()) >> lsaType;
 
     _LOG_DEBUG("Received sync update with higher " << lsaType
                << " sequence number than entry in LSDB");
 
     if (m_isLsaNew(originRouter, lsaType, seqNo)) {
-      if (lsaType == AdjLsa::TYPE_STRING && seqNo != 0 &&
+      if (lsaType == Lsa::Type::ADJACENCY && seqNo != 0 &&
           m_confParam.getHyperbolicState() == HYPERBOLIC_STATE_ON) {
         _LOG_ERROR("Got an update for adjacency LSA when hyperbolic routing"
                    << " is enabled. Not going to fetch.");
         return;
       }
 
-      if (lsaType == CoordinateLsa::TYPE_STRING && seqNo != 0 &&
+      if (lsaType == Lsa::Type::COORDINATE && seqNo != 0 &&
           m_confParam.getHyperbolicState() == HYPERBOLIC_STATE_OFF) {
         _LOG_ERROR("Got an update for coordinate LSA when link-state"
                    << " is enabled. Not going to fetch.");
@@ -143,7 +144,7 @@
 }
 
 void
-SyncLogicHandler::publishRoutingUpdate(const ndn::Name& type, const uint64_t& seqNo)
+SyncLogicHandler::publishRoutingUpdate(const Lsa::Type& type, const uint64_t& seqNo)
 {
   if (m_syncSocket == nullptr) {
     _LOG_FATAL("Cannot publish routing update; SyncSocket does not exist");
@@ -151,14 +152,19 @@
     BOOST_THROW_EXCEPTION(SyncLogicHandler::Error("Cannot publish routing update; SyncSocket does not exist"));
   }
 
-  if (type == NameLsa::TYPE_STRING) {
-    publishSyncUpdate(m_nameLsaUserPrefix, seqNo);
-  }
-  else if (type == AdjLsa::TYPE_STRING) {
+
+  switch (type) {
+  case Lsa::Type::ADJACENCY:
     publishSyncUpdate(m_adjLsaUserPrefix, seqNo);
-  }
-  else {
+    break;
+  case Lsa::Type::COORDINATE:
     publishSyncUpdate(m_coorLsaUserPrefix, seqNo);
+    break;
+  case Lsa::Type::NAME:
+    publishSyncUpdate(m_nameLsaUserPrefix, seqNo);
+    break;
+  default:
+    break;
   }
 }
 
@@ -170,13 +176,13 @@
   updatePrefix.append(m_confParam.getRouterName());
 
   m_nameLsaUserPrefix = updatePrefix;
-  m_nameLsaUserPrefix.append(NameLsa::TYPE_STRING);
+  m_nameLsaUserPrefix.append(std::to_string(Lsa::Type::NAME));
 
   m_adjLsaUserPrefix = updatePrefix;
-  m_adjLsaUserPrefix.append(AdjLsa::TYPE_STRING);
+  m_adjLsaUserPrefix.append(std::to_string(Lsa::Type::ADJACENCY));
 
   m_coorLsaUserPrefix = updatePrefix;
-  m_coorLsaUserPrefix.append(CoordinateLsa::TYPE_STRING);
+  m_coorLsaUserPrefix.append(std::to_string(Lsa::Type::COORDINATE));
 }
 
 void
diff --git a/src/communication/sync-logic-handler.hpp b/src/communication/sync-logic-handler.hpp
index afa1464..3a074ef 100644
--- a/src/communication/sync-logic-handler.hpp
+++ b/src/communication/sync-logic-handler.hpp
@@ -24,6 +24,7 @@
 
 #include "test-access-control.hpp"
 #include "signals.hpp"
+#include "lsa.hpp"
 
 #include <ndn-cxx/face.hpp>
 #include <ndn-cxx/util/signal.hpp>
@@ -48,7 +49,7 @@
 {
 public:
   using IsLsaNew =
-    std::function<bool(const ndn::Name&, const std::string& lsaType, const uint64_t&)>;
+    std::function<bool(const ndn::Name&, const Lsa::Type& lsaType, const uint64_t&)>;
 
   class Error : public std::runtime_error
   {
@@ -83,7 +84,7 @@
    * \sa publishSyncUpdate
    */
   void
-  publishRoutingUpdate(const ndn::Name& type, const uint64_t& seqNo);
+  publishRoutingUpdate(const Lsa::Type& type, const uint64_t& seqNo);
 
   /*! \brief Create and configure a socket to enable ChronoSync for this NLSR.
    *
diff --git a/src/lsa.cpp b/src/lsa.cpp
index ec27a35..1b5e804 100644
--- a/src/lsa.cpp
+++ b/src/lsa.cpp
@@ -38,22 +38,17 @@
 
 INIT_LOGGER("Lsa");
 
-const std::string NameLsa::TYPE_STRING = "name";
-const std::string AdjLsa::TYPE_STRING = "adjacency";
-const std::string CoordinateLsa::TYPE_STRING = "coordinate";
-
 const ndn::Name
 NameLsa::getKey() const
 {
   ndn::Name key = m_origRouter;
-  key.append(NameLsa::TYPE_STRING);
+  key.append(std::to_string(Lsa::Type::NAME));
   return key;
 }
 
 NameLsa::NameLsa(const ndn::Name& origR, uint32_t lsn,
                  const ndn::time::system_clock::TimePoint& lt,
                  NamePrefixList& npl)
-  : Lsa(NameLsa::TYPE_STRING)
 {
   m_origRouter = origR;
   m_lsSeqNo = lsn;
@@ -67,7 +62,7 @@
 NameLsa::getData()
 {
   std::ostringstream os;
-  os << m_origRouter << "|" << NameLsa::TYPE_STRING << "|" << m_lsSeqNo << "|"
+  os << m_origRouter << "|" << Lsa::Type::NAME << "|" << m_lsSeqNo << "|"
      << ndn::time::toIsoString(m_expirationTimePoint) << "|" << m_npl.size();
   for (const auto& name : m_npl.getNames()) {
     os << "|" << name;
@@ -89,7 +84,7 @@
     return false;
   }
   try {
-    if (*tok_iter++ != NameLsa::TYPE_STRING) {
+    if (*tok_iter++ != std::to_string(Lsa::Type::NAME)) {
       return false;
     }
 
@@ -119,7 +114,7 @@
 {
   _LOG_DEBUG("Name Lsa: ");
   _LOG_DEBUG("  Origination Router: " << m_origRouter);
-  _LOG_DEBUG("  Ls Type: " << m_lsType);
+  _LOG_DEBUG("  Ls Type: " << getType());
   _LOG_DEBUG("  Ls Seq No: " << m_lsSeqNo);
   _LOG_DEBUG("  Ls Lifetime: " << m_expirationTimePoint);
   _LOG_DEBUG("  Names: ");
@@ -135,7 +130,6 @@
 CoordinateLsa::CoordinateLsa(const ndn::Name& origR, uint32_t lsn,
                              const ndn::time::system_clock::TimePoint& lt,
                              double r, std::vector<double> theta)
-  : Lsa(CoordinateLsa::TYPE_STRING)
 {
   m_origRouter = origR;
   m_lsSeqNo = lsn;
@@ -148,7 +142,7 @@
 CoordinateLsa::getKey() const
 {
   ndn::Name key = m_origRouter;
-  key.append(CoordinateLsa::TYPE_STRING);
+  key.append(std::to_string(Lsa::Type::COORDINATE));
   return key;
 }
 
@@ -174,7 +168,7 @@
 CoordinateLsa::getData()
 {
   std::ostringstream os;
-  os << m_origRouter << "|" << CoordinateLsa::TYPE_STRING << "|" << m_lsSeqNo << "|"
+  os << m_origRouter << "|" << Lsa::Type::COORDINATE << "|" << m_lsSeqNo << "|"
      << ndn::time::toIsoString(m_expirationTimePoint) << "|" << m_corRad << "|"
      << m_angles.size() << "|";
 
@@ -198,7 +192,7 @@
   }
 
   try {
-    if (*tok_iter++ != CoordinateLsa::TYPE_STRING) {
+    if (*tok_iter++ != std::to_string(Lsa::Type::COORDINATE)) {
       return false;
     }
 
@@ -223,7 +217,7 @@
 {
   _LOG_DEBUG("Cor Lsa: ");
   _LOG_DEBUG("  Origination Router: " << m_origRouter);
-  _LOG_DEBUG("  Ls Type: " << m_lsType);
+  _LOG_DEBUG("  Ls Type: " << getType());
   _LOG_DEBUG("  Ls Seq No: " << m_lsSeqNo);
   _LOG_DEBUG("  Ls Lifetime: " << m_expirationTimePoint);
   _LOG_DEBUG("    Hyperbolic Radius: " << m_corRad);
@@ -236,7 +230,6 @@
 AdjLsa::AdjLsa(const ndn::Name& origR, uint32_t lsn,
                const ndn::time::system_clock::TimePoint& lt,
                uint32_t nl , AdjacencyList& adl)
-  : Lsa(AdjLsa::TYPE_STRING)
 {
   m_origRouter = origR;
   m_lsSeqNo = lsn;
@@ -254,7 +247,7 @@
 AdjLsa::getKey() const
 {
   ndn::Name key = m_origRouter;
-  key.append(AdjLsa::TYPE_STRING);
+  key.append(std::to_string(Lsa::Type::ADJACENCY));
   return key;
 }
 
@@ -268,7 +261,7 @@
 AdjLsa::getData()
 {
   std::ostringstream os;
-  os << m_origRouter << "|" << AdjLsa::TYPE_STRING << "|" << m_lsSeqNo << "|"
+  os << m_origRouter << "|" << Lsa::Type::ADJACENCY << "|" << m_lsSeqNo << "|"
      << ndn::time::toIsoString(m_expirationTimePoint) << "|" << m_adl.size();
   for (const auto& adjacent : m_adl.getAdjList()) {
     os << "|" << adjacent.getName() << "|" << adjacent.getFaceUri()
@@ -291,7 +284,7 @@
     return false;
   }
   try {
-    if (*tok_iter++ != AdjLsa::TYPE_STRING) {
+    if (*tok_iter++ != std::to_string(Lsa::Type::ADJACENCY)) {
       return false;
     }
 
@@ -351,7 +344,7 @@
 {
   os << "Adj Lsa:\n"
      << "  Origination Router: " << adjLsa.getOrigRouter() << "\n"
-     << "  Ls Type: " << adjLsa.getLsType() << "\n"
+     << "  Ls Type: " << adjLsa.getType() << "\n"
      << "  Ls Seq No: " << adjLsa.getLsSeqNo() << "\n"
      << "  Ls Lifetime: " << adjLsa.getExpirationTimePoint() << "\n"
      << "  Adjacents: \n";
@@ -369,4 +362,49 @@
   return os;
 }
 
+std::ostream&
+operator<<(std::ostream& os, const Lsa::Type& type)
+{
+  os << std::to_string(type);
+  return os;
+}
+
+std::istream&
+operator>>(std::istream& is, Lsa::Type& type)
+{
+  std::string typeString;
+  is >> typeString;
+  if (typeString == "ADJACENCY") {
+    type = Lsa::Type::ADJACENCY;
+  }
+  else if (typeString == "COORDINATE") {
+    type = Lsa::Type::COORDINATE;
+  }
+  else if (typeString == "NAME") {
+    type = Lsa::Type::NAME;
+  }
+  else {
+    type = Lsa::Type::BASE;
+  }
+  return is;
+}
+
 } // namespace nlsr
+
+namespace std {
+std::string
+to_string(const nlsr::Lsa::Type& type)
+{
+  switch (type) {
+  case nlsr::Lsa::Type::ADJACENCY:
+     return "ADJACENCY";
+  case nlsr::Lsa::Type::COORDINATE:
+    return "COORDINATE";
+  case nlsr::Lsa::Type::NAME:
+    return "NAME";
+  default:
+    return "BASE";
+  }
+}
+
+} // namespace std
diff --git a/src/lsa.hpp b/src/lsa.hpp
index d27ddd6..dd69d8e 100644
--- a/src/lsa.hpp
+++ b/src/lsa.hpp
@@ -37,19 +37,25 @@
 class Lsa
 {
 public:
-  Lsa(const std::string& lsaType)
+  enum class Type {
+    ADJACENCY,
+    COORDINATE,
+    NAME,
+    BASE
+  };
+
+  Lsa()
     : m_origRouter()
-    , m_lsType(lsaType)
     , m_lsSeqNo()
     , m_expirationTimePoint()
     , m_expiringEventId()
   {
   }
 
-  const std::string&
-  getLsType() const
+  virtual Type
+  getType() const
   {
-    return m_lsType;
+    return Type::BASE;
   }
 
   void
@@ -102,7 +108,6 @@
 
 protected:
   ndn::Name m_origRouter;
-  const std::string m_lsType;
   uint32_t m_lsSeqNo;
   ndn::time::system_clock::TimePoint m_expirationTimePoint;
   ndn::EventId m_expiringEventId;
@@ -112,8 +117,6 @@
 {
 public:
   NameLsa()
-    : Lsa(NameLsa::TYPE_STRING)
-    , m_npl()
   {
   }
 
@@ -121,6 +124,12 @@
           const ndn::time::system_clock::TimePoint& lt,
           NamePrefixList& npl);
 
+  Lsa::Type
+  getType() const override
+  {
+    return Lsa::Type::NAME;
+  }
+
   NamePrefixList&
   getNpl()
   {
@@ -180,8 +189,6 @@
 
 private:
   NamePrefixList m_npl;
-public:
-  static const std::string TYPE_STRING;
 };
 
 class AdjLsa: public Lsa
@@ -190,8 +197,6 @@
   typedef AdjacencyList::const_iterator const_iterator;
 
   AdjLsa()
-    : Lsa(AdjLsa::TYPE_STRING)
-    , m_adl()
   {
   }
 
@@ -199,6 +204,12 @@
          const ndn::time::system_clock::TimePoint& lt,
          uint32_t nl , AdjacencyList& adl);
 
+  Lsa::Type
+  getType() const override
+  {
+    return Lsa::Type::ADJACENCY;
+  }
+
   AdjacencyList&
   getAdl()
   {
@@ -277,17 +288,13 @@
 private:
   uint32_t m_noLink;
   AdjacencyList m_adl;
-
-public:
-  static const std::string TYPE_STRING;
 };
 
 class CoordinateLsa: public Lsa
 {
 public:
   CoordinateLsa()
-    : Lsa(CoordinateLsa::TYPE_STRING)
-    , m_corRad(0)
+    : m_corRad(0)
   {
   }
 
@@ -295,6 +302,12 @@
                 const ndn::time::system_clock::TimePoint& lt,
                 double r, std::vector<double> theta);
 
+  Lsa::Type
+  getType() const override
+  {
+    return Lsa::Type::COORDINATE;
+  }
+
   const ndn::Name
   getKey() const;
 
@@ -350,14 +363,22 @@
 private:
   double m_corRad;
   std::vector<double> m_angles;
-
-public:
-  static const std::string TYPE_STRING;
 };
 
 std::ostream&
 operator<<(std::ostream& os, const AdjLsa& adjLsa);
 
+std::ostream&
+operator<<(std::ostream& os, const Lsa::Type& type);
+
+std::istream&
+operator>>(std::istream& is, Lsa::Type& type);
+
 } // namespace nlsr
 
+namespace std {
+  std::string
+  to_string(const nlsr::Lsa::Type& type);
+} // namespace std
+
 #endif // NLSR_LSA_HPP
diff --git a/src/lsdb.cpp b/src/lsdb.cpp
index 480248e..2661813 100644
--- a/src/lsdb.cpp
+++ b/src/lsdb.cpp
@@ -66,7 +66,7 @@
   : m_nlsr(nlsr)
   , m_scheduler(scheduler)
   , m_sync(m_nlsr.getNlsrFace(),
-           [this] (const ndn::Name& routerName, const std::string& lsaType,
+           [this] (const ndn::Name& routerName, const Lsa::Type& lsaType,
                    const uint64_t& sequenceNumber) {
              return isLsaNew(routerName, lsaType, sequenceNumber);
            }, m_nlsr.getConfParameter())
@@ -166,7 +166,7 @@
   m_sequencingManager.increaseNameLsaSeq();
 
   m_sequencingManager.writeSeqNoToFile();
-  m_sync.publishRoutingUpdate(NameLsa::TYPE_STRING, m_sequencingManager.getNameLsaSeq());
+  m_sync.publishRoutingUpdate(Lsa::Type::NAME, m_sequencingManager.getNameLsaSeq());
 
   return installNameLsa(nameLsa);
 }
@@ -396,7 +396,7 @@
   if (m_nlsr.getConfParameter().getHyperbolicState() != HYPERBOLIC_STATE_OFF) {
     m_sequencingManager.increaseCorLsaSeq();
     m_sequencingManager.writeSeqNoToFile();
-    m_sync.publishRoutingUpdate(CoordinateLsa::TYPE_STRING, m_sequencingManager.getCorLsaSeq());
+    m_sync.publishRoutingUpdate(Lsa::Type::COORDINATE, m_sequencingManager.getCorLsaSeq());
   }
 
   installCoordinateLsa(corLsa);
@@ -628,7 +628,7 @@
         _LOG_DEBUG("Removing own Adj LSA; no ACTIVE neighbors");
         // Get this router's key
         ndn::Name key = m_nlsr.getConfParameter().getRouterPrefix();
-        key.append(AdjLsa::TYPE_STRING);
+        key.append(std::to_string(Lsa::Type::ADJACENCY));
 
         removeAdjLsa(key);
         // Recompute routing table after removal
@@ -770,7 +770,7 @@
   if (m_nlsr.getConfParameter().getHyperbolicState() != HYPERBOLIC_STATE_ON) {
     m_sequencingManager.increaseAdjLsaSeq();
     m_sequencingManager.writeSeqNoToFile();
-    m_sync.publishRoutingUpdate(AdjLsa::TYPE_STRING, m_sequencingManager.getAdjLsaSeq());
+    m_sync.publishRoutingUpdate(Lsa::Type::ADJACENCY, m_sequencingManager.getAdjLsaSeq());
   }
 
   return installAdjLsa(adjLsa);
@@ -854,7 +854,7 @@
                                                                  chkNameLsa->getLsSeqNo(),
                                                                  m_lsaRefreshTime));
         m_sequencingManager.writeSeqNoToFile();
-        m_sync.publishRoutingUpdate(NameLsa::TYPE_STRING, m_sequencingManager.getNameLsaSeq());
+        m_sync.publishRoutingUpdate(Lsa::Type::NAME, m_sequencingManager.getNameLsaSeq());
       }
       // Since we cannot refresh other router's LSAs, our only choice is to expire.
       else {
@@ -898,7 +898,7 @@
                                                                chkAdjLsa->getLsSeqNo(),
                                                                m_lsaRefreshTime));
         m_sequencingManager.writeSeqNoToFile();
-        m_sync.publishRoutingUpdate(AdjLsa::TYPE_STRING, m_sequencingManager.getAdjLsaSeq());
+        m_sync.publishRoutingUpdate(Lsa::Type::ADJACENCY, m_sequencingManager.getAdjLsaSeq());
       }
       // An LSA from another router is expiring
       else {
@@ -951,7 +951,7 @@
         // Only sync coordinate LSAs if link-state routing is disabled
         if (m_nlsr.getConfParameter().getHyperbolicState() != HYPERBOLIC_STATE_OFF) {
           m_sequencingManager.writeSeqNoToFile();
-          m_sync.publishRoutingUpdate(CoordinateLsa::TYPE_STRING, m_sequencingManager.getCorLsaSeq());
+          m_sync.publishRoutingUpdate(Lsa::Type::COORDINATE, m_sequencingManager.getCorLsaSeq());
         }
       }
       // We can't refresh other router's LSAs, so we remove it.
@@ -1004,18 +1004,20 @@
                                    std::bind(&Lsdb::onFetchLsaError, this, _1, _2, interestName,
                                              timeoutCount, deadline, lsaName, seqNo));
   // increment a specific SENT_LSA_INTEREST
-  std::string typeLSA = interestName[-2].toUri();
-  if (typeLSA == AdjLsa::TYPE_STRING) {
+  Lsa::Type lsaType;
+  std::istringstream(interestName[-2].toUri()) >> lsaType;
+  switch (lsaType) {
+  case Lsa::Type::ADJACENCY:
     lsaIncrementSignal(Statistics::PacketType::SENT_ADJ_LSA_INTEREST);
-  }
-  else if (typeLSA == CoordinateLsa::TYPE_STRING) {
+    break;
+  case Lsa::Type::COORDINATE:
     lsaIncrementSignal(Statistics::PacketType::SENT_COORD_LSA_INTEREST);
-  }
-  else if (typeLSA == NameLsa::TYPE_STRING) {
+    break;
+  case Lsa::Type::NAME:
     lsaIncrementSignal(Statistics::PacketType::SENT_NAME_LSA_INTEREST);
-  }
-  else {
-    _LOG_ERROR("typeLSA " + typeLSA + " not recognized; failed Statistics::PacketType conversion");
+    break;
+  default:
+    _LOG_ERROR("lsaType " << lsaType << " not recognized; failed Statistics::PacketType conversion");
   }
 }
 
@@ -1041,16 +1043,20 @@
     uint64_t seqNo = interestName[-1].toNumber();
     _LOG_DEBUG("LSA sequence number from interest: " << seqNo);
 
-    std::string interestedLsType = interestName[-2].toUri();
+    Lsa::Type interestedLsType;
+    std::istringstream(interestName[-2].toUri()) >> interestedLsType;
 
-    if (interestedLsType == NameLsa::TYPE_STRING) {
-      processInterestForNameLsa(interest, originRouter.append(interestedLsType), seqNo);
+    if (interestedLsType == Lsa::Type::NAME) {
+      processInterestForNameLsa(interest, originRouter.append(std::to_string(interestedLsType)),
+                                seqNo);
     }
-    else if (interestedLsType == AdjLsa::TYPE_STRING) {
-      processInterestForAdjacencyLsa(interest, originRouter.append(interestedLsType), seqNo);
+    else if (interestedLsType == Lsa::Type::ADJACENCY) {
+      processInterestForAdjacencyLsa(interest, originRouter.append(std::to_string(interestedLsType)),
+                                     seqNo);
     }
-    else if (interestedLsType == CoordinateLsa::TYPE_STRING) {
-      processInterestForCoordinateLsa(interest, originRouter.append(interestedLsType), seqNo);
+    else if (interestedLsType == Lsa::Type::COORDINATE) {
+      processInterestForCoordinateLsa(interest, originRouter.append(std::to_string(interestedLsType)),
+                                      seqNo);
     }
     else {
       _LOG_WARN("Received unrecognized LSA type: " << interestedLsType);
@@ -1192,16 +1198,20 @@
     std::string dataContent(reinterpret_cast<const char*>(data->getContent().value()),
                             data->getContent().value_size());
 
-    std::string interestedLsType  = dataName[-2].toUri();
+    Lsa::Type interestedLsType;
+    std::istringstream(dataName[-2].toUri()) >> interestedLsType;
 
-    if (interestedLsType == NameLsa::TYPE_STRING) {
-      processContentNameLsa(originRouter.append(interestedLsType), seqNo, dataContent);
+    if (interestedLsType == Lsa::Type::NAME) {
+      processContentNameLsa(originRouter.append(std::to_string(interestedLsType)), seqNo,
+                            dataContent);
     }
-    else if (interestedLsType == AdjLsa::TYPE_STRING) {
-      processContentAdjacencyLsa(originRouter.append(interestedLsType), seqNo, dataContent);
+    else if (interestedLsType == Lsa::Type::ADJACENCY) {
+      processContentAdjacencyLsa(originRouter.append(std::to_string(interestedLsType)), seqNo,
+                                 dataContent);
     }
-    else if (interestedLsType == CoordinateLsa::TYPE_STRING) {
-      processContentCoordinateLsa(originRouter.append(interestedLsType), seqNo, dataContent);
+    else if (interestedLsType == Lsa::Type::COORDINATE) {
+      processContentCoordinateLsa(originRouter.append(std::to_string(interestedLsType)), seqNo,
+                                  dataContent);
     }
     else {
       _LOG_WARN("Received unrecognized LSA Type: " << interestedLsType);
@@ -1284,36 +1294,34 @@
 
 //-----utility function -----
 bool
-Lsdb::doesLsaExist(const ndn::Name& key, const std::string& lsType)
+Lsdb::doesLsaExist(const ndn::Name& key, const Lsa::Type& lsType)
 {
-  if (lsType == NameLsa::TYPE_STRING) {
-    return doesNameLsaExist(key);
-  }
-  else if (lsType == AdjLsa::TYPE_STRING) {
+  switch (lsType) {
+  case Lsa::Type::ADJACENCY:
     return doesAdjLsaExist(key);
-  }
-  else if (lsType == CoordinateLsa::TYPE_STRING) {
+  case Lsa::Type::COORDINATE:
     return doesCoordinateLsaExist(key);
+  case Lsa::Type::NAME:
+    return doesNameLsaExist(key);
+  default:
+    return false;
   }
-  return false;
 }
 
 bool
-Lsdb::isLsaNew(const ndn::Name& routerName, const std::string& lsaType,
+Lsdb::isLsaNew(const ndn::Name& routerName, const Lsa::Type& lsaType,
                const uint64_t& sequenceNumber) {
   ndn::Name lsaKey = routerName;
-  lsaKey.append(lsaType);
+  lsaKey.append(std::to_string(lsaType));
 
-  if (lsaType == NameLsa::TYPE_STRING) {
-    return isNameLsaNew(lsaKey, sequenceNumber);
-  }
-  else if (lsaType == AdjLsa::TYPE_STRING) {
+  switch (lsaType) {
+  case Lsa::Type::ADJACENCY:
     return isAdjLsaNew(lsaKey, sequenceNumber);
-  }
-  else if (lsaType == CoordinateLsa::TYPE_STRING) {
+  case Lsa::Type::COORDINATE:
     return isCoordinateLsaNew(lsaKey, sequenceNumber);
-  }
-  else {
+  case Lsa::Type::NAME:
+    return isNameLsaNew(lsaKey, sequenceNumber);
+  default:
     return false;
   }
 }
diff --git a/src/lsdb.hpp b/src/lsdb.hpp
index 3a63e68..9fd76b7 100644
--- a/src/lsdb.hpp
+++ b/src/lsdb.hpp
@@ -51,10 +51,10 @@
   }
 
   bool
-  isLsaNew(const ndn::Name& routerName, const std::string& lsaType, const uint64_t& sequenceNumber);
+  isLsaNew(const ndn::Name& routerName, const Lsa::Type& lsaType, const uint64_t& sequenceNumber);
 
   bool
-  doesLsaExist(const ndn::Name& key, const std::string& lsType);
+  doesLsaExist(const ndn::Name& key, const Lsa::Type& lsType);
 
   /*! \brief Builds a name LSA for this router and then installs it
       into the LSDB.
diff --git a/src/route/routing-table-calculator.cpp b/src/route/routing-table-calculator.cpp
index 318ec64..c5f8e09 100644
--- a/src/route/routing-table-calculator.cpp
+++ b/src/route/routing-table-calculator.cpp
@@ -472,12 +472,12 @@
   double distance = UNKNOWN_DISTANCE;
 
   ndn::Name srcLsaKey = src;
-  srcLsaKey.append("coordinate");
+  srcLsaKey.append(std::to_string(Lsa::Type::COORDINATE));
 
   CoordinateLsa* srcLsa = lsdb.findCoordinateLsa(srcLsaKey);
 
   ndn::Name destLsaKey = dest;
-  destLsaKey.append("coordinate");
+  destLsaKey.append(std::to_string(Lsa::Type::COORDINATE));
 
   CoordinateLsa* destLsa = lsdb.findCoordinateLsa(destLsaKey);
 
diff --git a/src/route/routing-table.cpp b/src/route/routing-table.cpp
index 0f31885..a414e8a 100644
--- a/src/route/routing-table.cpp
+++ b/src/route/routing-table.cpp
@@ -58,14 +58,14 @@
     if ((!isHrEnabled
          &&
          pnlsr.getLsdb()
-         .doesLsaExist(pnlsr.getConfParameter().getRouterPrefix().toUri()
-                       + "/" + "adjacency", std::string("adjacency")))
+         .doesLsaExist(ndn::Name{pnlsr.getConfParameter().getRouterPrefix()}
+                       .append(std::to_string(Lsa::Type::ADJACENCY)), Lsa::Type::ADJACENCY))
         ||
         (isHrEnabled
          &&
          pnlsr.getLsdb()
-         .doesLsaExist(pnlsr.getConfParameter().getRouterPrefix().toUri()
-                       + "/" + "coordinate", std::string("coordinate")))) {
+         .doesLsaExist(ndn::Name{pnlsr.getConfParameter().getRouterPrefix()}
+                       .append(std::to_string(Lsa::Type::COORDINATE)), Lsa::Type::COORDINATE))) {
       if (pnlsr.getIsBuildAdjLsaSheduled() != 1) {
         _LOG_TRACE("Clearing old routing table");
         clearRoutingTable();