PageRenderTime 13ms CodeModel.GetById 1ms app.highlight 9ms RepoModel.GetById 1ms app.codeStats 0ms

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