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