@@ -93,8 +93,9 @@ makeAcceptAllAuthorization();
93
93
*/
94
94
using ValidateParameters = std::function<bool (const ControlParameters& params)>;
95
95
96
- /* * \brief A function to be called after ControlCommandHandler completes.
97
- * \param resp the response to be sent to requester
96
+ /* *
97
+ * \brief A function to be called after a ControlCommandHandler completes.
98
+ * \param resp The response that should be sent back to the requester.
98
99
*/
99
100
using CommandContinuation = std::function<void (const ControlResponse& resp)>;
100
101
@@ -195,17 +196,17 @@ class Dispatcher : noncopyable
195
196
* \throw std::out_of_range \p relPrefix overlaps with an existing relPrefix.
196
197
* \throw std::domain_error One or more top-level prefixes have been added.
197
198
*
198
- * Procedure for processing a ControlCommand:
199
+ * Procedure for processing a ControlCommand registered through this function :
199
200
* 1. Extract the NameComponent containing ControlParameters (the component after relPrefix),
200
201
* and parse ControlParameters into ParametersType; if parsing fails, abort these steps.
201
202
* 2. Perform authorization; if the authorization is rejected, perform the RejectReply action
202
203
* and abort these steps.
203
- * 3. Validate ControlParameters; if validation fails, create a ControlResponse with
204
+ * 3. Validate the ControlParameters; if validation fails, create a ControlResponse with
204
205
* StatusCode 400 and go to step 5.
205
206
* 4. Invoke the command handler, wait until CommandContinuation is called.
206
207
* 5. Encode the ControlResponse into one Data packet.
207
208
* 6. Sign the Data packet.
208
- * 7. If the Data packet is too large, abort these steps and log an error .
209
+ * 7. If the Data packet is too large, log an error and abort these steps .
209
210
* 8. Send the signed Data packet.
210
211
*/
211
212
template <typename ParametersType,
@@ -227,7 +228,8 @@ class Dispatcher : noncopyable
227
228
authorize = std::move (authorize),
228
229
validate = std::move (validate),
229
230
handle = std::move (handle)] (const auto & prefix, const auto & interest) {
230
- processCommand (prefix, relPrefix, interest, parse, authorize, validate, handle);
231
+ processCommand (prefix, relPrefix, interest, parse, authorize,
232
+ std::move (validate), std::move (handle));
231
233
};
232
234
}
233
235
@@ -296,13 +298,6 @@ class Dispatcher : noncopyable
296
298
private:
297
299
using InterestHandler = std::function<void (const Name& prefix, const Interest&)>;
298
300
299
- using AuthorizationAcceptedCallback = std::function<void (const std::string& requester,
300
- const Name& prefix,
301
- const Interest&,
302
- const shared_ptr<ControlParameters>&)>;
303
-
304
- using AuthorizationRejectedCallback = std::function<void (RejectReply, const Interest&)>;
305
-
306
301
/* *
307
302
* @brief The parser for extracting control parameters from a name component.
308
303
* @return A shared pointer to the extracted ControlParameters.
@@ -374,30 +369,28 @@ class Dispatcher : noncopyable
374
369
* @param parse function to extract the control parameters from the command
375
370
* @param authorize function to determine whether the command is authorized
376
371
* @param validate function to validate the command parameters
377
- * @param handler function to execute the command after authorization and validation
372
+ * @param handler function to execute the command after it is authorized and validated
378
373
*/
379
374
void
380
375
processCommand (const Name& prefix,
381
376
const Name& relPrefix,
382
377
const Interest& interest,
383
378
const ControlParametersParser& parse,
384
379
const Authorization& authorize,
385
- const ValidateParameters& validate,
386
- const ControlCommandHandler& handler);
380
+ ValidateParameters validate,
381
+ ControlCommandHandler handler);
387
382
388
383
/* *
389
384
* @brief Process an authorized control command.
390
385
*
391
- * @param requester the requester
392
386
* @param prefix the top-level prefix
393
387
* @param interest the incoming Interest
394
388
* @param parameters control parameters of this command
395
389
* @param validate function to validate the command parameters
396
- * @param handler function to execute the command after authorization and validation
390
+ * @param handler function to execute the command after its parameters are validated
397
391
*/
398
392
void
399
- processAuthorizedCommand (const std::string& requester,
400
- const Name& prefix,
393
+ processAuthorizedCommand (const Name& prefix,
401
394
const Interest& interest,
402
395
const shared_ptr<ControlParameters>& parameters,
403
396
const ValidateParameters& validate,
@@ -411,23 +404,21 @@ class Dispatcher : noncopyable
411
404
*
412
405
* @param prefix the top-level prefix
413
406
* @param interest the incoming Interest
414
- * @param authorize function to process verification
415
- * @param accepted callback for successful authorization
416
- * @param rejected callback for failed authorization
407
+ * @param authorize function to determine whether the request is authorized
408
+ * @param handler function to continue processing the request after it is authorized
417
409
*/
418
410
void
419
411
processStatusDatasetInterest (const Name& prefix,
420
412
const Interest& interest,
421
413
const Authorization& authorize,
422
- const AuthorizationAcceptedCallback& accepted,
423
- const AuthorizationRejectedCallback& rejected);
414
+ StatusDatasetHandler handler);
424
415
425
416
/* *
426
417
* @brief Process an authorized StatusDataset request.
427
418
*
428
419
* @param prefix the top-level prefix
429
420
* @param interest the incoming Interest
430
- * @param handler function to process this request
421
+ * @param handler function to process the dataset request
431
422
*/
432
423
void
433
424
processAuthorizedStatusDatasetInterest (const Name& prefix,
0 commit comments