22 #ifndef NDN_CXX_MGMT_NFD_CONTROLLER_HPP
23 #define NDN_CXX_MGMT_NFD_CONTROLLER_HPP
76 template<
typename Command>
83 startCommand(make_shared<Command>(), parameters, onSuccess, onFailure, options);
88 template<
typename Dataset>
89 std::enable_if_t<std::is_default_constructible<Dataset>::value>
90 fetch(
const std::function<
void(
typename Dataset::ResultType)>& onSuccess,
94 fetchDataset(make_shared<Dataset>(), onSuccess, onFailure, options);
99 template<
typename Dataset,
typename ParamType =
typename Dataset::ParamType>
102 const std::function<
void(
typename Dataset::ResultType)>& onSuccess,
106 fetchDataset(make_shared<Dataset>(param), onSuccess, onFailure, options);
111 startCommand(
const shared_ptr<ControlCommand>& command,
118 processCommandResponse(
const Data& data,
119 const shared_ptr<ControlCommand>& command,
124 processValidatedCommandResponse(
const Data& data,
125 const shared_ptr<ControlCommand>& command,
129 template<
typename Dataset>
131 fetchDataset(shared_ptr<Dataset> dataset,
132 const std::function<
void(
typename Dataset::ResultType)>& onSuccess,
137 fetchDataset(
const Name& prefix,
142 template<
typename Dataset>
144 processDatasetResponse(shared_ptr<Dataset> dataset,
145 const std::function<
void(
typename Dataset::ResultType)>& onSuccess,
150 processDatasetFetchError(
const DatasetFailCallback& onFailure, uint32_t code, std::string msg);
183 template<
typename Dataset>
185 Controller::fetchDataset(shared_ptr<Dataset> dataset,
186 const std::function<
void(
typename Dataset::ResultType)>& onSuccess,
187 const DatasetFailCallback& onFailure,
190 Name prefix = dataset->getDatasetPrefix(options.
getPrefix());
193 processDatasetResponse(std::move(d), onSuccess, onFailure, std::move(p));
198 template<
typename Dataset>
200 Controller::processDatasetResponse(shared_ptr<Dataset> dataset,
201 const std::function<
void(
typename Dataset::ResultType)>& onSuccess,
202 const DatasetFailCallback& onFailure,
205 typename Dataset::ResultType result;
208 result = dataset->parseResult(std::move(payload));
210 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
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 for transport, and uses the passed 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
a 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
a callback on dataset retrieval failure
function< void(const ControlParameters &)> CommandSucceedCallback
a 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