find-face.hpp
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
26 #ifndef NFD_TOOLS_NFDC_FIND_FACE_HPP
27 #define NFD_TOOLS_NFDC_FIND_FACE_HPP
28 
29 #include "execute-command.hpp"
30 
31 namespace nfd {
32 namespace tools {
33 namespace nfdc {
34 
35 using ndn::nfd::FaceQueryFilter;
36 using ndn::nfd::FaceStatus;
37 
40 class FindFace : noncopyable
41 {
42 public:
43  enum class Code {
44  OK = 0,
45  ERROR = 1,
46  NOT_FOUND = 3,
47  CANONIZE_ERROR = 4,
48  AMBIGUOUS = 5,
49  NOT_STARTED = -1,
50  IN_PROGRESS = -2,
51  };
52 
54  {
55  LOCAL_URI = 1
56  };
57 
58  explicit
60 
64  Code
65  execute(const FaceUri& faceUri, bool allowMulti = false);
66 
70  Code
71  execute(uint64_t faceId);
72 
78  Code
79  execute(const boost::any& faceIdOrUri, bool allowMulti = false);
80 
84  Code
85  execute(const FaceQueryFilter& filter, bool allowMulti = false);
86 
89  const std::vector<FaceStatus>&
90  getResults() const
91  {
92  return m_results;
93  }
94 
97  std::set<uint64_t>
98  getFaceIds() const;
99 
103  const FaceStatus&
104  getFaceStatus() const;
105 
106  uint64_t
107  getFaceId() const
108  {
109  return this->getFaceStatus().getFaceId();
110  }
111 
112  const std::string&
114  {
115  return m_errorReason;
116  }
117 
120  void
121  printDisambiguation(std::ostream& os, DisambiguationStyle style) const;
122 
123 private:
128  ndn::optional<FaceUri>
129  canonize(const std::string& fieldName, const FaceUri& input);
130 
135  void
136  query();
137 
138 private:
139  ExecuteContext& m_ctx;
140  FaceQueryFilter m_filter;
141  Code m_res = Code::NOT_STARTED;
142  std::vector<FaceStatus> m_results;
143  std::string m_errorReason;
144 };
145 
146 } // namespace nfdc
147 } // namespace tools
148 } // namespace nfd
149 
150 #endif // NFD_TOOLS_NFDC_FIND_FACE_HPP
FindFace(ExecuteContext &ctx)
Definition: find-face.cpp:36
context for command execution
found exactly one face, or found multiple faces when allowMulti is true
error during FaceUri canonization
found multiple faces and allowMulti is false
void printDisambiguation(std::ostream &os, DisambiguationStyle style) const
print results for disambiguation
Definition: find-face.cpp:169
Copyright (c) 2014-2015, Regents of the University of California, Arizona Board of Regents...
Definition: algorithm.hpp:32
procedure to find a face
Definition: find-face.hpp:40
Code execute(const FaceUri &faceUri, bool allowMulti=false)
find face by FaceUri
Definition: find-face.cpp:42
uint64_t getFaceId() const
Definition: find-face.hpp:107
const FaceStatus & getFaceStatus() const
Definition: find-face.cpp:162
const std::string & getErrorReason() const
Definition: find-face.hpp:113
const std::vector< FaceStatus > & getResults() const
Definition: find-face.hpp:90
std::set< uint64_t > getFaceIds() const
Definition: find-face.cpp:152