30 #include <ndn-cxx/util/logger.hpp> 46 FaceQueryFilter filter;
47 filter.setRemoteUri(faceUri.toString());
48 return this->
execute(filter, allowMulti);
54 FaceQueryFilter filter;
55 filter.setFaceId(faceId);
62 const uint64_t* faceId = ndn::any_cast<uint64_t>(&faceIdOrUri);
63 if (faceId !=
nullptr) {
67 return this->
execute(ndn::any_cast<FaceUri>(faceIdOrUri), allowMulti);
78 if (m_filter.hasRemoteUri()) {
79 auto remoteUri = canonize(
"remote FaceUri", FaceUri(m_filter.getRemoteUri()));
83 m_filter.setRemoteUri(remoteUri->toString());
86 if (m_filter.hasLocalUri()) {
87 auto localUri = canonize(
"local FaceUri", 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";
109 FindFace::canonize(
const std::string& fieldName,
const FaceUri& uri)
112 if (!FaceUri::canCanonize(uri.getScheme())) {
113 NDN_LOG_DEBUG(
"Using " << fieldName <<
"=" << uri <<
" without canonization");
117 optional<FaceUri> result;
135 auto datasetCb = [
this] (
const std::vector<ndn::nfd::FaceStatus>& result) {
139 auto failureCb = [
this] (uint32_t code,
const std::string& reason) {
141 m_errorReason =
"Error " + to_string(code) +
" when querying face: " + reason;
144 if (m_filter.empty()) {
145 m_ctx.
controller.fetch<ndn::nfd::FaceDataset>(
149 m_ctx.
controller.fetch<ndn::nfd::FaceQueryDataset>(
152 m_ctx.
face.processEvents();
158 std::set<uint64_t> faceIds;
159 for (
const FaceStatus& faceStatus : m_results) {
160 faceIds.insert(faceStatus.getFaceId());
168 BOOST_ASSERT(m_results.size() == 1);
169 return m_results.front();
176 for (
const auto& item : m_results) {
180 os << item.getFaceId() <<
" (local=" << item.getLocalUri() <<
')';
context for command execution
ndn::nfd::CommandOptions makeCommandOptions() const
Copyright (c) 2014-2015, Regents of the University of California, Arizona Board of Regents...
print different string on first and subsequent usage