Realistic 3D camera system
3D camera system components
basic_stream_descriptor.hpp
Go to the documentation of this file.
1 //
2 // posix/basic_stream_descriptor.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_BASIC_STREAM_DESCRIPTOR_HPP
12 #define ASIO_POSIX_BASIC_STREAM_DESCRIPTOR_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>
26 #include "asio/error.hpp"
29 
31 
32 namespace asio {
33 namespace posix {
34 
36 
47 template <typename StreamDescriptorService = stream_descriptor_service>
48 class basic_stream_descriptor
49  : public basic_descriptor<StreamDescriptorService>
50 {
51 public:
54  typedef typename StreamDescriptorService::native_handle_type native_type;
55 
57  typedef typename StreamDescriptorService::native_handle_type
58  native_handle_type;
59 
61 
70  explicit basic_stream_descriptor(asio::io_service& io_service)
71  : basic_descriptor<StreamDescriptorService>(io_service)
72  {
73  }
74 
76 
88  basic_stream_descriptor(asio::io_service& io_service,
89  const native_handle_type& native_descriptor)
90  : basic_descriptor<StreamDescriptorService>(io_service, native_descriptor)
91  {
92  }
93 
94 #if defined(ASIO_HAS_MOVE) || defined(GENERATING_DOCUMENTATION)
95 
105  basic_stream_descriptor(basic_stream_descriptor&& other)
106  : basic_descriptor<StreamDescriptorService>(
107  ASIO_MOVE_CAST(basic_stream_descriptor)(other))
108  {
109  }
110 
112 
122  basic_stream_descriptor& operator=(basic_stream_descriptor&& other)
123  {
124  basic_descriptor<StreamDescriptorService>::operator=(
125  ASIO_MOVE_CAST(basic_stream_descriptor)(other));
126  return *this;
127  }
128 #endif // defined(ASIO_HAS_MOVE) || defined(GENERATING_DOCUMENTATION)
129 
131 
157  template <typename ConstBufferSequence>
158  std::size_t write_some(const ConstBufferSequence& buffers)
159  {
160  asio::error_code ec;
161  std::size_t s = this->get_service().write_some(
162  this->get_implementation(), buffers, ec);
163  asio::detail::throw_error(ec, "write_some");
164  return s;
165  }
166 
168 
183  template <typename ConstBufferSequence>
184  std::size_t write_some(const ConstBufferSequence& buffers,
185  asio::error_code& ec)
186  {
187  return this->get_service().write_some(
188  this->get_implementation(), buffers, ec);
189  }
190 
192 
226  template <typename ConstBufferSequence, typename WriteHandler>
227  ASIO_INITFN_RESULT_TYPE(WriteHandler,
228  void (asio::error_code, std::size_t))
229  async_write_some(const ConstBufferSequence& buffers,
230  ASIO_MOVE_ARG(WriteHandler) handler)
231  {
232  // If you get an error on the following line it means that your handler does
233  // not meet the documented type requirements for a WriteHandler.
234  ASIO_WRITE_HANDLER_CHECK(WriteHandler, handler) type_check;
235 
236  return this->get_service().async_write_some(this->get_implementation(),
237  buffers, ASIO_MOVE_CAST(WriteHandler)(handler));
238  }
239 
241 
268  template <typename MutableBufferSequence>
269  std::size_t read_some(const MutableBufferSequence& buffers)
270  {
271  asio::error_code ec;
272  std::size_t s = this->get_service().read_some(
273  this->get_implementation(), buffers, ec);
274  asio::detail::throw_error(ec, "read_some");
275  return s;
276  }
277 
279 
295  template <typename MutableBufferSequence>
296  std::size_t read_some(const MutableBufferSequence& buffers,
297  asio::error_code& ec)
298  {
299  return this->get_service().read_some(
300  this->get_implementation(), buffers, ec);
301  }
302 
304 
339  template <typename MutableBufferSequence, typename ReadHandler>
340  ASIO_INITFN_RESULT_TYPE(ReadHandler,
341  void (asio::error_code, std::size_t))
342  async_read_some(const MutableBufferSequence& buffers,
343  ASIO_MOVE_ARG(ReadHandler) handler)
344  {
345  // If you get an error on the following line it means that your handler does
346  // not meet the documented type requirements for a ReadHandler.
347  ASIO_READ_HANDLER_CHECK(ReadHandler, handler) type_check;
348 
349  return this->get_service().async_read_some(this->get_implementation(),
350  buffers, ASIO_MOVE_CAST(ReadHandler)(handler));
351  }
352 };
353 
354 } // namespace posix
355 } // namespace asio
356 
357 #include "asio/detail/pop_options.hpp"
358 
359 #endif // defined(ASIO_HAS_POSIX_STREAM_DESCRIPTOR)
360  // || defined(GENERATING_DOCUMENTATION)
361 
362 #endif // ASIO_POSIX_BASIC_STREAM_DESCRIPTOR_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.
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)