rib-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_RIB_MODULE_HPP
27 #define NFD_TOOLS_NFDC_RIB_MODULE_HPP
28 
29 #include "module.hpp"
30 #include "command-parser.hpp"
31 
32 namespace nfd {
33 namespace tools {
34 namespace nfdc {
35 
36 using ndn::nfd::RibEntry;
37 using ndn::nfd::Route;
38 
42 class RibModule : public Module, noncopyable
43 {
44 public:
47  static void
49 
52  static void
53  list(ExecuteContext& ctx);
54 
57  static void
58  show(ExecuteContext& ctx);
59 
62  static void
63  add(ExecuteContext& ctx);
64 
67  static void
68  remove(ExecuteContext& ctx);
69 
70  void
71  fetchStatus(Controller& controller,
72  const function<void()>& onSuccess,
73  const Controller::DatasetFailCallback& onFailure,
74  const CommandOptions& options) override;
75 
76  void
77  formatStatusXml(std::ostream& os) const override;
78 
79  void
80  formatStatusText(std::ostream& os) const override;
81 
82 private:
83  using RoutePredicate = function<bool(const RibEntry&, const Route&)>;
84 
85  static void
86  listRoutesImpl(ExecuteContext& ctx, const RoutePredicate& filter);
87 
92  void
93  formatItemXml(std::ostream& os, const RibEntry& item) const;
94 
99  static void
100  formatEntryText(std::ostream& os, const RibEntry& entry);
101 
108  static void
109  formatRouteText(std::ostream& os, const RibEntry& entry, const Route& route,
110  bool includePrefix);
111 
112 private:
113  std::vector<RibEntry> m_status;
114 };
115 
116 } // namespace nfdc
117 } // namespace tools
118 } // namespace nfd
119 
120 #endif // NFD_TOOLS_NFDC_RIB_MODULE_HPP
context for command execution
static void list(ExecuteContext &ctx)
the &#39;route list&#39; command
Definition: rib-module.cpp:72
void formatStatusText(std::ostream &os) const override
format collected status as text
Definition: rib-module.cpp:321
Copyright (c) 2014-2015, Regents of the University of California, Arizona Board of Regents...
Definition: algorithm.hpp:32
void formatStatusXml(std::ostream &os) const override
format collected status as XML
Definition: rib-module.cpp:273
provides access to NFD RIB management
Definition: rib-module.hpp:42
static void add(ExecuteContext &ctx)
the &#39;route add&#39; command
Definition: rib-module.cpp:143
static void registerCommands(CommandParser &parser)
register &#39;route list&#39;, &#39;route show&#39;, &#39;route add&#39;, &#39;route remove&#39; commands
Definition: rib-module.cpp:35
provides access to an NFD management module
Definition: module.hpp:43
static void show(ExecuteContext &ctx)
the &#39;route show&#39; command
Definition: rib-module.cpp:106
void fetchStatus(Controller &controller, const function< void()> &onSuccess, const Controller::DatasetFailCallback &onFailure, const CommandOptions &options) override
collect status from NFD
Definition: rib-module.cpp:259