xfrout_client.h 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. // Copyright (C) 2010 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 XFROUT_CLIENT_H
  15. #define XFROUT_CLIENT_H
  16. #include <stdint.h>
  17. #include <string>
  18. #include <exceptions/exceptions.h>
  19. namespace isc {
  20. namespace xfr {
  21. struct XfroutClientImpl;
  22. class XfroutError: public Exception {
  23. public:
  24. XfroutError(const char *file, size_t line, const char *what):
  25. isc::Exception(file, line, what) {}
  26. };
  27. /// \brief The AbstractXfroutClient class is an abstract base class that
  28. /// defines the interfaces of XfroutClient.
  29. ///
  30. /// The intended primary usage of abstraction is to allow tests for the
  31. /// user class of XfroutClient without requiring actual communication.
  32. class AbstractXfroutClient {
  33. ///
  34. /// \name Constructors, Assignment Operator and Destructor.
  35. ///
  36. /// Note: The copy constructor and the assignment operator are
  37. /// intentionally defined as private to make it explicit that this is a
  38. /// pure base class.
  39. //@{
  40. private:
  41. AbstractXfroutClient(const AbstractXfroutClient& source);
  42. AbstractXfroutClient& operator=(const AbstractXfroutClient& source);
  43. protected:
  44. /// \brief The default constructor.
  45. ///
  46. /// This is intentionally defined as \c protected as this base class should
  47. /// never be instantiated (except as part of a derived class).
  48. AbstractXfroutClient() {}
  49. public:
  50. /// \brief The destructor.
  51. virtual ~AbstractXfroutClient() {}
  52. //@}
  53. virtual void connect() = 0;
  54. virtual void disconnect() = 0;
  55. virtual int sendXfroutRequestInfo(int tcp_sock, const void* msg_data,
  56. uint16_t msg_len) = 0;
  57. };
  58. class XfroutClient : public AbstractXfroutClient {
  59. public:
  60. XfroutClient(const std::string& file);
  61. ~XfroutClient();
  62. private:
  63. // make this class non copyable
  64. XfroutClient(const XfroutClient& source);
  65. XfroutClient& operator=(const XfroutClient& source);
  66. public:
  67. virtual void connect();
  68. virtual void disconnect();
  69. virtual int sendXfroutRequestInfo(int tcp_sock, const void* msg_data,
  70. uint16_t msg_len);
  71. private:
  72. XfroutClientImpl* impl_;
  73. };
  74. } // End for namespace xfr
  75. } // End for namespace isc
  76. #endif
  77. // Local Variables:
  78. // mode: c++
  79. // End: