~ubuntu-branches/ubuntu/intrepid/miro/intrepid

« back to all changes in this revision

Viewing changes to portable/libtorrent/include/libtorrent/asio/detail/posix_fd_set_adapter.hpp

  • Committer: Bazaar Package Importer
  • Author(s): Christopher James Halse Rogers
  • Date: 2008-02-09 13:37:10 UTC
  • mfrom: (1.1.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20080209133710-9rs90q6gckvp1b6i
Tags: 1.1.2-0ubuntu1
New upstream release

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
//
 
2
// posix_fd_set_adapter.hpp
 
3
// ~~~~~~~~~~~~~~~~~~~~~~~~
 
4
//
 
5
// Copyright (c) 2003-2007 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/push_options.hpp"
 
19
 
 
20
#include "asio/detail/socket_types.hpp"
 
21
 
 
22
#if !defined(BOOST_WINDOWS) && !defined(__CYGWIN__)
 
23
 
 
24
namespace asio {
 
25
namespace detail {
 
26
 
 
27
// Adapts the FD_SET type to meet the Descriptor_Set concept's requirements.
 
28
class posix_fd_set_adapter
 
29
{
 
30
public:
 
31
  posix_fd_set_adapter()
 
32
    : max_descriptor_(invalid_socket)
 
33
  {
 
34
    using namespace std; // Needed for memset on Solaris.
 
35
    FD_ZERO(&fd_set_);
 
36
  }
 
37
 
 
38
  void set(socket_type descriptor)
 
39
  {
 
40
    if (max_descriptor_ == invalid_socket || descriptor > max_descriptor_)
 
41
      max_descriptor_ = descriptor;
 
42
    FD_SET(descriptor, &fd_set_);
 
43
  }
 
44
 
 
45
  bool is_set(socket_type descriptor) const
 
46
  {
 
47
    return FD_ISSET(descriptor, &fd_set_) != 0;
 
48
  }
 
49
 
 
50
  operator fd_set*()
 
51
  {
 
52
    return &fd_set_;
 
53
  }
 
54
 
 
55
  socket_type max_descriptor() const
 
56
  {
 
57
    return max_descriptor_;
 
58
  }
 
59
 
 
60
private:
 
61
  fd_set fd_set_;
 
62
  socket_type max_descriptor_;
 
63
};
 
64
 
 
65
} // namespace detail
 
66
} // namespace asio
 
67
 
 
68
#endif // !defined(BOOST_WINDOWS) && !defined(__CYGWIN__)
 
69
 
 
70
#include "asio/detail/pop_options.hpp"
 
71
 
 
72
#endif // ASIO_DETAIL_POSIX_FD_SET_ADAPTER_HPP