/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/**
 * Copyright (c) 2017-2020, Regents of the University of California.
 *
 * This file is part of ndncert, a certificate management system based on NDN.
 *
 * ndncert 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.
 *
 * ndncert 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 copies of the GNU General Public License along with
 * ndncert, e.g., in COPYING.md file.  If not, see <http://www.gnu.org/licenses/>.
 *
 * See AUTHORS.md for complete list of ndncert authors and contributors.
 */

#ifndef NDNCERT_ASSIGNMENT_FUNCS_HPP
#define NDNCERT_ASSIGNMENT_FUNCS_HPP

#include "detail/ca-request-state.hpp"

namespace ndn {
namespace ndncert {

class NameAssignmentFunc : noncopyable
{
public:
  explicit NameAssignmentFunc(const std::string& factoryType, const std::string& format = "");

  virtual ~NameAssignmentFunc() = default;

  /**
   * @brief The name assignment function provided by the CA operator to generate available
   * namecomponents.
   *
   * The function does not guarantee that all the returned names are available. Therefore the
   * CA should further check the availability of each returned name and remove unavailable results.
   *
   * @param vector A list of parameter key-value pair used for name assignment.
   * @return a vector containing the possible namespaces derived from the parameters.
   */
  virtual std::vector<PartialName>
  assignName(const std::vector<std::tuple<std::string, std::string>>& params) = 0;

  const std::string FACTORY_TYPE;
  std::vector<std::string> m_nameFormat;

public:
  template <class ChallengeType>
  static void
  registerNameAssignmentFunc(const std::string& typeName)
  {
    FuncFactoryFactory& factory = getFactory();
    BOOST_ASSERT(factory.count(typeName) == 0);
    factory[typeName] = [](const std::string& format) { return std::make_unique<ChallengeType>(format); };
  }

  static unique_ptr<NameAssignmentFunc>
  createNameAssignmentFunc(const std::string& challengeType, const std::string& format = "");

private:
  typedef function<unique_ptr<NameAssignmentFunc>(const std::string&)> FactoryCreateFunc;
  typedef std::map<std::string, FactoryCreateFunc> FuncFactoryFactory;

  static FuncFactoryFactory&
  getFactory();
};

#define NDNCERT_REGISTER_FUNCFACTORY(C, T)                                        \
  static class NdnCert##C##FuncFactoryRegistrationClass {                         \
  public:                                                                         \
    NdnCert##C##FuncFactoryRegistrationClass()                                    \
    {                                                                             \
      ::ndn::ndncert::NameAssignmentFunc::registerNameAssignmentFunc<C>(T);       \
    }                                                                             \
  } g_NdnCert##C##ChallengeRegistrationVariable

} // namespace ndncert
} // namespace ndn

#endif // NDNCERT_ASSIGNMENT_FUNCS_HPP
