zonetable.h 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. // Copyright (C) 2010 Internet Systems Consortium, Inc. ("ISC")
  2. //
  3. // Permission to use, copy, modify, and/or distribute this software for any
  4. // purpose with or without fee is hereby granted, provided that the above
  5. // copyright notice and this permission notice appear in all copies.
  6. //
  7. // THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
  8. // REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
  9. // AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
  10. // INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
  11. // LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
  12. // OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  13. // PERFORMANCE OF THIS SOFTWARE.
  14. #ifndef __ZONETABLE_H
  15. #define __ZONETABLE_H 1
  16. #include <boost/shared_ptr.hpp>
  17. #include <dns/rrset.h>
  18. #include <datasrc/zone.h>
  19. namespace isc {
  20. namespace dns {
  21. class Name;
  22. class RRClass;
  23. }
  24. namespace datasrc {
  25. /// \brief A set of authoritative zones.
  26. ///
  27. /// \c ZoneTable class is primarily intended to be used as a backend for the
  28. /// \c MemoryDataSrc class, but is exposed as a separate class in case some
  29. /// application wants to use it directly (e.g. for a customized data source
  30. /// implementation).
  31. ///
  32. /// For more descriptions about its struct and interfaces, please refer to the
  33. /// corresponding struct and interfaces of \c MemoryDataSrc.
  34. class ZoneTable {
  35. public:
  36. struct FindResult {
  37. FindResult(result::Result param_code, const ZonePtr param_zone) :
  38. code(param_code), zone(param_zone)
  39. {}
  40. const result::Result code;
  41. const ZonePtr zone;
  42. };
  43. ///
  44. /// \name Constructors and Destructor.
  45. ///
  46. /// \b Note:
  47. /// The copy constructor and the assignment operator are intentionally
  48. /// defined as private, making this class non copyable.
  49. //@{
  50. private:
  51. ZoneTable(const ZoneTable& source);
  52. ZoneTable& operator=(const ZoneTable& source);
  53. public:
  54. /// Default constructor.
  55. ///
  56. /// This constructor internally involves resource allocation, and if
  57. /// it fails, a corresponding standard exception will be thrown.
  58. /// It never throws an exception otherwise.
  59. ZoneTable();
  60. /// The destructor.
  61. ~ZoneTable();
  62. //@}
  63. /// Add a \c Zone to the \c ZoneTable.
  64. ///
  65. /// \c Zone must not be associated with a NULL pointer; otherwise
  66. /// an exception of class \c InvalidParameter will be thrown.
  67. /// If internal resource allocation fails, a corresponding standard
  68. /// exception will be thrown.
  69. /// This method never throws an exception otherwise.
  70. ///
  71. /// \param zone A \c Zone object to be added.
  72. /// \return \c result::SUCCESS If the zone is successfully
  73. /// added to the zone table.
  74. /// \return \c result::EXIST The zone table already contains
  75. /// zone of the same origin.
  76. result::Result addZone(ZonePtr zone);
  77. /// Remove a \c Zone of the given origin name from the \c ZoneTable.
  78. ///
  79. /// This method never throws an exception.
  80. ///
  81. /// \param origin The origin name of the zone to be removed.
  82. /// \return \c result::SUCCESS If the zone is successfully
  83. /// removed from the zone table.
  84. /// \return \c result::NOTFOUND The zone table does not
  85. /// store the zone that matches \c origin.
  86. result::Result removeZone(const isc::dns::Name& origin);
  87. /// Find a \c Zone that best matches the given name in the \c ZoneTable.
  88. ///
  89. /// It searches the internal storage for a \c Zone that gives the
  90. /// longest match against \c name, and returns the result in the
  91. /// form of a \c FindResult object as follows:
  92. /// - \c code: The result code of the operation.
  93. /// - \c result::SUCCESS: A zone that gives an exact match
  94. /// is found
  95. /// - \c result::PARTIALMATCH: A zone whose origin is a
  96. /// super domain of \c name is found (but there is no exact match)
  97. /// - \c result::NOTFOUND: For all other cases.
  98. /// - \c zone: A <Boost> shared pointer to the found \c Zone object if one
  99. /// is found; otherwise \c NULL.
  100. ///
  101. /// This method never throws an exception.
  102. ///
  103. /// \param name A domain name for which the search is performed.
  104. /// \return A \c FindResult object enclosing the search result (see above).
  105. FindResult findZone(const isc::dns::Name& name) const;
  106. private:
  107. struct ZoneTableImpl;
  108. ZoneTableImpl* impl_;
  109. };
  110. }
  111. }
  112. #endif // __ZONETABLE_H
  113. // Local Variables:
  114. // mode: c++
  115. // End: