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

« back to all changes in this revision

Viewing changes to include/libtorrent/asio/ip/resolver_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
 
// resolver_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_IP_RESOLVER_SERVICE_HPP
12
 
#define ASIO_IP_RESOLVER_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/error.hpp"
21
 
#include "asio/io_service.hpp"
22
 
#include "asio/detail/resolver_service.hpp"
23
 
#include "asio/detail/service_base.hpp"
24
 
 
25
 
namespace asio {
26
 
namespace ip {
27
 
 
28
 
/// Default service implementation for a resolver.
29
 
template <typename InternetProtocol>
30
 
class resolver_service
31
 
#if defined(GENERATING_DOCUMENTATION)
32
 
  : public asio::io_service::service
33
 
#else
34
 
  : public asio::detail::service_base<
35
 
      resolver_service<InternetProtocol> >
36
 
#endif
37
 
{
38
 
public:
39
 
#if defined(GENERATING_DOCUMENTATION)
40
 
  /// The unique service identifier.
41
 
  static asio::io_service::id id;
42
 
#endif
43
 
 
44
 
  /// The protocol type.
45
 
  typedef InternetProtocol protocol_type;
46
 
 
47
 
  /// The endpoint type.
48
 
  typedef typename InternetProtocol::endpoint endpoint_type;
49
 
 
50
 
  /// The query type.
51
 
  typedef typename InternetProtocol::resolver_query query_type;
52
 
 
53
 
  /// The iterator type.
54
 
  typedef typename InternetProtocol::resolver_iterator iterator_type;
55
 
 
56
 
private:
57
 
  // The type of the platform-specific implementation.
58
 
  typedef asio::detail::resolver_service<InternetProtocol>
59
 
    service_impl_type;
60
 
 
61
 
public:
62
 
  /// The type of a resolver implementation.
63
 
#if defined(GENERATING_DOCUMENTATION)
64
 
  typedef implementation_defined implementation_type;
65
 
#else
66
 
  typedef typename service_impl_type::implementation_type implementation_type;
67
 
#endif
68
 
 
69
 
  /// Construct a new resolver service for the specified io_service.
70
 
  explicit resolver_service(asio::io_service& io_service)
71
 
    : asio::detail::service_base<
72
 
        resolver_service<InternetProtocol> >(io_service),
73
 
      service_impl_(asio::use_service<service_impl_type>(io_service))
74
 
  {
75
 
  }
76
 
 
77
 
  /// Destroy all user-defined handler objects owned by the service.
78
 
  void shutdown_service()
79
 
  {
80
 
  }
81
 
 
82
 
  /// Construct a new resolver implementation.
83
 
  void construct(implementation_type& impl)
84
 
  {
85
 
    service_impl_.construct(impl);
86
 
  }
87
 
 
88
 
  /// Destroy a resolver implementation.
89
 
  void destroy(implementation_type& impl)
90
 
  {
91
 
    service_impl_.destroy(impl);
92
 
  }
93
 
 
94
 
  /// Cancel pending asynchronous operations.
95
 
  void cancel(implementation_type& impl)
96
 
  {
97
 
    service_impl_.cancel(impl);
98
 
  }
99
 
 
100
 
  /// Resolve a query to a list of entries.
101
 
  iterator_type resolve(implementation_type& impl, const query_type& query,
102
 
      asio::error_code& ec)
103
 
  {
104
 
    return service_impl_.resolve(impl, query, ec);
105
 
  }
106
 
 
107
 
  /// Asynchronously resolve a query to a list of entries.
108
 
  template <typename Handler>
109
 
  void async_resolve(implementation_type& impl, const query_type& query,
110
 
      Handler handler)
111
 
  {
112
 
    service_impl_.async_resolve(impl, query, handler);
113
 
  }
114
 
 
115
 
  /// Resolve an endpoint to a list of entries.
116
 
  iterator_type resolve(implementation_type& impl,
117
 
      const endpoint_type& endpoint, asio::error_code& ec)
118
 
  {
119
 
    return service_impl_.resolve(impl, endpoint, ec);
120
 
  }
121
 
 
122
 
  /// Asynchronously resolve an endpoint to a list of entries.
123
 
  template <typename ResolveHandler>
124
 
  void async_resolve(implementation_type& impl, const endpoint_type& endpoint,
125
 
      ResolveHandler handler)
126
 
  {
127
 
    return service_impl_.async_resolve(impl, endpoint, handler);
128
 
  }
129
 
 
130
 
private:
131
 
  // The service that provides the platform-specific implementation.
132
 
  service_impl_type& service_impl_;
133
 
};
134
 
 
135
 
} // namespace ip
136
 
} // namespace asio
137
 
 
138
 
#include "asio/detail/pop_options.hpp"
139
 
 
140
 
#endif // ASIO_IP_RESOLVER_SERVICE_HPP