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

#include "common.hpp"

namespace ndn {
namespace ndns {

/**
 * @brief DNS Zone abstraction, which delegates records
 * @see http://en.wikipedia.org/wiki/DNS_zone
 * @see http://irl.cs.ucla.edu/data/files/theses/afanasyev-thesis.pdf
 *
 * This class is copyable, since it may be assigned to another Zone instance
 * when resolving Response or Query from database
 */
class Zone
{
public:
  Zone();

  /**
   * @brief create a Zone instance
   */
  explicit
  Zone(const Name& name, const time::seconds& ttl = time::seconds(3600));

  /**
   * @brief get name of the zone
   */
  const Name&
  getName() const
  {
    return m_name;
  }

  /**
   * @brief set name of the zone
   */
  void
  setName(const Name& name)
  {
    m_name = name;
  }

  /**
   * @brief get the id when the rr is stored in the database
   *  default value is 0, the database has to guarantee that id is greater than 0.
   */
  uint64_t
  getId() const
  {
    return m_id;
  }

  /**
   * @brief set the id when the rr is stored in the database
   *  default value is 0, the database has to guarantee that id is greater than 0.
   */
  void
  setId(uint64_t id)
  {
    m_id = id;
  }

  /**
   * @brief get default ttl of resource record delegated in this zone, measured by seconds.
   * default 3600 (seconds)
   */
  const time::seconds&
  getTtl() const
  {
    return m_ttl;
  }

  /**
   * @brief set default ttl of resource record delegated in this zone, measured by seconds.
   * default 3600 (seconds)
   */
  void
  setTtl(const time::seconds& ttl)
  {
    m_ttl = ttl;
  }

  /**
   * @brief two zones are equal if they have the same name. Zone's name is unique
   */
  bool
  operator==(const Zone& other) const
  {
    return (m_name == other.getName());
  }

  bool
  operator!=(const Zone& other) const
  {
    return (m_name != other.getName());
  }

private:
  uint64_t m_id;

  Name m_name;

  time::seconds m_ttl;
};

std::ostream&
operator<<(std::ostream& os, const Zone& zone);

} // namespace ndns
} // namespace ndn

#endif // NDNS_DAEMON_ZONE_HPP
