resolver_interface.h 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. // Copyright (C) 2010 CZ NIC
  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 __RESOLVER_INTERFACE_H
  15. #define __RESOLVER_INTERFACE_H
  16. #include <dns/message.h>
  17. #include <dns/rrset.h>
  18. /**
  19. * \file resolver_interface.h
  20. * \short Temporary interface to resolver.
  21. *
  22. * This file contains a dummy interface for the resolver, which does not yet
  23. * exist. When the resolver appears, this file should either wrap its
  24. * interface or, better, be removed completely.
  25. */
  26. namespace isc {
  27. namespace nsas {
  28. /**
  29. * \short Abstract interface to the resolver.
  30. *
  31. * Abstract interface to the resolver. The NameserverAddressStore uses this
  32. * to ask for addresses. It is here because resolver does not yet exist.
  33. *
  34. * It is abstract to allow tests pass dummy resolvers.
  35. */
  36. class ResolverInterface {
  37. public:
  38. /// \short An abstract callback when data from resolver are ready.
  39. class Callback {
  40. public:
  41. /// \short Some data arrived.
  42. virtual void success(
  43. const boost::shared_ptr<isc::dns::AbstractRRset>&
  44. response) = 0;
  45. /**
  46. * \short No data available.
  47. *
  48. * \todo Pass some reason.
  49. */
  50. virtual void failure() = 0;
  51. /// \short Virtual destructor, so descendants are cleaned up
  52. virtual ~ Callback() {};
  53. };
  54. typedef boost::shared_ptr<Callback> CallbackPtr;
  55. /**
  56. * \short Ask a question.
  57. *
  58. * Asks the resolver a question. Once the answer is ready
  59. * the callback is called.
  60. *
  61. * \param question What to ask. The resolver will decide who.
  62. * \param callback What should happen when the answer is ready.
  63. */
  64. virtual void resolve(const isc::dns::QuestionPtr& question,
  65. const CallbackPtr& callback) = 0;
  66. /// \short Virtual destructor, so descendants are properly cleaned up
  67. virtual ~ ResolverInterface() {}
  68. };
  69. } // namespace nsas
  70. } // namespace isc
  71. #endif //__RESOLVER_INTERFACE_H