mgmt: rename mgmt::ControlParameters to ControlParametersBase
It's extremely confusing to have two classes with the same name,
particularly when one is a base class of the other.
Change-Id: Ifdb347cd02cd116aa3e17f8e7ab95e870d8c8920
diff --git a/ndn-cxx/mgmt/control-parameters.hpp b/ndn-cxx/mgmt/control-parameters-base.hpp
similarity index 76%
rename from ndn-cxx/mgmt/control-parameters.hpp
rename to ndn-cxx/mgmt/control-parameters-base.hpp
index 211ca53..8346b15 100644
--- a/ndn-cxx/mgmt/control-parameters.hpp
+++ b/ndn-cxx/mgmt/control-parameters-base.hpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2013-2023 Regents of the University of California.
+ * Copyright (c) 2013-2025 Regents of the University of California.
*
* This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
*
@@ -19,21 +19,21 @@
* See AUTHORS.md for complete list of ndn-cxx authors and contributors.
*/
-#ifndef NDN_CXX_MGMT_CONTROL_PARAMETERS_HPP
-#define NDN_CXX_MGMT_CONTROL_PARAMETERS_HPP
+#ifndef NDN_CXX_MGMT_CONTROL_PARAMETERS_BASE_HPP
+#define NDN_CXX_MGMT_CONTROL_PARAMETERS_BASE_HPP
#include "ndn-cxx/encoding/block.hpp"
namespace ndn::mgmt {
/**
- * \brief Base class for a struct that contains ControlCommand parameters.
+ * \brief Base class for a struct that contains the parameters for a ControlCommand.
*/
-class ControlParameters
+class ControlParametersBase
{
public:
virtual
- ~ControlParameters() = default;
+ ~ControlParametersBase() = default;
virtual void
wireDecode(const Block& wire) = 0;
@@ -44,4 +44,4 @@
} // namespace ndn::mgmt
-#endif // NDN_CXX_MGMT_CONTROL_PARAMETERS_HPP
+#endif // NDN_CXX_MGMT_CONTROL_PARAMETERS_BASE_HPP
diff --git a/ndn-cxx/mgmt/dispatcher.cpp b/ndn-cxx/mgmt/dispatcher.cpp
index 7956198..d0c45b1 100644
--- a/ndn-cxx/mgmt/dispatcher.cpp
+++ b/ndn-cxx/mgmt/dispatcher.cpp
@@ -34,15 +34,14 @@
{
return [] (const Name& prefix,
const Interest& interest,
- const ControlParameters* params,
+ const ControlParametersBase* params,
const AcceptContinuation& accept,
const RejectContinuation& reject) {
accept("");
};
}
-Dispatcher::Dispatcher(Face& face, KeyChain& keyChain,
- const security::SigningInfo& signingInfo,
+Dispatcher::Dispatcher(Face& face, KeyChain& keyChain, const security::SigningInfo& signingInfo,
size_t imsCapacity)
: m_face(face)
, m_keyChain(keyChain)
@@ -168,7 +167,7 @@
ValidateParameters validate,
ControlCommandHandler handler)
{
- shared_ptr<ControlParameters> parameters;
+ ControlParametersPtr parameters;
try {
parameters = parse(prefix, interest);
}
@@ -189,7 +188,7 @@
void
Dispatcher::processAuthorizedCommand(const Name& prefix,
const Interest& interest,
- const shared_ptr<ControlParameters>& parameters,
+ const ControlParametersPtr& parameters,
const ValidateParameters& validate,
const ControlCommandHandler& handler)
{
diff --git a/ndn-cxx/mgmt/dispatcher.hpp b/ndn-cxx/mgmt/dispatcher.hpp
index cfc56b8..27dc529 100644
--- a/ndn-cxx/mgmt/dispatcher.hpp
+++ b/ndn-cxx/mgmt/dispatcher.hpp
@@ -23,10 +23,9 @@
#define NDN_CXX_MGMT_DISPATCHER_HPP
#include "ndn-cxx/face.hpp"
-#include "ndn-cxx/encoding/block.hpp"
#include "ndn-cxx/ims/in-memory-storage-fifo.hpp"
+#include "ndn-cxx/mgmt/control-parameters-base.hpp"
#include "ndn-cxx/mgmt/control-response.hpp"
-#include "ndn-cxx/mgmt/control-parameters.hpp"
#include "ndn-cxx/mgmt/status-dataset-context.hpp"
#include "ndn-cxx/security/key-chain.hpp"
@@ -75,7 +74,7 @@
* Either \p accept or \p reject must be called after authorization completes.
*/
using Authorization = std::function<void(const Name& prefix, const Interest& interest,
- const ControlParameters* params,
+ const ControlParametersBase* params,
const AcceptContinuation& accept,
const RejectContinuation& reject)>;
@@ -92,7 +91,7 @@
* \param params The parsed ControlParameters; guaranteed to be of the correct (sub-)type
* for the command.
*/
-using ValidateParameters = std::function<bool(ControlParameters& params)>;
+using ValidateParameters = std::function<bool(ControlParametersBase& params)>;
/**
* \brief A function to be called after a ControlCommandHandler completes.
@@ -100,15 +99,16 @@
*/
using CommandContinuation = std::function<void(const ControlResponse& resp)>;
-/** \brief A function to handle an authorized ControlCommand.
- * \param prefix top-level prefix, e.g., "/localhost/nfd";
- * \param interest incoming Interest
- * \param params parsed ControlParameters;
- * This is guaranteed to have correct type for the command,
- * and is valid (e.g., has all required fields).
+/**
+ * \brief A function to handle an authorized ControlCommand.
+ * \param prefix Top-level prefix, e.g., `/localhost/nfd`.
+ * \param interest Incoming Interest carrying the request.
+ * \param params The parsed ControlParameters; guaranteed to be of the correct (sub-)type
+ * and to be valid for the command (e.g., has all the required fields).
+ * \param done Function that must be called after command processing is complete.
*/
using ControlCommandHandler = std::function<void(const Name& prefix, const Interest& interest,
- const ControlParameters& params,
+ const ControlParametersBase& params,
const CommandContinuation& done)>;
// ---- STATUS DATASET ----
@@ -211,7 +211,7 @@
* 8. Send the signed Data packet.
*/
template<typename ParametersType,
- std::enable_if_t<std::is_convertible_v<ParametersType*, ControlParameters*>, int> = 0>
+ std::enable_if_t<std::is_convertible_v<ParametersType*, ControlParametersBase*>, int> = 0>
void
addControlCommand(const PartialName& relPrefix,
Authorization authorize,
@@ -222,7 +222,7 @@
auto relPrefixLen = relPrefix.size();
ParametersParser parse = [relPrefixLen] (const Name& prefix,
- const auto& interest) -> shared_ptr<ControlParameters> {
+ const auto& interest) -> ControlParametersPtr {
const name::Component& comp = interest.getName().get(prefix.size() + relPrefixLen);
return make_shared<ParametersType>(comp.blockFromValue());
};
@@ -349,6 +349,7 @@
addNotificationStream(const PartialName& relPrefix);
private:
+ using ControlParametersPtr = shared_ptr<ControlParametersBase>;
using InterestHandler = std::function<void(const Name& prefix, const Interest&)>;
/**
@@ -356,7 +357,7 @@
* @return A shared pointer to the extracted ControlParameters.
* @throw tlv::Error The request parameters cannot be parsed.
*/
- using ParametersParser = std::function<shared_ptr<ControlParameters>(const Name& prefix, const Interest&)>;
+ using ParametersParser = std::function<ControlParametersPtr(const Name& prefix, const Interest&)>;
void
checkPrefix(const PartialName& relPrefix) const;
@@ -443,7 +444,7 @@
void
processAuthorizedCommand(const Name& prefix,
const Interest& interest,
- const shared_ptr<ControlParameters>& parameters,
+ const ControlParametersPtr& parameters,
const ValidateParameters& validate,
const ControlCommandHandler& handler);
@@ -490,6 +491,10 @@
postNotification(const Block& notification, const PartialName& relPrefix);
private:
+ Face& m_face;
+ KeyChain& m_keyChain;
+ security::SigningInfo m_signingInfo;
+
struct TopPrefixEntry
{
ScopedRegisteredPrefixHandle registeredPrefix;
@@ -497,10 +502,6 @@
};
std::unordered_map<Name, TopPrefixEntry> m_topLevelPrefixes;
- Face& m_face;
- KeyChain& m_keyChain;
- security::SigningInfo m_signingInfo;
-
std::unordered_map<PartialName, InterestHandler> m_handlers;
// NotificationStream name => next sequence number
diff --git a/ndn-cxx/mgmt/nfd/control-command.hpp b/ndn-cxx/mgmt/nfd/control-command.hpp
index f9b15ca..adcf534 100644
--- a/ndn-cxx/mgmt/nfd/control-command.hpp
+++ b/ndn-cxx/mgmt/nfd/control-command.hpp
@@ -152,7 +152,7 @@
/**
* \brief Extract parameters from request Interest.
*/
- static shared_ptr<mgmt::ControlParameters>
+ static shared_ptr<mgmt::ControlParametersBase>
parseRequest(const Interest& interest, size_t prefixLen)
{
// /<prefix>/<module>/<verb>
diff --git a/ndn-cxx/mgmt/nfd/control-parameters.hpp b/ndn-cxx/mgmt/nfd/control-parameters.hpp
index b49ba4f..8120abd 100644
--- a/ndn-cxx/mgmt/nfd/control-parameters.hpp
+++ b/ndn-cxx/mgmt/nfd/control-parameters.hpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2013-2023 Regents of the University of California.
+ * Copyright (c) 2013-2025 Regents of the University of California.
*
* This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
*
@@ -24,7 +24,7 @@
#include "ndn-cxx/name.hpp"
#include "ndn-cxx/encoding/nfd-constants.hpp"
-#include "ndn-cxx/mgmt/control-parameters.hpp"
+#include "ndn-cxx/mgmt/control-parameters-base.hpp"
#include "ndn-cxx/util/time.hpp"
namespace ndn::nfd {
@@ -77,7 +77,7 @@
* \sa https://redmine.named-data.net/projects/nfd/wiki/ControlCommand#ControlParameters
* \details This type is copyable because it's an abstraction of a TLV type.
*/
-class ControlParameters : public mgmt::ControlParameters
+class ControlParameters : public mgmt::ControlParametersBase
{
public:
class Error : public tlv::Error
diff --git a/ndn-cxx/net/network-monitor-stub.hpp b/ndn-cxx/net/network-monitor-stub.hpp
index b6bf852..e63b952 100644
--- a/ndn-cxx/net/network-monitor-stub.hpp
+++ b/ndn-cxx/net/network-monitor-stub.hpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2013-2023 Regents of the University of California.
+ * Copyright (c) 2013-2025 Regents of the University of California.
*
* This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
*
@@ -72,7 +72,7 @@
* interface, it emits the #onInterfaceAdded signal. When the initial enumerating completes,
* it emits the onEnumerationCompleted signal.
*
- * To simulate this procedure on a newly constructed MockNetworkMonitor, the caller should
+ * To simulate this procedure on a newly constructed NetworkMonitorStub, the caller should
* invoke addInterface() once for each network interface that already exists, and then invoke
* emitEnumerationCompleted().
*/
diff --git a/tests/unit/mgmt/dispatcher.t.cpp b/tests/unit/mgmt/dispatcher.t.cpp
index 6a80012..8caedc2 100644
--- a/tests/unit/mgmt/dispatcher.t.cpp
+++ b/tests/unit/mgmt/dispatcher.t.cpp
@@ -38,7 +38,7 @@
InMemoryStorageFifo& storage{dispatcher.m_storage};
};
-class VoidParameters : public mgmt::ControlParameters
+class VoidParameters : public ControlParametersBase
{
public:
explicit
@@ -64,7 +64,7 @@
static Authorization
makeTestAuthorization()
{
- return [] (const Name&, const Interest& interest, const ControlParameters*,
+ return [] (const Name&, const Interest& interest, const ControlParametersBase*,
AcceptContinuation accept, RejectContinuation reject) {
if (interest.getName()[-1] == name::Component("valid")) {
accept("");
@@ -277,7 +277,7 @@
BOOST_AUTO_TEST_CASE(ControlCommandResponse)
{
auto handler = [] (const Name& prefix, const Interest& interest,
- const ControlParameters&, const CommandContinuation& done) {
+ const ControlParametersBase&, const CommandContinuation& done) {
BOOST_CHECK_EQUAL(prefix, "/root");
BOOST_CHECK_EQUAL(interest.getName().getPrefix(3),
Name("/root").append(nfd::CsConfigCommand::getName()));
@@ -304,7 +304,7 @@
BOOST_CHECK_EQUAL(resp.getText(), "the answer");
}
-class StatefulParameters : public mgmt::ControlParameters
+class StatefulParameters : public ControlParametersBase
{
public:
explicit
@@ -340,12 +340,12 @@
* ut::description("test for bug #4059"))
{
AcceptContinuation authorizationAccept;
- auto authorization = [&authorizationAccept] (const Name&, const Interest&, const ControlParameters*,
+ auto authorization = [&authorizationAccept] (const Name&, const Interest&, const ControlParametersBase*,
AcceptContinuation accept, RejectContinuation) {
authorizationAccept = std::move(accept);
};
- auto validateParameters = [] (const ControlParameters& params) {
+ auto validateParameters = [] (const ControlParametersBase& params) {
return dynamic_cast<const StatefulParameters&>(params).check();
};