1 | // |
2 | // posix/descriptor_base.hpp |
3 | // ~~~~~~~~~~~~~~~~~~~~~~~~~ |
4 | // |
5 | // Copyright (c) 2003-2015 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 | |
11 | #ifndef BOOST_ASIO_POSIX_DESCRIPTOR_BASE_HPP |
12 | #define BOOST_ASIO_POSIX_DESCRIPTOR_BASE_HPP |
13 | |
14 | #if defined(_MSC_VER) && (_MSC_VER >= 1200) |
15 | # pragma once |
16 | #endif // defined(_MSC_VER) && (_MSC_VER >= 1200) |
17 | |
18 | #include <boost/asio/detail/config.hpp> |
19 | |
20 | #if defined(BOOST_ASIO_HAS_POSIX_STREAM_DESCRIPTOR) \ |
21 | || defined(GENERATING_DOCUMENTATION) |
22 | |
23 | #include <boost/asio/detail/io_control.hpp> |
24 | #include <boost/asio/detail/socket_option.hpp> |
25 | |
26 | #include <boost/asio/detail/push_options.hpp> |
27 | |
28 | namespace boost { |
29 | namespace asio { |
30 | namespace posix { |
31 | |
32 | /// The descriptor_base class is used as a base for the basic_stream_descriptor |
33 | /// class template so that we have a common place to define the associated |
34 | /// IO control commands. |
35 | class descriptor_base |
36 | { |
37 | public: |
38 | /// (Deprecated: Use non_blocking().) IO control command to set the blocking |
39 | /// mode of the descriptor. |
40 | /** |
41 | * Implements the FIONBIO IO control command. |
42 | * |
43 | * @par Example |
44 | * @code |
45 | * boost::asio::posix::stream_descriptor descriptor(io_service); |
46 | * ... |
47 | * boost::asio::descriptor_base::non_blocking_io command(true); |
48 | * descriptor.io_control(command); |
49 | * @endcode |
50 | * |
51 | * @par Concepts: |
52 | * IoControlCommand. |
53 | */ |
54 | #if defined(GENERATING_DOCUMENTATION) |
55 | typedef implementation_defined non_blocking_io; |
56 | #else |
57 | typedef boost::asio::detail::io_control::non_blocking_io non_blocking_io; |
58 | #endif |
59 | |
60 | /// IO control command to get the amount of data that can be read without |
61 | /// blocking. |
62 | /** |
63 | * Implements the FIONREAD IO control command. |
64 | * |
65 | * @par Example |
66 | * @code |
67 | * boost::asio::posix::stream_descriptor descriptor(io_service); |
68 | * ... |
69 | * boost::asio::descriptor_base::bytes_readable command(true); |
70 | * descriptor.io_control(command); |
71 | * std::size_t bytes_readable = command.get(); |
72 | * @endcode |
73 | * |
74 | * @par Concepts: |
75 | * IoControlCommand. |
76 | */ |
77 | #if defined(GENERATING_DOCUMENTATION) |
78 | typedef implementation_defined bytes_readable; |
79 | #else |
80 | typedef boost::asio::detail::io_control::bytes_readable bytes_readable; |
81 | #endif |
82 | |
83 | protected: |
84 | /// Protected destructor to prevent deletion through this type. |
85 | ~descriptor_base() |
86 | { |
87 | } |
88 | }; |
89 | |
90 | } // namespace posix |
91 | } // namespace asio |
92 | } // namespace boost |
93 | |
94 | #include <boost/asio/detail/pop_options.hpp> |
95 | |
96 | #endif // defined(BOOST_ASIO_HAS_POSIX_STREAM_DESCRIPTOR) |
97 | // || defined(GENERATING_DOCUMENTATION) |
98 | |
99 | #endif // BOOST_ASIO_POSIX_DESCRIPTOR_BASE_HPP |
100 | |