29 #include <ndn-cxx/util/indented-stream.hpp> 57 using boost::logic::indeterminate;
65 p.setCapacity(*capacity);
67 if (!indeterminate(enableAdmit)) {
68 p.setFlagBit(ndn::nfd::BIT_CS_ENABLE_ADMIT, enableAdmit);
70 if (!indeterminate(enableServe)) {
71 p.setFlagBit(ndn::nfd::BIT_CS_ENABLE_SERVE, enableServe);
74 ctx.
controller.start<ndn::nfd::CsConfigCommand>(p,
75 [&] (
const ControlParameters& resp) {
77 ctx.
out <<
"cs-config-updated " 78 << ia(
"capacity") << resp.getCapacity()
79 << ia(
"admit") <<
text::OnOff{resp.getFlagBit(ndn::nfd::BIT_CS_ENABLE_ADMIT)}
80 << ia(
"serve") <<
text::OnOff{resp.getFlagBit(ndn::nfd::BIT_CS_ENABLE_SERVE)}
86 ctx.
face.processEvents();
92 auto prefix = ctx.
args.
get<Name>(
"prefix");
95 ControlParameters params;
96 params.setName(prefix);
98 params.setCount(*count);
101 ctx.
controller.start<ndn::nfd::CsEraseCommand>(
103 [&] (
const ControlParameters& resp) {
105 ctx.
out <<
"cs-erased " 106 << ia(
"prefix") << resp.getName()
107 << ia(
"count") << resp.getCount()
108 << ia(
"has-more") <<
text::YesNo{resp.hasCapacity()}
114 ctx.
face.processEvents();
119 const std::function<
void()>& onSuccess,
120 const Controller::DatasetFailCallback& onFailure,
121 const CommandOptions& options)
123 controller.fetch<ndn::nfd::CsInfoDataset>(
124 [
this, onSuccess] (
const CsInfo& result) {
141 os <<
"<capacity>" << item.getCapacity() <<
"</capacity>";
142 os <<
xml::Flag{
"admitEnabled", item.getEnableAdmit()};
143 os <<
xml::Flag{
"serveEnabled", item.getEnableServe()};
144 os <<
"<nEntries>" << item.getNEntries() <<
"</nEntries>";
145 os <<
"<nHits>" << item.getNHits() <<
"</nHits>";
146 os <<
"<nMisses>" << item.getNMisses() <<
"</nMisses>";
153 os <<
"CS information:\n";
154 ndn::util::IndentedStream indented(os,
" ");
162 os << ia(
"capacity") << item.getCapacity()
163 << ia(
"admit") <<
text::OnOff{item.getEnableAdmit()}
164 << ia(
"serve") <<
text::OnOff{item.getEnableServe()}
165 << ia(
"nEntries") << item.getNEntries()
166 << ia(
"nHits") << item.getNHits()
167 << ia(
"nMisses") << item.getNMisses()
const CommandArguments & args
ndn::nfd::CommandOptions makeCommandOptions() const
Controller::CommandFailCallback makeCommandFailureHandler(const std::string &commandName)
std::ostream & out
output stream
context for command execution
Copyright (c) 2014-2015, Regents of the University of California, Arizona Board of Regents...
print attributes of an item
print boolean as 'yes' or 'no'
print boolean as 'on' or 'off'