descriptor_base.hpp 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. //
  2. // descriptor_base.hpp
  3. // ~~~~~~~~~~~~~~~~~~~
  4. //
  5. // Copyright (c) 2003-2008 Christopher M. Kohlhoff (chris at kohlhoff dot com)
  6. //
  7. // Distributed under the Boost Software License, Version 1.0. (See accompanying
  8. // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
  9. //
  10. #ifndef BOOST_ASIO_POSIX_DESCRIPTOR_BASE_HPP
  11. #define BOOST_ASIO_POSIX_DESCRIPTOR_BASE_HPP
  12. #if defined(_MSC_VER) && (_MSC_VER >= 1200)
  13. # pragma once
  14. #endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
  15. #include <boost/asio/detail/push_options.hpp>
  16. #include <boost/asio/detail/push_options.hpp>
  17. #include <boost/config.hpp>
  18. #include <boost/detail/workaround.hpp>
  19. #include <boost/asio/detail/pop_options.hpp>
  20. #include <boost/asio/detail/io_control.hpp>
  21. #include <boost/asio/detail/socket_option.hpp>
  22. namespace boost {
  23. namespace asio {
  24. namespace posix {
  25. /// The descriptor_base class is used as a base for the basic_stream_descriptor
  26. /// class template so that we have a common place to define the associated
  27. /// IO control commands.
  28. class descriptor_base
  29. {
  30. public:
  31. /// IO control command to set the blocking mode of the descriptor.
  32. /**
  33. * Implements the FIONBIO IO control command.
  34. *
  35. * @par Example
  36. * @code
  37. * boost::asio::posix::stream_descriptor descriptor(io_service);
  38. * ...
  39. * boost::asio::descriptor_base::non_blocking_io command(true);
  40. * descriptor.io_control(command);
  41. * @endcode
  42. *
  43. * @par Concepts:
  44. * IoControlCommand.
  45. */
  46. #if defined(GENERATING_DOCUMENTATION)
  47. typedef implementation_defined non_blocking_io;
  48. #else
  49. typedef boost::asio::detail::io_control::non_blocking_io non_blocking_io;
  50. #endif
  51. /// IO control command to get the amount of data that can be read without
  52. /// blocking.
  53. /**
  54. * Implements the FIONREAD IO control command.
  55. *
  56. * @par Example
  57. * @code
  58. * boost::asio::posix::stream_descriptor descriptor(io_service);
  59. * ...
  60. * boost::asio::descriptor_base::bytes_readable command(true);
  61. * descriptor.io_control(command);
  62. * std::size_t bytes_readable = command.get();
  63. * @endcode
  64. *
  65. * @par Concepts:
  66. * IoControlCommand.
  67. */
  68. #if defined(GENERATING_DOCUMENTATION)
  69. typedef implementation_defined bytes_readable;
  70. #else
  71. typedef boost::asio::detail::io_control::bytes_readable bytes_readable;
  72. #endif
  73. protected:
  74. /// Protected destructor to prevent deletion through this type.
  75. ~descriptor_base()
  76. {
  77. }
  78. };
  79. } // namespace posix
  80. } // namespace asio
  81. } // namespace boost
  82. #include <boost/asio/detail/pop_options.hpp>
  83. #endif // BOOST_ASIO_POSIX_DESCRIPTOR_BASE_HPP