Statistics
| Revision:

root / tmp / org.txm.statsengine.r.core.win32 / res / win32 / library / BH / include / boost / asio / detail / bind_handler.hpp @ 2486

History | View | Annotate | Download (13.2 kB)

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 BOOST_ASIO_DETAIL_BIND_HANDLER_HPP
12
#define BOOST_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 <boost/asio/detail/config.hpp>
19
#include <boost/asio/detail/handler_alloc_helpers.hpp>
20
#include <boost/asio/detail/handler_cont_helpers.hpp>
21
#include <boost/asio/detail/handler_invoke_helpers.hpp>
22

    
23
#include <boost/asio/detail/push_options.hpp>
24

    
25
namespace boost {
26
namespace asio {
27
namespace detail {
28

    
29
template <typename Handler, typename Arg1>
30
class binder1
31
{
32
public:
33
  binder1(const Handler& handler, const Arg1& arg1)
34
    : handler_(handler),
35
      arg1_(arg1)
36
  {
37
  }
38

    
39
  binder1(Handler& handler, const Arg1& arg1)
40
    : handler_(BOOST_ASIO_MOVE_CAST(Handler)(handler)),
41
      arg1_(arg1)
42
  {
43
  }
44

    
45
  void operator()()
46
  {
47
    handler_(static_cast<const Arg1&>(arg1_));
48
  }
49

    
50
  void operator()() const
51
  {
52
    handler_(arg1_);
53
  }
54

    
55
//private:
56
  Handler handler_;
57
  Arg1 arg1_;
58
};
59

    
60
template <typename Handler, typename Arg1>
61
inline void* asio_handler_allocate(std::size_t size,
62
    binder1<Handler, Arg1>* this_handler)
63
{
64
  return boost_asio_handler_alloc_helpers::allocate(
65
      size, this_handler->handler_);
66
}
67

    
68
template <typename Handler, typename Arg1>
69
inline void asio_handler_deallocate(void* pointer, std::size_t size,
70
    binder1<Handler, Arg1>* this_handler)
71
{
72
  boost_asio_handler_alloc_helpers::deallocate(
73
      pointer, size, this_handler->handler_);
74
}
75

    
76
template <typename Handler, typename Arg1>
77
inline bool asio_handler_is_continuation(
78
    binder1<Handler, Arg1>* this_handler)
79
{
80
  return boost_asio_handler_cont_helpers::is_continuation(
81
      this_handler->handler_);
82
}
83

    
84
template <typename Function, typename Handler, typename Arg1>
85
inline void asio_handler_invoke(Function& function,
86
    binder1<Handler, Arg1>* this_handler)
87
{
88
  boost_asio_handler_invoke_helpers::invoke(
89
      function, this_handler->handler_);
90
}
91

    
92
template <typename Function, typename Handler, typename Arg1>
93
inline void asio_handler_invoke(const Function& function,
94
    binder1<Handler, Arg1>* this_handler)
95
{
96
  boost_asio_handler_invoke_helpers::invoke(
97
      function, this_handler->handler_);
98
}
99

    
100
template <typename Handler, typename Arg1>
101
inline binder1<Handler, Arg1> bind_handler(Handler handler,
102
    const Arg1& arg1)
103
{
104
  return binder1<Handler, Arg1>(handler, arg1);
105
}
106

    
107
template <typename Handler, typename Arg1, typename Arg2>
108
class binder2
109
{
110
public:
111
  binder2(const Handler& handler, const Arg1& arg1, const Arg2& arg2)
112
    : handler_(handler),
113
      arg1_(arg1),
114
      arg2_(arg2)
115
  {
116
  }
117

    
118
  binder2(Handler& handler, const Arg1& arg1, const Arg2& arg2)
119
    : handler_(BOOST_ASIO_MOVE_CAST(Handler)(handler)),
120
      arg1_(arg1),
121
      arg2_(arg2)
122
  {
123
  }
124

    
125
  void operator()()
126
  {
127
    handler_(static_cast<const Arg1&>(arg1_),
128
        static_cast<const Arg2&>(arg2_));
129
  }
130

    
131
  void operator()() const
132
  {
133
    handler_(arg1_, arg2_);
134
  }
135

    
136
//private:
137
  Handler handler_;
138
  Arg1 arg1_;
139
  Arg2 arg2_;
140
};
141

    
142
template <typename Handler, typename Arg1, typename Arg2>
143
inline void* asio_handler_allocate(std::size_t size,
144
    binder2<Handler, Arg1, Arg2>* this_handler)
145
{
146
  return boost_asio_handler_alloc_helpers::allocate(
147
      size, this_handler->handler_);
148
}
149

    
150
template <typename Handler, typename Arg1, typename Arg2>
151
inline void asio_handler_deallocate(void* pointer, std::size_t size,
152
    binder2<Handler, Arg1, Arg2>* this_handler)
153
{
154
  boost_asio_handler_alloc_helpers::deallocate(
155
      pointer, size, this_handler->handler_);
156
}
157

    
158
template <typename Handler, typename Arg1, typename Arg2>
159
inline bool asio_handler_is_continuation(
160
    binder2<Handler, Arg1, Arg2>* this_handler)
161
{
162
  return boost_asio_handler_cont_helpers::is_continuation(
163
      this_handler->handler_);
164
}
165

    
166
template <typename Function, typename Handler, typename Arg1, typename Arg2>
167
inline void asio_handler_invoke(Function& function,
168
    binder2<Handler, Arg1, Arg2>* this_handler)
169
{
170
  boost_asio_handler_invoke_helpers::invoke(
171
      function, this_handler->handler_);
172
}
173

    
174
template <typename Function, typename Handler, typename Arg1, typename Arg2>
175
inline void asio_handler_invoke(const Function& function,
176
    binder2<Handler, Arg1, Arg2>* this_handler)
177
{
178
  boost_asio_handler_invoke_helpers::invoke(
179
      function, this_handler->handler_);
180
}
181

    
182
template <typename Handler, typename Arg1, typename Arg2>
183
inline binder2<Handler, Arg1, Arg2> bind_handler(Handler handler,
184
    const Arg1& arg1, const Arg2& arg2)
185
{
186
  return binder2<Handler, Arg1, Arg2>(handler, arg1, arg2);
187
}
188

    
189
template <typename Handler, typename Arg1, typename Arg2, typename Arg3>
190
class binder3
191
{
192
public:
193
  binder3(const Handler& handler, const Arg1& arg1, const Arg2& arg2,
194
      const Arg3& arg3)
195
    : handler_(handler),
196
      arg1_(arg1),
197
      arg2_(arg2),
198
      arg3_(arg3)
199
  {
200
  }
201

    
202
  binder3(Handler& handler, const Arg1& arg1, const Arg2& arg2,
203
      const Arg3& arg3)
204
    : handler_(BOOST_ASIO_MOVE_CAST(Handler)(handler)),
205
      arg1_(arg1),
206
      arg2_(arg2),
207
      arg3_(arg3)
208
  {
209
  }
210

    
211
  void operator()()
212
  {
213
    handler_(static_cast<const Arg1&>(arg1_),
214
        static_cast<const Arg2&>(arg2_),
215
        static_cast<const Arg3&>(arg3_));
216
  }
217

    
218
  void operator()() const
219
  {
220
    handler_(arg1_, arg2_, arg3_);
221
  }
222

    
223
//private:
224
  Handler handler_;
225
  Arg1 arg1_;
226
  Arg2 arg2_;
227
  Arg3 arg3_;
228
};
229

    
230
template <typename Handler, typename Arg1, typename Arg2, typename Arg3>
231
inline void* asio_handler_allocate(std::size_t size,
232
    binder3<Handler, Arg1, Arg2, Arg3>* this_handler)
233
{
234
  return boost_asio_handler_alloc_helpers::allocate(
235
      size, this_handler->handler_);
236
}
237

    
238
template <typename Handler, typename Arg1, typename Arg2, typename Arg3>
239
inline void asio_handler_deallocate(void* pointer, std::size_t size,
240
    binder3<Handler, Arg1, Arg2, Arg3>* this_handler)
241
{
242
  boost_asio_handler_alloc_helpers::deallocate(
243
      pointer, size, this_handler->handler_);
244
}
245

    
246
template <typename Handler, typename Arg1, typename Arg2, typename Arg3>
247
inline bool asio_handler_is_continuation(
248
    binder3<Handler, Arg1, Arg2, Arg3>* this_handler)
249
{
250
  return boost_asio_handler_cont_helpers::is_continuation(
251
      this_handler->handler_);
252
}
253

    
254
template <typename Function, typename Handler, typename Arg1, typename Arg2,
255
    typename Arg3>
256
inline void asio_handler_invoke(Function& function,
257
    binder3<Handler, Arg1, Arg2, Arg3>* this_handler)
258
{
259
  boost_asio_handler_invoke_helpers::invoke(
260
      function, this_handler->handler_);
261
}
262

    
263
template <typename Function, typename Handler, typename Arg1, typename Arg2,
264
    typename Arg3>
265
inline void asio_handler_invoke(const Function& function,
266
    binder3<Handler, Arg1, Arg2, Arg3>* this_handler)
267
{
268
  boost_asio_handler_invoke_helpers::invoke(
269
      function, this_handler->handler_);
270
}
271

    
272
template <typename Handler, typename Arg1, typename Arg2, typename Arg3>
273
inline binder3<Handler, Arg1, Arg2, Arg3> bind_handler(Handler handler,
274
    const Arg1& arg1, const Arg2& arg2, const Arg3& arg3)
275
{
276
  return binder3<Handler, Arg1, Arg2, Arg3>(handler, arg1, arg2, arg3);
277
}
278

    
279
template <typename Handler, typename Arg1, typename Arg2, typename Arg3,
280
    typename Arg4>
281
class binder4
282
{
283
public:
284
  binder4(const Handler& handler, const Arg1& arg1, const Arg2& arg2,
285
      const Arg3& arg3, const Arg4& arg4)
286
    : handler_(handler),
287
      arg1_(arg1),
288
      arg2_(arg2),
289
      arg3_(arg3),
290
      arg4_(arg4)
291
  {
292
  }
293

    
294
  binder4(Handler& handler, const Arg1& arg1, const Arg2& arg2,
295
      const Arg3& arg3, const Arg4& arg4)
296
    : handler_(BOOST_ASIO_MOVE_CAST(Handler)(handler)),
297
      arg1_(arg1),
298
      arg2_(arg2),
299
      arg3_(arg3),
300
      arg4_(arg4)
301
  {
302
  }
303

    
304
  void operator()()
305
  {
306
    handler_(static_cast<const Arg1&>(arg1_),
307
        static_cast<const Arg2&>(arg2_),
308
        static_cast<const Arg3&>(arg3_),
309
        static_cast<const Arg4&>(arg4_));
310
  }
311

    
312
  void operator()() const
313
  {
314
    handler_(arg1_, arg2_, arg3_, arg4_);
315
  }
316

    
317
//private:
318
  Handler handler_;
319
  Arg1 arg1_;
320
  Arg2 arg2_;
321
  Arg3 arg3_;
322
  Arg4 arg4_;
323
};
324

    
325
template <typename Handler, typename Arg1, typename Arg2, typename Arg3,
326
    typename Arg4>
327
inline void* asio_handler_allocate(std::size_t size,
328
    binder4<Handler, Arg1, Arg2, Arg3, Arg4>* this_handler)
329
{
330
  return boost_asio_handler_alloc_helpers::allocate(
331
      size, this_handler->handler_);
332
}
333

    
334
template <typename Handler, typename Arg1, typename Arg2, typename Arg3,
335
    typename Arg4>
336
inline void asio_handler_deallocate(void* pointer, std::size_t size,
337
    binder4<Handler, Arg1, Arg2, Arg3, Arg4>* this_handler)
338
{
339
  boost_asio_handler_alloc_helpers::deallocate(
340
      pointer, size, this_handler->handler_);
341
}
342

    
343
template <typename Handler, typename Arg1, typename Arg2, typename Arg3,
344
    typename Arg4>
345
inline bool asio_handler_is_continuation(
346
    binder4<Handler, Arg1, Arg2, Arg3, Arg4>* this_handler)
347
{
348
  return boost_asio_handler_cont_helpers::is_continuation(
349
      this_handler->handler_);
350
}
351

    
352
template <typename Function, typename Handler, typename Arg1, typename Arg2,
353
    typename Arg3, typename Arg4>
354
inline void asio_handler_invoke(Function& function,
355
    binder4<Handler, Arg1, Arg2, Arg3, Arg4>* this_handler)
356
{
357
  boost_asio_handler_invoke_helpers::invoke(
358
      function, this_handler->handler_);
359
}
360

    
361
template <typename Function, typename Handler, typename Arg1, typename Arg2,
362
    typename Arg3, typename Arg4>
363
inline void asio_handler_invoke(const Function& function,
364
    binder4<Handler, Arg1, Arg2, Arg3, Arg4>* this_handler)
365
{
366
  boost_asio_handler_invoke_helpers::invoke(
367
      function, this_handler->handler_);
368
}
369

    
370
template <typename Handler, typename Arg1, typename Arg2, typename Arg3,
371
    typename Arg4>
372
inline binder4<Handler, Arg1, Arg2, Arg3, Arg4> bind_handler(
373
    Handler handler, const Arg1& arg1, const Arg2& arg2,
374
    const Arg3& arg3, const Arg4& arg4)
375
{
376
  return binder4<Handler, Arg1, Arg2, Arg3, Arg4>(handler, arg1, arg2, arg3,
377
      arg4);
378
}
379

    
380
template <typename Handler, typename Arg1, typename Arg2, typename Arg3,
381
    typename Arg4, typename Arg5>
382
class binder5
383
{
384
public:
385
  binder5(const Handler& handler, const Arg1& arg1, const Arg2& arg2,
386
      const Arg3& arg3, const Arg4& arg4, const Arg5& arg5)
387
    : handler_(handler),
388
      arg1_(arg1),
389
      arg2_(arg2),
390
      arg3_(arg3),
391
      arg4_(arg4),
392
      arg5_(arg5)
393
  {
394
  }
395

    
396
  binder5(Handler& handler, const Arg1& arg1, const Arg2& arg2,
397
      const Arg3& arg3, const Arg4& arg4, const Arg5& arg5)
398
    : handler_(BOOST_ASIO_MOVE_CAST(Handler)(handler)),
399
      arg1_(arg1),
400
      arg2_(arg2),
401
      arg3_(arg3),
402
      arg4_(arg4),
403
      arg5_(arg5)
404
  {
405
  }
406

    
407
  void operator()()
408
  {
409
    handler_(static_cast<const Arg1&>(arg1_),
410
        static_cast<const Arg2&>(arg2_),
411
        static_cast<const Arg3&>(arg3_),
412
        static_cast<const Arg4&>(arg4_),
413
        static_cast<const Arg5&>(arg5_));
414
  }
415

    
416
  void operator()() const
417
  {
418
    handler_(arg1_, arg2_, arg3_, arg4_, arg5_);
419
  }
420

    
421
//private:
422
  Handler handler_;
423
  Arg1 arg1_;
424
  Arg2 arg2_;
425
  Arg3 arg3_;
426
  Arg4 arg4_;
427
  Arg5 arg5_;
428
};
429

    
430
template <typename Handler, typename Arg1, typename Arg2, typename Arg3,
431
    typename Arg4, typename Arg5>
432
inline void* asio_handler_allocate(std::size_t size,
433
    binder5<Handler, Arg1, Arg2, Arg3, Arg4, Arg5>* this_handler)
434
{
435
  return boost_asio_handler_alloc_helpers::allocate(
436
      size, this_handler->handler_);
437
}
438

    
439
template <typename Handler, typename Arg1, typename Arg2, typename Arg3,
440
    typename Arg4, typename Arg5>
441
inline void asio_handler_deallocate(void* pointer, std::size_t size,
442
    binder5<Handler, Arg1, Arg2, Arg3, Arg4, Arg5>* this_handler)
443
{
444
  boost_asio_handler_alloc_helpers::deallocate(
445
      pointer, size, this_handler->handler_);
446
}
447

    
448
template <typename Handler, typename Arg1, typename Arg2, typename Arg3,
449
    typename Arg4, typename Arg5>
450
inline bool asio_handler_is_continuation(
451
    binder5<Handler, Arg1, Arg2, Arg3, Arg4, Arg5>* this_handler)
452
{
453
  return boost_asio_handler_cont_helpers::is_continuation(
454
      this_handler->handler_);
455
}
456

    
457
template <typename Function, typename Handler, typename Arg1, typename Arg2,
458
    typename Arg3, typename Arg4, typename Arg5>
459
inline void asio_handler_invoke(Function& function,
460
    binder5<Handler, Arg1, Arg2, Arg3, Arg4, Arg5>* this_handler)
461
{
462
  boost_asio_handler_invoke_helpers::invoke(
463
      function, this_handler->handler_);
464
}
465

    
466
template <typename Function, typename Handler, typename Arg1, typename Arg2,
467
    typename Arg3, typename Arg4, typename Arg5>
468
inline void asio_handler_invoke(const Function& function,
469
    binder5<Handler, Arg1, Arg2, Arg3, Arg4, Arg5>* this_handler)
470
{
471
  boost_asio_handler_invoke_helpers::invoke(
472
      function, this_handler->handler_);
473
}
474

    
475
template <typename Handler, typename Arg1, typename Arg2, typename Arg3,
476
    typename Arg4, typename Arg5>
477
inline binder5<Handler, Arg1, Arg2, Arg3, Arg4, Arg5> bind_handler(
478
    Handler handler, const Arg1& arg1, const Arg2& arg2,
479
    const Arg3& arg3, const Arg4& arg4, const Arg5& arg5)
480
{
481
  return binder5<Handler, Arg1, Arg2, Arg3, Arg4, Arg5>(handler, arg1, arg2,
482
      arg3, arg4, arg5);
483
}
484

    
485
} // namespace detail
486
} // namespace asio
487
} // namespace boost
488

    
489
#include <boost/asio/detail/pop_options.hpp>
490

    
491
#endif // BOOST_ASIO_DETAIL_BIND_HANDLER_HPP