lsa: simplified key getter
refs: #4354
Change-Id: Id886d41ff98530e1953066593640232d31b93b26
diff --git a/src/lsa.cpp b/src/lsa.cpp
index afb76a1..00aa797 100644
--- a/src/lsa.cpp
+++ b/src/lsa.cpp
@@ -48,11 +48,9 @@
}
const ndn::Name
-NameLsa::getKey() const
+Lsa::getKey() const
{
- ndn::Name key = m_origRouter;
- key.append(std::to_string(Lsa::Type::NAME));
- return key;
+ return ndn::Name(m_origRouter).append(std::to_string(getType()));
}
NameLsa::NameLsa(const ndn::Name& origR, uint32_t lsn,
@@ -146,14 +144,6 @@
m_angles = theta;
}
-const ndn::Name
-CoordinateLsa::getKey() const
-{
- ndn::Name key = m_origRouter;
- key.append(std::to_string(Lsa::Type::COORDINATE));
- return key;
-}
-
bool
CoordinateLsa::isEqualContent(const CoordinateLsa& clsa)
{
@@ -247,14 +237,6 @@
}
}
-const ndn::Name
-AdjLsa::getKey() const
-{
- ndn::Name key = m_origRouter;
- key.append(std::to_string(Lsa::Type::ADJACENCY));
- return key;
-}
-
bool
AdjLsa::isEqualContent(AdjLsa& alsa)
{
diff --git a/src/lsa.hpp b/src/lsa.hpp
index 72ca145..8bc9e30 100644
--- a/src/lsa.hpp
+++ b/src/lsa.hpp
@@ -112,6 +112,13 @@
virtual std::string
serialize() const = 0;
+ /*! \brief Gets the key for this LSA.
+
+ Format is: \<router name\>/\<LSA type>\
+ */
+ const ndn::Name
+ getKey() const;
+
virtual bool
initializeFromContent(const std::string& content) = 0;
@@ -172,13 +179,6 @@
m_npl.remove(name);
}
- /*! \brief Gets the key for this LSA.
-
- Format is: \<router name\>/\<LSA type>\
- */
- const ndn::Name
- getKey() const;
-
/*! \brief Initializes this LSA object with content's data.
\param content The data (e.g. name prefixes) to initialize this LSA with.
@@ -246,9 +246,6 @@
m_adl.insert(adj);
}
- const ndn::Name
- getKey() const;
-
/*! \brief Initializes this adj. LSA from the supplied content.
\param content The content that this LSA is to have, formatted
@@ -325,9 +322,6 @@
return Lsa::Type::COORDINATE;
}
- const ndn::Name
- getKey() const;
-
/*! \brief Initializes this coordinate LSA with the data in content.
\param content The string content that is used to build the LSA.