zone_table_accessor_cache.h 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. // Copyright (C) 2013 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 DATASRC_ZONE_TABLE_ACCESSOR_CACHE_H
  15. #define DATASRC_ZONE_TABLE_ACCESSOR_CACHE_H
  16. #include <datasrc/zone_table_accessor.h>
  17. #include <boost/noncopyable.hpp>
  18. namespace isc {
  19. namespace datasrc {
  20. namespace internal {
  21. class CacheConfig;
  22. /// \brief A \c ZoneTableAccessor implementation for in-memory cache.
  23. ///
  24. /// This class implements the \c ZoneTableAccessor interface for in-memory
  25. /// cache. Its conceptual table consists of the zones that are specified
  26. /// to be loaded into memory in configuration. Note that these zones
  27. /// may or may not actually be loaded in memory. In fact, this class object
  28. /// is intended to be used by applications that load these zones into memory,
  29. /// so that the application can get a list of zones to be loaded. Also, even
  30. /// after loading, some zone may still not be loaded, e.g., due to an error
  31. /// in the corresponding zone file.
  32. ///
  33. /// An object of this class is expected to be returned by
  34. /// \c ConfigurableClientList. Normal applications shouldn't instantiate
  35. /// this class directly. It's still defined to be publicly visible for
  36. /// testing purposes but, to clarify the intent, it's hidden in the
  37. /// "internal" namespace.
  38. class ZoneTableAccessorCache : public ZoneTableAccessor {
  39. public:
  40. /// \brief Constructor.
  41. ///
  42. /// This class takes a \c CacheConfig object and holds it throughout
  43. /// its lifetime. The caller must ensure that the configuration is
  44. /// valid throughout the lifetime of this accessor object.
  45. ///
  46. /// \throw None
  47. ///
  48. /// \param config The cache configuration that the accessor refers to.
  49. ZoneTableAccessorCache(const CacheConfig& config) : config_(config) {}
  50. /// \brief In-memory cache version of \c getIterator().
  51. ///
  52. /// As returned from this version of iterator, \c ZoneSpec::index
  53. /// will always be set to 0 at the moment.
  54. ///
  55. /// \throw None except std::bad_alloc in case of memory allocation failure
  56. virtual IteratorPtr getIterator() const;
  57. private:
  58. const CacheConfig& config_;
  59. };
  60. }
  61. }
  62. }
  63. #endif // DATASRC_ZONE_TABLE_ACCESSOR_CACHE_H
  64. // Local Variables:
  65. // mode: c++
  66. // End: