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 \