face-id-fetcher.hpp
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
26 #ifndef NFD_TOOLS_NFDC_FACE_ID_FETCHER_HPP
27 #define NFD_TOOLS_NFDC_FACE_ID_FETCHER_HPP
28 
29 #include "core/common.hpp"
30 #include <ndn-cxx/face.hpp>
31 #include <ndn-cxx/mgmt/nfd/controller.hpp>
32 #include <ndn-cxx/util/face-uri.hpp>
33 #include <ndn-cxx/security/validator-null.hpp>
34 
35 namespace nfd {
36 namespace tools {
37 namespace nfdc {
38 
39 using ndn::util::FaceUri;
40 
42 {
43 public:
44  typedef std::function<void(uint32_t)> SuccessCallback;
45  typedef std::function<void(const std::string&)> FailureCallback;
46 
55  static void
56  start(ndn::Face& face,
57  ndn::nfd::Controller& controller,
58  const std::string& input,
59  bool allowCreate,
60  const SuccessCallback& onSucceed,
61  const FailureCallback& onFail);
62 
63 private:
64  FaceIdFetcher(ndn::Face& face,
65  ndn::nfd::Controller& controller,
66  bool allowCreate,
67  const SuccessCallback& onSucceed,
68  const FailureCallback& onFail);
69 
70  void
71  onQuerySuccess(const ndn::ConstBufferPtr& data,
72  const FaceUri& canonicalUri);
73 
74  void
75  onQueryFailure(uint32_t errorCode,
76  const FaceUri& canonicalUri);
77 
78  void
79  onCanonizeSuccess(const FaceUri& canonicalUri);
80 
81  void
82  onCanonizeFailure(const std::string& reason);
83 
84  void
85  startGetFaceId(const FaceUri& faceUri);
86 
87  void
88  startFaceCreate(const FaceUri& canonicalUri);
89 
90  void
91  onFaceCreateError(const ndn::nfd::ControlResponse& response,
92  const std::string& message);
93 
94  void
95  succeed(uint32_t faceId);
96 
97  void
98  fail(const std::string& reason);
99 
100 private:
101  ndn::Face& m_face;
102  ndn::nfd::Controller& m_controller;
103  bool m_allowCreate;
104  SuccessCallback m_onSucceed;
105  FailureCallback m_onFail;
106  ndn::ValidatorNull m_validator;
107 };
108 
109 } // namespace nfdc
110 } // namespace tools
111 } // namespace nfd
112 
113 #endif // NFD_TOOLS_NFDC_FACE_ID_FETCHER_HPP
Copyright (c) 2014-2015, Regents of the University of California, Arizona Board of Regents...
Definition: algorithm.hpp:32
std::function< void(const std::string &)> FailureCallback
static void start(ndn::Face &face, ndn::nfd::Controller &controller, const std::string &input, bool allowCreate, const SuccessCallback &onSucceed, const FailureCallback &onFail)
obtain FaceId from input
std::function< void(uint32_t)> SuccessCallback