Shock Jiang | 30ad892 | 2014-09-04 15:08:52 -0700 | [diff] [blame^] | 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
| 2 | /** |
| 3 | * Copyright (c) 2014, Regents of the University of California. |
| 4 | * |
| 5 | * This file is part of NDNS (Named Data Networking Domain Name Service). |
| 6 | * See AUTHORS.md for complete list of NDNS authors and contributors. |
| 7 | * |
| 8 | * NDNS is free software: you can redistribute it and/or modify it under the terms |
| 9 | * of the GNU General Public License as published by the Free Software Foundation, |
| 10 | * either version 3 of the License, or (at your option) any later version. |
| 11 | * |
| 12 | * NDNS is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; |
| 13 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR |
| 14 | * PURPOSE. See the GNU General Public License for more details. |
| 15 | * |
| 16 | * You should have received a copy of the GNU General Public License along with |
| 17 | * NDNS, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>. |
| 18 | */ |
| 19 | |
| 20 | #ifndef NDNS_ZONE_HPP |
| 21 | #define NDNS_ZONE_HPP |
| 22 | |
| 23 | #include <ndn-cxx/name.hpp> |
| 24 | #include <iostream> |
| 25 | |
| 26 | namespace ndn { |
| 27 | namespace ndns { |
| 28 | |
| 29 | /** |
| 30 | * @brief DNS Zone abstraction, which delegates records |
| 31 | * @see http://en.wikipedia.org/wiki/DNS_zone |
| 32 | * @see http://irl.cs.ucla.edu/data/files/theses/afanasyev-thesis.pdf |
| 33 | * |
| 34 | * The class is copyable, since it may be assigned to another Zone instance |
| 35 | * when resolving Response or Query from database |
| 36 | */ |
| 37 | class Zone |
| 38 | { |
| 39 | public: |
| 40 | Zone(); |
| 41 | |
| 42 | /** |
| 43 | * @brief create a Zone instance |
| 44 | */ |
| 45 | explicit |
| 46 | Zone(const Name& name); |
| 47 | |
| 48 | const Name& |
| 49 | getName() const |
| 50 | { |
| 51 | return m_name; |
| 52 | } |
| 53 | |
| 54 | void |
| 55 | setName(const Name& name) |
| 56 | { |
| 57 | m_name = name; |
| 58 | } |
| 59 | |
| 60 | uint32_t |
| 61 | getId() const |
| 62 | { |
| 63 | return m_id; |
| 64 | } |
| 65 | |
| 66 | void |
| 67 | setId(uint32_t id) |
| 68 | { |
| 69 | m_id = id; |
| 70 | } |
| 71 | |
| 72 | bool |
| 73 | operator==(const Zone& other) const |
| 74 | { |
| 75 | return (m_name == other.getName()); |
| 76 | } |
| 77 | |
| 78 | private: |
| 79 | /** |
| 80 | * @brief the id when the rr is stored in the database |
| 81 | * default value is 0, the database has to guarantee that id is greater than 0. |
| 82 | */ |
| 83 | uint32_t m_id; |
| 84 | |
| 85 | /** |
| 86 | * @brief the zone's name, which means all its |
| 87 | * delegated subzones or labels are under this namespace |
| 88 | */ |
| 89 | Name m_name; |
| 90 | }; |
| 91 | |
| 92 | std::ostream& |
| 93 | operator<<(std::ostream& os, const Zone& zone); |
| 94 | |
| 95 | } // namespace ndns |
| 96 | } // namespace ndn |
| 97 | |
| 98 | #endif // NDNS_ZONE_HPP |