Realistic 3D camera system
3D camera system components
winrt_resolver_service.hpp
Go to the documentation of this file.
1 //
2 // detail/winrt_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_DETAIL_WINRT_RESOLVER_SERVICE_HPP
12 #define ASIO_DETAIL_WINRT_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 
20 #if defined(ASIO_WINDOWS_RUNTIME)
21 
30 
32 
33 namespace asio {
34 namespace detail {
35 
36 template <typename Protocol>
37 class winrt_resolver_service
38 {
39 public:
40  // The implementation type of the resolver. A cancellation token is used to
41  // indicate to the asynchronous operation that the operation has been
42  // cancelled.
43  typedef socket_ops::shared_cancel_token_type implementation_type;
44 
45  // The endpoint type.
46  typedef typename Protocol::endpoint endpoint_type;
47 
48  // The query type.
50 
51  // The iterator type.
52  typedef asio::ip::basic_resolver_iterator<Protocol> iterator_type;
53 
54  // Constructor.
55  winrt_resolver_service(asio::io_service& io_service)
56  : io_service_(use_service<io_service_impl>(io_service)),
57  async_manager_(use_service<winrt_async_manager>(io_service))
58  {
59  }
60 
61  // Destructor.
62  ~winrt_resolver_service()
63  {
64  }
65 
66  // Destroy all user-defined handler objects owned by the service.
67  void shutdown_service()
68  {
69  }
70 
71  // Perform any fork-related housekeeping.
72  void fork_service(asio::io_service::fork_event)
73  {
74  }
75 
76  // Construct a new resolver implementation.
77  void construct(implementation_type&)
78  {
79  }
80 
81  // Destroy a resolver implementation.
82  void destroy(implementation_type&)
83  {
84  }
85 
86  // Cancel pending asynchronous operations.
87  void cancel(implementation_type&)
88  {
89  }
90 
91  // Resolve a query to a list of entries.
92  iterator_type resolve(implementation_type&,
93  const query_type& query, asio::error_code& ec)
94  {
95  try
96  {
97  using namespace Windows::Networking::Sockets;
98  auto endpoint_pairs = async_manager_.sync(
99  DatagramSocket::GetEndpointPairsAsync(
100  winrt_utils::host_name(query.host_name()),
101  winrt_utils::string(query.service_name())), ec);
102 
103  if (ec)
104  return iterator_type();
105 
106  return iterator_type::create(
107  endpoint_pairs, query.hints(),
108  query.host_name(), query.service_name());
109  }
110  catch (Platform::Exception^ e)
111  {
112  ec = asio::error_code(e->HResult,
114  return iterator_type();
115  }
116  }
117 
118  // Asynchronously resolve a query to a list of entries.
119  template <typename Handler>
120  void async_resolve(implementation_type&,
121  const query_type& query, Handler& handler)
122  {
123  bool is_continuation =
125 
126  // Allocate and construct an operation to wrap the handler.
127  typedef winrt_resolve_op<Protocol, Handler> op;
128  typename op::ptr p = { asio::detail::addressof(handler),
130  sizeof(op), handler), 0 };
131  p.p = new (p.v) op(query, handler);
132 
133  ASIO_HANDLER_CREATION((p.p, "resolver", &impl, "async_resolve"));
134 
135  try
136  {
137  using namespace Windows::Networking::Sockets;
138  async_manager_.async(DatagramSocket::GetEndpointPairsAsync(
139  winrt_utils::host_name(query.host_name()),
140  winrt_utils::string(query.service_name())), p.p);
141  p.v = p.p = 0;
142  }
143  catch (Platform::Exception^ e)
144  {
145  p.p->ec_ = asio::error_code(
146  e->HResult, asio::system_category());
147  io_service_.post_immediate_completion(p.p, is_continuation);
148  p.v = p.p = 0;
149  }
150  }
151 
152  // Resolve an endpoint to a list of entries.
153  iterator_type resolve(implementation_type&,
154  const endpoint_type&, asio::error_code& ec)
155  {
157  return iterator_type();
158  }
159 
160  // Asynchronously resolve an endpoint to a list of entries.
161  template <typename Handler>
162  void async_resolve(implementation_type&,
163  const endpoint_type&, Handler& handler)
164  {
166  const iterator_type iterator;
167  io_service_.get_io_service().post(
168  detail::bind_handler(handler, ec, iterator));
169  }
170 
171 private:
172  io_service_impl& io_service_;
173  winrt_async_manager& async_manager_;
174 };
175 
176 } // namespace detail
177 } // namespace asio
178 
180 
181 #endif // defined(ASIO_WINDOWS_RUNTIME)
182 
183 #endif // ASIO_DETAIL_WINRT_RESOLVER_SERVICE_HPP
shared_ptr< void > shared_cancel_token_type
Definition: socket_ops.hpp:62
Provides core I/O functionality.
Definition: io_service.hpp:184
pylon Camera Software Suite for Linux for Use with Basler Gigabit the pylon Viewer and the IP Configurator applications might not be available System I340 and I350 series Although the pylon software will work with any GigE network we would recommend to use one of these adapters USB For U3V devices a USB3 capable USB controller is necessary For best performance and stability we highly recommend a kernel the following settings should be i e
Service & use_service(io_service &ios)
Definition: io_service.hpp:26
class task_io_service io_service_impl
Definition: io_service.hpp:48
fork_event
Fork-related event notifications.
Definition: io_service.hpp:501
bool is_continuation(Context &context)
Class to represent an error code value.
Definition: error_code.hpp:80
ASIO_DECL std::string host_name()
Get the current host name.
Definition: host_name.ipp:29
void * allocate(std::size_t s, Handler &h)
binder1< Handler, Arg1 > bind_handler(Handler handler, const Arg1 &arg1)
#define ASIO_HANDLER_CREATION(args)
ASIO_DECL const error_category & system_category()
Returns the error category used for the system errors produced by asio.
Definition: error_code.ipp:118
Operation not supported.
Definition: error.hpp:166