dns_answer.h 3.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. // Copyright (C) 2011 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 __ASIOLINK_DNS_ANSWER_H
  15. #define __ASIOLINK_DNS_ANSWER_H 1
  16. #include <asiolink/io_message.h>
  17. namespace asiolink {
  18. /// \brief The \c DNSAnswer class is an abstract base class for a DNS
  19. /// Answer provider function.
  20. ///
  21. /// Specific derived class implementations are hidden within the
  22. /// implementation. Instances of the derived classes can be called
  23. /// as functions via the operator() interface. Pointers to these
  24. /// instances can then be provided to the \c IOService class
  25. /// via its constructor.
  26. ///
  27. /// A DNS Answer provider function takes answer data that has been obtained
  28. /// from a DNS Lookup provider functon and readies it to be sent to the
  29. /// client. After it has run, the OutputBuffer object passed to it should
  30. /// contain the answer to the query rendered into wire format.
  31. class DNSAnswer {
  32. ///
  33. /// \name Constructors and Destructor
  34. ///
  35. /// Note: The copy constructor and the assignment operator are
  36. /// intentionally defined as private, making this class non-copyable.
  37. //@{
  38. private:
  39. DNSAnswer(const DNSAnswer& source);
  40. DNSAnswer& operator=(const DNSAnswer& source);
  41. protected:
  42. /// \brief The default constructor.
  43. ///
  44. /// This is intentionally defined as \c protected as this base class
  45. /// should never be instantiated (except as part of a derived class).
  46. DNSAnswer() {}
  47. public:
  48. /// \brief The destructor
  49. virtual ~DNSAnswer() {}
  50. //@}
  51. /// \brief The function operator
  52. ///
  53. /// This makes its call indirectly via the "self" pointer, ensuring
  54. /// that the function ultimately invoked will be the one in the derived
  55. /// class.
  56. ///
  57. /// \param io_message The event message to handle
  58. /// \param query_message The DNS MessagePtr of the original query
  59. /// \param answer_message The DNS MessagePtr of the answer we are
  60. /// building
  61. /// \param buffer Intermediate data results are put here
  62. virtual void operator()(const IOMessage& io_message,
  63. isc::dns::MessagePtr query_message,
  64. isc::dns::MessagePtr answer_message,
  65. isc::dns::OutputBufferPtr buffer) const = 0;
  66. };
  67. } // namespace asiolink
  68. #endif // __ASIOLINK_DNS_ANSWER_H