zone_table_config.h 3.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  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_CONFIG_H
  15. #define DATASRC_ZONE_TABLE_CONFIG_H
  16. #include <dns/name.h>
  17. #include <cc/data.h>
  18. #include <datasrc/memory/load_action.h>
  19. #include <map>
  20. #include <string>
  21. namespace isc {
  22. namespace datasrc {
  23. class DataSourceClient;
  24. namespace internal {
  25. /// This class is intended to be an interface between DataSourceClient and
  26. /// memory ZoneTableSegment implementations. This class understands the
  27. /// configuration parameters for DataSourceClient related to in-memory cache,
  28. /// and convert it to native, type-safe objects so that it can be used by
  29. /// ZoneTableSegment implementations. It also provides unified interface
  30. /// for getting a list of zones to be loaded in to memory and
  31. /// and memory::LoadAction object that can be used for the load, regardless
  32. /// of the underlying data source properties, i.e., whether it's special
  33. /// "MasterFiles" type or other generic data sources.
  34. ///
  35. /// This class is publicly defined because it has to be referenced by both
  36. /// DataSourceClient and ZoneTableSegment (other than for testing purposes),
  37. /// but it's essentially private to these two classes. It's therefore
  38. /// defined in an "internal" namespace, and isn't expected to be used by
  39. /// other classes or user applications. Likewise, this file is not expected
  40. /// to be installed with other publicly usable header files.
  41. class ZoneTableConfig {
  42. public:
  43. ZoneTableConfig(const std::string& datasrc_type,
  44. const DataSourceClient* datasrc_client,
  45. const data::Element& datasrc_conf);
  46. /// Return corresponding \c LoadAction for the given name of zone.
  47. /// It would return a different functor depending on the details of the
  48. /// underlying data source.
  49. memory::LoadAction getLoadAction(const dns::Name& zone_name) const;
  50. /// This allows ZoneTableSegment to iterate over all zones to be loaded
  51. /// in to memory. In this initial implementation we directly give
  52. /// read-only access to the underlying map to minimize the diff, but
  53. /// it's not clean in terms of encapsulation and performance (eventually
  54. /// we may have to look up in the underlying data source to get the list
  55. /// of zones, in which case constructing a map can be very expensive).
  56. typedef std::map<dns::Name, std::string> Zones;
  57. const Zones& getZoneConfig() const { return (zone_config_); }
  58. private:
  59. // client of underlying data source, will be NULL for MasterFile datasrc
  60. const DataSourceClient* datasrc_client_;
  61. Zones zone_config_;
  62. };
  63. }
  64. }
  65. }
  66. #endif // DATASRC_ZONE_TABLE_CONFIG_H
  67. // Local Variables:
  68. // mode: c++
  69. // End: