lsdb: rebuild using boost::multi_index to replace 3 LSA lists
refs: #4127
Co-authored-by: Nick Gordon <nmgordon@memphis.edu>
Change-Id: Ic179f90019e472157b0d61c6db02a4afaf4843b6
diff --git a/src/lsa/lsa.cpp b/src/lsa/lsa.cpp
index 73ddbe7..dd8267e 100644
--- a/src/lsa/lsa.cpp
+++ b/src/lsa/lsa.cpp
@@ -27,7 +27,7 @@
namespace nlsr {
-Lsa::Lsa(const ndn::Name& originRouter, uint32_t seqNo,
+Lsa::Lsa(const ndn::Name& originRouter, uint64_t seqNo,
ndn::time::system_clock::TimePoint expirationTimePoint)
: m_originRouter(originRouter)
, m_seqNo(seqNo)
@@ -35,12 +35,6 @@
{
}
-ndn::Name
-Lsa::getKey() const
-{
- return ndn::Name(m_originRouter).append(boost::lexical_cast<std::string>((getType())));
-}
-
template<ndn::encoding::Tag TAG>
size_t
Lsa::wireEncode(ndn::EncodingImpl<TAG>& encoder) const
@@ -70,20 +64,12 @@
m_originRouter.clear();
m_seqNo = 0;
- m_baseWire = wire;
+ ndn::Block baseWire = wire;
+ baseWire.parse();
- if (m_baseWire.type() != ndn::tlv::nlsr::Lsa) {
- std::stringstream error;
- error << "Expected Lsa Block, but Block is of a different type: #"
- << m_baseWire.type();
- BOOST_THROW_EXCEPTION(Error(error.str()));
- }
+ auto val = baseWire.elements_begin();
- m_baseWire.parse();
-
- ndn::Block::element_const_iterator val = m_baseWire.elements_begin();
-
- if (val != m_baseWire.elements_end() && val->type() == ndn::tlv::Name) {
+ if (val != baseWire.elements_end() && val->type() == ndn::tlv::Name) {
m_originRouter.wireDecode(*val);
}
else {
@@ -92,7 +78,7 @@
++val;
- if (val != m_baseWire.elements_end() && val->type() == ndn::tlv::nlsr::SequenceNumber) {
+ if (val != baseWire.elements_end() && val->type() == ndn::tlv::nlsr::SequenceNumber) {
m_seqNo = ndn::readNonNegativeInteger(*val);
++val;
}
@@ -100,7 +86,7 @@
BOOST_THROW_EXCEPTION(Error("Missing required SequenceNumber field"));
}
- if (val != m_baseWire.elements_end() && val->type() == ndn::tlv::nlsr::ExpirationTime) {
+ if (val != baseWire.elements_end() && val->type() == ndn::tlv::nlsr::ExpirationTime) {
m_expirationTimePoint = ndn::time::fromString(readString(*val));
}
else {