Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011 #ifndef ASIO_WINDOWS_STREAM_HANDLE_SERVICE_HPP
00012 #define ASIO_WINDOWS_STREAM_HANDLE_SERVICE_HPP
00013
00014 #if defined(_MSC_VER) && (_MSC_VER >= 1200)
00015 # pragma once
00016 #endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
00017
00018 #include "asio/detail/push_options.hpp"
00019
00020 #include "asio/detail/push_options.hpp"
00021 #include <cstddef>
00022 #include <boost/config.hpp>
00023 #include "asio/detail/pop_options.hpp"
00024
00025 #include "asio/error.hpp"
00026 #include "asio/io_service.hpp"
00027 #include "asio/detail/service_base.hpp"
00028 #include "asio/detail/win_iocp_handle_service.hpp"
00029
00030 #if !defined(ASIO_DISABLE_WINDOWS_STREAM_HANDLE)
00031 # if defined(ASIO_HAS_IOCP)
00032 # define ASIO_HAS_WINDOWS_STREAM_HANDLE 1
00033 # endif // defined(ASIO_HAS_IOCP)
00034 #endif // !defined(ASIO_DISABLE_WINDOWS_STREAM_HANDLE)
00035
00036 #if defined(ASIO_HAS_WINDOWS_STREAM_HANDLE) \
00037 || defined(GENERATING_DOCUMENTATION)
00038
00039 namespace asio {
00040 namespace windows {
00041
00043 class stream_handle_service
00044 #if defined(GENERATING_DOCUMENTATION)
00045 : public asio::io_service::service
00046 #else
00047 : public asio::detail::service_base<stream_handle_service>
00048 #endif
00049 {
00050 public:
00051 #if defined(GENERATING_DOCUMENTATION)
00052
00053 static asio::io_service::id id;
00054 #endif
00055
00056 private:
00057
00058 typedef detail::win_iocp_handle_service service_impl_type;
00059
00060 public:
00062 #if defined(GENERATING_DOCUMENTATION)
00063 typedef implementation_defined implementation_type;
00064 #else
00065 typedef service_impl_type::implementation_type implementation_type;
00066 #endif
00067
00069 #if defined(GENERATING_DOCUMENTATION)
00070 typedef implementation_defined native_type;
00071 #else
00072 typedef service_impl_type::native_type native_type;
00073 #endif
00074
00076 explicit stream_handle_service(asio::io_service& io_service)
00077 : asio::detail::service_base<stream_handle_service>(io_service),
00078 service_impl_(asio::use_service<service_impl_type>(io_service))
00079 {
00080 }
00081
00083 void shutdown_service()
00084 {
00085 }
00086
00088 void construct(implementation_type& impl)
00089 {
00090 service_impl_.construct(impl);
00091 }
00092
00094 void destroy(implementation_type& impl)
00095 {
00096 service_impl_.destroy(impl);
00097 }
00098
00100 asio::error_code assign(implementation_type& impl,
00101 const native_type& native_handle, asio::error_code& ec)
00102 {
00103 return service_impl_.assign(impl, native_handle, ec);
00104 }
00105
00107 bool is_open(const implementation_type& impl) const
00108 {
00109 return service_impl_.is_open(impl);
00110 }
00111
00113 asio::error_code close(implementation_type& impl,
00114 asio::error_code& ec)
00115 {
00116 return service_impl_.close(impl, ec);
00117 }
00118
00120 native_type native(implementation_type& impl)
00121 {
00122 return service_impl_.native(impl);
00123 }
00124
00126 asio::error_code cancel(implementation_type& impl,
00127 asio::error_code& ec)
00128 {
00129 return service_impl_.cancel(impl, ec);
00130 }
00131
00133 template <typename ConstBufferSequence>
00134 std::size_t write_some(implementation_type& impl,
00135 const ConstBufferSequence& buffers, asio::error_code& ec)
00136 {
00137 return service_impl_.write_some(impl, buffers, ec);
00138 }
00139
00141 template <typename ConstBufferSequence, typename WriteHandler>
00142 void async_write_some(implementation_type& impl,
00143 const ConstBufferSequence& buffers, WriteHandler handler)
00144 {
00145 service_impl_.async_write_some(impl, buffers, handler);
00146 }
00147
00149 template <typename MutableBufferSequence>
00150 std::size_t read_some(implementation_type& impl,
00151 const MutableBufferSequence& buffers, asio::error_code& ec)
00152 {
00153 return service_impl_.read_some(impl, buffers, ec);
00154 }
00155
00157 template <typename MutableBufferSequence, typename ReadHandler>
00158 void async_read_some(implementation_type& impl,
00159 const MutableBufferSequence& buffers, ReadHandler handler)
00160 {
00161 service_impl_.async_read_some(impl, buffers, handler);
00162 }
00163
00164 private:
00165
00166 service_impl_type& service_impl_;
00167 };
00168
00169 }
00170 }
00171
00172 #endif // defined(ASIO_HAS_WINDOWS_STREAM_HANDLE)
00173
00174
00175 #include "asio/detail/pop_options.hpp"
00176
00177 #endif // ASIO_WINDOWS_STREAM_HANDLE_SERVICE_HPP