Skip to content

Commit 0e13ed3

Browse files
committed
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
1 parent cb385e3 commit 0e13ed3

File tree

7 files changed

+43
-43
lines changed

7 files changed

+43
-43
lines changed

ndn-cxx/mgmt/control-parameters.hpp renamed to ndn-cxx/mgmt/control-parameters-base.hpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
22
/*
3-
* Copyright (c) 2013-2023 Regents of the University of California.
3+
* Copyright (c) 2013-2025 Regents of the University of California.
44
*
55
* This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
66
*
@@ -19,21 +19,21 @@
1919
* See AUTHORS.md for complete list of ndn-cxx authors and contributors.
2020
*/
2121

22-
#ifndef NDN_CXX_MGMT_CONTROL_PARAMETERS_HPP
23-
#define NDN_CXX_MGMT_CONTROL_PARAMETERS_HPP
22+
#ifndef NDN_CXX_MGMT_CONTROL_PARAMETERS_BASE_HPP
23+
#define NDN_CXX_MGMT_CONTROL_PARAMETERS_BASE_HPP
2424

2525
#include "ndn-cxx/encoding/block.hpp"
2626

2727
namespace ndn::mgmt {
2828

2929
/**
30-
* \brief Base class for a struct that contains ControlCommand parameters.
30+
* \brief Base class for a struct that contains the parameters for a ControlCommand.
3131
*/
32-
class ControlParameters
32+
class ControlParametersBase
3333
{
3434
public:
3535
virtual
36-
~ControlParameters() = default;
36+
~ControlParametersBase() = default;
3737

3838
virtual void
3939
wireDecode(const Block& wire) = 0;
@@ -44,4 +44,4 @@ class ControlParameters
4444

4545
} // namespace ndn::mgmt
4646

47-
#endif // NDN_CXX_MGMT_CONTROL_PARAMETERS_HPP
47+
#endif // NDN_CXX_MGMT_CONTROL_PARAMETERS_BASE_HPP

ndn-cxx/mgmt/dispatcher.cpp

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,15 +34,14 @@ makeAcceptAllAuthorization()
3434
{
3535
return [] (const Name& prefix,
3636
const Interest& interest,
37-
const ControlParameters* params,
37+
const ControlParametersBase* params,
3838
const AcceptContinuation& accept,
3939
const RejectContinuation& reject) {
4040
accept("");
4141
};
4242
}
4343

44-
Dispatcher::Dispatcher(Face& face, KeyChain& keyChain,
45-
const security::SigningInfo& signingInfo,
44+
Dispatcher::Dispatcher(Face& face, KeyChain& keyChain, const security::SigningInfo& signingInfo,
4645
size_t imsCapacity)
4746
: m_face(face)
4847
, m_keyChain(keyChain)
@@ -168,7 +167,7 @@ Dispatcher::processCommand(const Name& prefix,
168167
ValidateParameters validate,
169168
ControlCommandHandler handler)
170169
{
171-
shared_ptr<ControlParameters> parameters;
170+
ControlParametersPtr parameters;
172171
try {
173172
parameters = parse(prefix, interest);
174173
}
@@ -189,7 +188,7 @@ Dispatcher::processCommand(const Name& prefix,
189188
void
190189
Dispatcher::processAuthorizedCommand(const Name& prefix,
191190
const Interest& interest,
192-
const shared_ptr<ControlParameters>& parameters,
191+
const ControlParametersPtr& parameters,
193192
const ValidateParameters& validate,
194193
const ControlCommandHandler& handler)
195194
{

ndn-cxx/mgmt/dispatcher.hpp

Lines changed: 20 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,9 @@
2323
#define NDN_CXX_MGMT_DISPATCHER_HPP
2424

2525
#include "ndn-cxx/face.hpp"
26-
#include "ndn-cxx/encoding/block.hpp"
2726
#include "ndn-cxx/ims/in-memory-storage-fifo.hpp"
27+
#include "ndn-cxx/mgmt/control-parameters-base.hpp"
2828
#include "ndn-cxx/mgmt/control-response.hpp"
29-
#include "ndn-cxx/mgmt/control-parameters.hpp"
3029
#include "ndn-cxx/mgmt/status-dataset-context.hpp"
3130
#include "ndn-cxx/security/key-chain.hpp"
3231

@@ -75,7 +74,7 @@ using RejectContinuation = std::function<void(RejectReply)>;
7574
* Either \p accept or \p reject must be called after authorization completes.
7675
*/
7776
using Authorization = std::function<void(const Name& prefix, const Interest& interest,
78-
const ControlParameters* params,
77+
const ControlParametersBase* params,
7978
const AcceptContinuation& accept,
8079
const RejectContinuation& reject)>;
8180

@@ -92,23 +91,24 @@ makeAcceptAllAuthorization();
9291
* \param params The parsed ControlParameters; guaranteed to be of the correct (sub-)type
9392
* for the command.
9493
*/
95-
using ValidateParameters = std::function<bool(ControlParameters& params)>;
94+
using ValidateParameters = std::function<bool(ControlParametersBase& params)>;
9695

9796
/**
9897
* \brief A function to be called after a ControlCommandHandler completes.
9998
* \param resp The response that should be sent back to the requester.
10099
*/
101100
using CommandContinuation = std::function<void(const ControlResponse& resp)>;
102101

103-
/** \brief A function to handle an authorized ControlCommand.
104-
* \param prefix top-level prefix, e.g., "/localhost/nfd";
105-
* \param interest incoming Interest
106-
* \param params parsed ControlParameters;
107-
* This is guaranteed to have correct type for the command,
108-
* and is valid (e.g., has all required fields).
102+
/**
103+
* \brief A function to handle an authorized ControlCommand.
104+
* \param prefix Top-level prefix, e.g., `/localhost/nfd`.
105+
* \param interest Incoming Interest carrying the request.
106+
* \param params The parsed ControlParameters; guaranteed to be of the correct (sub-)type
107+
* and to be valid for the command (e.g., has all the required fields).
108+
* \param done Function that must be called after command processing is complete.
109109
*/
110110
using ControlCommandHandler = std::function<void(const Name& prefix, const Interest& interest,
111-
const ControlParameters& params,
111+
const ControlParametersBase& params,
112112
const CommandContinuation& done)>;
113113

114114
// ---- STATUS DATASET ----
@@ -211,7 +211,7 @@ class Dispatcher : noncopyable
211211
* 8. Send the signed Data packet.
212212
*/
213213
template<typename ParametersType,
214-
std::enable_if_t<std::is_convertible_v<ParametersType*, ControlParameters*>, int> = 0>
214+
std::enable_if_t<std::is_convertible_v<ParametersType*, ControlParametersBase*>, int> = 0>
215215
void
216216
addControlCommand(const PartialName& relPrefix,
217217
Authorization authorize,
@@ -222,7 +222,7 @@ class Dispatcher : noncopyable
222222

223223
auto relPrefixLen = relPrefix.size();
224224
ParametersParser parse = [relPrefixLen] (const Name& prefix,
225-
const auto& interest) -> shared_ptr<ControlParameters> {
225+
const auto& interest) -> ControlParametersPtr {
226226
const name::Component& comp = interest.getName().get(prefix.size() + relPrefixLen);
227227
return make_shared<ParametersType>(comp.blockFromValue());
228228
};
@@ -349,14 +349,15 @@ class Dispatcher : noncopyable
349349
addNotificationStream(const PartialName& relPrefix);
350350

351351
private:
352+
using ControlParametersPtr = shared_ptr<ControlParametersBase>;
352353
using InterestHandler = std::function<void(const Name& prefix, const Interest&)>;
353354

354355
/**
355356
* @brief The parser for extracting the parameters from a command request.
356357
* @return A shared pointer to the extracted ControlParameters.
357358
* @throw tlv::Error The request parameters cannot be parsed.
358359
*/
359-
using ParametersParser = std::function<shared_ptr<ControlParameters>(const Name& prefix, const Interest&)>;
360+
using ParametersParser = std::function<ControlParametersPtr(const Name& prefix, const Interest&)>;
360361

361362
void
362363
checkPrefix(const PartialName& relPrefix) const;
@@ -443,7 +444,7 @@ class Dispatcher : noncopyable
443444
void
444445
processAuthorizedCommand(const Name& prefix,
445446
const Interest& interest,
446-
const shared_ptr<ControlParameters>& parameters,
447+
const ControlParametersPtr& parameters,
447448
const ValidateParameters& validate,
448449
const ControlCommandHandler& handler);
449450

@@ -490,17 +491,17 @@ class Dispatcher : noncopyable
490491
postNotification(const Block& notification, const PartialName& relPrefix);
491492

492493
private:
494+
Face& m_face;
495+
KeyChain& m_keyChain;
496+
security::SigningInfo m_signingInfo;
497+
493498
struct TopPrefixEntry
494499
{
495500
ScopedRegisteredPrefixHandle registeredPrefix;
496501
std::vector<ScopedInterestFilterHandle> interestFilters;
497502
};
498503
std::unordered_map<Name, TopPrefixEntry> m_topLevelPrefixes;
499504

500-
Face& m_face;
501-
KeyChain& m_keyChain;
502-
security::SigningInfo m_signingInfo;
503-
504505
std::unordered_map<PartialName, InterestHandler> m_handlers;
505506

506507
// NotificationStream name => next sequence number

ndn-cxx/mgmt/nfd/control-command.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ class ControlCommand : noncopyable
152152
/**
153153
* \brief Extract parameters from request Interest.
154154
*/
155-
static shared_ptr<mgmt::ControlParameters>
155+
static shared_ptr<mgmt::ControlParametersBase>
156156
parseRequest(const Interest& interest, size_t prefixLen)
157157
{
158158
// /<prefix>/<module>/<verb>

ndn-cxx/mgmt/nfd/control-parameters.hpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
22
/*
3-
* Copyright (c) 2013-2023 Regents of the University of California.
3+
* Copyright (c) 2013-2025 Regents of the University of California.
44
*
55
* This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
66
*
@@ -24,7 +24,7 @@
2424

2525
#include "ndn-cxx/name.hpp"
2626
#include "ndn-cxx/encoding/nfd-constants.hpp"
27-
#include "ndn-cxx/mgmt/control-parameters.hpp"
27+
#include "ndn-cxx/mgmt/control-parameters-base.hpp"
2828
#include "ndn-cxx/util/time.hpp"
2929

3030
namespace ndn::nfd {
@@ -77,7 +77,7 @@ inline constexpr std::string_view CONTROL_PARAMETER_FIELD[CONTROL_PARAMETER_UBOU
7777
* \sa https://redmine.named-data.net/projects/nfd/wiki/ControlCommand#ControlParameters
7878
* \details This type is copyable because it's an abstraction of a TLV type.
7979
*/
80-
class ControlParameters : public mgmt::ControlParameters
80+
class ControlParameters : public mgmt::ControlParametersBase
8181
{
8282
public:
8383
class Error : public tlv::Error

ndn-cxx/net/network-monitor-stub.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
22
/*
3-
* Copyright (c) 2013-2023 Regents of the University of California.
3+
* Copyright (c) 2013-2025 Regents of the University of California.
44
*
55
* This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
66
*
@@ -72,7 +72,7 @@ class NetworkMonitorStub : public NetworkMonitor
7272
* interface, it emits the #onInterfaceAdded signal. When the initial enumerating completes,
7373
* it emits the onEnumerationCompleted signal.
7474
*
75-
* To simulate this procedure on a newly constructed MockNetworkMonitor, the caller should
75+
* To simulate this procedure on a newly constructed NetworkMonitorStub, the caller should
7676
* invoke addInterface() once for each network interface that already exists, and then invoke
7777
* emitEnumerationCompleted().
7878
*/

tests/unit/mgmt/dispatcher.t.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ class DispatcherFixture : public IoKeyChainFixture
3838
InMemoryStorageFifo& storage{dispatcher.m_storage};
3939
};
4040

41-
class VoidParameters : public mgmt::ControlParameters
41+
class VoidParameters : public ControlParametersBase
4242
{
4343
public:
4444
explicit
@@ -64,7 +64,7 @@ class VoidParameters : public mgmt::ControlParameters
6464
static Authorization
6565
makeTestAuthorization()
6666
{
67-
return [] (const Name&, const Interest& interest, const ControlParameters*,
67+
return [] (const Name&, const Interest& interest, const ControlParametersBase*,
6868
AcceptContinuation accept, RejectContinuation reject) {
6969
if (interest.getName()[-1] == name::Component("valid")) {
7070
accept("");
@@ -277,7 +277,7 @@ BOOST_AUTO_TEST_CASE(ControlCommandNew,
277277
BOOST_AUTO_TEST_CASE(ControlCommandResponse)
278278
{
279279
auto handler = [] (const Name& prefix, const Interest& interest,
280-
const ControlParameters&, const CommandContinuation& done) {
280+
const ControlParametersBase&, const CommandContinuation& done) {
281281
BOOST_CHECK_EQUAL(prefix, "/root");
282282
BOOST_CHECK_EQUAL(interest.getName().getPrefix(3),
283283
Name("/root").append(nfd::CsConfigCommand::getName()));
@@ -304,7 +304,7 @@ BOOST_AUTO_TEST_CASE(ControlCommandResponse)
304304
BOOST_CHECK_EQUAL(resp.getText(), "the answer");
305305
}
306306

307-
class StatefulParameters : public mgmt::ControlParameters
307+
class StatefulParameters : public ControlParametersBase
308308
{
309309
public:
310310
explicit
@@ -340,12 +340,12 @@ BOOST_AUTO_TEST_CASE(ControlCommandAsyncAuthorization,
340340
* ut::description("test for bug #4059"))
341341
{
342342
AcceptContinuation authorizationAccept;
343-
auto authorization = [&authorizationAccept] (const Name&, const Interest&, const ControlParameters*,
343+
auto authorization = [&authorizationAccept] (const Name&, const Interest&, const ControlParametersBase*,
344344
AcceptContinuation accept, RejectContinuation) {
345345
authorizationAccept = std::move(accept);
346346
};
347347

348-
auto validateParameters = [] (const ControlParameters& params) {
348+
auto validateParameters = [] (const ControlParametersBase& params) {
349349
return dynamic_cast<const StatefulParameters&>(params).check();
350350
};
351351

0 commit comments

Comments
 (0)