control-command.hpp
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
22 #ifndef NDN_MGMT_NFD_CONTROL_COMMAND_HPP
23 #define NDN_MGMT_NFD_CONTROL_COMMAND_HPP
24 
25 #include "control-parameters.hpp"
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  validateRequest(const ControlParameters& parameters) const override;
152 
153  void
154  validateResponse(const ControlParameters& parameters) const override;
155 };
156 
157 
164 {
165 public:
167 
168  void
169  applyDefaultsToRequest(ControlParameters& parameters) const override;
170 
171  void
172  validateRequest(const ControlParameters& parameters) const override;
173 
178  void
179  validateResponse(const ControlParameters& parameters) const override;
180 };
181 
182 
189 {
190 public:
192 
193  void
194  validateRequest(const ControlParameters& parameters) const override;
195 
196  void
197  validateResponse(const ControlParameters& parameters) const override;
198 };
199 
200 
207 {
208 public:
210 
211  void
212  applyDefaultsToRequest(ControlParameters& parameters) const override;
213 
214  void
215  validateResponse(const ControlParameters& parameters) const override;
216 };
217 
218 
225 {
226 public:
228 
229  void
230  applyDefaultsToRequest(ControlParameters& parameters) const override;
231 
232  void
233  validateResponse(const ControlParameters& parameters) const override;
234 };
235 
236 
243 {
244 public:
246 };
247 
248 
255 {
256 public:
258 
259  void
260  validateRequest(const ControlParameters& parameters) const override;
261 
262  void
263  validateResponse(const ControlParameters& parameters) const override;
264 };
265 
266 
273 {
274 public:
276 
277  void
278  applyDefaultsToRequest(ControlParameters& parameters) const override;
279 
280  void
281  validateResponse(const ControlParameters& parameters) const override;
282 };
283 
284 
291 {
292 public:
294 
295  void
296  applyDefaultsToRequest(ControlParameters& parameters) const override;
297 
298  void
299  validateResponse(const ControlParameters& parameters) const override;
300 };
301 
302 } // namespace nfd
303 } // namespace ndn
304 
305 #endif // NDN_MGMT_NFD_CONTROL_COMMAND_HPP
virtual void applyDefaultsToResponse(ControlParameters &parameters) const
apply default values to missing fields in response
represents a strategy-choice/set command
Copyright (c) 2013-2017 Regents of the University of California.
Definition: common.hpp:66
represents a fib/add-nexthop command
represents parameters in a ControlCommand request or response
FieldValidator m_requestValidator
FieldValidator for request ControlParameters.
base class of NFD ControlCommand
virtual void validateResponse(const ControlParameters &parameters) const
validate response parameters
STL namespace.
virtual void validateRequest(const ControlParameters &parameters) const
validate request parameters
FieldValidator m_responseValidator
FieldValidator for response ControlParameters.
represents a strategy-choice/set command
represents a fib/remove-nexthop command
ControlCommand(const std::string &module, const std::string &verb)
represents a faces/create command
Name getRequestName(const Name &commandPrefix, const ControlParameters &parameters) const
construct the Name for a request Interest
FieldValidator & required(ControlParameterField field)
declare a required field
Represents an absolute name.
Definition: name.hpp:42
represents a rib/unregister command
represents a faces/update command
represents a rib/register command
Component holds a read-only name component value.
virtual void applyDefaultsToRequest(ControlParameters &parameters) const
apply default values to missing fields in request
represents a faces/destroy command
represents an error in ControlParameters
FieldValidator & optional(ControlParameterField field)
declare an optional field