Realistic 3D camera system
3D camera system components
random_access_handle_service.hpp
Go to the documentation of this file.
1 //
2 // windows/random_access_handle_service.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_RANDOM_ACCESS_HANDLE_SERVICE_HPP
12 #define 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 "asio/detail/config.hpp"
19 
20 #if defined(ASIO_HAS_WINDOWS_RANDOM_ACCESS_HANDLE) \
21  || defined(GENERATING_DOCUMENTATION)
22 
23 #include <cstddef>
24 #include "asio/async_result.hpp"
25 #include "asio/detail/cstdint.hpp"
27 #include "asio/error.hpp"
28 #include "asio/io_service.hpp"
29 
31 
32 namespace asio {
33 namespace windows {
34 
36 class random_access_handle_service
37 #if defined(GENERATING_DOCUMENTATION)
39 #else
40  : public asio::detail::service_base<random_access_handle_service>
41 #endif
42 {
43 public:
44 #if defined(GENERATING_DOCUMENTATION)
45  static asio::io_service::id id;
47 #endif
48 
49 private:
50  // The type of the platform-specific implementation.
51  typedef detail::win_iocp_handle_service service_impl_type;
52 
53 public:
55 #if defined(GENERATING_DOCUMENTATION)
56  typedef implementation_defined implementation_type;
57 #else
58  typedef service_impl_type::implementation_type implementation_type;
59 #endif
60 
62 #if defined(GENERATING_DOCUMENTATION)
63  typedef implementation_defined native_type;
64 #else
65  typedef service_impl_type::native_handle_type native_type;
66 #endif
67 
69 #if defined(GENERATING_DOCUMENTATION)
70  typedef implementation_defined native_handle_type;
71 #else
72  typedef service_impl_type::native_handle_type native_handle_type;
73 #endif
74 
76  explicit random_access_handle_service(asio::io_service& io_service)
77  : asio::detail::service_base<
78  random_access_handle_service>(io_service),
79  service_impl_(io_service)
80  {
81  }
82 
84  void construct(implementation_type& impl)
85  {
86  service_impl_.construct(impl);
87  }
88 
89 #if defined(ASIO_HAS_MOVE) || defined(GENERATING_DOCUMENTATION)
90  void move_construct(implementation_type& impl,
92  implementation_type& other_impl)
93  {
94  service_impl_.move_construct(impl, other_impl);
95  }
96 
98  void move_assign(implementation_type& impl,
99  random_access_handle_service& other_service,
100  implementation_type& other_impl)
101  {
102  service_impl_.move_assign(impl, other_service.service_impl_, other_impl);
103  }
104 #endif // defined(ASIO_HAS_MOVE) || defined(GENERATING_DOCUMENTATION)
105 
107  void destroy(implementation_type& impl)
108  {
109  service_impl_.destroy(impl);
110  }
111 
113  asio::error_code assign(implementation_type& impl,
114  const native_handle_type& handle, asio::error_code& ec)
115  {
116  return service_impl_.assign(impl, handle, ec);
117  }
118 
120  bool is_open(const implementation_type& impl) const
121  {
122  return service_impl_.is_open(impl);
123  }
124 
126  asio::error_code close(implementation_type& impl,
127  asio::error_code& ec)
128  {
129  return service_impl_.close(impl, ec);
130  }
131 
133  native_type native(implementation_type& impl)
134  {
135  return service_impl_.native_handle(impl);
136  }
137 
139  native_handle_type native_handle(implementation_type& impl)
140  {
141  return service_impl_.native_handle(impl);
142  }
143 
145  asio::error_code cancel(implementation_type& impl,
146  asio::error_code& ec)
147  {
148  return service_impl_.cancel(impl, ec);
149  }
150 
152  template <typename ConstBufferSequence>
153  std::size_t write_some_at(implementation_type& impl, uint64_t offset,
154  const ConstBufferSequence& buffers, asio::error_code& ec)
155  {
156  return service_impl_.write_some_at(impl, offset, buffers, ec);
157  }
158 
160  template <typename ConstBufferSequence, typename WriteHandler>
161  ASIO_INITFN_RESULT_TYPE(WriteHandler,
162  void (asio::error_code, std::size_t))
163  async_write_some_at(implementation_type& impl,
164  uint64_t offset, const ConstBufferSequence& buffers,
165  ASIO_MOVE_ARG(WriteHandler) handler)
166  {
168  WriteHandler, void (asio::error_code, std::size_t)> init(
169  ASIO_MOVE_CAST(WriteHandler)(handler));
170 
171  service_impl_.async_write_some_at(impl, offset, buffers, init.handler);
172 
173  return init.result.get();
174  }
175 
177  template <typename MutableBufferSequence>
178  std::size_t read_some_at(implementation_type& impl, uint64_t offset,
179  const MutableBufferSequence& buffers, asio::error_code& ec)
180  {
181  return service_impl_.read_some_at(impl, offset, buffers, ec);
182  }
183 
185  template <typename MutableBufferSequence, typename ReadHandler>
186  ASIO_INITFN_RESULT_TYPE(ReadHandler,
187  void (asio::error_code, std::size_t))
188  async_read_some_at(implementation_type& impl,
189  uint64_t offset, const MutableBufferSequence& buffers,
190  ASIO_MOVE_ARG(ReadHandler) handler)
191  {
193  ReadHandler, void (asio::error_code, std::size_t)> init(
194  ASIO_MOVE_CAST(ReadHandler)(handler));
195 
196  service_impl_.async_read_some_at(impl, offset, buffers, init.handler);
197 
198  return init.result.get();
199  }
200 
201 private:
202  // Destroy all user-defined handler objects owned by the service.
203  void shutdown_service()
204  {
205  service_impl_.shutdown_service();
206  }
207 
208  // The platform-specific implementation.
209  service_impl_type service_impl_;
210 };
211 
212 } // namespace windows
213 } // namespace asio
214 
216 
217 #endif // defined(ASIO_HAS_WINDOWS_RANDOM_ACCESS_HANDLE)
218  // || defined(GENERATING_DOCUMENTATION)
219 
220 #endif // ASIO_WINDOWS_RANDOM_ACCESS_HANDLE_SERVICE_HPP
Class used to uniquely identify a service.
Definition: io_service.hpp:665
Provides core I/O functionality.
Definition: io_service.hpp:184
asio::basic_streambuf< Allocator > MatchCondition enable_if< is_match_condition< MatchCondition >::value >::type *detail::async_result_init< ReadHandler, void(asio::error_code, std::size_t)> init(ASIO_MOVE_CAST(ReadHandler)(handler))
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
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
ASIO_DECL int close(int d, state_type &state, asio::error_code &ec)
#define ASIO_MOVE_CAST(type)
Definition: config.hpp:138
Base class for all io_service services.
Definition: io_service.hpp:674