Realistic 3D camera system
3D camera system components
resolver_service.hpp
Go to the documentation of this file.
1 //
2 // ip/resolver_service.hpp
3 // ~~~~~~~~~~~~~~~~~~~~~~~
4 //
5 // Copyright (c) 2003-2015 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/config.hpp"
19 #include "asio/async_result.hpp"
20 #include "asio/error_code.hpp"
21 #include "asio/io_service.hpp"
24 
25 #if defined(ASIO_WINDOWS_RUNTIME)
27 #else
29 #endif
30 
32 
33 namespace asio {
34 namespace ip {
35 
37 template <typename InternetProtocol>
39 #if defined(GENERATING_DOCUMENTATION)
41 #else
43  resolver_service<InternetProtocol> >
44 #endif
45 {
46 public:
47 #if defined(GENERATING_DOCUMENTATION)
48  static asio::io_service::id id;
50 #endif
51 
53  typedef InternetProtocol protocol_type;
54 
56  typedef typename InternetProtocol::endpoint endpoint_type;
57 
60 
63 
64 private:
65  // The type of the platform-specific implementation.
66 #if defined(ASIO_WINDOWS_RUNTIME)
67  typedef asio::detail::winrt_resolver_service<InternetProtocol>
69 #else
71  service_impl_type;
72 #endif
73 
74 public:
76 #if defined(GENERATING_DOCUMENTATION)
77  typedef implementation_defined implementation_type;
78 #else
80 #endif
81 
84  : asio::detail::service_base<
85  resolver_service<InternetProtocol> >(io_service),
86  service_impl_(io_service)
87  {
88  }
89 
91  void construct(implementation_type& impl)
92  {
93  service_impl_.construct(impl);
94  }
95 
97  void destroy(implementation_type& impl)
98  {
99  service_impl_.destroy(impl);
100  }
101 
103  void cancel(implementation_type& impl)
104  {
105  service_impl_.cancel(impl);
106  }
107 
109  iterator_type resolve(implementation_type& impl, const query_type& query,
110  asio::error_code& ec)
111  {
112  return service_impl_.resolve(impl, query, ec);
113  }
114 
116  template <typename ResolveHandler>
117  ASIO_INITFN_RESULT_TYPE(ResolveHandler,
118  void (asio::error_code, iterator_type))
119  async_resolve(implementation_type& impl, const query_type& query,
120  ASIO_MOVE_ARG(ResolveHandler) handler)
121  {
123  ResolveHandler, void (asio::error_code, iterator_type)> init(
124  ASIO_MOVE_CAST(ResolveHandler)(handler));
125 
126  service_impl_.async_resolve(impl, query, init.handler);
127 
128  return init.result.get();
129  }
130 
134  {
135  return service_impl_.resolve(impl, endpoint, ec);
136  }
137 
139  template <typename ResolveHandler>
140  ASIO_INITFN_RESULT_TYPE(ResolveHandler,
142  async_resolve(implementation_type& impl, const endpoint_type& endpoint,
143  ASIO_MOVE_ARG(ResolveHandler) handler)
144  {
146  ResolveHandler, void (asio::error_code, iterator_type)> init(
147  ASIO_MOVE_CAST(ResolveHandler)(handler));
148 
149  service_impl_.async_resolve(impl, endpoint, init.handler);
150 
151  return init.result.get();
152  }
153 
154 private:
155  // Destroy all user-defined handler objects owned by the service.
156  void shutdown_service()
157  {
158  service_impl_.shutdown_service();
159  }
160 
161  // Perform any fork-related housekeeping.
162  void fork_service(asio::io_service::fork_event event)
163  {
164  service_impl_.fork_service(event);
165  }
166 
167  // The platform-specific implementation.
168  service_impl_type service_impl_;
169 };
170 
171 } // namespace ip
172 } // namespace asio
173 
175 
176 #endif // ASIO_IP_RESOLVER_SERVICE_HPP
ASIO_DECL void destroy(implementation_type &)
ASIO_DECL void construct(implementation_type &impl)
An query to be passed to a resolver.
Class used to uniquely identify a service.
Definition: io_service.hpp:665
Provides core I/O functionality.
Definition: io_service.hpp:184
asio::basic_streambuf< Allocator > MatchCondition enable_if< is_match_condition< MatchCondition >::value >::type *detail::async_result_init< ReadHandler, void(asio::error_code, std::size_t)> init(ASIO_MOVE_CAST(ReadHandler)(handler))
void destroy(implementation_type &impl)
Destroy a resolver implementation.
service_impl_type::implementation_type implementation_type
The type of a resolver implementation.
void async_resolve(implementation_type &impl, const query_type &query, Handler &handler)
iterator_type resolve(implementation_type &impl, const query_type &query, asio::error_code &ec)
Resolve a query to a list of entries.
resolver_service(asio::io_service &io_service)
Construct a new resolver service for the specified io_service.
ASIO_DECL void fork_service(asio::io_service::fork_event fork_ev)
ASIO_DECL void cancel(implementation_type &impl)
void construct(implementation_type &impl)
Construct a new resolver implementation.
ASIO_INITFN_RESULT_TYPE(ResolveHandler, void(asio::error_code, iterator_type)) async_resolve(implementation_type &impl
Asynchronously resolve a query to a list of entries.
void cancel(implementation_type &impl)
Cancel pending asynchronous operations.
fork_event
Fork-related event notifications.
Definition: io_service.hpp:501
iterator_type resolve(implementation_type &impl, const endpoint_type &endpoint, asio::error_code &ec)
Resolve an endpoint to a list of entries.
Class to represent an error code value.
Definition: error_code.hpp:80
socket_ops::shared_cancel_token_type implementation_type
An iterator over the entries produced by a resolver.
static asio::detail::service_id< resolver_service< InternetProtocol > > id
Definition: io_service.hpp:748
const endpoint_type & endpoint
Default service implementation for a resolver.
handler_type< Handler, Signature >::type handler
const query_type ASIO_MOVE_ARG(ResolveHandler) handler)
InternetProtocol::endpoint endpoint_type
The endpoint type.
#define ASIO_MOVE_CAST(type)
Definition: config.hpp:138
async_result< typename handler_type< Handler, Signature >::type > result
null_event event
Definition: event.hpp:36
Base class for all io_service services.
Definition: io_service.hpp:674
basic_resolver_query< InternetProtocol > query_type
The query type.
basic_resolver_iterator< InternetProtocol > iterator_type
The iterator type.
iterator_type resolve(implementation_type &, const query_type &query, asio::error_code &ec)
InternetProtocol protocol_type
The protocol type.