43 .
setTitle(
"show strategy choice of an entry")
49 .
setTitle(
"set strategy choice for a name prefix")
56 .
setTitle(
"clear strategy choice at a name prefix")
64 ctx.
controller.fetch<ndn::nfd::StrategyChoiceDataset>(
65 [&] (
const std::vector<StrategyChoice>& dataset) {
66 for (
const StrategyChoice& entry : dataset) {
74 ctx.
face.processEvents();
80 auto prefix = ctx.
args.
get<Name>(
"prefix");
82 ctx.
controller.fetch<ndn::nfd::StrategyChoiceDataset>(
83 [&] (
const std::vector<StrategyChoice>& dataset) {
85 for (
const StrategyChoice& entry : dataset) {
86 if (entry.getName().isPrefixOf(prefix) &&
87 entry.getName().size() >= match.getName().size()) {
96 ctx.
face.processEvents();
102 auto prefix = ctx.
args.
get<Name>(
"prefix");
103 auto strategy = ctx.
args.
get<Name>(
"strategy");
105 ctx.
controller.start<ndn::nfd::StrategyChoiceSetCommand>(
106 ControlParameters().setName(prefix).setStrategy(strategy),
107 [&] (
const ControlParameters& resp) {
108 ctx.
out <<
"strategy-set ";
110 ctx.
out << ia(
"prefix") << resp.getName()
111 << ia(
"strategy") << resp.getStrategy() <<
'\n';
113 [&] (
const ControlResponse& resp) {
114 if (resp.getCode() == 404) {
116 ctx.
err <<
"Unknown strategy: " << strategy <<
'\n';
124 ctx.
face.processEvents();
130 auto prefix = ctx.
args.
get<Name>(
"prefix");
132 if (prefix.empty()) {
134 ctx.
err <<
"Unsetting default strategy is prohibited\n";
138 ctx.
controller.start<ndn::nfd::StrategyChoiceUnsetCommand>(
139 ControlParameters().setName(prefix),
140 [&] (
const ControlParameters& resp) {
141 ctx.
out <<
"strategy-unset ";
143 ctx.
out << ia(
"prefix") << resp.getName() <<
'\n';
148 ctx.
face.processEvents();
153 const function<
void()>& onSuccess,
154 const Controller::DatasetFailCallback& onFailure,
155 const CommandOptions& options)
157 controller.fetch<ndn::nfd::StrategyChoiceDataset>(
158 [
this, onSuccess] (
const std::vector<StrategyChoice>& result) {
168 os <<
"<strategyChoices>";
169 for (
const StrategyChoice& item : m_status) {
172 os <<
"</strategyChoices>";
178 os <<
"<strategyChoice>";
179 os <<
"<namespace>" <<
xml::Text{item.getName().toUri()} <<
"</namespace>";
180 os <<
"<strategy><name>" <<
xml::Text{item.getStrategy().toUri()} <<
"</name></strategy>";
181 os <<
"</strategyChoice>";
187 os <<
"Strategy choices:\n";
188 for (
const StrategyChoice& item : m_status) {
199 os << ia(
"prefix") << item.getName()
200 << ia(
"strategy") << item.getStrategy()
const CommandArguments & args
ndn::nfd::CommandOptions makeCommandOptions() const
Controller::CommandFailCallback makeCommandFailureHandler(const std::string &commandName)
std::ostream & out
output stream
context for command execution
int exitCode
program exit code
Controller::DatasetFailCallback makeDatasetFailureHandler(const std::string &datasetName)
Copyright (c) 2014-2015, Regents of the University of California, Arizona Board of Regents...
print attributes of an item
std::ostream & err
error stream