/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/**
 * Copyright (c) 2014-2017,  Regents of the University of California,
 *                           Arizona Board of Regents,
 *                           Colorado State University,
 *                           University Pierre & Marie Curie, Sorbonne University,
 *                           Washington University in St. Louis,
 *                           Beijing Institute of Technology,
 *                           The University of Memphis.
 *
 * This file is part of NFD (Named Data Networking Forwarding Daemon).
 * See AUTHORS.md for complete list of NFD authors and contributors.
 *
 * NFD is free software: you can redistribute it and/or modify it under the terms
 * of the GNU General Public License as published by the Free Software Foundation,
 * either version 3 of the License, or (at your option) any later version.
 *
 * NFD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
 * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
 * PURPOSE.  See the GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License along with
 * NFD, e.g., in COPYING.md file.  If not, see <http://www.gnu.org/licenses/>.
 */

#ifndef NFD_TOOLS_NFDC_RIB_MODULE_HPP
#define NFD_TOOLS_NFDC_RIB_MODULE_HPP

#include "module.hpp"
#include "command-parser.hpp"

namespace nfd {
namespace tools {
namespace nfdc {

using ndn::nfd::RibEntry;
using ndn::nfd::Route;

/** \brief provides access to NFD RIB management
 *  \sa https://redmine.named-data.net/projects/nfd/wiki/RibMgmt
 */
class RibModule : public Module, noncopyable
{
public:
  /** \brief register 'route list', 'route show', 'route add', 'route remove' commands
   */
  static void
  registerCommands(CommandParser& parser);

  /** \brief the 'route list' command
   */
  static void
  list(ExecuteContext& ctx);

  /** \brief the 'route show' command
   */
  static void
  show(ExecuteContext& ctx);

  /** \brief the 'route add' command
   */
  static void
  add(ExecuteContext& ctx);

  /** \brief the 'route remove' command
   */
  static void
  remove(ExecuteContext& ctx);

  void
  fetchStatus(Controller& controller,
              const function<void()>& onSuccess,
              const Controller::DatasetFailCallback& onFailure,
              const CommandOptions& options) override;

  void
  formatStatusXml(std::ostream& os) const override;

  void
  formatStatusText(std::ostream& os) const override;

private:
  using RoutePredicate = function<bool(const RibEntry&, const Route&)>;

  static void
  listRoutesImpl(ExecuteContext& ctx, const RoutePredicate& filter);

  /** \brief format a single status item as XML
   *  \param os output stream
   *  \param item status item
   */
  void
  formatItemXml(std::ostream& os, const RibEntry& item) const;

  /** \brief format a RibEntry as text
   *  \param os output stream
   *  \param entry RIB entry
   */
  static void
  formatEntryText(std::ostream& os, const RibEntry& entry);

  /** \brief format a Route as text
   *  \param os output stream
   *  \param entry RIB entry
   *  \param route RIB route within \p entry
   *  \param includePrefix whether to print the name prefix
   */
  static void
  formatRouteText(std::ostream& os, const RibEntry& entry, const Route& route,
                  bool includePrefix);

private:
  std::vector<RibEntry> m_status;
};

} // namespace nfdc
} // namespace tools
} // namespace nfd

#endif // NFD_TOOLS_NFDC_RIB_MODULE_HPP
