/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
 * Copyright (c) 2014-2018, Regents of the University of California.
 *
 * This file is part of NDNS (Named Data Networking Domain Name Service).
 * See AUTHORS.md for complete list of NDNS authors and contributors.
 *
 * NDNS 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.
 *
 * NDNS 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
 * NDNS, e.g., in COPYING.md file.  If not, see <http://www.gnu.org/licenses/>.
 */

#ifndef NDNS_CLIENTS_QUERY_CONTROLLER_HPP
#define NDNS_CLIENTS_QUERY_CONTROLLER_HPP

#include "query.hpp"
#include "response.hpp"

#include <ndn-cxx/data.hpp>
#include <ndn-cxx/interest.hpp>
#include <ndn-cxx/name.hpp>
#include <ndn-cxx/face.hpp>


namespace ndn {
namespace ndns {

/**
 * @brief callback function when succeeding getting the final Response
 * @param[in] Data the Data packet which contains the Response, client should verify the packet
 * @param[in] Response the Final Response converted from Data
 */
typedef function<void(const Data&, const Response&)> QuerySucceedCallback;

/**
 * @brief callback function when failing to get the final Response
 */
typedef function<void(uint32_t errCode, const std::string& errMsg)> QueryFailCallback;

/**
 * @brief a Query Controller interface
 *
 */
class QueryController : noncopyable
{
public:
  QueryController(const Name& dstLabel, const name::Component& rrType,
                  const time::milliseconds& interestLifetime,
                  const QuerySucceedCallback& onSucceed, const QueryFailCallback& onFail,
                  Face& face);

  virtual
  ~QueryController() = default;

  /**
   * @brief start query process.
   */
  virtual void
  start() = 0;

  /**
   * @brief should keep sending query, or has ended yet,
   */
  virtual bool
  hasEnded() = 0;

  virtual void
  setStartComponentIndex(size_t startIndex) = 0;

public:
  ////////////////
  // getter

  const Name&
  getDstLabel() const
  {
    return m_dstLabel;
  }

  const time::milliseconds&
  getInterestLifetime() const
  {
    return m_interestLifetime;
  }

  const name::Component&
  getRrType() const
  {
    return m_rrType;
  }

protected:
  const Name m_dstLabel;
  const name::Component m_rrType;
  const time::milliseconds m_interestLifetime;

  const QuerySucceedCallback m_onSucceed;
  const QueryFailCallback m_onFail;

  Face& m_face;

};

std::ostream&
operator<<(std::ostream& os, const QueryController& ctr);

} // namespace ndns
} // namespace ndn

#endif // NDNS_CLIENTS_QUERY_CONTROLLER_HPP
