/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
 * Copyright (c) 2014-2022,  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_DAEMON_FACE_PROTOCOL_FACTORY_HPP
#define NFD_DAEMON_FACE_PROTOCOL_FACTORY_HPP

#include "channel.hpp"
#include "face.hpp"
#include "face-system.hpp"

#include <boost/range/adaptor/map.hpp>
#include <boost/range/algorithm/copy.hpp>

namespace nfd {
namespace face {

/** \brief Parameters to ProtocolFactory constructor
 *
 *  Every ProtocolFactory subclass is expected to have a constructor that accepts CtorParams,
 *  which in turn passes it to ProtocolFactory base class constructor. Parameters are passed as a
 *  struct rather than individually, so that a future change in list of parameters does not
 *  require updates to subclass constructors.
 */
struct ProtocolFactoryCtorParams
{
  FaceCreatedCallback addFace;
  shared_ptr<ndn::net::NetworkMonitor> netmon;
};

/** \brief Provides support for an underlying protocol
 *  \sa FaceSystem
 *
 *  A protocol factory provides support for an underlying protocol and owns Channel objects.
 *  It can process a subsection of face_system config section and create channels and multicast
 *  faces accordingly.
 */
class ProtocolFactory : noncopyable
{
public: // registry
  using CtorParams = ProtocolFactoryCtorParams;

  /** \brief Register a protocol factory type
   *  \tparam PF subclass of ProtocolFactory
   *  \param id factory identifier
   */
  template<typename PF>
  static void
  registerType(const std::string& id = PF::getId())
  {
    BOOST_ASSERT(!id.empty());
    auto r = getRegistry().insert_or_assign(id, [] (auto&&... p) {
      return make_unique<PF>(std::forward<decltype(p)>(p)...);
    });
    BOOST_VERIFY(r.second);
  }

  /** \brief Create a protocol factory instance
   *  \retval nullptr if a factory with the given \p id is not registered
   */
  static unique_ptr<ProtocolFactory>
  create(const std::string& id, const CtorParams& params);

  /** \brief Get all registered protocol factory ids
   */
  static std::set<std::string>
  listRegistered();

public:
  /** \brief Base class for all exceptions thrown by ProtocolFactory subclasses
   */
  class Error : public std::runtime_error
  {
  public:
    using std::runtime_error::runtime_error;
  };

  explicit
  ProtocolFactory(const CtorParams& params);

  virtual
  ~ProtocolFactory() = 0;

#ifdef DOXYGEN
  /** \brief Get id for this protocol factory
   *
   *  face_system.factory-id config section is processed by the protocol factory.
   */
  static const std::string&
  getId() noexcept;
#endif

  /** \brief Get FaceUri schemes accepted by this protocol factory
   */
  const std::set<std::string>&
  getProvidedSchemes() const
  {
    return providedSchemes;
  }

  /** \brief Process face_system subsection that corresponds to this protocol factory id
   *  \param configSection the configuration section or boost::none to indicate it is omitted
   *  \param context provides access to data structures and contextual information
   *  \throw ConfigFile::Error invalid configuration
   */
  void
  processConfig(OptionalConfigSection configSection, FaceSystem::ConfigContext& context);

  /** \brief Encapsulates a face creation request and all its parameters
   *
   *  Parameters are passed as a struct rather than individually, so that a future change in the list
   *  of parameters does not require an update to the method signature in all subclasses.
   */
  struct CreateFaceRequest
  {
    FaceUri remoteUri;
    std::optional<FaceUri> localUri;
    FaceParams params;
  };

  /** \brief Create a unicast face
   *  \param req request object containing the face creation parameters
   *  \param onCreated callback if face creation succeeds or face already exists; the settings
   *                   of an existing face are not updated if they differ from the request
   *  \param onFailure callback if face creation fails
   */
  void
  createFace(const CreateFaceRequest& req,
             const FaceCreatedCallback& onCreated,
             const FaceCreationFailedCallback& onFailure);

  /** \brief Create a netdev-bound face
   *  \param remote remote FaceUri, must be canonical
   *  \param netdev local network interface
   *  \return new face
   *  \throw Error cannot create a face using specified arguments
   *  \note The caller must ensure there is no existing netdev-bound face with same remote FaceUri
   *        on the same local network interface.
   */
  shared_ptr<Face>
  createNetdevBoundFace(const FaceUri& remote,
                        const shared_ptr<const ndn::net::NetworkInterface>& netdev);

  /** \brief Get list of open channels (listening + non-listening)
   */
  std::vector<shared_ptr<const Channel>>
  getChannels() const;

protected:
  template<typename ChannelMap>
  static std::vector<shared_ptr<const Channel>>
  getChannelsFromMap(const ChannelMap& channelMap)
  {
    std::vector<shared_ptr<const Channel>> channels;
    boost::copy(channelMap | boost::adaptors::map_values, std::back_inserter(channels));
    return channels;
  }

private:
  /** \brief Process face_system subsection that corresponds to this protocol factory id
   *  \sa processConfig
   *
   *  A subclass should override this method if it supports configuration options in the config
   *  file, and do all the required processing here. The subclass should throw ConfigFile::Error
   *  if it encounters unrecognized options or invalid values. It should also update
   *  \p providedSchemes as needed.
   *
   *  The base class implementation does nothing.
   */
  virtual void
  doProcessConfig(OptionalConfigSection configSection, FaceSystem::ConfigContext& context);

  /** \brief Create a unicast face
   *  \sa createFace
   *
   *  The base class implementation always invokes the failure callback with error code 406,
   *  indicating unicast face creation is not supported.
   */
  virtual void
  doCreateFace(const CreateFaceRequest& req,
               const FaceCreatedCallback& onCreated,
               const FaceCreationFailedCallback& onFailure);

  /** \brief Create a netdev-bound face
   *  \sa createNetdevBoundFace
   *
   *  The base class implementation always throws Error, indicating netdev-bound faces are not
   *  supported.
   *
   *  A subclass that offers netdev-bound faces should override this method, and also expose
   *  "scheme+dev" in providedSchemes. For example, UdpFactory should provide "udp4+dev" scheme,
   *  in addition to "udp4" scheme.
   *
   *  The face should be constructed immediately. Face persistency shall be reported as PERMANENT.
   *  Face state shall remain DOWN until underlying transport is connected. The face shall remain
   *  open until after .close() is invoked, and survive all socket errors; in case the network
   *  interface disappears, the face shall remain DOWN until .close() is invoked.
   */
  virtual shared_ptr<Face>
  doCreateNetdevBoundFace(const FaceUri& remote,
                          const shared_ptr<const ndn::net::NetworkInterface>& netif);

  /** \brief Get list of open channels (listening + non-listening)
   *  \sa getChannels
   *
   *  The base class implementation returns an empty list.
   */
  virtual std::vector<shared_ptr<const Channel>>
  doGetChannels() const;

private: // registry
  using CreateFunc = std::function<unique_ptr<ProtocolFactory>(const CtorParams&)>;
  using Registry = std::map<std::string, CreateFunc>; // indexed by factory id

  static Registry&
  getRegistry();

protected:
  std::set<std::string> providedSchemes; ///< FaceUri schemes provided by this protocol factory
  FaceCreatedCallback addFace; ///< callback when a new face is created

  /** \brief NetworkMonitor for listing available network interfaces and monitoring their changes
   *
   *  ProtocolFactory subclass should check the NetworkMonitor has sufficient capabilities prior
   *  to usage.
   */
  shared_ptr<ndn::net::NetworkMonitor> netmon;
};

} // namespace face
} // namespace nfd

/** \brief Registers a protocol factory
 *
 *  This macro should appear once in the .cpp file of each protocol factory.
 */
#define NFD_REGISTER_PROTOCOL_FACTORY(PF)                      \
static class NfdAuto ## PF ## ProtocolFactoryRegistrationClass \
{                                                              \
public:                                                        \
  NfdAuto ## PF ## ProtocolFactoryRegistrationClass()          \
  {                                                            \
    ::nfd::face::ProtocolFactory::registerType<PF>();          \
  }                                                            \
} g_nfdAuto ## PF ## ProtocolFactoryRegistrationVariable

#endif // NFD_DAEMON_FACE_PROTOCOL_FACTORY_HPP
