22 #ifndef NDN_CXX_MGMT_NFD_CONTROLLER_HPP
23 #define NDN_CXX_MGMT_NFD_CONTROLLER_HPP
63 template<
typename Dataset>
65 std::function<void(
const std::invoke_result_t<decltype(&Dataset::parseResult), Dataset,
ConstBufferPtr>&)>;
92 template<
typename Command>
99 startCommand(std::make_shared<Command>(), parameters, onSuccess, onFailure, options);
105 template<
typename Dataset>
106 std::enable_if_t<std::is_default_constructible_v<Dataset>>
111 fetchDataset(Dataset(), onSuccess, onFailure, options);
117 template<
typename Dataset,
typename ParamType>
124 fetchDataset(Dataset(std::forward<ParamType>(param)), onSuccess, onFailure, options);
129 startCommand(
const shared_ptr<ControlCommand>& command,
133 const CommandOptions& options);
136 processCommandResponse(
const Data& data,
137 const shared_ptr<ControlCommand>& command,
142 processValidatedCommandResponse(
const Data& data,
143 const shared_ptr<ControlCommand>& command,
147 template<
typename Dataset>
149 fetchDataset(Dataset&& dataset,
150 const DatasetSuccessCallback<Dataset>& onSuccess,
152 const CommandOptions& options);
155 fetchDataset(
const Name& prefix,
158 const CommandOptions& options);
187 template<
typename Dataset>
189 Controller::fetchDataset(Dataset&& dataset,
196 [=, dataset = std::forward<Dataset>(dataset)] (
ConstBufferPtr payload) {
197 std::invoke_result_t<decltype(&Dataset::parseResult), Dataset,
ConstBufferPtr> result;
199 result = dataset.parseResult(std::move(payload));
203 onFailure(
ERROR_SERVER,
"Dataset decoding failure: "s + e.what());
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.
Controller(Face &face, KeyChain &keyChain, security::Validator &validator=security::getAcceptAllValidator())
Construct a Controller that uses face as transport and keyChain to sign commands.
@ ERROR_LBOUND
Inclusive lower bound of error codes.
@ ERROR_VALIDATION
Error code for response validation failure.
@ ERROR_SERVER
Error code for server error.
@ ERROR_NACK
Error code for network Nack.
@ ERROR_TIMEOUT
Error code for timeout.
void start(const ControlParameters ¶meters, const CommandSuccessCallback &onSuccess, const CommandFailureCallback &onFailure, const CommandOptions &options={})
Start command execution.
std::enable_if_t< std::is_default_constructible_v< Dataset > > fetch(const DatasetSuccessCallback< Dataset > &onSuccess, const DatasetFailureCallback &onFailure, const CommandOptions &options={})
Start dataset fetching.
void fetch(ParamType &¶m, const DatasetSuccessCallback< Dataset > &onSuccess, const DatasetFailureCallback &onFailure, const CommandOptions &options={})
Start dataset fetching.
security::InterestSigner m_signer
security::Validator & m_validator
std::set< shared_ptr< SegmentFetcher > > m_fetchers
Helper class to create signed Interests.
The main interface for signing key management.
Interface for validating data and interest packets.
Represents an error in TLV encoding or decoding.
#define NDN_CXX_PUBLIC_WITH_TESTS_ELSE_PROTECTED
std::function< void(const ControlResponse &)> CommandFailureCallback
Callback on command failure.
std::function< void(uint32_t code, const std::string &reason)> DatasetFailureCallback
Callback on dataset retrieval failure.
std::function< void(const ControlParameters &)> CommandSuccessCallback
Callback on command success.
std::function< void(const std::invoke_result_t< decltype(&Dataset::parseResult), Dataset, ConstBufferPtr > &)> DatasetSuccessCallback
Callback on dataset retrieval success.
Validator & getAcceptAllValidator()
std::shared_ptr< const Buffer > ConstBufferPtr