22 #ifndef NDN_MGMT_NFD_CONTROLLER_HPP 23 #define NDN_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,
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,
205 typename Dataset::ResultType result;
208 result = dataset->parseResult(std::move(payload));
223 #endif // NDN_MGMT_NFD_CONTROLLER_HPP void start(const ControlParameters ¶meters, const CommandSucceedCallback &onSuccess, const CommandFailCallback &onFailure, const CommandOptions &options=CommandOptions())
start command execution
The interface of signing key management.
represents parameters in a ControlCommand request or response
security::CommandInterestSigner m_signer
function< void(const ControlResponse &)> CommandFailCallback
a callback on command failure
function< void(uint32_t code, const std::string &reason)> DatasetFailCallback
a callback on dataset retrieval failure
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
static const uint32_t ERROR_TIMEOUT
error code for timeout
Helper class to create signed Interests.
static const uint32_t ERROR_LBOUND
inclusive lower bound of error codes
contains options for ControlCommand execution
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
Controller(Face &face, KeyChain &keyChain, security::v2::Validator &validator=security::getAcceptAllValidator())
construct a Controller that uses face for transport, and uses the passed KeyChain to sign commands ...
#define NDN_CXX_PUBLIC_WITH_TESTS_ELSE_PROTECTED
Represents an absolute name.
std::set< shared_ptr< util::SegmentFetcher > > m_fetchers
function< void(const ControlParameters &)> CommandSucceedCallback
a callback on command success
const Name & getPrefix() const
security::v2::Validator & m_validator
Validator & getAcceptAllValidator()
Represents a Data packet.
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
Interface for validating data and interest packets.
static const uint32_t ERROR_SERVER
error code for server error
static const uint32_t ERROR_NACK
error code for network Nack
shared_ptr< const Buffer > ConstBufferPtr