nlsr: implement NameLsa::isEqualContent
Change-Id: Ibf9021144f5ff253515875ac61de97740a1fecd7
refs: #2962
diff --git a/src/lsa.cpp b/src/lsa.cpp
index 52a9948..46dc1c4 100644
--- a/src/lsa.cpp
+++ b/src/lsa.cpp
@@ -112,6 +112,12 @@
return true;
}
+bool
+NameLsa::isEqualContent(const NameLsa& other) const
+{
+ return m_npl == other.getNpl();
+}
+
void
NameLsa::writeLog()
{
diff --git a/src/lsa.hpp b/src/lsa.hpp
index 934ba40..9d4f89f 100644
--- a/src/lsa.hpp
+++ b/src/lsa.hpp
@@ -127,6 +127,12 @@
return m_npl;
}
+ const NamePrefixList&
+ getNpl() const
+ {
+ return m_npl;
+ }
+
void
addName(const ndn::Name& name)
{
@@ -166,6 +172,9 @@
bool
initializeFromContent(const std::string& content);
+ bool
+ isEqualContent(const NameLsa& other) const;
+
void
writeLog();
@@ -346,4 +355,4 @@
} // namespace nlsr
-#endif //NLSR_LSA_HPP
+#endif // NLSR_LSA_HPP
diff --git a/src/name-prefix-list.cpp b/src/name-prefix-list.cpp
index 37c66dc..ec52068 100644
--- a/src/name-prefix-list.cpp
+++ b/src/name-prefix-list.cpp
@@ -77,6 +77,12 @@
return false;
}
+bool
+NamePrefixList::operator==(const NamePrefixList& other) const
+{
+ return m_nameList == other.getNameList();
+}
+
void
NamePrefixList::sort()
{
@@ -95,4 +101,14 @@
}
}
+std::ostream&
+operator<<(std::ostream& os, const NamePrefixList& list) {
+ os << "Name prefix list: {\n";
+ for (const auto& name : list.getNameList()) {
+ os << name << "\n";
+ }
+ os << "}" << std::endl;
+ return os;
+}
+
} // namespace nlsr
diff --git a/src/name-prefix-list.hpp b/src/name-prefix-list.hpp
index 77f0801..12669ce 100644
--- a/src/name-prefix-list.hpp
+++ b/src/name-prefix-list.hpp
@@ -66,6 +66,15 @@
return m_nameList;
}
+ const std::list<ndn::Name>&
+ getNameList() const
+ {
+ return m_nameList;
+ }
+
+ bool
+ operator==(const NamePrefixList& other) const;
+
void
writeLog();
@@ -74,6 +83,9 @@
};
+std::ostream&
+operator<<(std::ostream& os, const NamePrefixList& list);
+
} // namespace nlsr
-#endif //NLSR_NAME_PREFIX_LIST_HPP
+#endif // NLSR_NAME_PREFIX_LIST_HPP