lsa: define AdjLsa operator==
Delete noLink field that is not used anywhere.
refs #4094
Change-Id: I646eb2dc828935c1f75ec2c036ba4fd60e907706
diff --git a/src/lsa/adj-lsa.cpp b/src/lsa/adj-lsa.cpp
index 38edb63..ac583e4 100644
--- a/src/lsa/adj-lsa.cpp
+++ b/src/lsa/adj-lsa.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2014-2023, The University of Memphis,
+ * Copyright (c) 2014-2024, The University of Memphis,
* Regents of the University of California,
* Arizona Board of Regents.
*
@@ -25,10 +25,8 @@
namespace nlsr {
AdjLsa::AdjLsa(const ndn::Name& originRouter, uint64_t seqNo,
- const ndn::time::system_clock::time_point& timepoint,
- uint32_t noLink, AdjacencyList& adl)
+ const ndn::time::system_clock::time_point& timepoint, AdjacencyList& adl)
: Lsa(originRouter, seqNo, timepoint)
- , m_noLink(noLink)
{
for (const auto& adjacent : adl.getAdjList()) {
if (adjacent.getStatus() == Adjacent::STATUS_ACTIVE) {
@@ -42,12 +40,6 @@
wireDecode(block);
}
-bool
-AdjLsa::isEqualContent(const AdjLsa& alsa) const
-{
- return m_adl == alsa.getAdl();
-}
-
template<ndn::encoding::Tag TAG>
size_t
AdjLsa::wireEncode(ndn::EncodingImpl<TAG>& block) const
@@ -143,7 +135,7 @@
AdjLsa::update(const std::shared_ptr<Lsa>& lsa)
{
auto alsa = std::static_pointer_cast<AdjLsa>(lsa);
- if (!isEqualContent(*alsa)) {
+ if (*this != *alsa) {
resetAdl();
for (const auto& adjacent : alsa->getAdl()) {
addAdjacent(adjacent);
diff --git a/src/lsa/adj-lsa.hpp b/src/lsa/adj-lsa.hpp
index 5aad4c0..133e95c 100644
--- a/src/lsa/adj-lsa.hpp
+++ b/src/lsa/adj-lsa.hpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2014-2023, The University of Memphis,
+ * Copyright (c) 2014-2024, The University of Memphis,
* Regents of the University of California,
* Arizona Board of Regents.
*
@@ -26,6 +26,8 @@
#include "adjacent.hpp"
#include "adjacency-list.hpp"
+#include <boost/operators.hpp>
+
namespace nlsr {
/*!
@@ -35,7 +37,7 @@
Adjacency*
*/
-class AdjLsa : public Lsa
+class AdjLsa : public Lsa, private boost::equality_comparable<AdjLsa>
{
public:
typedef AdjacencyList::const_iterator const_iterator;
@@ -43,8 +45,7 @@
AdjLsa() = default;
AdjLsa(const ndn::Name& originR, uint64_t seqNo,
- const ndn::time::system_clock::time_point& timepoint,
- uint32_t noLink, AdjacencyList& adl);
+ const ndn::time::system_clock::time_point& timepoint, AdjacencyList& adl);
AdjLsa(const ndn::Block& block);
@@ -74,21 +75,12 @@
}
void
- addAdjacent(Adjacent adj)
+ addAdjacent(const Adjacent& adj)
{
m_wire.reset();
m_adl.insert(adj);
}
- uint32_t
- getNoLink()
- {
- return m_noLink;
- }
-
- bool
- isEqualContent(const AdjLsa& alsa) const;
-
const_iterator
begin() const
{
@@ -117,8 +109,16 @@
std::tuple<bool, std::list<ndn::Name>, std::list<ndn::Name>>
update(const std::shared_ptr<Lsa>& lsa) override;
-private:
- uint32_t m_noLink;
+private: // non-member operators
+ // NOTE: the following "hidden friend" operators are available via
+ // argument-dependent lookup only and must be defined inline.
+ // boost::equality_comparable provides != operator.
+
+ friend bool
+ operator==(const AdjLsa& lhs, const AdjLsa& rhs)
+ {
+ return lhs.m_adl == rhs.m_adl;
+ }
PUBLIC_WITH_TESTS_ELSE_PRIVATE:
AdjacencyList m_adl;
diff --git a/src/lsdb.cpp b/src/lsdb.cpp
index f672a41..608b575 100644
--- a/src/lsdb.cpp
+++ b/src/lsdb.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2014-2023, The University of Memphis,
+ * Copyright (c) 2014-2024, The University of Memphis,
* Regents of the University of California,
* Arizona Board of Regents.
*
@@ -343,7 +343,6 @@
{
AdjLsa adjLsa(m_thisRouterPrefix, m_sequencingManager.getAdjLsaSeq() + 1,
getLsaExpirationTimePoint(),
- m_confParam.getAdjacencyList().getNumOfActiveNeighbor(),
m_confParam.getAdjacencyList());
m_sequencingManager.increaseAdjLsaSeq();
m_sequencingManager.writeSeqNoToFile();