rib: turn RibUpdate into an aggregate
And move it together with RibUpdateList and RibUpdateBatch.
Also remove a few unused functions from RibEntry.
Change-Id: Id4f79fda27d3bffb8411e2a95c24154e2cb80c4f
diff --git a/tests/daemon/rib/fib-updates-common.hpp b/tests/daemon/rib/fib-updates-common.hpp
index 15e623f..4230114 100644
--- a/tests/daemon/rib/fib-updates-common.hpp
+++ b/tests/daemon/rib/fib-updates-common.hpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2014-2023, Regents of the University of California,
+ * Copyright (c) 2014-2025, Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
@@ -101,13 +101,6 @@
class FibUpdatesFixture : public GlobalIoFixture, public KeyChainFixture
{
public:
- FibUpdatesFixture()
- : face(g_io, m_keyChain)
- , controller(face, m_keyChain)
- , fibUpdater(rib, controller)
- {
- }
-
void
insertRoute(const Name& name, uint64_t faceId,
std::underlying_type_t<ndn::nfd::RouteOrigin> origin,
@@ -115,13 +108,7 @@
std::underlying_type_t<ndn::nfd::RouteFlags> flags)
{
auto route = createRoute(faceId, origin, cost, flags);
-
- rib::RibUpdate update;
- update.setAction(rib::RibUpdate::REGISTER)
- .setName(name)
- .setRoute(route);
-
- rib.beginApplyUpdate(update, nullptr, nullptr);
+ rib.beginApplyUpdate({rib::RibUpdate::REGISTER, name, route}, nullptr, nullptr);
pollIo();
}
@@ -130,13 +117,7 @@
std::underlying_type_t<ndn::nfd::RouteOrigin> origin)
{
auto route = createRoute(faceId, origin, 0, 0);
-
- rib::RibUpdate update;
- update.setAction(rib::RibUpdate::UNREGISTER)
- .setName(name)
- .setRoute(route);
-
- rib.beginApplyUpdate(update, nullptr, nullptr);
+ rib.beginApplyUpdate({rib::RibUpdate::UNREGISTER, name, route}, nullptr, nullptr);
pollIo();
}
@@ -167,11 +148,10 @@
}
public:
- ndn::DummyClientFace face;
- ndn::nfd::Controller controller;
-
+ ndn::DummyClientFace face{g_io, m_keyChain};
+ ndn::nfd::Controller controller{face, m_keyChain};
rib::Rib rib;
- MockFibUpdater fibUpdater;
+ MockFibUpdater fibUpdater{rib, controller};
};
} // namespace nfd::tests
diff --git a/tests/daemon/rib/rib-update.t.cpp b/tests/daemon/rib/rib-update-batch.t.cpp
similarity index 70%
rename from tests/daemon/rib/rib-update.t.cpp
rename to tests/daemon/rib/rib-update-batch.t.cpp
index 0941693..b2c8431 100644
--- a/tests/daemon/rib/rib-update.t.cpp
+++ b/tests/daemon/rib/rib-update-batch.t.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2014-2024, Regents of the University of California,
+ * Copyright (c) 2014-2025, Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
@@ -23,7 +23,6 @@
* NFD, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
*/
-#include "rib/rib-update.hpp"
#include "rib/rib-update-batch.hpp"
#include "tests/test-common.hpp"
@@ -34,48 +33,40 @@
using namespace nfd::rib;
BOOST_AUTO_TEST_SUITE(Rib)
-BOOST_AUTO_TEST_SUITE(TestRibUpdate)
+BOOST_AUTO_TEST_SUITE(TestRibUpdateBatch)
-BOOST_AUTO_TEST_CASE(Batch)
+BOOST_AUTO_TEST_CASE(AddAndIterate)
{
const uint64_t faceId = 1;
RibUpdateBatch batch(faceId);
Route routeRegister = createRoute(faceId, 128, 10, ndn::nfd::ROUTE_FLAG_CHILD_INHERIT);
- RibUpdate registerUpdate;
- registerUpdate.setAction(RibUpdate::REGISTER)
- .setName("/a")
- .setRoute(routeRegister);
-
+ RibUpdate registerUpdate{RibUpdate::REGISTER, "/a", routeRegister};
batch.add(registerUpdate);
BOOST_CHECK_EQUAL(batch.getFaceId(), faceId);
Route routeUnregister = createRoute(faceId, 0, 0, ndn::nfd::ROUTE_FLAG_CAPTURE);
- RibUpdate unregisterUpdate;
- unregisterUpdate.setAction(RibUpdate::UNREGISTER)
- .setName("/a/b")
- .setRoute(routeUnregister);
-
+ RibUpdate unregisterUpdate{RibUpdate::UNREGISTER, "/a/b", routeUnregister};
batch.add(unregisterUpdate);
BOOST_REQUIRE_EQUAL(batch.size(), 2);
auto it = batch.begin();
- BOOST_CHECK_EQUAL(it->getAction(), RibUpdate::REGISTER);
- BOOST_CHECK_EQUAL(it->getName(), "/a");
- BOOST_CHECK_EQUAL(it->getRoute(), routeRegister);
+ BOOST_CHECK_EQUAL(it->action, RibUpdate::REGISTER);
+ BOOST_CHECK_EQUAL(it->name, "/a");
+ BOOST_CHECK_EQUAL(it->route, routeRegister);
++it;
- BOOST_CHECK_EQUAL(it->getAction(), RibUpdate::UNREGISTER);
- BOOST_CHECK_EQUAL(it->getName(), "/a/b");
- BOOST_CHECK_EQUAL(it->getRoute(), routeUnregister);
+ BOOST_CHECK_EQUAL(it->action, RibUpdate::UNREGISTER);
+ BOOST_CHECK_EQUAL(it->name, "/a/b");
+ BOOST_CHECK_EQUAL(it->route, routeUnregister);
++it;
BOOST_CHECK(it == batch.end());
}
-BOOST_AUTO_TEST_SUITE_END() // TestRibUpdate
+BOOST_AUTO_TEST_SUITE_END() // TestRibUpdateBatch
BOOST_AUTO_TEST_SUITE_END() // Rib
} // namespace nfd::tests