NS-3 based Named Data Networking (NDN) simulator
ndnSIM 2.5: NDN, CCN, CCNx, content centric networks
API Documentation
control-command.hpp
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright (c) 2013-2018 Regents of the University of California.
4  *
5  * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
6  *
7  * ndn-cxx library is free software: you can redistribute it and/or modify it under the
8  * terms of the GNU Lesser General Public License as published by the Free Software
9  * Foundation, either version 3 of the License, or (at your option) any later version.
10  *
11  * ndn-cxx library is distributed in the hope that it will be useful, but WITHOUT ANY
12  * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
13  * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
14  *
15  * You should have received copies of the GNU General Public License and GNU Lesser
16  * General Public License along with ndn-cxx, e.g., in COPYING.md file. If not, see
17  * <http://www.gnu.org/licenses/>.
18  *
19  * See AUTHORS.md for complete list of ndn-cxx authors and contributors.
20  */
21 
22 #ifndef NDN_MGMT_NFD_CONTROL_COMMAND_HPP
23 #define NDN_MGMT_NFD_CONTROL_COMMAND_HPP
24 
26 
27 namespace ndn {
28 namespace nfd {
29 
35 class ControlCommand : noncopyable
36 {
37 public:
40  class ArgumentError : public std::invalid_argument
41  {
42  public:
43  explicit
44  ArgumentError(const std::string& what)
45  : std::invalid_argument(what)
46  {
47  }
48  };
49 
50  virtual
52 
56  virtual void
57  validateRequest(const ControlParameters& parameters) const;
58 
61  virtual void
62  applyDefaultsToRequest(ControlParameters& parameters) const;
63 
67  virtual void
68  validateResponse(const ControlParameters& parameters) const;
69 
72  virtual void
73  applyDefaultsToResponse(ControlParameters& parameters) const;
74 
78  Name
79  getRequestName(const Name& commandPrefix, const ControlParameters& parameters) const;
80 
81 protected:
82  ControlCommand(const std::string& module, const std::string& verb);
83 
85  {
86  public:
88 
93  {
94  m_required[field] = true;
95  return *this;
96  }
97 
102  {
103  m_optional[field] = true;
104  return *this;
105  }
106 
111  void
112  validate(const ControlParameters& parameters) const;
113 
114  private:
115  std::vector<bool> m_required;
116  std::vector<bool> m_optional;
117  };
118 
119 protected:
130 
131 private:
132  name::Component m_module;
133  name::Component m_verb;
134 };
135 
136 
143 {
144 public:
146 
147  void
148  applyDefaultsToRequest(ControlParameters& parameters) const override;
149 
150  void
151  validateResponse(const ControlParameters& parameters) const override;
152 };
153 
154 
161 {
162 public:
164 
165  void
166  applyDefaultsToRequest(ControlParameters& parameters) const override;
167 
172  void
173  validateResponse(const ControlParameters& parameters) const override;
174 };
175 
176 
183 {
184 public:
186 
187  void
188  validateRequest(const ControlParameters& parameters) const override;
189 
190  void
191  validateResponse(const ControlParameters& parameters) const override;
192 };
193 
194 
201 {
202 public:
204 
205  void
206  applyDefaultsToRequest(ControlParameters& parameters) const override;
207 
208  void
209  validateResponse(const ControlParameters& parameters) const override;
210 };
211 
212 
219 {
220 public:
222 
223  void
224  applyDefaultsToRequest(ControlParameters& parameters) const override;
225 
226  void
227  validateResponse(const ControlParameters& parameters) const override;
228 };
229 
230 
237 {
238 public:
239  CsConfigCommand();
240 };
241 
242 
249 {
250 public:
251  CsEraseCommand();
252 
253  void
254  validateRequest(const ControlParameters& parameters) const override;
255 
256  void
257  validateResponse(const ControlParameters& parameters) const override;
258 };
259 
260 
267 {
268 public:
270 };
271 
272 
279 {
280 public:
282 
283  void
284  validateRequest(const ControlParameters& parameters) const override;
285 
286  void
287  validateResponse(const ControlParameters& parameters) const override;
288 };
289 
290 
297 {
298 public:
300 
301  void
302  applyDefaultsToRequest(ControlParameters& parameters) const override;
303 
304  void
305  validateResponse(const ControlParameters& parameters) const override;
306 };
307 
308 
315 {
316 public:
318 
319  void
320  applyDefaultsToRequest(ControlParameters& parameters) const override;
321 
322  void
323  validateResponse(const ControlParameters& parameters) const override;
324 };
325 
326 } // namespace nfd
327 } // namespace ndn
328 
329 #endif // NDN_MGMT_NFD_CONTROL_COMMAND_HPP
ndn::nfd::FibRemoveNextHopCommand
represents a fib/remove-nexthop command
Definition: control-command.hpp:219
ndn::nfd::StrategyChoiceSetCommand
represents a strategy-choice/set command
Definition: control-command.hpp:267
ndn::nfd::StrategyChoiceUnsetCommand
represents a strategy-choice/set command
Definition: control-command.hpp:279
ndn::nfd::CsEraseCommand
represents a cs/erase command
Definition: control-command.hpp:249
ndn::nfd::RibRegisterCommand
represents a rib/register command
Definition: control-command.hpp:297
ndn::nfd::ControlCommand::FieldValidator::FieldValidator
FieldValidator()
Definition: control-command.cpp:69
ndn::nfd::CsEraseCommand::CsEraseCommand
CsEraseCommand()
Definition: control-command.cpp:275
ndn::nfd::FaceUpdateCommand::applyDefaultsToRequest
void applyDefaultsToRequest(ControlParameters &parameters) const override
apply default values to missing fields in request
Definition: control-command.cpp:159
ndn::nfd::ControlCommand::applyDefaultsToResponse
virtual void applyDefaultsToResponse(ControlParameters &parameters) const
apply default values to missing fields in response
Definition: control-command.cpp:53
ndn::nfd::StrategyChoiceUnsetCommand::validateResponse
void validateResponse(const ControlParameters &parameters) const override
validate response parameters
Definition: control-command.cpp:335
ndn::nfd::CsEraseCommand::validateRequest
void validateRequest(const ControlParameters &parameters) const override
validate request parameters
Definition: control-command.cpp:288
ndn::nfd::FaceDestroyCommand::FaceDestroyCommand
FaceDestroyCommand()
Definition: control-command.cpp:176
ndn::nfd::RibRegisterCommand::RibRegisterCommand
RibRegisterCommand()
Definition: control-command.cpp:340
ndn::nfd::FaceDestroyCommand
represents a faces/destroy command
Definition: control-command.hpp:183
ndn::nfd::FibRemoveNextHopCommand::FibRemoveNextHopCommand
FibRemoveNextHopCommand()
Definition: control-command.cpp:234
ndn::nfd::FibAddNextHopCommand::FibAddNextHopCommand
FibAddNextHopCommand()
Definition: control-command.cpp:200
ndn::nfd::ControlCommand::getRequestName
Name getRequestName(const Name &commandPrefix, const ControlParameters &parameters) const
construct the Name for a request Interest
Definition: control-command.cpp:58
ndn::nfd::FibRemoveNextHopCommand::validateResponse
void validateResponse(const ControlParameters &parameters) const override
validate response parameters
Definition: control-command.cpp:254
ndn::nfd::ControlCommand::ArgumentError
represents an error in ControlParameters
Definition: control-command.hpp:41
ndn::nfd::RibRegisterCommand::applyDefaultsToRequest
void applyDefaultsToRequest(ControlParameters &parameters) const override
apply default values to missing fields in request
Definition: control-command.cpp:360
ndn::nfd::ControlCommand::validateResponse
virtual void validateResponse(const ControlParameters &parameters) const
validate response parameters
Definition: control-command.cpp:47
ndn::nfd::RibUnregisterCommand::applyDefaultsToRequest
void applyDefaultsToRequest(ControlParameters &parameters) const override
apply default values to missing fields in request
Definition: control-command.cpp:400
ndn::nfd::FaceCreateCommand::validateResponse
void validateResponse(const ControlParameters &parameters) const override
validate response parameters
Definition: control-command.cpp:131
ndn::Name
Represents an absolute name.
Definition: name.hpp:44
ndn::nfd::FibAddNextHopCommand
represents a fib/add-nexthop command
Definition: control-command.hpp:201
nfd
Copyright (c) 2011-2015 Regents of the University of California.
Definition: ndn-common.hpp:40
ndn::nfd::CsConfigCommand::CsConfigCommand
CsConfigCommand()
Definition: control-command.cpp:263
ndn::nfd::RibUnregisterCommand::validateResponse
void validateResponse(const ControlParameters &parameters) const override
validate response parameters
Definition: control-command.cpp:411
ndn::nfd::ControlCommand::~ControlCommand
virtual ~ControlCommand()
ndn::nfd::FaceUpdateCommand::FaceUpdateCommand
FaceUpdateCommand()
Definition: control-command.cpp:140
ndn::nfd::FaceCreateCommand::applyDefaultsToRequest
void applyDefaultsToRequest(ControlParameters &parameters) const override
apply default values to missing fields in request
Definition: control-command.cpp:123
ndn::nfd::ControlCommand::m_requestValidator
FieldValidator m_requestValidator
FieldValidator for request ControlParameters.
Definition: control-command.hpp:124
ndn::nfd::ControlParameterField
ControlParameterField
Definition: control-parameters.hpp:36
ndn::nfd::FaceCreateCommand
represents a faces/create command
Definition: control-command.hpp:143
ndn::nfd::RibUnregisterCommand
represents a rib/unregister command
Definition: control-command.hpp:315
ndn::nfd::ControlCommand::FieldValidator::validate
void validate(const ControlParameters &parameters) const
verify that all required fields are present, and all present fields are either required or optional
Definition: control-command.cpp:76
ndn::nfd::FaceUpdateCommand
represents a faces/update command
Definition: control-command.hpp:161
ndn::nfd::ControlCommand::ArgumentError::ArgumentError
ArgumentError(const std::string &what)
Definition: control-command.hpp:44
ndn::nfd::FibAddNextHopCommand::applyDefaultsToRequest
void applyDefaultsToRequest(ControlParameters &parameters) const override
apply default values to missing fields in request
Definition: control-command.cpp:214
ndn::nfd::FaceUpdateCommand::validateResponse
void validateResponse(const ControlParameters &parameters) const override
Definition: control-command.cpp:167
ndn::nfd::ControlParameters
represents parameters in a ControlCommand request or response
Definition: control-parameters.hpp:82
ndn::nfd::ControlCommand::FieldValidator::required
FieldValidator & required(ControlParameterField field)
declare a required field
Definition: control-command.hpp:92
ndn::nfd::ControlCommand::validateRequest
virtual void validateRequest(const ControlParameters &parameters) const
validate request parameters
Definition: control-command.cpp:36
ndn::nfd::FaceCreateCommand::FaceCreateCommand
FaceCreateCommand()
Definition: control-command.cpp:99
ndn::name::Component
Represents a name component.
Definition: name-component.hpp:94
ndn::nfd::ControlCommand
base class of NFD ControlCommand
Definition: control-command.hpp:36
ndn::nfd::RibRegisterCommand::validateResponse
void validateResponse(const ControlParameters &parameters) const override
validate response parameters
Definition: control-command.cpp:377
ndn::nfd::ControlCommand::FieldValidator::optional
FieldValidator & optional(ControlParameterField field)
declare an optional field
Definition: control-command.hpp:101
ndn::nfd::ControlCommand::m_responseValidator
FieldValidator m_responseValidator
FieldValidator for response ControlParameters.
Definition: control-command.hpp:129
ndn::nfd::StrategyChoiceUnsetCommand::StrategyChoiceUnsetCommand
StrategyChoiceUnsetCommand()
Definition: control-command.cpp:316
ndn::nfd::ControlCommand::applyDefaultsToRequest
virtual void applyDefaultsToRequest(ControlParameters &parameters) const
apply default values to missing fields in request
Definition: control-command.cpp:42
ndn::nfd::CsConfigCommand
represents a cs/config command
Definition: control-command.hpp:237
ndn::nfd::FibRemoveNextHopCommand::applyDefaultsToRequest
void applyDefaultsToRequest(ControlParameters &parameters) const override
apply default values to missing fields in request
Definition: control-command.cpp:246
ndn::nfd::ControlCommand::FieldValidator
Definition: control-command.hpp:85
ndn::nfd::RibUnregisterCommand::RibUnregisterCommand
RibUnregisterCommand()
Definition: control-command.cpp:386
ndn::nfd::FaceDestroyCommand::validateRequest
void validateRequest(const ControlParameters &parameters) const override
validate request parameters
Definition: control-command.cpp:185
ndn::nfd::ControlCommand::ControlCommand
ControlCommand(const std::string &module, const std::string &verb)
Definition: control-command.cpp:27
ndn::nfd::FibAddNextHopCommand::validateResponse
void validateResponse(const ControlParameters &parameters) const override
validate response parameters
Definition: control-command.cpp:225
ndn::nfd::FaceDestroyCommand::validateResponse
void validateResponse(const ControlParameters &parameters) const override
validate response parameters
Definition: control-command.cpp:195
control-parameters.hpp
ndn::nfd::StrategyChoiceUnsetCommand::validateRequest
void validateRequest(const ControlParameters &parameters) const override
validate request parameters
Definition: control-command.cpp:325
ndn::nfd::CsEraseCommand::validateResponse
void validateResponse(const ControlParameters &parameters) const override
validate response parameters
Definition: control-command.cpp:298
ndn::nfd::StrategyChoiceSetCommand::StrategyChoiceSetCommand
StrategyChoiceSetCommand()
Definition: control-command.cpp:307
ndn
Copyright (c) 2011-2015 Regents of the University of California.
Definition: ndn-strategy-choice-helper.hpp:34