22 #ifndef NDN_MGMT_NFD_CONTROLLER_HPP 23 #define NDN_MGMT_NFD_CONTROLLER_HPP 29 #include "../../security/validator-null.hpp" 73 template<
typename Command>
76 const CommandSucceedCallback& onSuccess,
77 const CommandFailCallback& onFailure,
80 shared_ptr<ControlCommand> command = make_shared<Command>();
81 this->startCommand(command, parameters, onSuccess, onFailure, options);
86 template<
typename Dataset>
87 typename std::enable_if<std::is_default_constructible<Dataset>::value>::type
88 fetch(
const std::function<
void(
typename Dataset::ResultType)>& onSuccess,
89 const DatasetFailCallback& onFailure,
92 this->fetchDataset(make_shared<Dataset>(), onSuccess, onFailure, options);
97 template<
typename Dataset,
typename ParamType =
typename Dataset::ParamType>
100 const std::function<
void(
typename Dataset::ResultType)>& onSuccess,
101 const DatasetFailCallback& onFailure,
104 this->fetchDataset(make_shared<Dataset>(param), onSuccess, onFailure, options);
109 startCommand(
const shared_ptr<ControlCommand>& command,
111 const CommandSucceedCallback& onSuccess,
112 const CommandFailCallback& onFailure,
116 processCommandResponse(
const Data& data,
117 const shared_ptr<ControlCommand>& command,
118 const CommandSucceedCallback& onSuccess,
119 const CommandFailCallback& onFailure);
122 processValidatedCommandResponse(
const Data& data,
123 const shared_ptr<ControlCommand>& command,
124 const CommandSucceedCallback& onSuccess,
125 const CommandFailCallback& onFailure);
127 template<
typename Dataset>
129 fetchDataset(shared_ptr<Dataset> dataset,
130 const std::function<
void(
typename Dataset::ResultType)>& onSuccess,
131 const DatasetFailCallback& onFailure,
135 fetchDataset(
const Name& prefix,
136 const std::function<
void(
const ConstBufferPtr&)>& processResponse,
137 const DatasetFailCallback& onFailure,
140 template<
typename Dataset>
142 processDatasetResponse(shared_ptr<Dataset> dataset,
143 const std::function<
void(
typename Dataset::ResultType)>& onSuccess,
144 const DatasetFailCallback& onFailure,
148 processDatasetFetchError(
const DatasetFailCallback& onFailure, uint32_t code, std::string msg);
180 template<
typename Dataset>
182 Controller::fetchDataset(shared_ptr<Dataset> dataset,
183 const std::function<
void(
typename Dataset::ResultType)>& onSuccess1,
184 const DatasetFailCallback& onFailure1,
187 const std::function<void(typename Dataset::ResultType)>& onSuccess = onSuccess1 ?
188 onSuccess1 : [] (
const typename Dataset::ResultType&) {};
189 const DatasetFailCallback& onFailure = onFailure1 ?
190 onFailure1 : [] (uint32_t,
const std::string&) {};
192 Name prefix = dataset->getDatasetPrefix(options.
getPrefix());
193 this->fetchDataset(prefix,
194 bind(&Controller::processDatasetResponse<Dataset>,
this, dataset, onSuccess, onFailure, _1),
199 template<
typename Dataset>
201 Controller::processDatasetResponse(shared_ptr<Dataset> dataset,
202 const std::function<
void(
typename Dataset::ResultType)>& onSuccess,
203 const DatasetFailCallback& onFailure,
206 typename Dataset::ResultType result;
208 result = dataset->parseResult(payload);
211 onFailure(ERROR_SERVER, e.what());
221 #endif // NDN_MGMT_NFD_CONTROLLER_HPP void start(const ControlParameters ¶meters, const CommandSucceedCallback &onSuccess, const CommandFailCallback &onFailure, const CommandOptions &options=CommandOptions())
start command execution
Copyright (c) 2011-2015 Regents of the University of California.
security::KeyChain & m_keyChain
represents parameters in a ControlCommand request or response
The packet signing interface.
std::enable_if< std::is_default_constructible< Dataset >::value >::type fetch(const std::function< void(typename Dataset::ResultType)> &onSuccess, const DatasetFailCallback &onFailure, const CommandOptions &options=CommandOptions())
start dataset fetching
function< void(const ControlResponse &)> CommandFailCallback
a callback on command failure
static const uint32_t ERROR_TIMEOUT
error code for timeout
function< void(const ControlParameters &)> CommandSucceedCallback
a callback on command success
static const uint32_t ERROR_LBOUND
inclusive lower bound of error codes
contains options for ControlCommand execution
Copyright (c) 2011-2015 Regents of the University of California.
provides the interfaces for packet validation.
Provide a communication channel with local or remote NDN forwarder.
NFD Management protocol client.
static const uint32_t ERROR_VALIDATION
error code for response validation failure
Name abstraction to represent an absolute name.
const Name & getPrefix() const
security::Validator & m_validator
shared_ptr< const Buffer > ConstBufferPtr
void fetch(const ParamType ¶m, const std::function< void(typename Dataset::ResultType)> &onSuccess, const DatasetFailCallback &onFailure, const CommandOptions &options=CommandOptions())
start dataset fetching
represents an error in TLV encoding or decoding
static const uint32_t ERROR_SERVER
error code for server error
static const uint32_t ERROR_NACK
error code for network Nack
function< void(uint32_t code, const std::string &reason)> DatasetFailCallback
a callback on dataset retrieval failure