Further reduce the use of std::bind()
And also avoid deprecated ndn-cxx type aliases
Change-Id: I87e903b9671a3cf1c1b9ab30d4594d595c3c6da9
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