resolver_interface.h 2.7 KB

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