/** NDN-Atmos: Cataloging Service for distributed data originally developed
 *  for atmospheric science data
 *  Copyright (C) 2015 Colorado State University
 *
 *  NDN-Atmos 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.
 *
 *  NDN-Atmos 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 NDN-Atmos.  If not, see <http://www.gnu.org/licenses/>.
**/

#ifndef ATMOS_UTIL_CATALOG_ADAPTER_HPP
#define ATMOS_UTIL_CATALOG_ADAPTER_HPP

#include <ndn-cxx/data.hpp>
#include <ndn-cxx/face.hpp>
#include <ndn-cxx/interest.hpp>
#include <ndn-cxx/name.hpp>
#include <ndn-cxx/security/key-chain.hpp>
#include <ndn-cxx/encoding/block.hpp>

#include <memory>
#include <string>

#include <iostream>
#include "util/config-file.hpp"


namespace atmos {
namespace util {

/**
 * Catalog Adapter acts as a common interface for Classes that need to register as Interest Filters
 *
 * Both QueryAdapter and PublisherAdapter use this as a template to allow consistancy between
 * their designs and flow-control
 */
class CatalogAdapter {
public:
  class Error : public std::runtime_error
  {
  public:
    explicit
    Error(const std::string& what)
      : std::runtime_error(what)
    {
    }
  };

  /**
   * Constructor
   * @param face:       Face that will be used for NDN communications
   * @param keyChain:   KeyChain that will be used for data signing
   */
  CatalogAdapter(const std::shared_ptr<ndn::Face>& face,
                 const std::shared_ptr<ndn::KeyChain>& keyChain);

  virtual
  ~CatalogAdapter();

  /**
   * Helper function that sets the configuration section handler
   * @param config: ConfigFile object to set the handler
   * @param prefix: Catalog prefix
   * @param nameFields: string vector that contains filter category names
   * @param databaseTable: table name in the database
   */
  virtual void
  setConfigFile(util::ConfigFile& config,
                const ndn::Name& prefix,
                const std::vector<std::string>& nameFields,
                const std::string& databaseTable) = 0;

protected:

  /**
   * Callback function that handles the section parsing jobs
   */
  virtual void
  onConfig(const util::ConfigSection& section,
           bool isDryDun,
           const std::string& fileName,
           const ndn::Name& prefix) = 0;

  // @{ (onData and onTimeout) and/or onInterest should be overwritten at a minimum

  /**
   * Timeout from a Data request
   *
   * @param interest: Interest that failed to be satisfied (within the timelimit)
   */
  virtual void
  onTimeout(const ndn::Interest& interest);

  /**
   * Callback that should/can be used to evaluate that the Interest Filter has been correctly set up
   *
   * @param prefix: Name that will be routed to this class
   */
  virtual void
  onRegisterSuccess(const ndn::Name& prefix);

  /**
   * Callback that should/can be used to evaluate that the Interest Filter has been correctly set up
   *
   * @param prefix: Name that failed to route
   * @param reason: String explanation as to why the failure occured
   */
  virtual void
  onRegisterFailure(const ndn::Name& prefix, const std::string& reason);

protected:
  // Face to communicate with
  const std::shared_ptr<ndn::Face> m_face;
  // KeyChain used for data signing
  const std::shared_ptr<ndn::KeyChain> m_keyChain;
  ndn::Name m_prefix;
  // Name for the signing key
  ndn::Name m_signingId;
  std::vector<std::string> m_nameFields;
  std::string m_databaseTable;
}; // class CatalogAdapter


} // namespace util
} // namespace atmos

#endif //ATMOS_UTIL_CATALOG_ADAPTER_HPP
