Realistic 3D camera system
3D camera system components
bind_handler.hpp
Go to the documentation of this file.
1 //
2 // detail/bind_handler.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_BIND_HANDLER_HPP
12 #define ASIO_DETAIL_BIND_HANDLER_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"
22 
24 
25 namespace asio {
26 namespace detail {
27 
28 template <typename Handler, typename Arg1>
29 class binder1
30 {
31 public:
32  binder1(const Handler& handler, const Arg1& arg1)
33  : handler_(handler),
34  arg1_(arg1)
35  {
36  }
37 
38  binder1(Handler& handler, const Arg1& arg1)
39  : handler_(ASIO_MOVE_CAST(Handler)(handler)),
40  arg1_(arg1)
41  {
42  }
43 
44  void operator()()
45  {
46  handler_(static_cast<const Arg1&>(arg1_));
47  }
48 
49  void operator()() const
50  {
51  handler_(arg1_);
52  }
53 
54 //private:
55  Handler handler_;
56  Arg1 arg1_;
57 };
58 
59 template <typename Handler, typename Arg1>
60 inline void* asio_handler_allocate(std::size_t size,
61  binder1<Handler, Arg1>* this_handler)
62 {
64  size, this_handler->handler_);
65 }
66 
67 template <typename Handler, typename Arg1>
68 inline void asio_handler_deallocate(void* pointer, std::size_t size,
69  binder1<Handler, Arg1>* this_handler)
70 {
72  pointer, size, this_handler->handler_);
73 }
74 
75 template <typename Handler, typename Arg1>
77  binder1<Handler, Arg1>* this_handler)
78 {
80  this_handler->handler_);
81 }
82 
83 template <typename Function, typename Handler, typename Arg1>
84 inline void asio_handler_invoke(Function& function,
85  binder1<Handler, Arg1>* this_handler)
86 {
88  function, this_handler->handler_);
89 }
90 
91 template <typename Function, typename Handler, typename Arg1>
92 inline void asio_handler_invoke(const Function& function,
93  binder1<Handler, Arg1>* this_handler)
94 {
96  function, this_handler->handler_);
97 }
98 
99 template <typename Handler, typename Arg1>
100 inline binder1<Handler, Arg1> bind_handler(Handler handler,
101  const Arg1& arg1)
102 {
103  return binder1<Handler, Arg1>(handler, arg1);
104 }
105 
106 template <typename Handler, typename Arg1, typename Arg2>
107 class binder2
108 {
109 public:
110  binder2(const Handler& handler, const Arg1& arg1, const Arg2& arg2)
111  : handler_(handler),
112  arg1_(arg1),
113  arg2_(arg2)
114  {
115  }
116 
117  binder2(Handler& handler, const Arg1& arg1, const Arg2& arg2)
118  : handler_(ASIO_MOVE_CAST(Handler)(handler)),
119  arg1_(arg1),
120  arg2_(arg2)
121  {
122  }
123 
124  void operator()()
125  {
126  handler_(static_cast<const Arg1&>(arg1_),
127  static_cast<const Arg2&>(arg2_));
128  }
129 
130  void operator()() const
131  {
132  handler_(arg1_, arg2_);
133  }
134 
135 //private:
136  Handler handler_;
137  Arg1 arg1_;
138  Arg2 arg2_;
139 };
140 
141 template <typename Handler, typename Arg1, typename Arg2>
142 inline void* asio_handler_allocate(std::size_t size,
143  binder2<Handler, Arg1, Arg2>* this_handler)
144 {
146  size, this_handler->handler_);
147 }
148 
149 template <typename Handler, typename Arg1, typename Arg2>
150 inline void asio_handler_deallocate(void* pointer, std::size_t size,
151  binder2<Handler, Arg1, Arg2>* this_handler)
152 {
154  pointer, size, this_handler->handler_);
155 }
156 
157 template <typename Handler, typename Arg1, typename Arg2>
159  binder2<Handler, Arg1, Arg2>* this_handler)
160 {
162  this_handler->handler_);
163 }
164 
165 template <typename Function, typename Handler, typename Arg1, typename Arg2>
166 inline void asio_handler_invoke(Function& function,
167  binder2<Handler, Arg1, Arg2>* this_handler)
168 {
170  function, this_handler->handler_);
171 }
172 
173 template <typename Function, typename Handler, typename Arg1, typename Arg2>
174 inline void asio_handler_invoke(const Function& function,
175  binder2<Handler, Arg1, Arg2>* this_handler)
176 {
178  function, this_handler->handler_);
179 }
180 
181 template <typename Handler, typename Arg1, typename Arg2>
183  const Arg1& arg1, const Arg2& arg2)
184 {
185  return binder2<Handler, Arg1, Arg2>(handler, arg1, arg2);
186 }
187 
188 template <typename Handler, typename Arg1, typename Arg2, typename Arg3>
189 class binder3
190 {
191 public:
192  binder3(const Handler& handler, const Arg1& arg1, const Arg2& arg2,
193  const Arg3& arg3)
194  : handler_(handler),
195  arg1_(arg1),
196  arg2_(arg2),
197  arg3_(arg3)
198  {
199  }
200 
201  binder3(Handler& handler, const Arg1& arg1, const Arg2& arg2,
202  const Arg3& arg3)
203  : handler_(ASIO_MOVE_CAST(Handler)(handler)),
204  arg1_(arg1),
205  arg2_(arg2),
206  arg3_(arg3)
207  {
208  }
209 
210  void operator()()
211  {
212  handler_(static_cast<const Arg1&>(arg1_),
213  static_cast<const Arg2&>(arg2_),
214  static_cast<const Arg3&>(arg3_));
215  }
216 
217  void operator()() const
218  {
219  handler_(arg1_, arg2_, arg3_);
220  }
221 
222 //private:
223  Handler handler_;
224  Arg1 arg1_;
225  Arg2 arg2_;
226  Arg3 arg3_;
227 };
228 
229 template <typename Handler, typename Arg1, typename Arg2, typename Arg3>
230 inline void* asio_handler_allocate(std::size_t size,
232 {
234  size, this_handler->handler_);
235 }
236 
237 template <typename Handler, typename Arg1, typename Arg2, typename Arg3>
238 inline void asio_handler_deallocate(void* pointer, std::size_t size,
240 {
242  pointer, size, this_handler->handler_);
243 }
244 
245 template <typename Handler, typename Arg1, typename Arg2, typename Arg3>
248 {
250  this_handler->handler_);
251 }
252 
253 template <typename Function, typename Handler, typename Arg1, typename Arg2,
254  typename Arg3>
255 inline void asio_handler_invoke(Function& function,
257 {
259  function, this_handler->handler_);
260 }
261 
262 template <typename Function, typename Handler, typename Arg1, typename Arg2,
263  typename Arg3>
264 inline void asio_handler_invoke(const Function& function,
266 {
268  function, this_handler->handler_);
269 }
270 
271 template <typename Handler, typename Arg1, typename Arg2, typename Arg3>
273  const Arg1& arg1, const Arg2& arg2, const Arg3& arg3)
274 {
275  return binder3<Handler, Arg1, Arg2, Arg3>(handler, arg1, arg2, arg3);
276 }
277 
278 template <typename Handler, typename Arg1, typename Arg2, typename Arg3,
279  typename Arg4>
280 class binder4
281 {
282 public:
283  binder4(const Handler& handler, const Arg1& arg1, const Arg2& arg2,
284  const Arg3& arg3, const Arg4& arg4)
285  : handler_(handler),
286  arg1_(arg1),
287  arg2_(arg2),
288  arg3_(arg3),
289  arg4_(arg4)
290  {
291  }
292 
293  binder4(Handler& handler, const Arg1& arg1, const Arg2& arg2,
294  const Arg3& arg3, const Arg4& arg4)
295  : handler_(ASIO_MOVE_CAST(Handler)(handler)),
296  arg1_(arg1),
297  arg2_(arg2),
298  arg3_(arg3),
299  arg4_(arg4)
300  {
301  }
302 
303  void operator()()
304  {
305  handler_(static_cast<const Arg1&>(arg1_),
306  static_cast<const Arg2&>(arg2_),
307  static_cast<const Arg3&>(arg3_),
308  static_cast<const Arg4&>(arg4_));
309  }
310 
311  void operator()() const
312  {
313  handler_(arg1_, arg2_, arg3_, arg4_);
314  }
315 
316 //private:
317  Handler handler_;
318  Arg1 arg1_;
319  Arg2 arg2_;
320  Arg3 arg3_;
321  Arg4 arg4_;
322 };
323 
324 template <typename Handler, typename Arg1, typename Arg2, typename Arg3,
325  typename Arg4>
326 inline void* asio_handler_allocate(std::size_t size,
328 {
330  size, this_handler->handler_);
331 }
332 
333 template <typename Handler, typename Arg1, typename Arg2, typename Arg3,
334  typename Arg4>
335 inline void asio_handler_deallocate(void* pointer, std::size_t size,
337 {
339  pointer, size, this_handler->handler_);
340 }
341 
342 template <typename Handler, typename Arg1, typename Arg2, typename Arg3,
343  typename Arg4>
346 {
348  this_handler->handler_);
349 }
350 
351 template <typename Function, typename Handler, typename Arg1, typename Arg2,
352  typename Arg3, typename Arg4>
353 inline void asio_handler_invoke(Function& function,
355 {
357  function, this_handler->handler_);
358 }
359 
360 template <typename Function, typename Handler, typename Arg1, typename Arg2,
361  typename Arg3, typename Arg4>
362 inline void asio_handler_invoke(const Function& function,
364 {
366  function, this_handler->handler_);
367 }
368 
369 template <typename Handler, typename Arg1, typename Arg2, typename Arg3,
370  typename Arg4>
372  Handler handler, const Arg1& arg1, const Arg2& arg2,
373  const Arg3& arg3, const Arg4& arg4)
374 {
375  return binder4<Handler, Arg1, Arg2, Arg3, Arg4>(handler, arg1, arg2, arg3,
376  arg4);
377 }
378 
379 template <typename Handler, typename Arg1, typename Arg2, typename Arg3,
380  typename Arg4, typename Arg5>
381 class binder5
382 {
383 public:
384  binder5(const Handler& handler, const Arg1& arg1, const Arg2& arg2,
385  const Arg3& arg3, const Arg4& arg4, const Arg5& arg5)
386  : handler_(handler),
387  arg1_(arg1),
388  arg2_(arg2),
389  arg3_(arg3),
390  arg4_(arg4),
391  arg5_(arg5)
392  {
393  }
394 
395  binder5(Handler& handler, const Arg1& arg1, const Arg2& arg2,
396  const Arg3& arg3, const Arg4& arg4, const Arg5& arg5)
397  : handler_(ASIO_MOVE_CAST(Handler)(handler)),
398  arg1_(arg1),
399  arg2_(arg2),
400  arg3_(arg3),
401  arg4_(arg4),
402  arg5_(arg5)
403  {
404  }
405 
406  void operator()()
407  {
408  handler_(static_cast<const Arg1&>(arg1_),
409  static_cast<const Arg2&>(arg2_),
410  static_cast<const Arg3&>(arg3_),
411  static_cast<const Arg4&>(arg4_),
412  static_cast<const Arg5&>(arg5_));
413  }
414 
415  void operator()() const
416  {
417  handler_(arg1_, arg2_, arg3_, arg4_, arg5_);
418  }
419 
420 //private:
421  Handler handler_;
422  Arg1 arg1_;
423  Arg2 arg2_;
424  Arg3 arg3_;
425  Arg4 arg4_;
426  Arg5 arg5_;
427 };
428 
429 template <typename Handler, typename Arg1, typename Arg2, typename Arg3,
430  typename Arg4, typename Arg5>
431 inline void* asio_handler_allocate(std::size_t size,
433 {
435  size, this_handler->handler_);
436 }
437 
438 template <typename Handler, typename Arg1, typename Arg2, typename Arg3,
439  typename Arg4, typename Arg5>
440 inline void asio_handler_deallocate(void* pointer, std::size_t size,
442 {
444  pointer, size, this_handler->handler_);
445 }
446 
447 template <typename Handler, typename Arg1, typename Arg2, typename Arg3,
448  typename Arg4, typename Arg5>
451 {
453  this_handler->handler_);
454 }
455 
456 template <typename Function, typename Handler, typename Arg1, typename Arg2,
457  typename Arg3, typename Arg4, typename Arg5>
458 inline void asio_handler_invoke(Function& function,
460 {
462  function, this_handler->handler_);
463 }
464 
465 template <typename Function, typename Handler, typename Arg1, typename Arg2,
466  typename Arg3, typename Arg4, typename Arg5>
467 inline void asio_handler_invoke(const Function& function,
469 {
471  function, this_handler->handler_);
472 }
473 
474 template <typename Handler, typename Arg1, typename Arg2, typename Arg3,
475  typename Arg4, typename Arg5>
477  Handler handler, const Arg1& arg1, const Arg2& arg2,
478  const Arg3& arg3, const Arg4& arg4, const Arg5& arg5)
479 {
480  return binder5<Handler, Arg1, Arg2, Arg3, Arg4, Arg5>(handler, arg1, arg2,
481  arg3, arg4, arg5);
482 }
483 
484 } // namespace detail
485 } // namespace asio
486 
488 
489 #endif // ASIO_DETAIL_BIND_HANDLER_HPP
void asio_handler_deallocate(void *pointer, std::size_t size, binder1< Handler, Arg1 > *this_handler)
binder1(Handler &handler, const Arg1 &arg1)
void * asio_handler_allocate(std::size_t size, binder1< Handler, Arg1 > *this_handler)
binder2(const Handler &handler, const Arg1 &arg1, const Arg2 &arg2)
binder5(const Handler &handler, const Arg1 &arg1, const Arg2 &arg2, const Arg3 &arg3, const Arg4 &arg4, const Arg5 &arg5)
binder1(const Handler &handler, const Arg1 &arg1)
void operator()() const
void operator()() const
binder3(Handler &handler, const Arg1 &arg1, const Arg2 &arg2, const Arg3 &arg3)
void invoke(Function &function, Context &context)
binder4(const Handler &handler, const Arg1 &arg1, const Arg2 &arg2, const Arg3 &arg3, const Arg4 &arg4)
void operator()() const
void operator()() const
void operator()() const
void asio_handler_invoke(Function &function, binder1< Handler, Arg1 > *this_handler)
bool is_continuation(Context &context)
void deallocate(void *p, std::size_t s, Handler &h)
binder4(Handler &handler, const Arg1 &arg1, const Arg2 &arg2, const Arg3 &arg3, const Arg4 &arg4)
void * allocate(std::size_t s, Handler &h)
binder3(const Handler &handler, const Arg1 &arg1, const Arg2 &arg2, const Arg3 &arg3)
#define ASIO_MOVE_CAST(type)
Definition: config.hpp:138
binder5(Handler &handler, const Arg1 &arg1, const Arg2 &arg2, const Arg3 &arg3, const Arg4 &arg4, const Arg5 &arg5)
binder1< Handler, Arg1 > bind_handler(Handler handler, const Arg1 &arg1)
binder2(Handler &handler, const Arg1 &arg1, const Arg2 &arg2)
bool asio_handler_is_continuation(binder1< Handler, Arg1 > *this_handler)