28 #include <ndn-cxx/util/logger.hpp> 44 FaceQueryFilter filter;
45 filter.setRemoteUri(faceUri.toString());
46 return this->
execute(filter, allowMulti);
52 FaceQueryFilter filter;
53 filter.setFaceId(faceId);
60 const uint64_t* faceId = boost::any_cast<uint64_t>(&faceIdOrUri);
61 if (faceId !=
nullptr) {
65 return this->
execute(boost::any_cast<FaceUri>(faceIdOrUri), allowMulti);
76 if (m_filter.hasRemoteUri()) {
77 auto remoteUri = this->canonize(
"remote", FaceUri(m_filter.getRemoteUri()));
82 m_filter.setRemoteUri(remoteUri->toString());
85 if (m_filter.hasLocalUri()) {
86 auto localUri = this->canonize(
"local", FaceUri(m_filter.getLocalUri()));
91 m_filter.setLocalUri(localUri->toString());
96 if (m_results.size() == 0) {
98 m_errorReason =
"Face not found";
100 else if (m_results.size() > 1 && !allowMulti) {
102 m_errorReason =
"Multiple faces match the query";
108 ndn::optional<FaceUri>
109 FindFace::canonize(
const std::string& fieldName,
const FaceUri& input)
111 if (!FaceUri::canCanonize(input.getScheme())) {
112 NDN_LOG_DEBUG(
"Using " << fieldName <<
'=' << input <<
" without canonization");
116 ndn::optional<FaceUri> result;
118 [&result] (
const FaceUri& canonicalUri) { result = canonicalUri; },
119 [
this, fieldName] (
const std::string& errorReason) {
120 m_errorReason =
"Error during " + fieldName +
" FaceUri canonization: " + errorReason;
123 m_ctx.
face.processEvents();
131 auto datasetCb = [
this] (
const std::vector<ndn::nfd::FaceStatus>& result) {
135 auto failureCb = [
this] (uint32_t code,
const std::string& reason) {
137 m_errorReason =
"Error " + std::to_string(code) +
" when querying face: " + reason;
140 if (m_filter.empty()) {
141 m_ctx.
controller.fetch<ndn::nfd::FaceDataset>(
145 m_ctx.
controller.fetch<ndn::nfd::FaceQueryDataset>(
148 m_ctx.
face.processEvents();
154 std::set<uint64_t> faceIds;
155 for (
const FaceStatus& faceStatus : m_results) {
156 faceIds.insert(faceStatus.getFaceId());
164 BOOST_ASSERT(m_results.size() == 1);
165 return m_results.front();
172 for (
const auto& item : m_results) {
176 os << item.getFaceId() <<
" (local=" << item.getLocalUri() <<
')';
ndn::nfd::CommandOptions makeCommandOptions() const
context for command execution
time::nanoseconds getTimeout() const
Copyright (c) 2014-2015, Regents of the University of California, Arizona Board of Regents...
print different string on first and subsequent usage