Realistic 3D camera system
3D camera system components
stream_handle_service.hpp
Go to the documentation of this file.
1 //
2 // windows/stream_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_STREAM_HANDLE_SERVICE_HPP
12 #define ASIO_WINDOWS_STREAM_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_STREAM_HANDLE) \
21  || defined(GENERATING_DOCUMENTATION)
22 
23 #include <cstddef>
24 #include "asio/async_result.hpp"
26 #include "asio/error.hpp"
27 #include "asio/io_service.hpp"
28 
30 
31 namespace asio {
32 namespace windows {
33 
35 class stream_handle_service
36 #if defined(GENERATING_DOCUMENTATION)
38 #else
39  : public asio::detail::service_base<stream_handle_service>
40 #endif
41 {
42 public:
43 #if defined(GENERATING_DOCUMENTATION)
44  static asio::io_service::id id;
46 #endif
47 
48 private:
49  // The type of the platform-specific implementation.
50  typedef detail::win_iocp_handle_service service_impl_type;
51 
52 public:
54 #if defined(GENERATING_DOCUMENTATION)
55  typedef implementation_defined implementation_type;
56 #else
57  typedef service_impl_type::implementation_type implementation_type;
58 #endif
59 
61 #if defined(GENERATING_DOCUMENTATION)
62  typedef implementation_defined native_type;
63 #else
64  typedef service_impl_type::native_handle_type native_type;
65 #endif
66 
68 #if defined(GENERATING_DOCUMENTATION)
69  typedef implementation_defined native_handle_type;
70 #else
71  typedef service_impl_type::native_handle_type native_handle_type;
72 #endif
73 
75  explicit stream_handle_service(asio::io_service& io_service)
76  : asio::detail::service_base<stream_handle_service>(io_service),
77  service_impl_(io_service)
78  {
79  }
80 
82  void construct(implementation_type& impl)
83  {
84  service_impl_.construct(impl);
85  }
86 
87 #if defined(ASIO_HAS_MOVE) || defined(GENERATING_DOCUMENTATION)
88  void move_construct(implementation_type& impl,
90  implementation_type& other_impl)
91  {
92  service_impl_.move_construct(impl, other_impl);
93  }
94 
96  void move_assign(implementation_type& impl,
97  stream_handle_service& other_service,
98  implementation_type& other_impl)
99  {
100  service_impl_.move_assign(impl, other_service.service_impl_, other_impl);
101  }
102 #endif // defined(ASIO_HAS_MOVE) || defined(GENERATING_DOCUMENTATION)
103 
105  void destroy(implementation_type& impl)
106  {
107  service_impl_.destroy(impl);
108  }
109 
111  asio::error_code assign(implementation_type& impl,
112  const native_handle_type& handle, asio::error_code& ec)
113  {
114  return service_impl_.assign(impl, handle, ec);
115  }
116 
118  bool is_open(const implementation_type& impl) const
119  {
120  return service_impl_.is_open(impl);
121  }
122 
124  asio::error_code close(implementation_type& impl,
125  asio::error_code& ec)
126  {
127  return service_impl_.close(impl, ec);
128  }
129 
131  native_type native(implementation_type& impl)
132  {
133  return service_impl_.native_handle(impl);
134  }
135 
137  native_handle_type native_handle(implementation_type& impl)
138  {
139  return service_impl_.native_handle(impl);
140  }
141 
143  asio::error_code cancel(implementation_type& impl,
144  asio::error_code& ec)
145  {
146  return service_impl_.cancel(impl, ec);
147  }
148 
150  template <typename ConstBufferSequence>
151  std::size_t write_some(implementation_type& impl,
152  const ConstBufferSequence& buffers, asio::error_code& ec)
153  {
154  return service_impl_.write_some(impl, buffers, ec);
155  }
156 
158  template <typename ConstBufferSequence, typename WriteHandler>
159  ASIO_INITFN_RESULT_TYPE(WriteHandler,
160  void (asio::error_code, std::size_t))
161  async_write_some(implementation_type& impl,
162  const ConstBufferSequence& buffers,
163  ASIO_MOVE_ARG(WriteHandler) handler)
164  {
166  WriteHandler, void (asio::error_code, std::size_t)> init(
167  ASIO_MOVE_CAST(WriteHandler)(handler));
168 
169  service_impl_.async_write_some(impl, buffers, init.handler);
170 
171  return init.result.get();
172  }
173 
175  template <typename MutableBufferSequence>
176  std::size_t read_some(implementation_type& impl,
177  const MutableBufferSequence& buffers, asio::error_code& ec)
178  {
179  return service_impl_.read_some(impl, buffers, ec);
180  }
181 
183  template <typename MutableBufferSequence, typename ReadHandler>
184  ASIO_INITFN_RESULT_TYPE(ReadHandler,
185  void (asio::error_code, std::size_t))
186  async_read_some(implementation_type& impl,
187  const MutableBufferSequence& buffers,
188  ASIO_MOVE_ARG(ReadHandler) handler)
189  {
191  ReadHandler, void (asio::error_code, std::size_t)> init(
192  ASIO_MOVE_CAST(ReadHandler)(handler));
193 
194  service_impl_.async_read_some(impl, buffers, init.handler);
195 
196  return init.result.get();
197  }
198 
199 private:
200  // Destroy all user-defined handler objects owned by the service.
201  void shutdown_service()
202  {
203  service_impl_.shutdown_service();
204  }
205 
206  // The platform-specific implementation.
207  service_impl_type service_impl_;
208 };
209 
210 } // namespace windows
211 } // namespace asio
212 
214 
215 #endif // defined(ASIO_HAS_WINDOWS_STREAM_HANDLE)
216  // || defined(GENERATING_DOCUMENTATION)
217 
218 #endif // ASIO_WINDOWS_STREAM_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))
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