/Src/Dependencies/Boost/boost/asio/windows/random_access_handle_service.hpp

http://hadesmem.googlecode.com/ · C++ Header · 208 lines · 142 code · 33 blank · 33 comment · 3 complexity · 139293378f5e1a288a63bf3dcff8027f MD5 · raw file

  1. //
  2. // windows/random_access_handle_service.hpp
  3. // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  4. //
  5. // Copyright (c) 2003-2011 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_WINDOWS_RANDOM_ACCESS_HANDLE_SERVICE_HPP
  11. #define BOOST_ASIO_WINDOWS_RANDOM_ACCESS_HANDLE_SERVICE_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/config.hpp>
  16. #if defined(BOOST_ASIO_HAS_WINDOWS_RANDOM_ACCESS_HANDLE) \
  17. || defined(GENERATING_DOCUMENTATION)
  18. #include <cstddef>
  19. #include <boost/config.hpp>
  20. #include <boost/cstdint.hpp>
  21. #include <boost/asio/detail/win_iocp_handle_service.hpp>
  22. #include <boost/asio/error.hpp>
  23. #include <boost/asio/io_service.hpp>
  24. #include <boost/asio/detail/push_options.hpp>
  25. namespace boost {
  26. namespace asio {
  27. namespace windows {
  28. /// Default service implementation for a random-access handle.
  29. class random_access_handle_service
  30. #if defined(GENERATING_DOCUMENTATION)
  31. : public boost::asio::io_service::service
  32. #else
  33. : public boost::asio::detail::service_base<random_access_handle_service>
  34. #endif
  35. {
  36. public:
  37. #if defined(GENERATING_DOCUMENTATION)
  38. /// The unique service identifier.
  39. static boost::asio::io_service::id id;
  40. #endif
  41. private:
  42. // The type of the platform-specific implementation.
  43. typedef detail::win_iocp_handle_service service_impl_type;
  44. public:
  45. /// The type of a random-access handle implementation.
  46. #if defined(GENERATING_DOCUMENTATION)
  47. typedef implementation_defined implementation_type;
  48. #else
  49. typedef service_impl_type::implementation_type implementation_type;
  50. #endif
  51. /// (Deprecated: Use native_handle_type.) The native handle type.
  52. #if defined(GENERATING_DOCUMENTATION)
  53. typedef implementation_defined native_type;
  54. #else
  55. typedef service_impl_type::native_handle_type native_type;
  56. #endif
  57. /// The native handle type.
  58. #if defined(GENERATING_DOCUMENTATION)
  59. typedef implementation_defined native_handle_type;
  60. #else
  61. typedef service_impl_type::native_handle_type native_handle_type;
  62. #endif
  63. /// Construct a new random-access handle service for the specified io_service.
  64. explicit random_access_handle_service(boost::asio::io_service& io_service)
  65. : boost::asio::detail::service_base<
  66. random_access_handle_service>(io_service),
  67. service_impl_(io_service)
  68. {
  69. }
  70. /// Construct a new random-access handle implementation.
  71. void construct(implementation_type& impl)
  72. {
  73. service_impl_.construct(impl);
  74. }
  75. #if defined(BOOST_ASIO_HAS_MOVE) || defined(GENERATING_DOCUMENTATION)
  76. /// Move-construct a new random-access handle implementation.
  77. void move_construct(implementation_type& impl,
  78. implementation_type& other_impl)
  79. {
  80. service_impl_.move_construct(impl, other_impl);
  81. }
  82. /// Move-assign from another random-access handle implementation.
  83. void move_assign(implementation_type& impl,
  84. random_access_handle_service& other_service,
  85. implementation_type& other_impl)
  86. {
  87. service_impl_.move_assign(impl, other_service.service_impl_, other_impl);
  88. }
  89. #endif // defined(BOOST_ASIO_HAS_MOVE) || defined(GENERATING_DOCUMENTATION)
  90. /// Destroy a random-access handle implementation.
  91. void destroy(implementation_type& impl)
  92. {
  93. service_impl_.destroy(impl);
  94. }
  95. /// Assign an existing native handle to a random-access handle.
  96. boost::system::error_code assign(implementation_type& impl,
  97. const native_handle_type& handle, boost::system::error_code& ec)
  98. {
  99. return service_impl_.assign(impl, handle, ec);
  100. }
  101. /// Determine whether the handle is open.
  102. bool is_open(const implementation_type& impl) const
  103. {
  104. return service_impl_.is_open(impl);
  105. }
  106. /// Close a random-access handle implementation.
  107. boost::system::error_code close(implementation_type& impl,
  108. boost::system::error_code& ec)
  109. {
  110. return service_impl_.close(impl, ec);
  111. }
  112. /// (Deprecated: Use native_handle().) Get the native handle implementation.
  113. native_type native(implementation_type& impl)
  114. {
  115. return service_impl_.native_handle(impl);
  116. }
  117. /// Get the native handle implementation.
  118. native_handle_type native_handle(implementation_type& impl)
  119. {
  120. return service_impl_.native_handle(impl);
  121. }
  122. /// Cancel all asynchronous operations associated with the handle.
  123. boost::system::error_code cancel(implementation_type& impl,
  124. boost::system::error_code& ec)
  125. {
  126. return service_impl_.cancel(impl, ec);
  127. }
  128. /// Write the given data at the specified offset.
  129. template <typename ConstBufferSequence>
  130. std::size_t write_some_at(implementation_type& impl, boost::uint64_t offset,
  131. const ConstBufferSequence& buffers, boost::system::error_code& ec)
  132. {
  133. return service_impl_.write_some_at(impl, offset, buffers, ec);
  134. }
  135. /// Start an asynchronous write at the specified offset.
  136. template <typename ConstBufferSequence, typename WriteHandler>
  137. void async_write_some_at(implementation_type& impl,
  138. boost::uint64_t offset, const ConstBufferSequence& buffers,
  139. BOOST_ASIO_MOVE_ARG(WriteHandler) handler)
  140. {
  141. service_impl_.async_write_some_at(impl, offset, buffers,
  142. BOOST_ASIO_MOVE_CAST(WriteHandler)(handler));
  143. }
  144. /// Read some data from the specified offset.
  145. template <typename MutableBufferSequence>
  146. std::size_t read_some_at(implementation_type& impl, boost::uint64_t offset,
  147. const MutableBufferSequence& buffers, boost::system::error_code& ec)
  148. {
  149. return service_impl_.read_some_at(impl, offset, buffers, ec);
  150. }
  151. /// Start an asynchronous read at the specified offset.
  152. template <typename MutableBufferSequence, typename ReadHandler>
  153. void async_read_some_at(implementation_type& impl,
  154. boost::uint64_t offset, const MutableBufferSequence& buffers,
  155. BOOST_ASIO_MOVE_ARG(ReadHandler) handler)
  156. {
  157. service_impl_.async_read_some_at(impl, offset, buffers,
  158. BOOST_ASIO_MOVE_CAST(ReadHandler)(handler));
  159. }
  160. private:
  161. // Destroy all user-defined handler objects owned by the service.
  162. void shutdown_service()
  163. {
  164. service_impl_.shutdown_service();
  165. }
  166. // The platform-specific implementation.
  167. service_impl_type service_impl_;
  168. };
  169. } // namespace windows
  170. } // namespace asio
  171. } // namespace boost
  172. #include <boost/asio/detail/pop_options.hpp>
  173. #endif // defined(BOOST_ASIO_HAS_WINDOWS_RANDOM_ACCESS_HANDLE)
  174. // || defined(GENERATING_DOCUMENTATION)
  175. #endif // BOOST_ASIO_WINDOWS_RANDOM_ACCESS_HANDLE_SERVICE_HPP