dummy_io_cb.h 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  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 __DUMMY_IO_CB_H
  15. #define __DUMMY_IO_CB_H
  16. #include <iostream>
  17. #include <asio/error.hpp>
  18. #include <asio/error_code.hpp>
  19. namespace isc {
  20. namespace asiolink {
  21. /// \brief Asynchronous I/O Completion Callback
  22. ///
  23. /// The two socket classes (UDPSocket and TCPSocket) require that the I/O
  24. /// completion callback function have an operator() method with the appropriate
  25. /// signature. The classes are templates, any class with that method and
  26. /// signature can be passed as the callback object - there is no need for a
  27. /// base class defining the interface. However, some users of the socket
  28. /// classes do not use the asynchronous I/O operations, yet have to supply a
  29. /// template parameter. This is the reason for this class - it is the dummy
  30. /// template parameter.
  31. class DummyIOCallback {
  32. public:
  33. /// \brief Asynchronous I/O callback method
  34. ///
  35. /// TODO: explain why this method should never be called.
  36. /// This should be unused.
  37. void operator()(asio::error_code)
  38. {
  39. // TODO: log an error if this method ever gets called.
  40. }
  41. /// \brief Asynchronous I/O callback method
  42. ///
  43. /// TODO: explain why this method should never be called.
  44. /// This should be unused.
  45. void operator()(asio::error_code, size_t)
  46. {
  47. // TODO: log an error if this method ever gets called.
  48. }
  49. };
  50. } // namespace asiolink
  51. } // namespace isc
  52. #endif // __DUMMY_IO_CB_H