Further reduce the use of std::bind()
And also avoid deprecated ndn-cxx type aliases
Change-Id: I87e903b9671a3cf1c1b9ab30d4594d595c3c6da9
diff --git a/daemon/fw/unsolicited-data-policy.cpp b/daemon/fw/unsolicited-data-policy.cpp
index 8ad0f66..c1a7358 100644
--- a/daemon/fw/unsolicited-data-policy.cpp
+++ b/daemon/fw/unsolicited-data-policy.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2014-2022, Regents of the University of California,
+ * Copyright (c) 2014-2023, Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
@@ -66,7 +66,6 @@
return policyNames;
}
-const std::string DropAllUnsolicitedDataPolicy::POLICY_NAME("drop-all");
NFD_REGISTER_UNSOLICITED_DATA_POLICY(DropAllUnsolicitedDataPolicy);
UnsolicitedDataDecision
@@ -75,7 +74,6 @@
return UnsolicitedDataDecision::DROP;
}
-const std::string AdmitLocalUnsolicitedDataPolicy::POLICY_NAME("admit-local");
NFD_REGISTER_UNSOLICITED_DATA_POLICY(AdmitLocalUnsolicitedDataPolicy);
UnsolicitedDataDecision
@@ -87,7 +85,6 @@
return UnsolicitedDataDecision::DROP;
}
-const std::string AdmitNetworkUnsolicitedDataPolicy::POLICY_NAME("admit-network");
NFD_REGISTER_UNSOLICITED_DATA_POLICY(AdmitNetworkUnsolicitedDataPolicy);
UnsolicitedDataDecision
@@ -99,7 +96,6 @@
return UnsolicitedDataDecision::DROP;
}
-const std::string AdmitAllUnsolicitedDataPolicy::POLICY_NAME("admit-all");
NFD_REGISTER_UNSOLICITED_DATA_POLICY(AdmitAllUnsolicitedDataPolicy);
UnsolicitedDataDecision
diff --git a/daemon/fw/unsolicited-data-policy.hpp b/daemon/fw/unsolicited-data-policy.hpp
index d49d40a..ec9984b 100644
--- a/daemon/fw/unsolicited-data-policy.hpp
+++ b/daemon/fw/unsolicited-data-policy.hpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2014-2022, Regents of the University of California,
+ * Copyright (c) 2014-2023, Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
@@ -60,10 +60,10 @@
public: // registry
template<typename P>
static void
- registerPolicy(const std::string& policyName = P::POLICY_NAME)
+ registerPolicy(std::string_view policyName = P::POLICY_NAME)
{
BOOST_ASSERT(!policyName.empty());
- auto r = getRegistry().insert_or_assign(policyName, [] { return make_unique<P>(); });
+ auto r = getRegistry().insert_or_assign(std::string(policyName), [] { return make_unique<P>(); });
BOOST_VERIFY(r.second);
}
@@ -96,7 +96,7 @@
decide(const Face& inFace, const Data& data) const final;
public:
- static const std::string POLICY_NAME;
+ static constexpr std::string_view POLICY_NAME{"drop-all"};
};
/**
@@ -109,7 +109,7 @@
decide(const Face& inFace, const Data& data) const final;
public:
- static const std::string POLICY_NAME;
+ static constexpr std::string_view POLICY_NAME{"admit-local"};
};
/**
@@ -122,7 +122,7 @@
decide(const Face& inFace, const Data& data) const final;
public:
- static const std::string POLICY_NAME;
+ static constexpr std::string_view POLICY_NAME{"admit-network"};
};
/**
@@ -135,7 +135,7 @@
decide(const Face& inFace, const Data& data) const final;
public:
- static const std::string POLICY_NAME;
+ static constexpr std::string_view POLICY_NAME{"admit-all"};
};
/**
@@ -146,9 +146,9 @@
} // namespace nfd::fw
/**
- * \brief Registers an unsolicited data policy
- * \param P A subclass of nfd::fw::UnsolicitedDataPolicy. \p P must have a static data
- * member `POLICY_NAME` convertible to std::string that contains the policy name.
+ * \brief Registers an unsolicited data policy.
+ * \param P A subclass of nfd::fw::UnsolicitedDataPolicy. \p P must have a static const data
+ * member `POLICY_NAME` convertible to std::string_view that contains the policy name.
*/
#define NFD_REGISTER_UNSOLICITED_DATA_POLICY(P) \
static class NfdAuto ## P ## UnsolicitedDataPolicyRegistrationClass \
diff --git a/daemon/mgmt/cs-manager.cpp b/daemon/mgmt/cs-manager.cpp
index 36d7014..a88b40c 100644
--- a/daemon/mgmt/cs-manager.cpp
+++ b/daemon/mgmt/cs-manager.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2014-2022, Regents of the University of California,
+ * Copyright (c) 2014-2023, Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
@@ -38,11 +38,11 @@
, m_fwCounters(fwCounters)
{
registerCommandHandler<ndn::nfd::CsConfigCommand>("config",
- std::bind(&CsManager::changeConfig, this, _4, _5));
+ [this] (auto&&, auto&&, auto&&, auto&&... args) { changeConfig(std::forward<decltype(args)>(args)...); });
registerCommandHandler<ndn::nfd::CsEraseCommand>("erase",
- std::bind(&CsManager::erase, this, _4, _5));
-
- registerStatusDatasetHandler("info", std::bind(&CsManager::serveInfo, this, _1, _2, _3));
+ [this] (auto&&, auto&&, auto&&, auto&&... args) { erase(std::forward<decltype(args)>(args)...); });
+ registerStatusDatasetHandler("info",
+ [this] (auto&&, auto&&, auto&&... args) { serveInfo(std::forward<decltype(args)>(args)...); });
}
void
@@ -99,7 +99,7 @@
}
void
-CsManager::serveInfo(const Name&, const Interest&, ndn::mgmt::StatusDatasetContext& context) const
+CsManager::serveInfo(ndn::mgmt::StatusDatasetContext& context) const
{
ndn::nfd::CsInfo info;
info.setCapacity(m_cs.getLimit());
diff --git a/daemon/mgmt/cs-manager.hpp b/daemon/mgmt/cs-manager.hpp
index 95fbffc..58fe362 100644
--- a/daemon/mgmt/cs-manager.hpp
+++ b/daemon/mgmt/cs-manager.hpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2014-2021, Regents of the University of California,
+ * Copyright (c) 2014-2023, Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
@@ -62,8 +62,7 @@
/** \brief Serve CS information dataset.
*/
void
- serveInfo(const Name& topPrefix, const Interest& interest,
- ndn::mgmt::StatusDatasetContext& context) const;
+ serveInfo(ndn::mgmt::StatusDatasetContext& context) const;
public:
static constexpr size_t ERASE_LIMIT = 256;
diff --git a/daemon/mgmt/face-manager.cpp b/daemon/mgmt/face-manager.cpp
index cc89061..b7109fa 100644
--- a/daemon/mgmt/face-manager.cpp
+++ b/daemon/mgmt/face-manager.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2014-2022, Regents of the University of California,
+ * Copyright (c) 2014-2023, Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
@@ -48,16 +48,19 @@
{
// register handlers for ControlCommand
registerCommandHandler<ndn::nfd::FaceCreateCommand>("create",
- std::bind(&FaceManager::createFace, this, _4, _5));
+ [this] (auto&&, auto&&, auto&&, auto&&... args) { createFace(std::forward<decltype(args)>(args)...); });
registerCommandHandler<ndn::nfd::FaceUpdateCommand>("update",
- std::bind(&FaceManager::updateFace, this, _3, _4, _5));
+ [this] (auto&&, auto&&, auto&&... args) { updateFace(std::forward<decltype(args)>(args)...); });
registerCommandHandler<ndn::nfd::FaceDestroyCommand>("destroy",
- std::bind(&FaceManager::destroyFace, this, _4, _5));
+ [this] (auto&&, auto&&, auto&&, auto&&... args) { destroyFace(std::forward<decltype(args)>(args)...); });
// register handlers for StatusDataset
- registerStatusDatasetHandler("list", std::bind(&FaceManager::listFaces, this, _3));
- registerStatusDatasetHandler("channels", std::bind(&FaceManager::listChannels, this, _3));
- registerStatusDatasetHandler("query", std::bind(&FaceManager::queryFaces, this, _2, _3));
+ registerStatusDatasetHandler("list",
+ [this] (auto&&, auto&&, auto&&... args) { listFaces(std::forward<decltype(args)>(args)...); });
+ registerStatusDatasetHandler("channels",
+ [this] (auto&&, auto&&, auto&&... args) { listChannels(std::forward<decltype(args)>(args)...); });
+ registerStatusDatasetHandler("query",
+ [this] (auto&&, auto&&... args) { queryFaces(std::forward<decltype(args)>(args)...); });
// register notification stream
m_postNotification = registerNotificationStream("events");
diff --git a/daemon/mgmt/fib-manager.cpp b/daemon/mgmt/fib-manager.cpp
index 474d616..24b044b 100644
--- a/daemon/mgmt/fib-manager.cpp
+++ b/daemon/mgmt/fib-manager.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2014-2022, Regents of the University of California,
+ * Copyright (c) 2014-2023, Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
@@ -45,16 +45,15 @@
, m_faceTable(faceTable)
{
registerCommandHandler<ndn::nfd::FibAddNextHopCommand>("add-nexthop",
- std::bind(&FibManager::addNextHop, this, _2, _3, _4, _5));
+ [this] (auto&&, auto&&, auto&&... args) { addNextHop(std::forward<decltype(args)>(args)...); });
registerCommandHandler<ndn::nfd::FibRemoveNextHopCommand>("remove-nexthop",
- std::bind(&FibManager::removeNextHop, this, _2, _3, _4, _5));
-
- registerStatusDatasetHandler("list", std::bind(&FibManager::listEntries, this, _1, _2, _3));
+ [this] (auto&&, auto&&, auto&&... args) { removeNextHop(std::forward<decltype(args)>(args)...); });
+ registerStatusDatasetHandler("list",
+ [this] (auto&&, auto&&, auto&&... args) { listEntries(std::forward<decltype(args)>(args)...); });
}
void
-FibManager::addNextHop(const Name&, const Interest& interest,
- ControlParameters parameters,
+FibManager::addNextHop(const Interest& interest, ControlParameters parameters,
const ndn::mgmt::CommandContinuation& done)
{
setFaceForSelfRegistration(interest, parameters);
@@ -84,8 +83,7 @@
}
void
-FibManager::removeNextHop(const Name&, const Interest& interest,
- ControlParameters parameters,
+FibManager::removeNextHop(const Interest& interest, ControlParameters parameters,
const ndn::mgmt::CommandContinuation& done)
{
setFaceForSelfRegistration(interest, parameters);
@@ -121,8 +119,7 @@
}
void
-FibManager::listEntries(const Name&, const Interest&,
- ndn::mgmt::StatusDatasetContext& context)
+FibManager::listEntries(ndn::mgmt::StatusDatasetContext& context)
{
for (const auto& entry : m_fib) {
const auto& nexthops = entry.getNextHops() |
diff --git a/daemon/mgmt/fib-manager.hpp b/daemon/mgmt/fib-manager.hpp
index ca04391..ba490bf 100644
--- a/daemon/mgmt/fib-manager.hpp
+++ b/daemon/mgmt/fib-manager.hpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2014-2021, Regents of the University of California,
+ * Copyright (c) 2014-2023, Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
@@ -48,18 +48,15 @@
private:
void
- addNextHop(const Name& topPrefix, const Interest& interest,
- ControlParameters parameters,
+ addNextHop(const Interest& interest, ControlParameters parameters,
const ndn::mgmt::CommandContinuation& done);
void
- removeNextHop(const Name& topPrefix, const Interest& interest,
- ControlParameters parameters,
+ removeNextHop(const Interest& interest, ControlParameters parameters,
const ndn::mgmt::CommandContinuation& done);
void
- listEntries(const Name& topPrefix, const Interest& interest,
- ndn::mgmt::StatusDatasetContext& context);
+ listEntries(ndn::mgmt::StatusDatasetContext& context);
private:
void
diff --git a/daemon/mgmt/forwarder-status-manager.cpp b/daemon/mgmt/forwarder-status-manager.cpp
index 818d054..d8ed725 100644
--- a/daemon/mgmt/forwarder-status-manager.cpp
+++ b/daemon/mgmt/forwarder-status-manager.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2014-2021, Regents of the University of California,
+ * Copyright (c) 2014-2023, Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
@@ -35,7 +35,7 @@
, m_startTimestamp(time::system_clock::now())
{
m_dispatcher.addStatusDataset("status/general", ndn::mgmt::makeAcceptAllAuthorization(),
- std::bind(&ForwarderStatusManager::listGeneralStatus, this, _1, _2, _3));
+ [this] (auto&&, auto&&, auto&& ctx) { listGeneralStatus(std::forward<decltype(ctx)>(ctx)); });
}
ndn::nfd::ForwarderStatus
@@ -67,8 +67,7 @@
}
void
-ForwarderStatusManager::listGeneralStatus(const Name&, const Interest&,
- ndn::mgmt::StatusDatasetContext& context)
+ForwarderStatusManager::listGeneralStatus(ndn::mgmt::StatusDatasetContext& context)
{
auto status = this->collectGeneralStatus();
const auto& wire = status.wireEncode();
diff --git a/daemon/mgmt/forwarder-status-manager.hpp b/daemon/mgmt/forwarder-status-manager.hpp
index f93650c..4208fe5 100644
--- a/daemon/mgmt/forwarder-status-manager.hpp
+++ b/daemon/mgmt/forwarder-status-manager.hpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2014-2022, Regents of the University of California,
+ * Copyright (c) 2014-2023, Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
@@ -51,8 +51,7 @@
* \brief Provides the general status dataset.
*/
void
- listGeneralStatus(const Name& topPrefix, const Interest& interest,
- ndn::mgmt::StatusDatasetContext& context);
+ listGeneralStatus(ndn::mgmt::StatusDatasetContext& context);
private:
Forwarder& m_forwarder;
diff --git a/daemon/mgmt/manager-base.cpp b/daemon/mgmt/manager-base.cpp
index ee5f782..979fc16 100644
--- a/daemon/mgmt/manager-base.cpp
+++ b/daemon/mgmt/manager-base.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2014-2022, Regents of the University of California,
+ * Copyright (c) 2014-2023, Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
@@ -27,13 +27,13 @@
namespace nfd {
-ManagerBase::ManagerBase(const std::string& module, Dispatcher& dispatcher)
+ManagerBase::ManagerBase(std::string_view module, Dispatcher& dispatcher)
: m_module(module)
, m_dispatcher(dispatcher)
{
}
-ManagerBase::ManagerBase(const std::string& module, Dispatcher& dispatcher,
+ManagerBase::ManagerBase(std::string_view module, Dispatcher& dispatcher,
CommandAuthenticator& authenticator)
: m_module(module)
, m_dispatcher(dispatcher)
diff --git a/daemon/mgmt/manager-base.hpp b/daemon/mgmt/manager-base.hpp
index 7702271..08aca11 100644
--- a/daemon/mgmt/manager-base.hpp
+++ b/daemon/mgmt/manager-base.hpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2014-2022, Regents of the University of California,
+ * Copyright (c) 2014-2023, Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
@@ -64,11 +64,11 @@
protected:
/**
- * @warning if you use this constructor, you MUST override makeAuthorization()
+ * @warning If you use this constructor, you MUST override makeAuthorization().
*/
- ManagerBase(const std::string& module, Dispatcher& dispatcher);
+ ManagerBase(std::string_view module, Dispatcher& dispatcher);
- ManagerBase(const std::string& module, Dispatcher& dispatcher,
+ ManagerBase(std::string_view module, Dispatcher& dispatcher,
CommandAuthenticator& authenticator);
NFD_PUBLIC_WITH_TESTS_ELSE_PROTECTED: // registrations to the dispatcher
diff --git a/daemon/mgmt/rib-manager.cpp b/daemon/mgmt/rib-manager.cpp
index 9b5f043..4943672 100644
--- a/daemon/mgmt/rib-manager.cpp
+++ b/daemon/mgmt/rib-manager.cpp
@@ -60,11 +60,11 @@
, m_isLocalhopEnabled(false)
{
registerCommandHandler<ndn::nfd::RibRegisterCommand>("register",
- std::bind(&RibManager::registerEntry, this, _2, _3, _4, _5));
+ [this] (auto&&, auto&&, auto&&... args) { registerEntry(std::forward<decltype(args)>(args)...); });
registerCommandHandler<ndn::nfd::RibUnregisterCommand>("unregister",
- std::bind(&RibManager::unregisterEntry, this, _2, _3, _4, _5));
-
- registerStatusDatasetHandler("list", std::bind(&RibManager::listEntries, this, _1, _2, _3));
+ [this] (auto&&, auto&&, auto&&... args) { unregisterEntry(std::forward<decltype(args)>(args)...); });
+ registerStatusDatasetHandler("list",
+ [this] (auto&&, auto&&, auto&&... args) { listEntries(std::forward<decltype(args)>(args)...); });
}
void
@@ -215,8 +215,7 @@
}
void
-RibManager::registerEntry(const Name& topPrefix, const Interest& interest,
- ControlParameters parameters,
+RibManager::registerEntry(const Interest& interest, ControlParameters parameters,
const ndn::mgmt::CommandContinuation& done)
{
if (parameters.getName().size() > Fib::getMaxDepth()) {
@@ -246,8 +245,7 @@
}
void
-RibManager::unregisterEntry(const Name&, const Interest& interest,
- ControlParameters parameters,
+RibManager::unregisterEntry(const Interest& interest, ControlParameters parameters,
const ndn::mgmt::CommandContinuation& done)
{
setFaceForSelfRegistration(interest, parameters);
@@ -263,7 +261,7 @@
}
void
-RibManager::listEntries(const Name&, const Interest&, ndn::mgmt::StatusDatasetContext& context)
+RibManager::listEntries(ndn::mgmt::StatusDatasetContext& context)
{
auto now = time::steady_clock::now();
for (const auto& kv : m_rib) {
@@ -426,9 +424,8 @@
NFD_LOG_DEBUG("Fetching active faces");
m_nfdController.fetch<ndn::nfd::FaceDataset>(
- std::bind(&RibManager::removeInvalidFaces, this, _1),
- std::bind(&RibManager::onFetchActiveFacesFailure, this, _1, _2),
- ndn::nfd::CommandOptions());
+ [this] (auto&&... args) { removeInvalidFaces(std::forward<decltype(args)>(args)...); },
+ [this] (auto&&... args) { onFetchActiveFacesFailure(std::forward<decltype(args)>(args)...); });
}
void
diff --git a/daemon/mgmt/rib-manager.hpp b/daemon/mgmt/rib-manager.hpp
index 206ecc0..8589b0b 100644
--- a/daemon/mgmt/rib-manager.hpp
+++ b/daemon/mgmt/rib-manager.hpp
@@ -200,22 +200,19 @@
/** \brief Serve rib/register command.
*/
void
- registerEntry(const Name& topPrefix, const Interest& interest,
- ControlParameters parameters,
+ registerEntry(const Interest& interest, ControlParameters parameters,
const ndn::mgmt::CommandContinuation& done);
/** \brief Serve rib/unregister command.
*/
void
- unregisterEntry(const Name& topPrefix, const Interest& interest,
- ControlParameters parameters,
+ unregisterEntry(const Interest& interest, ControlParameters parameters,
const ndn::mgmt::CommandContinuation& done);
/** \brief Serve rib/list dataset.
*/
void
- listEntries(const Name& topPrefix, const Interest& interest,
- ndn::mgmt::StatusDatasetContext& context);
+ listEntries(ndn::mgmt::StatusDatasetContext& context);
void
setFaceForSelfRegistration(const Interest& request, ControlParameters& parameters);
diff --git a/daemon/mgmt/strategy-choice-manager.cpp b/daemon/mgmt/strategy-choice-manager.cpp
index fa18856..af74ee1 100644
--- a/daemon/mgmt/strategy-choice-manager.cpp
+++ b/daemon/mgmt/strategy-choice-manager.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2014-2022, Regents of the University of California,
+ * Copyright (c) 2014-2023, Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
@@ -43,12 +43,11 @@
, m_table(strategyChoice)
{
registerCommandHandler<ndn::nfd::StrategyChoiceSetCommand>("set",
- std::bind(&StrategyChoiceManager::setStrategy, this, _4, _5));
+ [this] (auto&&, auto&&, auto&&, auto&&... args) { setStrategy(std::forward<decltype(args)>(args)...); });
registerCommandHandler<ndn::nfd::StrategyChoiceUnsetCommand>("unset",
- std::bind(&StrategyChoiceManager::unsetStrategy, this, _4, _5));
-
+ [this] (auto&&, auto&&, auto&&, auto&&... args) { unsetStrategy(std::forward<decltype(args)>(args)...); });
registerStatusDatasetHandler("list",
- std::bind(&StrategyChoiceManager::listChoices, this, _3));
+ [this] (auto&&, auto&&, auto&&... args) { listChoices(std::forward<decltype(args)>(args)...); });
}
void
diff --git a/daemon/rib/rib.cpp b/daemon/rib/rib.cpp
index 1d002a1..952cc9a 100644
--- a/daemon/rib/rib.cpp
+++ b/daemon/rib/rib.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2014-2022, Regents of the University of California,
+ * Copyright (c) 2014-2023, Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
@@ -410,14 +410,16 @@
UpdateQueueItem item = std::move(m_updateBatches.front());
m_updateBatches.pop_front();
- RibUpdateBatch& batch = item.batch;
-
// Until task #1698, each RibUpdateBatch contains exactly one RIB update
- BOOST_ASSERT(batch.size() == 1);
+ BOOST_ASSERT(item.batch.size() == 1);
- auto fibSuccessCb = std::bind(&Rib::onFibUpdateSuccess, this, batch, _1, item.managerSuccessCallback);
- auto fibFailureCb = std::bind(&Rib::onFibUpdateFailure, this, item.managerFailureCallback, _1, _2);
- m_fibUpdater->computeAndSendFibUpdates(batch, fibSuccessCb, fibFailureCb);
+ m_fibUpdater->computeAndSendFibUpdates(item.batch,
+ [this, batch = item.batch, successCb = item.managerSuccessCallback] (const auto& routes) {
+ onFibUpdateSuccess(batch, routes, successCb);
+ },
+ [this, failureCb = item.managerFailureCallback] (const auto& code, const auto& error) {
+ onFibUpdateFailure(failureCb, code, error);
+ });
}
void
diff --git a/daemon/table/cs-policy-lru.cpp b/daemon/table/cs-policy-lru.cpp
index 80b5994..4ddecc2 100644
--- a/daemon/table/cs-policy-lru.cpp
+++ b/daemon/table/cs-policy-lru.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2014-2022, Regents of the University of California,
+ * Copyright (c) 2014-2023, Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
@@ -28,7 +28,6 @@
namespace nfd::cs::lru {
-const std::string LruPolicy::POLICY_NAME = "lru";
NFD_REGISTER_CS_POLICY(LruPolicy);
LruPolicy::LruPolicy()
diff --git a/daemon/table/cs-policy-lru.hpp b/daemon/table/cs-policy-lru.hpp
index 9a62c6c..014a65f 100644
--- a/daemon/table/cs-policy-lru.hpp
+++ b/daemon/table/cs-policy-lru.hpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2014-2022, Regents of the University of California,
+ * Copyright (c) 2014-2023, Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
@@ -43,16 +43,14 @@
>
>;
-/** \brief Least-Recently-Used (LRU) replacement policy.
+/**
+ * \brief Least-Recently-Used (LRU) replacement policy.
*/
class LruPolicy final : public Policy
{
public:
LruPolicy();
-public:
- static const std::string POLICY_NAME;
-
private:
void
doAfterInsert(EntryRef i) final;
@@ -69,12 +67,15 @@
void
evictEntries() final;
-private:
- /** \brief Moves an entry to the end of queue.
+ /**
+ * \brief Moves an entry to the end of queue.
*/
void
insertToQueue(EntryRef i, bool isNewEntry);
+public:
+ static constexpr std::string_view POLICY_NAME{"lru"};
+
private:
Queue m_queue;
};
diff --git a/daemon/table/cs-policy-priority-fifo.cpp b/daemon/table/cs-policy-priority-fifo.cpp
index 4405e66..ed0da6e 100644
--- a/daemon/table/cs-policy-priority-fifo.cpp
+++ b/daemon/table/cs-policy-priority-fifo.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2014-2022, Regents of the University of California,
+ * Copyright (c) 2014-2023, Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
@@ -29,7 +29,6 @@
namespace nfd::cs::priority_fifo {
-const std::string PriorityFifoPolicy::POLICY_NAME = "priority_fifo";
NFD_REGISTER_CS_POLICY(PriorityFifoPolicy);
PriorityFifoPolicy::PriorityFifoPolicy()
diff --git a/daemon/table/cs-policy-priority-fifo.hpp b/daemon/table/cs-policy-priority-fifo.hpp
index eaa4c81..44ebe9e 100644
--- a/daemon/table/cs-policy-priority-fifo.hpp
+++ b/daemon/table/cs-policy-priority-fifo.hpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2014-2022, Regents of the University of California,
+ * Copyright (c) 2014-2023, Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
@@ -68,9 +68,6 @@
~PriorityFifoPolicy() final;
-public:
- static const std::string POLICY_NAME;
-
private:
void
doAfterInsert(EntryRef i) final;
@@ -111,6 +108,9 @@
void
moveToStaleQueue(EntryRef i);
+public:
+ static constexpr std::string_view POLICY_NAME{"priority_fifo"};
+
private:
Queue m_queues[QUEUE_MAX];
std::map<EntryRef, EntryInfo*> m_entryInfoMap;
diff --git a/daemon/table/cs-policy.hpp b/daemon/table/cs-policy.hpp
index 748a45b..3291bda 100644
--- a/daemon/table/cs-policy.hpp
+++ b/daemon/table/cs-policy.hpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2014-2022, Regents of the University of California,
+ * Copyright (c) 2014-2023, Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
@@ -40,10 +40,10 @@
public: // registry
template<typename P>
static void
- registerPolicy(const std::string& policyName = P::POLICY_NAME)
+ registerPolicy(std::string_view policyName = P::POLICY_NAME)
{
BOOST_ASSERT(!policyName.empty());
- auto r = getRegistry().insert_or_assign(policyName, [] { return make_unique<P>(); });
+ auto r = getRegistry().insert_or_assign(std::string(policyName), [] { return make_unique<P>(); });
BOOST_VERIFY(r.second);
}