Statistics
| Revision:

root / tmp / org.txm.statsengine.r.core.win32 / res / win32 / library / BH / include / boost / asio / ip / resolver_service.hpp @ 2486

History | View | Annotate | Download (5 kB)

1 2486 sjacqu01
//
2 2486 sjacqu01
// ip/resolver_service.hpp
3 2486 sjacqu01
// ~~~~~~~~~~~~~~~~~~~~~~~
4 2486 sjacqu01
//
5 2486 sjacqu01
// Copyright (c) 2003-2015 Christopher M. Kohlhoff (chris at kohlhoff dot com)
6 2486 sjacqu01
//
7 2486 sjacqu01
// Distributed under the Boost Software License, Version 1.0. (See accompanying
8 2486 sjacqu01
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
9 2486 sjacqu01
//
10 2486 sjacqu01
11 2486 sjacqu01
#ifndef BOOST_ASIO_IP_RESOLVER_SERVICE_HPP
12 2486 sjacqu01
#define BOOST_ASIO_IP_RESOLVER_SERVICE_HPP
13 2486 sjacqu01
14 2486 sjacqu01
#if defined(_MSC_VER) && (_MSC_VER >= 1200)
15 2486 sjacqu01
# pragma once
16 2486 sjacqu01
#endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
17 2486 sjacqu01
18 2486 sjacqu01
#include <boost/asio/detail/config.hpp>
19 2486 sjacqu01
#include <boost/asio/async_result.hpp>
20 2486 sjacqu01
#include <boost/system/error_code.hpp>
21 2486 sjacqu01
#include <boost/asio/io_service.hpp>
22 2486 sjacqu01
#include <boost/asio/ip/basic_resolver_iterator.hpp>
23 2486 sjacqu01
#include <boost/asio/ip/basic_resolver_query.hpp>
24 2486 sjacqu01
25 2486 sjacqu01
#if defined(BOOST_ASIO_WINDOWS_RUNTIME)
26 2486 sjacqu01
# include <boost/asio/detail/winrt_resolver_service.hpp>
27 2486 sjacqu01
#else
28 2486 sjacqu01
# include <boost/asio/detail/resolver_service.hpp>
29 2486 sjacqu01
#endif
30 2486 sjacqu01
31 2486 sjacqu01
#include <boost/asio/detail/push_options.hpp>
32 2486 sjacqu01
33 2486 sjacqu01
namespace boost {
34 2486 sjacqu01
namespace asio {
35 2486 sjacqu01
namespace ip {
36 2486 sjacqu01
37 2486 sjacqu01
/// Default service implementation for a resolver.
38 2486 sjacqu01
template <typename InternetProtocol>
39 2486 sjacqu01
class resolver_service
40 2486 sjacqu01
#if defined(GENERATING_DOCUMENTATION)
41 2486 sjacqu01
  : public boost::asio::io_service::service
42 2486 sjacqu01
#else
43 2486 sjacqu01
  : public boost::asio::detail::service_base<
44 2486 sjacqu01
      resolver_service<InternetProtocol> >
45 2486 sjacqu01
#endif
46 2486 sjacqu01
{
47 2486 sjacqu01
public:
48 2486 sjacqu01
#if defined(GENERATING_DOCUMENTATION)
49 2486 sjacqu01
  /// The unique service identifier.
50 2486 sjacqu01
  static boost::asio::io_service::id id;
51 2486 sjacqu01
#endif
52 2486 sjacqu01
53 2486 sjacqu01
  /// The protocol type.
54 2486 sjacqu01
  typedef InternetProtocol protocol_type;
55 2486 sjacqu01
56 2486 sjacqu01
  /// The endpoint type.
57 2486 sjacqu01
  typedef typename InternetProtocol::endpoint endpoint_type;
58 2486 sjacqu01
59 2486 sjacqu01
  /// The query type.
60 2486 sjacqu01
  typedef basic_resolver_query<InternetProtocol> query_type;
61 2486 sjacqu01
62 2486 sjacqu01
  /// The iterator type.
63 2486 sjacqu01
  typedef basic_resolver_iterator<InternetProtocol> iterator_type;
64 2486 sjacqu01
65 2486 sjacqu01
private:
66 2486 sjacqu01
  // The type of the platform-specific implementation.
67 2486 sjacqu01
#if defined(BOOST_ASIO_WINDOWS_RUNTIME)
68 2486 sjacqu01
  typedef boost::asio::detail::winrt_resolver_service<InternetProtocol>
69 2486 sjacqu01
    service_impl_type;
70 2486 sjacqu01
#else
71 2486 sjacqu01
  typedef boost::asio::detail::resolver_service<InternetProtocol>
72 2486 sjacqu01
    service_impl_type;
73 2486 sjacqu01
#endif
74 2486 sjacqu01
75 2486 sjacqu01
public:
76 2486 sjacqu01
  /// The type of a resolver implementation.
77 2486 sjacqu01
#if defined(GENERATING_DOCUMENTATION)
78 2486 sjacqu01
  typedef implementation_defined implementation_type;
79 2486 sjacqu01
#else
80 2486 sjacqu01
  typedef typename service_impl_type::implementation_type implementation_type;
81 2486 sjacqu01
#endif
82 2486 sjacqu01
83 2486 sjacqu01
  /// Construct a new resolver service for the specified io_service.
84 2486 sjacqu01
  explicit resolver_service(boost::asio::io_service& io_service)
85 2486 sjacqu01
    : boost::asio::detail::service_base<
86 2486 sjacqu01
        resolver_service<InternetProtocol> >(io_service),
87 2486 sjacqu01
      service_impl_(io_service)
88 2486 sjacqu01
  {
89 2486 sjacqu01
  }
90 2486 sjacqu01
91 2486 sjacqu01
  /// Construct a new resolver implementation.
92 2486 sjacqu01
  void construct(implementation_type& impl)
93 2486 sjacqu01
  {
94 2486 sjacqu01
    service_impl_.construct(impl);
95 2486 sjacqu01
  }
96 2486 sjacqu01
97 2486 sjacqu01
  /// Destroy a resolver implementation.
98 2486 sjacqu01
  void destroy(implementation_type& impl)
99 2486 sjacqu01
  {
100 2486 sjacqu01
    service_impl_.destroy(impl);
101 2486 sjacqu01
  }
102 2486 sjacqu01
103 2486 sjacqu01
  /// Cancel pending asynchronous operations.
104 2486 sjacqu01
  void cancel(implementation_type& impl)
105 2486 sjacqu01
  {
106 2486 sjacqu01
    service_impl_.cancel(impl);
107 2486 sjacqu01
  }
108 2486 sjacqu01
109 2486 sjacqu01
  /// Resolve a query to a list of entries.
110 2486 sjacqu01
  iterator_type resolve(implementation_type& impl, const query_type& query,
111 2486 sjacqu01
      boost::system::error_code& ec)
112 2486 sjacqu01
  {
113 2486 sjacqu01
    return service_impl_.resolve(impl, query, ec);
114 2486 sjacqu01
  }
115 2486 sjacqu01
116 2486 sjacqu01
  /// Asynchronously resolve a query to a list of entries.
117 2486 sjacqu01
  template <typename ResolveHandler>
118 2486 sjacqu01
  BOOST_ASIO_INITFN_RESULT_TYPE(ResolveHandler,
119 2486 sjacqu01
      void (boost::system::error_code, iterator_type))
120 2486 sjacqu01
  async_resolve(implementation_type& impl, const query_type& query,
121 2486 sjacqu01
      BOOST_ASIO_MOVE_ARG(ResolveHandler) handler)
122 2486 sjacqu01
  {
123 2486 sjacqu01
    boost::asio::detail::async_result_init<
124 2486 sjacqu01
      ResolveHandler, void (boost::system::error_code, iterator_type)> init(
125 2486 sjacqu01
        BOOST_ASIO_MOVE_CAST(ResolveHandler)(handler));
126 2486 sjacqu01
127 2486 sjacqu01
    service_impl_.async_resolve(impl, query, init.handler);
128 2486 sjacqu01
129 2486 sjacqu01
    return init.result.get();
130 2486 sjacqu01
  }
131 2486 sjacqu01
132 2486 sjacqu01
  /// Resolve an endpoint to a list of entries.
133 2486 sjacqu01
  iterator_type resolve(implementation_type& impl,
134 2486 sjacqu01
      const endpoint_type& endpoint, boost::system::error_code& ec)
135 2486 sjacqu01
  {
136 2486 sjacqu01
    return service_impl_.resolve(impl, endpoint, ec);
137 2486 sjacqu01
  }
138 2486 sjacqu01
139 2486 sjacqu01
  /// Asynchronously resolve an endpoint to a list of entries.
140 2486 sjacqu01
  template <typename ResolveHandler>
141 2486 sjacqu01
  BOOST_ASIO_INITFN_RESULT_TYPE(ResolveHandler,
142 2486 sjacqu01
      void (boost::system::error_code, iterator_type))
143 2486 sjacqu01
  async_resolve(implementation_type& impl, const endpoint_type& endpoint,
144 2486 sjacqu01
      BOOST_ASIO_MOVE_ARG(ResolveHandler) handler)
145 2486 sjacqu01
  {
146 2486 sjacqu01
    boost::asio::detail::async_result_init<
147 2486 sjacqu01
      ResolveHandler, void (boost::system::error_code, iterator_type)> init(
148 2486 sjacqu01
        BOOST_ASIO_MOVE_CAST(ResolveHandler)(handler));
149 2486 sjacqu01
150 2486 sjacqu01
    service_impl_.async_resolve(impl, endpoint, init.handler);
151 2486 sjacqu01
152 2486 sjacqu01
    return init.result.get();
153 2486 sjacqu01
  }
154 2486 sjacqu01
155 2486 sjacqu01
private:
156 2486 sjacqu01
  // Destroy all user-defined handler objects owned by the service.
157 2486 sjacqu01
  void shutdown_service()
158 2486 sjacqu01
  {
159 2486 sjacqu01
    service_impl_.shutdown_service();
160 2486 sjacqu01
  }
161 2486 sjacqu01
162 2486 sjacqu01
  // Perform any fork-related housekeeping.
163 2486 sjacqu01
  void fork_service(boost::asio::io_service::fork_event event)
164 2486 sjacqu01
  {
165 2486 sjacqu01
    service_impl_.fork_service(event);
166 2486 sjacqu01
  }
167 2486 sjacqu01
168 2486 sjacqu01
  // The platform-specific implementation.
169 2486 sjacqu01
  service_impl_type service_impl_;
170 2486 sjacqu01
};
171 2486 sjacqu01
172 2486 sjacqu01
} // namespace ip
173 2486 sjacqu01
} // namespace asio
174 2486 sjacqu01
} // namespace boost
175 2486 sjacqu01
176 2486 sjacqu01
#include <boost/asio/detail/pop_options.hpp>
177 2486 sjacqu01
178 2486 sjacqu01
#endif // BOOST_ASIO_IP_RESOLVER_SERVICE_HPP