Audio plugin host https://kx.studio/carla
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

resolver_service.hpp 4.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178
  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. #ifndef ASIO_IP_RESOLVER_SERVICE_HPP
  11. #define ASIO_IP_RESOLVER_SERVICE_HPP
  12. #if defined(_MSC_VER) && (_MSC_VER >= 1200)
  13. # pragma once
  14. #endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
  15. #include "asio/detail/config.hpp"
  16. #include "asio/async_result.hpp"
  17. #include "asio/error_code.hpp"
  18. #include "asio/io_context.hpp"
  19. #include "asio/ip/basic_resolver_iterator.hpp"
  20. #include "asio/ip/basic_resolver_query.hpp"
  21. #include "asio/ip/basic_resolver_results.hpp"
  22. #if defined(ASIO_WINDOWS_RUNTIME)
  23. # include "asio/detail/winrt_resolver_service.hpp"
  24. #else
  25. # include "asio/detail/resolver_service.hpp"
  26. #endif
  27. #include "asio/detail/push_options.hpp"
  28. namespace asio {
  29. namespace ip {
  30. /// Default service implementation for a resolver.
  31. template <typename InternetProtocol>
  32. class resolver_service
  33. #if defined(GENERATING_DOCUMENTATION)
  34. : public asio::io_context::service
  35. #else
  36. : public asio::detail::service_base<
  37. resolver_service<InternetProtocol> >
  38. #endif
  39. {
  40. public:
  41. #if defined(GENERATING_DOCUMENTATION)
  42. /// The unique service identifier.
  43. static asio::io_context::id id;
  44. #endif
  45. /// The protocol type.
  46. typedef InternetProtocol protocol_type;
  47. /// The endpoint type.
  48. typedef typename InternetProtocol::endpoint endpoint_type;
  49. /// The query type.
  50. typedef basic_resolver_query<InternetProtocol> query_type;
  51. /// The iterator type.
  52. typedef basic_resolver_iterator<InternetProtocol> iterator_type;
  53. /// The results type.
  54. typedef basic_resolver_results<InternetProtocol> results_type;
  55. private:
  56. // The type of the platform-specific implementation.
  57. #if defined(ASIO_WINDOWS_RUNTIME)
  58. typedef asio::detail::winrt_resolver_service<InternetProtocol>
  59. service_impl_type;
  60. #else
  61. typedef asio::detail::resolver_service<InternetProtocol>
  62. service_impl_type;
  63. #endif
  64. public:
  65. /// The type of a resolver implementation.
  66. #if defined(GENERATING_DOCUMENTATION)
  67. typedef implementation_defined implementation_type;
  68. #else
  69. typedef typename service_impl_type::implementation_type implementation_type;
  70. #endif
  71. /// Construct a new resolver service for the specified io_context.
  72. explicit resolver_service(asio::io_context& io_context)
  73. : asio::detail::service_base<
  74. resolver_service<InternetProtocol> >(io_context),
  75. service_impl_(io_context)
  76. {
  77. }
  78. /// Construct a new resolver implementation.
  79. void construct(implementation_type& impl)
  80. {
  81. service_impl_.construct(impl);
  82. }
  83. /// Destroy a resolver implementation.
  84. void destroy(implementation_type& impl)
  85. {
  86. service_impl_.destroy(impl);
  87. }
  88. /// Cancel pending asynchronous operations.
  89. void cancel(implementation_type& impl)
  90. {
  91. service_impl_.cancel(impl);
  92. }
  93. /// Resolve a query to a list of entries.
  94. results_type resolve(implementation_type& impl, const query_type& query,
  95. asio::error_code& ec)
  96. {
  97. return service_impl_.resolve(impl, query, ec);
  98. }
  99. /// Asynchronously resolve a query to a list of entries.
  100. template <typename ResolveHandler>
  101. ASIO_INITFN_RESULT_TYPE(ResolveHandler,
  102. void (asio::error_code, results_type))
  103. async_resolve(implementation_type& impl, const query_type& query,
  104. ASIO_MOVE_ARG(ResolveHandler) handler)
  105. {
  106. asio::async_completion<ResolveHandler,
  107. void (asio::error_code, results_type)> init(handler);
  108. service_impl_.async_resolve(impl, query, init.handler);
  109. return init.result.get();
  110. }
  111. /// Resolve an endpoint to a list of entries.
  112. results_type resolve(implementation_type& impl,
  113. const endpoint_type& endpoint, asio::error_code& ec)
  114. {
  115. return service_impl_.resolve(impl, endpoint, ec);
  116. }
  117. /// Asynchronously resolve an endpoint to a list of entries.
  118. template <typename ResolveHandler>
  119. ASIO_INITFN_RESULT_TYPE(ResolveHandler,
  120. void (asio::error_code, results_type))
  121. async_resolve(implementation_type& impl, const endpoint_type& endpoint,
  122. ASIO_MOVE_ARG(ResolveHandler) handler)
  123. {
  124. asio::async_completion<ResolveHandler,
  125. void (asio::error_code, results_type)> init(handler);
  126. service_impl_.async_resolve(impl, endpoint, init.handler);
  127. return init.result.get();
  128. }
  129. private:
  130. // Destroy all user-defined handler objects owned by the service.
  131. void shutdown()
  132. {
  133. service_impl_.shutdown();
  134. }
  135. // Perform any fork-related housekeeping.
  136. void notify_fork(asio::io_context::fork_event event)
  137. {
  138. service_impl_.notify_fork(event);
  139. }
  140. // The platform-specific implementation.
  141. service_impl_type service_impl_;
  142. };
  143. } // namespace ip
  144. } // namespace asio
  145. #include "asio/detail/pop_options.hpp"
  146. #endif // ASIO_IP_RESOLVER_SERVICE_HPP