2
// resolver_service.hpp
3
// ~~~~~~~~~~~~~~~~~~~~
5
// Copyright (c) 2003-2008 Christopher M. Kohlhoff (chris at kohlhoff dot com)
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)
11
#ifndef ASIO_IP_RESOLVER_SERVICE_HPP
12
#define ASIO_IP_RESOLVER_SERVICE_HPP
14
#if defined(_MSC_VER) && (_MSC_VER >= 1200)
16
#endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
18
#include "asio/detail/push_options.hpp"
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"
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
34
: public asio::detail::service_base<
35
resolver_service<InternetProtocol> >
39
#if defined(GENERATING_DOCUMENTATION)
40
/// The unique service identifier.
41
static asio::io_service::id id;
44
/// The protocol type.
45
typedef InternetProtocol protocol_type;
47
/// The endpoint type.
48
typedef typename InternetProtocol::endpoint endpoint_type;
51
typedef typename InternetProtocol::resolver_query query_type;
53
/// The iterator type.
54
typedef typename InternetProtocol::resolver_iterator iterator_type;
57
// The type of the platform-specific implementation.
58
typedef asio::detail::resolver_service<InternetProtocol>
62
/// The type of a resolver implementation.
63
#if defined(GENERATING_DOCUMENTATION)
64
typedef implementation_defined implementation_type;
66
typedef typename service_impl_type::implementation_type implementation_type;
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))
77
/// Destroy all user-defined handler objects owned by the service.
78
void shutdown_service()
82
/// Construct a new resolver implementation.
83
void construct(implementation_type& impl)
85
service_impl_.construct(impl);
88
/// Destroy a resolver implementation.
89
void destroy(implementation_type& impl)
91
service_impl_.destroy(impl);
94
/// Cancel pending asynchronous operations.
95
void cancel(implementation_type& impl)
97
service_impl_.cancel(impl);
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)
104
return service_impl_.resolve(impl, query, ec);
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,
112
service_impl_.async_resolve(impl, query, handler);
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)
119
return service_impl_.resolve(impl, endpoint, ec);
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)
127
return service_impl_.async_resolve(impl, endpoint, handler);
131
// The service that provides the platform-specific implementation.
132
service_impl_type& service_impl_;
138
#include "asio/detail/pop_options.hpp"
140
#endif // ASIO_IP_RESOLVER_SERVICE_HPP