Realistic 3D camera system
3D camera system components
basic_random_access_handle.hpp
Go to the documentation of this file.
1 //
2 // windows/basic_random_access_handle.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 ASIO_WINDOWS_BASIC_RANDOM_ACCESS_HANDLE_HPP
12 #define ASIO_WINDOWS_BASIC_RANDOM_ACCESS_HANDLE_HPP
13 
14 #if defined(_MSC_VER) && (_MSC_VER >= 1200)
15 # pragma once
16 #endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
17 
18 #include "asio/detail/config.hpp"
19 
20 #if defined(ASIO_HAS_WINDOWS_RANDOM_ACCESS_HANDLE) \
21  || defined(GENERATING_DOCUMENTATION)
22 
23 #include <cstddef>
26 #include "asio/error.hpp"
29 
31 
32 namespace asio {
33 namespace windows {
34 
36 
44 template <typename RandomAccessHandleService = random_access_handle_service>
45 class basic_random_access_handle
46  : public basic_handle<RandomAccessHandleService>
47 {
48 public:
51  typedef typename RandomAccessHandleService::native_handle_type native_type;
52 
54  typedef typename RandomAccessHandleService::native_handle_type
55  native_handle_type;
56 
58 
66  explicit basic_random_access_handle(asio::io_service& io_service)
67  : basic_handle<RandomAccessHandleService>(io_service)
68  {
69  }
70 
72 
84  basic_random_access_handle(asio::io_service& io_service,
85  const native_handle_type& handle)
86  : basic_handle<RandomAccessHandleService>(io_service, handle)
87  {
88  }
89 
90 #if defined(ASIO_HAS_MOVE) || defined(GENERATING_DOCUMENTATION)
91 
102  basic_random_access_handle(basic_random_access_handle&& other)
103  : basic_handle<RandomAccessHandleService>(
104  ASIO_MOVE_CAST(basic_random_access_handle)(other))
105  {
106  }
107 
109 
120  basic_random_access_handle& operator=(basic_random_access_handle&& other)
121  {
122  basic_handle<RandomAccessHandleService>::operator=(
123  ASIO_MOVE_CAST(basic_random_access_handle)(other));
124  return *this;
125  }
126 #endif // defined(ASIO_HAS_MOVE) || defined(GENERATING_DOCUMENTATION)
127 
129 
157  template <typename ConstBufferSequence>
158  std::size_t write_some_at(uint64_t offset,
159  const ConstBufferSequence& buffers)
160  {
161  asio::error_code ec;
162  std::size_t s = this->get_service().write_some_at(
163  this->get_implementation(), offset, buffers, ec);
164  asio::detail::throw_error(ec, "write_some_at");
165  return s;
166  }
167 
169 
186  template <typename ConstBufferSequence>
187  std::size_t write_some_at(uint64_t offset,
188  const ConstBufferSequence& buffers, asio::error_code& ec)
189  {
190  return this->get_service().write_some_at(
191  this->get_implementation(), offset, buffers, ec);
192  }
193 
195 
231  template <typename ConstBufferSequence, typename WriteHandler>
232  ASIO_INITFN_RESULT_TYPE(WriteHandler,
233  void (asio::error_code, std::size_t))
234  async_write_some_at(uint64_t offset,
235  const ConstBufferSequence& buffers,
236  ASIO_MOVE_ARG(WriteHandler) handler)
237  {
238  // If you get an error on the following line it means that your handler does
239  // not meet the documented type requirements for a WriteHandler.
240  ASIO_WRITE_HANDLER_CHECK(WriteHandler, handler) type_check;
241 
242  return this->get_service().async_write_some_at(this->get_implementation(),
243  offset, buffers, ASIO_MOVE_CAST(WriteHandler)(handler));
244  }
245 
247 
276  template <typename MutableBufferSequence>
277  std::size_t read_some_at(uint64_t offset,
278  const MutableBufferSequence& buffers)
279  {
280  asio::error_code ec;
281  std::size_t s = this->get_service().read_some_at(
282  this->get_implementation(), offset, buffers, ec);
283  asio::detail::throw_error(ec, "read_some_at");
284  return s;
285  }
286 
288 
306  template <typename MutableBufferSequence>
307  std::size_t read_some_at(uint64_t offset,
308  const MutableBufferSequence& buffers, asio::error_code& ec)
309  {
310  return this->get_service().read_some_at(
311  this->get_implementation(), offset, buffers, ec);
312  }
313 
315 
352  template <typename MutableBufferSequence, typename ReadHandler>
353  ASIO_INITFN_RESULT_TYPE(ReadHandler,
354  void (asio::error_code, std::size_t))
355  async_read_some_at(uint64_t offset,
356  const MutableBufferSequence& buffers,
357  ASIO_MOVE_ARG(ReadHandler) handler)
358  {
359  // If you get an error on the following line it means that your handler does
360  // not meet the documented type requirements for a ReadHandler.
361  ASIO_READ_HANDLER_CHECK(ReadHandler, handler) type_check;
362 
363  return this->get_service().async_read_some_at(this->get_implementation(),
364  offset, buffers, ASIO_MOVE_CAST(ReadHandler)(handler));
365  }
366 };
367 
368 } // namespace windows
369 } // namespace asio
370 
371 #include "asio/detail/pop_options.hpp"
372 
373 #endif // defined(ASIO_HAS_WINDOWS_RANDOM_ACCESS_HANDLE)
374  // || defined(GENERATING_DOCUMENTATION)
375 
376 #endif // ASIO_WINDOWS_BASIC_RANDOM_ACCESS_HANDLE_HPP
void throw_error(const asio::error_code &err)
Definition: throw_error.hpp:31
Provides core I/O functionality.
Definition: io_service.hpp:184
SocketService & s
Definition: connect.hpp:521
STL namespace.
uint64_t offset
Definition: read_at.hpp:571
ASIO_INITFN_RESULT_TYPE(ComposedConnectHandler, void(asio::error_code, Iterator)) async_connect(basic_socket< Protocol
const MutableBufferSequence & buffers
Definition: read.hpp:521
#define ASIO_READ_HANDLER_CHECK(handler_type, handler)
asio::basic_streambuf< Allocator > CompletionCondition ASIO_MOVE_ARG(ReadHandler) handler)
Definition: read.hpp:704
Class to represent an error code value.
Definition: error_code.hpp:80
#define ASIO_MOVE_CAST(type)
Definition: config.hpp:138
#define ASIO_WRITE_HANDLER_CHECK(handler_type, handler)