22 #ifndef NDN_CXX_MGMT_NFD_CONTROLLER_HPP
23 #define NDN_CXX_MGMT_NFD_CONTROLLER_HPP
79 template<
typename Command>
86 startCommand(make_shared<Command>(), parameters, onSuccess, onFailure, options);
91 template<
typename Dataset>
92 std::enable_if_t<std::is_default_constructible<Dataset>::value>
93 fetch(
const std::function<
void(
typename Dataset::ResultType)>& onSuccess,
97 fetchDataset(make_shared<Dataset>(), onSuccess, onFailure, options);
102 template<
typename Dataset,
typename ParamType =
typename Dataset::ParamType>
105 const std::function<
void(
typename Dataset::ResultType)>& onSuccess,
109 fetchDataset(make_shared<Dataset>(param), onSuccess, onFailure, options);
114 startCommand(
const shared_ptr<ControlCommand>& command,
121 processCommandResponse(
const Data& data,
122 const shared_ptr<ControlCommand>& command,
127 processValidatedCommandResponse(
const Data& data,
128 const shared_ptr<ControlCommand>& command,
132 template<
typename Dataset>
134 fetchDataset(shared_ptr<Dataset> dataset,
135 const std::function<
void(
typename Dataset::ResultType)>& onSuccess,
140 fetchDataset(
const Name& prefix,
145 template<
typename Dataset>
147 processDatasetResponse(shared_ptr<Dataset> dataset,
148 const std::function<
void(
typename Dataset::ResultType)>& onSuccess,
153 processDatasetFetchError(
const DatasetFailCallback& onFailure, uint32_t code, std::string msg);
181 template<
typename Dataset>
183 Controller::fetchDataset(shared_ptr<Dataset> dataset,
184 const std::function<
void(
typename Dataset::ResultType)>& onSuccess,
185 const DatasetFailCallback& onFailure,
188 Name prefix = dataset->getDatasetPrefix(options.
getPrefix());
191 processDatasetResponse(std::move(d), onSuccess, onFailure, std::move(p));
196 template<
typename Dataset>
198 Controller::processDatasetResponse(shared_ptr<Dataset> dataset,
199 const std::function<
void(
typename Dataset::ResultType)>& onSuccess,
200 const DatasetFailCallback& onFailure,
203 typename Dataset::ResultType result;
206 result = dataset->parseResult(std::move(payload));
208 catch (
const tlv::Error& e) {
Represents a Data packet.
Provide a communication channel with local or remote NDN forwarder.
Represents an absolute name.
Contains options for ControlCommand execution.
const Name & getPrefix() const
Returns the command prefix.
Represents parameters in a ControlCommand request or response.
NFD Management protocol client.
static const uint32_t ERROR_TIMEOUT
Error code for timeout.
static const uint32_t ERROR_SERVER
Error code for server error.
void fetch(const ParamType ¶m, const std::function< void(typename Dataset::ResultType)> &onSuccess, const DatasetFailCallback &onFailure, const CommandOptions &options=CommandOptions())
Start dataset fetching.
static const uint32_t ERROR_LBOUND
Inclusive lower bound of error codes.
std::enable_if_t< std::is_default_constructible< Dataset >::value > fetch(const std::function< void(typename Dataset::ResultType)> &onSuccess, const DatasetFailCallback &onFailure, const CommandOptions &options=CommandOptions())
Start dataset fetching.
Controller(Face &face, KeyChain &keyChain, security::Validator &validator=security::getAcceptAllValidator())
Construct a Controller that uses face as transport and keyChain to sign commands.
static const uint32_t ERROR_VALIDATION
Error code for response validation failure.
void start(const ControlParameters ¶meters, const CommandSucceedCallback &onSuccess, const CommandFailCallback &onFailure, const CommandOptions &options=CommandOptions())
Start command execution.
security::InterestSigner m_signer
function< void(const ControlResponse &)> CommandFailCallback
Callback on command failure.
static const uint32_t ERROR_NACK
Error code for network Nack.
std::set< shared_ptr< util::SegmentFetcher > > m_fetchers
security::Validator & m_validator
function< void(uint32_t code, const std::string &reason)> DatasetFailCallback
Callback on dataset retrieval failure.
function< void(const ControlParameters &)> CommandSucceedCallback
Callback on command success.
Helper class to create signed Interests.
Interface for validating data and interest packets.
#define NDN_CXX_PUBLIC_WITH_TESTS_ELSE_PROTECTED
Validator & getAcceptAllValidator()
shared_ptr< const Buffer > ConstBufferPtr