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

  /**
   * @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
