route: communicate routing changes using signals
The RoutingTable now has a signal that it emits upon finishing
calculation, which other modules can subscribe to. The NamePrefixTable
now references this emitted container to update its local copies of
routing information.
Change-Id: Id601776258ad0367cc47461ea8f86a710eada132
refs: #4249
diff --git a/src/route/routing-table.cpp b/src/route/routing-table.cpp
index 238852a..547e943 100644
--- a/src/route/routing-table.cpp
+++ b/src/route/routing-table.cpp
@@ -34,6 +34,14 @@
INIT_LOGGER("RoutingTable");
+RoutingTable::RoutingTable(ndn::Scheduler& scheduler)
+ : afterRoutingChange{std::make_shared<AfterRoutingChange>()}
+ , m_scheduler(scheduler)
+ , m_NO_NEXT_HOP{-12345}
+ , m_routingCalcInterval{static_cast<uint32_t>(ROUTING_CALC_INTERVAL_DEFAULT)}
+{
+}
+
void
RoutingTable::calculate(Nlsr& pnlsr)
{
@@ -81,7 +89,7 @@
}
// Inform the NPT that updates have been made
_LOG_DEBUG("Calling Update NPT With new Route");
- pnlsr.getNamePrefixTable().updateWithNewRoute();
+ (*afterRoutingChange)(m_rTable);
writeLog(pnlsr.getConfParameter().getHyperbolicState());
pnlsr.getNamePrefixTable().writeLog();
pnlsr.getFib().writeLog();
@@ -98,7 +106,7 @@
clearDryRoutingTable(); // for dry run options
// need to update NPT here
_LOG_DEBUG("Calling Update NPT With new Route");
- pnlsr.getNamePrefixTable().updateWithNewRoute();
+ (*afterRoutingChange)(m_rTable);
writeLog(pnlsr.getConfParameter().getHyperbolicState());
pnlsr.getNamePrefixTable().writeLog();
pnlsr.getFib().writeLog();