~ubuntu-branches/ubuntu/maverick/libtorrent-rasterbar/maverick

« back to all changes in this revision

Viewing changes to include/libtorrent/asio/windows/stream_handle_service.hpp

  • Committer: Bazaar Package Importer
  • Author(s): Christophe Sauthier
  • Date: 2010-08-10 12:59:37 UTC
  • mfrom: (1.3.7 upstream)
  • Revision ID: james.westby@ubuntu.com-20100810125937-jbcmmf17y8yo9hgz
Tags: 0.15.0-0ubuntu1
* New upstream version.
* debian/patches/100_fix_html_docs.patch: refreshed.
* debian/control: bump up standards-version to 3.9.1 (no changes).

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
//
2
 
// stream_handle_service.hpp
3
 
// ~~~~~~~~~~~~~~~~~~~~~~~~~
4
 
//
5
 
// Copyright (c) 2003-2008 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_WINDOWS_STREAM_HANDLE_SERVICE_HPP
12
 
#define ASIO_WINDOWS_STREAM_HANDLE_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/push_options.hpp"
19
 
 
20
 
#include "asio/detail/push_options.hpp"
21
 
#include <cstddef>
22
 
#include <boost/config.hpp>
23
 
#include "asio/detail/pop_options.hpp"
24
 
 
25
 
#include "asio/error.hpp"
26
 
#include "asio/io_service.hpp"
27
 
#include "asio/detail/service_base.hpp"
28
 
#include "asio/detail/win_iocp_handle_service.hpp"
29
 
 
30
 
#if !defined(ASIO_DISABLE_WINDOWS_STREAM_HANDLE)
31
 
# if defined(ASIO_HAS_IOCP)
32
 
#  define ASIO_HAS_WINDOWS_STREAM_HANDLE 1
33
 
# endif // defined(ASIO_HAS_IOCP)
34
 
#endif // !defined(ASIO_DISABLE_WINDOWS_STREAM_HANDLE)
35
 
 
36
 
#if defined(ASIO_HAS_WINDOWS_STREAM_HANDLE) \
37
 
  || defined(GENERATING_DOCUMENTATION)
38
 
 
39
 
namespace asio {
40
 
namespace windows {
41
 
 
42
 
/// Default service implementation for a stream handle.
43
 
class stream_handle_service
44
 
#if defined(GENERATING_DOCUMENTATION)
45
 
  : public asio::io_service::service
46
 
#else
47
 
  : public asio::detail::service_base<stream_handle_service>
48
 
#endif
49
 
{
50
 
public:
51
 
#if defined(GENERATING_DOCUMENTATION)
52
 
  /// The unique service identifier.
53
 
  static asio::io_service::id id;
54
 
#endif
55
 
 
56
 
private:
57
 
  // The type of the platform-specific implementation.
58
 
  typedef detail::win_iocp_handle_service service_impl_type;
59
 
 
60
 
public:
61
 
  /// The type of a stream handle implementation.
62
 
#if defined(GENERATING_DOCUMENTATION)
63
 
  typedef implementation_defined implementation_type;
64
 
#else
65
 
  typedef service_impl_type::implementation_type implementation_type;
66
 
#endif
67
 
 
68
 
  /// The native handle type.
69
 
#if defined(GENERATING_DOCUMENTATION)
70
 
  typedef implementation_defined native_type;
71
 
#else
72
 
  typedef service_impl_type::native_type native_type;
73
 
#endif
74
 
 
75
 
  /// Construct a new stream handle service for the specified io_service.
76
 
  explicit stream_handle_service(asio::io_service& io_service)
77
 
    : asio::detail::service_base<stream_handle_service>(io_service),
78
 
      service_impl_(asio::use_service<service_impl_type>(io_service))
79
 
  {
80
 
  }
81
 
 
82
 
  /// Destroy all user-defined handler objects owned by the service.
83
 
  void shutdown_service()
84
 
  {
85
 
  }
86
 
 
87
 
  /// Construct a new stream handle implementation.
88
 
  void construct(implementation_type& impl)
89
 
  {
90
 
    service_impl_.construct(impl);
91
 
  }
92
 
 
93
 
  /// Destroy a stream handle implementation.
94
 
  void destroy(implementation_type& impl)
95
 
  {
96
 
    service_impl_.destroy(impl);
97
 
  }
98
 
 
99
 
  /// Assign an existing native handle to a stream handle.
100
 
  asio::error_code assign(implementation_type& impl,
101
 
      const native_type& native_handle, asio::error_code& ec)
102
 
  {
103
 
    return service_impl_.assign(impl, native_handle, ec);
104
 
  }
105
 
 
106
 
  /// Determine whether the handle is open.
107
 
  bool is_open(const implementation_type& impl) const
108
 
  {
109
 
    return service_impl_.is_open(impl);
110
 
  }
111
 
 
112
 
  /// Close a stream handle implementation.
113
 
  asio::error_code close(implementation_type& impl,
114
 
      asio::error_code& ec)
115
 
  {
116
 
    return service_impl_.close(impl, ec);
117
 
  }
118
 
 
119
 
  /// Get the native handle implementation.
120
 
  native_type native(implementation_type& impl)
121
 
  {
122
 
    return service_impl_.native(impl);
123
 
  }
124
 
 
125
 
  /// Cancel all asynchronous operations associated with the handle.
126
 
  asio::error_code cancel(implementation_type& impl,
127
 
      asio::error_code& ec)
128
 
  {
129
 
    return service_impl_.cancel(impl, ec);
130
 
  }
131
 
 
132
 
  /// Write the given data to the stream.
133
 
  template <typename ConstBufferSequence>
134
 
  std::size_t write_some(implementation_type& impl,
135
 
      const ConstBufferSequence& buffers, asio::error_code& ec)
136
 
  {
137
 
    return service_impl_.write_some(impl, buffers, ec);
138
 
  }
139
 
 
140
 
  /// Start an asynchronous write.
141
 
  template <typename ConstBufferSequence, typename WriteHandler>
142
 
  void async_write_some(implementation_type& impl,
143
 
      const ConstBufferSequence& buffers, WriteHandler handler)
144
 
  {
145
 
    service_impl_.async_write_some(impl, buffers, handler);
146
 
  }
147
 
 
148
 
  /// Read some data from the stream.
149
 
  template <typename MutableBufferSequence>
150
 
  std::size_t read_some(implementation_type& impl,
151
 
      const MutableBufferSequence& buffers, asio::error_code& ec)
152
 
  {
153
 
    return service_impl_.read_some(impl, buffers, ec);
154
 
  }
155
 
 
156
 
  /// Start an asynchronous read.
157
 
  template <typename MutableBufferSequence, typename ReadHandler>
158
 
  void async_read_some(implementation_type& impl,
159
 
      const MutableBufferSequence& buffers, ReadHandler handler)
160
 
  {
161
 
    service_impl_.async_read_some(impl, buffers, handler);
162
 
  }
163
 
 
164
 
private:
165
 
  // The service that provides the platform-specific implementation.
166
 
  service_impl_type& service_impl_;
167
 
};
168
 
 
169
 
} // namespace windows
170
 
} // namespace asio
171
 
 
172
 
#endif // defined(ASIO_HAS_WINDOWS_STREAM_HANDLE)
173
 
       //   || defined(GENERATING_DOCUMENTATION)
174
 
 
175
 
#include "asio/detail/pop_options.hpp"
176
 
 
177
 
#endif // ASIO_WINDOWS_STREAM_HANDLE_SERVICE_HPP