zone_table_accessor_cache.h 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  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 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. /// of 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. /// it directly. It's still defined publicly visibly for testing purpose,
  36. /// but to clarify the intent it's hidden in the "internal" namespace.
  37. class ZoneTableAccessorCache : public ZoneTableAccessor {
  38. public:
  39. /// \brief Constructor.
  40. ///
  41. /// This class takes a \c CacheConfig object and holds it throughout
  42. /// its lifetime. The caller must ensure the configuration is valid
  43. /// throughout the lifetime of this accessor object.
  44. ///
  45. /// \throw None
  46. ///
  47. /// \param config The cache configuration that the accessor refers to.
  48. ZoneTableAccessorCache(const CacheConfig& config) : config_(config) {}
  49. /// \brief in-memmory cache version of getIterator().
  50. ///
  51. /// From this version of iterator, `ZoneSpec::index` will always be set
  52. /// to 0 at the moment.
  53. ///
  54. /// \throw None except std::bad_alloc in case of memory allocation failure
  55. virtual IteratorPtr getIterator() const;
  56. private:
  57. const CacheConfig& config_;
  58. };
  59. }
  60. }
  61. }
  62. #endif // DATASRC_ZONE_TABLE_ACCESSOR_CACHE_H
  63. // Local Variables:
  64. // mode: c++
  65. // End: