lsa: change type variable to enum class

Change-Id: I7fba951649771700ce6ccc4be7fb400546607e96
refs: #4340
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