Realistic 3D camera system
3D camera system components
posix_fd_set_adapter.hpp
Go to the documentation of this file.
1 //
2 // detail/posix_fd_set_adapter.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_POSIX_FD_SET_ADAPTER_HPP
12 #define ASIO_DETAIL_POSIX_FD_SET_ADAPTER_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_WINDOWS) \
21  && !defined(__CYGWIN__) \
22  && !defined(ASIO_WINDOWS_RUNTIME)
23 
24 #include <cstring>
28 
30 
31 namespace asio {
32 namespace detail {
33 
34 // Adapts the FD_SET type to meet the Descriptor_Set concept's requirements.
36 {
37 public:
39  : max_descriptor_(invalid_socket)
40  {
41  using namespace std; // Needed for memset on Solaris.
42  FD_ZERO(&fd_set_);
43  }
44 
45  void reset()
46  {
47  using namespace std; // Needed for memset on Solaris.
48  FD_ZERO(&fd_set_);
49  }
50 
51  bool set(socket_type descriptor)
52  {
53  if (descriptor < (socket_type)FD_SETSIZE)
54  {
55  if (max_descriptor_ == invalid_socket || descriptor > max_descriptor_)
56  max_descriptor_ = descriptor;
57  FD_SET(descriptor, &fd_set_);
58  return true;
59  }
60  return false;
61  }
62 
64  {
66  while (i != operations.end())
67  {
69  if (!set(op_iter->first))
70  {
72  operations.cancel_operations(op_iter, ops, ec);
73  }
74  }
75  }
76 
77  bool is_set(socket_type descriptor) const
78  {
79  return FD_ISSET(descriptor, &fd_set_) != 0;
80  }
81 
82  operator fd_set*()
83  {
84  return &fd_set_;
85  }
86 
88  {
89  return max_descriptor_;
90  }
91 
93  op_queue<operation>& ops) const
94  {
96  while (i != operations.end())
97  {
99  if (is_set(op_iter->first))
100  operations.perform_operations(op_iter, ops);
101  }
102  }
103 
104 private:
105  mutable fd_set fd_set_;
106  socket_type max_descriptor_;
107 };
108 
109 } // namespace detail
110 } // namespace asio
111 
113 
114 #endif // !defined(ASIO_WINDOWS)
115  // && !defined(__CYGWIN__)
116  // && !defined(ASIO_WINDOWS_RUNTIME)
117 
118 #endif // ASIO_DETAIL_POSIX_FD_SET_ADAPTER_HPP
void perform(reactor_op_queue< socket_type > &operations, op_queue< operation > &ops) const
STL namespace.
bool perform_operations(iterator i, op_queue< operation > &ops)
The descriptor cannot fit into the select system call&#39;s fd_set.
Definition: error.hpp:223
Class to represent an error code value.
Definition: error_code.hpp:80
const int invalid_socket
bool is_set(socket_type descriptor) const