[netdata] unify GetNext...() methods into a single template (#11812)

This change updates the `NetworkData` iteration methods to reduce
redundant code and simplify their use.

Previously, separate methods were defined to iterate over different
types of network data entries (e.g., `GetNextOnMeshPrefix()`,
`GetNextExternalRoute()`). This change unifies these into a single
template method, `NetworkData::GetNext<EntryType>()`. A similar
change is applied to unify the corresponding `Contains...()`
methods into a single template.
This commit is contained in:
Abtin Keshavarzian
2025-08-13 10:15:24 -07:00
committed by GitHub
parent 19b5bfedbf
commit b89d05c5fc
16 changed files with 186 additions and 272 deletions
+5 -5
View File
@@ -179,12 +179,12 @@ void TestNetworkDataIterator(void)
for (const auto &route : routes)
{
SuccessOrQuit(netData.GetNextExternalRoute(iter, rconfig));
SuccessOrQuit(netData.GetNext(iter, rconfig));
PrintExternalRouteConfig(rconfig);
VerifyOrQuit(CompareExternalRouteConfig(rconfig, route));
}
VerifyOrQuit(netData.GetNextExternalRoute(iter, rconfig) == kErrorNotFound);
VerifyOrQuit(netData.GetNext(iter, rconfig) == kErrorNotFound);
netData.FindRlocs(kAnyBrOrServer, kAnyRole, rlocs);
VerifyRlocsArray(rlocs, kRlocs);
@@ -303,7 +303,7 @@ void TestNetworkDataIterator(void)
for (const auto &route : routes)
{
SuccessOrQuit(netData.GetNextExternalRoute(iter, rconfig));
SuccessOrQuit(netData.GetNext(iter, rconfig));
PrintExternalRouteConfig(rconfig);
VerifyOrQuit(CompareExternalRouteConfig(rconfig, route));
}
@@ -471,7 +471,7 @@ void TestNetworkDataIterator(void)
for (const auto &route : routes)
{
SuccessOrQuit(netData.GetNextExternalRoute(iter, rconfig));
SuccessOrQuit(netData.GetNext(iter, rconfig));
PrintExternalRouteConfig(rconfig);
VerifyOrQuit(CompareExternalRouteConfig(rconfig, route));
}
@@ -480,7 +480,7 @@ void TestNetworkDataIterator(void)
for (const auto &prefix : prefixes)
{
SuccessOrQuit(netData.GetNextOnMeshPrefix(iter, pconfig));
SuccessOrQuit(netData.GetNext(iter, pconfig));
PrintOnMeshPrefixConfig(pconfig);
VerifyOrQuit(CompareOnMeshPrefixConfig(pconfig, prefix));
}