Realistic 3D camera system
3D camera system components
io_control.hpp
Go to the documentation of this file.
1 //
2 // detail/io_control.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_DETAIL_IO_CONTROL_HPP
12 #define ASIO_DETAIL_IO_CONTROL_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 #include <cstddef>
21 
23 
24 namespace asio {
25 namespace detail {
26 namespace io_control {
27 
28 // IO control command for non-blocking I/O.
30 {
31 public:
32  // Default constructor.
34  : value_(0)
35  {
36  }
37 
38  // Construct with a specific command value.
39  non_blocking_io(bool value)
40  : value_(value ? 1 : 0)
41  {
42  }
43 
44  // Get the name of the IO control command.
45  int name() const
46  {
47  return static_cast<int>(ASIO_OS_DEF(FIONBIO));
48  }
49 
50  // Set the value of the I/O control command.
51  void set(bool value)
52  {
53  value_ = value ? 1 : 0;
54  }
55 
56  // Get the current value of the I/O control command.
57  bool get() const
58  {
59  return value_ != 0;
60  }
61 
62  // Get the address of the command data.
64  {
65  return &value_;
66  }
67 
68  // Get the address of the command data.
70  {
71  return &value_;
72  }
73 
74 private:
76 };
77 
78 // I/O control command for getting number of bytes available.
80 {
81 public:
82  // Default constructor.
84  : value_(0)
85  {
86  }
87 
88  // Construct with a specific command value.
89  bytes_readable(std::size_t value)
90  : value_(static_cast<detail::ioctl_arg_type>(value))
91  {
92  }
93 
94  // Get the name of the IO control command.
95  int name() const
96  {
97  return static_cast<int>(ASIO_OS_DEF(FIONREAD));
98  }
99 
100  // Set the value of the I/O control command.
101  void set(std::size_t value)
102  {
103  value_ = static_cast<detail::ioctl_arg_type>(value);
104  }
105 
106  // Get the current value of the I/O control command.
107  std::size_t get() const
108  {
109  return static_cast<std::size_t>(value_);
110  }
111 
112  // Get the address of the command data.
114  {
115  return &value_;
116  }
117 
118  // Get the address of the command data.
120  {
121  return &value_;
122  }
123 
124 private:
125  detail::ioctl_arg_type value_;
126 };
127 
128 } // namespace io_control
129 } // namespace detail
130 } // namespace asio
131 
133 
134 #endif // ASIO_DETAIL_IO_CONTROL_HPP
detail::ioctl_arg_type * data()
Definition: io_control.hpp:113
#define ASIO_OS_DEF(c)
const detail::ioctl_arg_type * data() const
Definition: io_control.hpp:119
const detail::ioctl_arg_type * data() const
Definition: io_control.hpp:69
detail::ioctl_arg_type * data()
Definition: io_control.hpp:63