Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011 #ifndef ASIO_WINDOWS_BASIC_HANDLE_HPP
00012 #define ASIO_WINDOWS_BASIC_HANDLE_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 <boost/config.hpp>
00022 #include "asio/detail/pop_options.hpp"
00023
00024 #include "asio/basic_io_object.hpp"
00025 #include "asio/error.hpp"
00026 #include "asio/detail/throw_error.hpp"
00027
00028 namespace asio {
00029 namespace windows {
00030
00032
00040 template <typename HandleService>
00041 class basic_handle
00042 : public basic_io_object<HandleService>
00043 {
00044 public:
00046 typedef typename HandleService::native_type native_type;
00047
00049 typedef basic_handle<HandleService> lowest_layer_type;
00050
00052
00058 explicit basic_handle(asio::io_service& io_service)
00059 : basic_io_object<HandleService>(io_service)
00060 {
00061 }
00062
00064
00074 basic_handle(asio::io_service& io_service,
00075 const native_type& native_handle)
00076 : basic_io_object<HandleService>(io_service)
00077 {
00078 asio::error_code ec;
00079 this->service.assign(this->implementation, native_handle, ec);
00080 asio::detail::throw_error(ec);
00081 }
00082
00084
00092 lowest_layer_type& lowest_layer()
00093 {
00094 return *this;
00095 }
00096
00098
00099
00100
00101
00102
00103
00104
00105 void assign(const native_type& native_handle)
00106 {
00107 asio::error_code ec;
00108 this->service.assign(this->implementation, native_handle, ec);
00109 asio::detail::throw_error(ec);
00110 }
00111
00113
00114
00115
00116
00117
00118
00119
00120 asio::error_code assign(const native_type& native_handle,
00121 asio::error_code& ec)
00122 {
00123 return this->service.assign(this->implementation, native_handle, ec);
00124 }
00125
00127 bool is_open() const
00128 {
00129 return this->service.is_open(this->implementation);
00130 }
00131
00133
00140 void close()
00141 {
00142 asio::error_code ec;
00143 this->service.close(this->implementation, ec);
00144 asio::detail::throw_error(ec);
00145 }
00146
00148
00155 asio::error_code close(asio::error_code& ec)
00156 {
00157 return this->service.close(this->implementation, ec);
00158 }
00159
00161
00166 native_type native()
00167 {
00168 return this->service.native(this->implementation);
00169 }
00170
00172
00179 void cancel()
00180 {
00181 asio::error_code ec;
00182 this->service.cancel(this->implementation, ec);
00183 asio::detail::throw_error(ec);
00184 }
00185
00187
00194 asio::error_code cancel(asio::error_code& ec)
00195 {
00196 return this->service.cancel(this->implementation, ec);
00197 }
00198
00199 protected:
00201 ~basic_handle()
00202 {
00203 }
00204 };
00205
00206 }
00207 }
00208
00209 #include "asio/detail/pop_options.hpp"
00210
00211 #endif // ASIO_WINDOWS_BASIC_HANDLE_HPP