forwarder-general-module.hpp
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
26 #ifndef NFD_TOOLS_NFDC_FORWARDER_GENERAL_MODULE_HPP
27 #define NFD_TOOLS_NFDC_FORWARDER_GENERAL_MODULE_HPP
28 
29 #include "module.hpp"
30 #include <ndn-cxx/security/validator.hpp>
31 
32 namespace nfd {
33 namespace tools {
34 namespace nfdc {
35 
36 using ndn::nfd::ForwarderStatus;
37 
38 class NfdIdCollector;
39 
43 class ForwarderGeneralModule : public Module, noncopyable
44 {
45 public:
47 
48  virtual void
49  fetchStatus(Controller& controller,
50  const function<void()>& onSuccess,
51  const Controller::DatasetFailCallback& onFailure,
52  const CommandOptions& options) override;
53 
54  void
55  setNfdIdCollector(const NfdIdCollector& nfdIdCollector)
56  {
57  m_nfdIdCollector = &nfdIdCollector;
58  }
59 
60  virtual void
61  formatStatusXml(std::ostream& os) const override;
62 
68  void
69  formatItemXml(std::ostream& os, const ForwarderStatus& item, const Name& nfdId) const;
70 
71  virtual void
72  formatStatusText(std::ostream& os) const override;
73 
79  void
80  formatItemText(std::ostream& os, const ForwarderStatus& item, const Name& nfdId) const;
81 
82 private:
83  const Name&
84  getNfdId() const;
85 
86 private:
87  const NfdIdCollector* m_nfdIdCollector;
88  ForwarderStatus m_status;
89 };
90 
91 
98 class NfdIdCollector : public ndn::Validator
99 {
100 public:
101  explicit
102  NfdIdCollector(unique_ptr<ndn::Validator> inner);
103 
104  bool
105  hasNfdId() const
106  {
107  return m_hasNfdId;
108  }
109 
110  const Name&
111  getNfdId() const;
112 
113 protected:
114  virtual void
115  checkPolicy(const Interest& interest, int nSteps,
116  const ndn::OnInterestValidated& accept,
117  const ndn::OnInterestValidationFailed& reject,
118  std::vector<shared_ptr<ndn::ValidationRequest>>& nextSteps) override
119  {
120  BOOST_ASSERT(nSteps == 0);
121  m_inner->validate(interest, accept, reject);
122  }
123 
124  virtual void
125  checkPolicy(const Data& data, int nSteps,
126  const ndn::OnDataValidated& accept,
127  const ndn::OnDataValidationFailed& reject,
128  std::vector<shared_ptr<ndn::ValidationRequest>>& nextSteps) override;
129 
130 private:
131  unique_ptr<ndn::Validator> m_inner;
132  bool m_hasNfdId;
133  Name m_nfdId;
134 };
135 
136 } // namespace nfdc
137 } // namespace tools
138 } // namespace nfd
139 
140 #endif // NFD_TOOLS_NFDC_FORWARDER_GENERAL_MODULE_HPP
virtual void formatStatusXml(std::ostream &os) const override
format collected status as XML
void formatItemText(std::ostream &os, const ForwarderStatus &item, const Name &nfdId) const
format a single status item as text
a validator that can collect NFD's signing certificate name
virtual void fetchStatus(Controller &controller, const function< void()> &onSuccess, const Controller::DatasetFailCallback &onFailure, const CommandOptions &options) override
collect status from NFD
NfdIdCollector(unique_ptr< ndn::Validator > inner)
Copyright (c) 2014-2015, Regents of the University of California, Arizona Board of Regents...
Definition: algorithm.hpp:32
void formatItemXml(std::ostream &os, const ForwarderStatus &item, const Name &nfdId) const
format a single status item as XML
provides access to NFD forwarder general status
virtual void formatStatusText(std::ostream &os) const override
format collected status as text
void setNfdIdCollector(const NfdIdCollector &nfdIdCollector)
provides access to an NFD management module
Definition: module.hpp:42
virtual void checkPolicy(const Interest &interest, int nSteps, const ndn::OnInterestValidated &accept, const ndn::OnInterestValidationFailed &reject, std::vector< shared_ptr< ndn::ValidationRequest >> &nextSteps) override