Realistic 3D camera system
3D camera system components
stream_descriptor_service.hpp
Go to the documentation of this file.
1 //
2 // posix/stream_descriptor_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_POSIX_STREAM_DESCRIPTOR_SERVICE_HPP
12 #define ASIO_POSIX_STREAM_DESCRIPTOR_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_POSIX_STREAM_DESCRIPTOR) \
21  || defined(GENERATING_DOCUMENTATION)
22 
23 #include <cstddef>
24 #include "asio/async_result.hpp"
25 #include "asio/error.hpp"
26 #include "asio/io_service.hpp"
28 
30 
31 namespace asio {
32 namespace posix {
33 
35 class stream_descriptor_service
36 #if defined(GENERATING_DOCUMENTATION)
38 #else
39  : public asio::detail::service_base<stream_descriptor_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::reactive_descriptor_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_descriptor_service(asio::io_service& io_service)
76  : asio::detail::service_base<stream_descriptor_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_descriptor_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& native_descriptor,
113  asio::error_code& ec)
114  {
115  return service_impl_.assign(impl, native_descriptor, ec);
116  }
117 
119  bool is_open(const implementation_type& impl) const
120  {
121  return service_impl_.is_open(impl);
122  }
123 
125  asio::error_code close(implementation_type& impl,
126  asio::error_code& ec)
127  {
128  return service_impl_.close(impl, ec);
129  }
130 
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  native_handle_type release(implementation_type& impl)
146  {
147  return service_impl_.release(impl);
148  }
149 
151  asio::error_code cancel(implementation_type& impl,
152  asio::error_code& ec)
153  {
154  return service_impl_.cancel(impl, ec);
155  }
156 
158  template <typename IoControlCommand>
159  asio::error_code io_control(implementation_type& impl,
160  IoControlCommand& command, asio::error_code& ec)
161  {
162  return service_impl_.io_control(impl, command, ec);
163  }
164 
166  bool non_blocking(const implementation_type& impl) const
167  {
168  return service_impl_.non_blocking(impl);
169  }
170 
172  asio::error_code non_blocking(implementation_type& impl,
173  bool mode, asio::error_code& ec)
174  {
175  return service_impl_.non_blocking(impl, mode, ec);
176  }
177 
179  bool native_non_blocking(const implementation_type& impl) const
180  {
181  return service_impl_.native_non_blocking(impl);
182  }
183 
185  asio::error_code native_non_blocking(implementation_type& impl,
186  bool mode, asio::error_code& ec)
187  {
188  return service_impl_.native_non_blocking(impl, mode, ec);
189  }
190 
192  template <typename ConstBufferSequence>
193  std::size_t write_some(implementation_type& impl,
194  const ConstBufferSequence& buffers, asio::error_code& ec)
195  {
196  return service_impl_.write_some(impl, buffers, ec);
197  }
198 
200  template <typename ConstBufferSequence, typename WriteHandler>
201  ASIO_INITFN_RESULT_TYPE(WriteHandler,
202  void (asio::error_code, std::size_t))
203  async_write_some(implementation_type& impl,
204  const ConstBufferSequence& buffers,
205  ASIO_MOVE_ARG(WriteHandler) handler)
206  {
208  WriteHandler, void (asio::error_code, std::size_t)> init(
209  ASIO_MOVE_CAST(WriteHandler)(handler));
210 
211  service_impl_.async_write_some(impl, buffers, init.handler);
212 
213  return init.result.get();
214  }
215 
217  template <typename MutableBufferSequence>
218  std::size_t read_some(implementation_type& impl,
219  const MutableBufferSequence& buffers, asio::error_code& ec)
220  {
221  return service_impl_.read_some(impl, buffers, ec);
222  }
223 
225  template <typename MutableBufferSequence, typename ReadHandler>
226  ASIO_INITFN_RESULT_TYPE(ReadHandler,
227  void (asio::error_code, std::size_t))
228  async_read_some(implementation_type& impl,
229  const MutableBufferSequence& buffers,
230  ASIO_MOVE_ARG(ReadHandler) handler)
231  {
233  ReadHandler, void (asio::error_code, std::size_t)> init(
234  ASIO_MOVE_CAST(ReadHandler)(handler));
235 
236  service_impl_.async_read_some(impl, buffers, init.handler);
237 
238  return init.result.get();
239  }
240 
241 private:
242  // Destroy all user-defined handler objects owned by the service.
243  void shutdown_service()
244  {
245  service_impl_.shutdown_service();
246  }
247 
248  // The platform-specific implementation.
249  service_impl_type service_impl_;
250 };
251 
252 } // namespace posix
253 } // namespace asio
254 
256 
257 #endif // defined(ASIO_HAS_POSIX_STREAM_DESCRIPTOR)
258  // || defined(GENERATING_DOCUMENTATION)
259 
260 #endif // ASIO_POSIX_STREAM_DESCRIPTOR_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