Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(157)

Side by Side Diff: webrtc/base/bind.h

Issue 2719683002: Rewrite rtc::Bind using variadic templates. (Closed)
Patch Set: Mention where sequence_generator comes from in a comment. Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | webrtc/base/bind.h.pump » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // This file was GENERATED by command:
2 // pump.py bind.h.pump
3 // DO NOT EDIT BY HAND!!!
4
5 /* 1 /*
6 * Copyright 2012 The WebRTC Project Authors. All rights reserved. 2 * Copyright 2012 The WebRTC Project Authors. All rights reserved.
7 * 3 *
8 * Use of this source code is governed by a BSD-style license 4 * Use of this source code is governed by a BSD-style license
9 * that can be found in the LICENSE file in the root of the source 5 * that can be found in the LICENSE file in the root of the source
10 * tree. An additional intellectual property rights grant can be found 6 * tree. An additional intellectual property rights grant can be found
11 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
12 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
13 */ 9 */
14 10
15 // To generate bind.h from bind.h.pump, execute:
16 // /home/build/google3/third_party/gtest/scripts/pump.py bind.h.pump
17
18 // Bind() is an overloaded function that converts method calls into function 11 // Bind() is an overloaded function that converts method calls into function
19 // objects (aka functors). The method object is captured as a scoped_refptr<> if 12 // objects (aka functors). The method object is captured as a scoped_refptr<> if
20 // possible, and as a raw pointer otherwise. Any arguments to the method are 13 // possible, and as a raw pointer otherwise. Any arguments to the method are
21 // captured by value. The return value of Bind is a stateful, nullary function 14 // captured by value. The return value of Bind is a stateful, nullary function
22 // object. Care should be taken about the lifetime of objects captured by 15 // object. Care should be taken about the lifetime of objects captured by
23 // Bind(); the returned functor knows nothing about the lifetime of a non 16 // Bind(); the returned functor knows nothing about the lifetime of a non
24 // ref-counted method object or any arguments passed by pointer, and calling the 17 // ref-counted method object or any arguments passed by pointer, and calling the
25 // functor with a destroyed object will surely do bad things. 18 // functor with a destroyed object will surely do bad things.
26 // 19 //
27 // Example usage: 20 // Example usage:
(...skipping 29 matching lines...) Expand all
57 // auto functor = rtc::Bind(&Bar::Test, bar); 50 // auto functor = rtc::Bind(&Bar::Test, bar);
58 // bar = nullptr; 51 // bar = nullptr;
59 // // The functor stores an internal scoped_refptr<Bar>, so this is safe. 52 // // The functor stores an internal scoped_refptr<Bar>, so this is safe.
60 // functor(); 53 // functor();
61 // } 54 // }
62 // 55 //
63 56
64 #ifndef WEBRTC_BASE_BIND_H_ 57 #ifndef WEBRTC_BASE_BIND_H_
65 #define WEBRTC_BASE_BIND_H_ 58 #define WEBRTC_BASE_BIND_H_
66 59
60 #include <tuple>
61 #include <type_traits>
62
67 #include "webrtc/base/scoped_ref_ptr.h" 63 #include "webrtc/base/scoped_ref_ptr.h"
68 #include "webrtc/base/template_util.h" 64 #include "webrtc/base/template_util.h"
69 65
70 #define NONAME 66 #define NONAME
71 67
72 namespace rtc { 68 namespace rtc {
73 namespace detail { 69 namespace detail {
74 // This is needed because the template parameters in Bind can't be resolved 70 // This is needed because the template parameters in Bind can't be resolved
75 // if they're used both as parameters of the function pointer type and as 71 // if they're used both as parameters of the function pointer type and as
76 // parameters to Bind itself: the function pointer parameters are exact 72 // parameters to Bind itself: the function pointer parameters are exact
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
124 // otherwise. 120 // otherwise.
125 template <class T> 121 template <class T>
126 struct PointerType { 122 struct PointerType {
127 typedef typename TernaryTypeOperator<IsRefCounted<T>::value, 123 typedef typename TernaryTypeOperator<IsRefCounted<T>::value,
128 scoped_refptr<T>, 124 scoped_refptr<T>,
129 T*>::type type; 125 T*>::type type;
130 }; 126 };
131 127
132 } // namespace detail 128 } // namespace detail
133 129
134 template <class ObjectT, class MethodT, class R> 130 template <class ObjectT, class MethodT, class R, typename... Args>
135 class MethodFunctor0 { 131 class MethodFunctor {
136 public: 132 public:
137 MethodFunctor0(MethodT method, ObjectT* object) 133 MethodFunctor(MethodT method, ObjectT* object, Args... args)
138 : method_(method), object_(object) {} 134 : method_(method), object_(object), args_(args...) {}
139 R operator()() const { 135 R operator()() const {
140 return (object_->*method_)(); } 136 return CallMethod(typename sequence_generator<sizeof...(Args)>::type());
137 }
138
141 private: 139 private:
140 // Use sequence_generator (see template_util.h) to expand a MethodFunctor
141 // with 2 arguments to (std::get<0>(args_), std::get<1>(args_)), for
142 // instance.
143 template <int... S>
144 R CallMethod(sequence<S...>) const {
145 return (object_->*method_)(std::get<S>(args_)...);
146 }
147
142 MethodT method_; 148 MethodT method_;
143 typename detail::PointerType<ObjectT>::type object_; 149 typename detail::PointerType<ObjectT>::type object_;
150 typename std::tuple<typename std::remove_reference<Args>::type...> args_;
144 }; 151 };
145 152
146 template <class FunctorT, class R> 153 template <class FunctorT, class R, typename... Args>
147 class Functor0 { 154 class Functor {
148 public: 155 public:
149 explicit Functor0(const FunctorT& functor) 156 Functor(const FunctorT& functor, Args... args)
150 : functor_(functor) {} 157 : functor_(functor), args_(args...) {}
151 R operator()() const { 158 R operator()() const {
152 return functor_(); } 159 return CallFunction(typename sequence_generator<sizeof...(Args)>::type());
160 }
161
153 private: 162 private:
163 // Use sequence_generator (see template_util.h) to expand a Functor
164 // with 2 arguments to (std::get<0>(args_), std::get<1>(args_)), for
165 // instance.
166 template <int... S>
167 R CallFunction(sequence<S...>) const {
168 return functor_(std::get<S>(args_)...);
169 }
170
154 FunctorT functor_; 171 FunctorT functor_;
172 typename std::tuple<typename std::remove_reference<Args>::type...> args_;
155 }; 173 };
156 174
175 #define FP_T(x) R (ObjectT::*x)(Args...)
157 176
158 #define FP_T(x) R (ObjectT::*x)() 177 template <class ObjectT, class R, typename... Args>
159 178 MethodFunctor<ObjectT, FP_T(NONAME), R, Args...> Bind(
160 template <class ObjectT, class R> 179 FP_T(method),
161 MethodFunctor0<ObjectT, FP_T(NONAME), R> 180 ObjectT* object,
162 Bind(FP_T(method), ObjectT* object) { 181 typename detail::identity<Args>::type... args) {
163 return MethodFunctor0<ObjectT, FP_T(NONAME), R>( 182 return MethodFunctor<ObjectT, FP_T(NONAME), R, Args...>(method, object,
164 method, object); 183 args...);
165 } 184 }
166 185
167 #undef FP_T 186 #undef FP_T
168 #define FP_T(x) R (ObjectT::*x)() const 187 #define FP_T(x) R (ObjectT::*x)(Args...) const
169 188
170 template <class ObjectT, class R> 189 template <class ObjectT, class R, typename... Args>
171 MethodFunctor0<const ObjectT, FP_T(NONAME), R> 190 MethodFunctor<const ObjectT, FP_T(NONAME), R, Args...> Bind(
172 Bind(FP_T(method), const ObjectT* object) { 191 FP_T(method),
173 return MethodFunctor0<const ObjectT, FP_T(NONAME), R>( 192 const ObjectT* object,
174 method, object); 193 typename detail::identity<Args>::type... args) {
194 return MethodFunctor<const ObjectT, FP_T(NONAME), R, Args...>(method, object,
195 args...);
175 } 196 }
176 197
177 #undef FP_T 198 #undef FP_T
178 #define FP_T(x) R (ObjectT::*x)() 199 #define FP_T(x) R (ObjectT::*x)(Args...)
179 200
180 template <class ObjectT, class R> 201 template <class ObjectT, class R, typename... Args>
181 MethodFunctor0<ObjectT, FP_T(NONAME), R> 202 MethodFunctor<ObjectT, FP_T(NONAME), R, Args...> Bind(
182 Bind(FP_T(method), const scoped_refptr<ObjectT>& object) { 203 FP_T(method),
183 return MethodFunctor0<ObjectT, FP_T(NONAME), R>( 204 const scoped_refptr<ObjectT>& object,
184 method, object.get()); 205 typename detail::identity<Args>::type... args) {
206 return MethodFunctor<ObjectT, FP_T(NONAME), R, Args...>(method, object.get(),
207 args...);
185 } 208 }
186 209
187 #undef FP_T 210 #undef FP_T
188 #define FP_T(x) R (*x)() 211 #define FP_T(x) R (*x)(Args...)
189 212
190 template <class R> 213 template <class R, typename... Args>
191 Functor0<FP_T(NONAME), R> 214 Functor<FP_T(NONAME), R, Args...> Bind(
192 Bind(FP_T(function)) { 215 FP_T(function),
193 return Functor0<FP_T(NONAME), R>( 216 typename detail::identity<Args>::type... args) {
194 function); 217 return Functor<FP_T(NONAME), R, Args...>(function, args...);
195 } 218 }
196 219
197 #undef FP_T 220 #undef FP_T
198
199 template <class ObjectT, class MethodT, class R,
200 class P1>
201 class MethodFunctor1 {
202 public:
203 MethodFunctor1(MethodT method, ObjectT* object,
204 P1 p1)
205 : method_(method), object_(object),
206 p1_(p1) {}
207 R operator()() const {
208 return (object_->*method_)(p1_); }
209 private:
210 MethodT method_;
211 typename detail::PointerType<ObjectT>::type object_;
212 typename rtc::remove_reference<P1>::type p1_;
213 };
214
215 template <class FunctorT, class R,
216 class P1>
217 class Functor1 {
218 public:
219 Functor1(const FunctorT& functor, P1 p1)
220 : functor_(functor),
221 p1_(p1) {}
222 R operator()() const {
223 return functor_(p1_); }
224 private:
225 FunctorT functor_;
226 typename rtc::remove_reference<P1>::type p1_;
227 };
228
229
230 #define FP_T(x) R (ObjectT::*x)(P1)
231
232 template <class ObjectT, class R,
233 class P1>
234 MethodFunctor1<ObjectT, FP_T(NONAME), R, P1>
235 Bind(FP_T(method), ObjectT* object,
236 typename detail::identity<P1>::type p1) {
237 return MethodFunctor1<ObjectT, FP_T(NONAME), R, P1>(
238 method, object, p1);
239 }
240
241 #undef FP_T
242 #define FP_T(x) R (ObjectT::*x)(P1) const
243
244 template <class ObjectT, class R,
245 class P1>
246 MethodFunctor1<const ObjectT, FP_T(NONAME), R, P1>
247 Bind(FP_T(method), const ObjectT* object,
248 typename detail::identity<P1>::type p1) {
249 return MethodFunctor1<const ObjectT, FP_T(NONAME), R, P1>(
250 method, object, p1);
251 }
252
253 #undef FP_T
254 #define FP_T(x) R (ObjectT::*x)(P1)
255
256 template <class ObjectT, class R,
257 class P1>
258 MethodFunctor1<ObjectT, FP_T(NONAME), R, P1>
259 Bind(FP_T(method), const scoped_refptr<ObjectT>& object,
260 typename detail::identity<P1>::type p1) {
261 return MethodFunctor1<ObjectT, FP_T(NONAME), R, P1>(
262 method, object.get(), p1);
263 }
264
265 #undef FP_T
266 #define FP_T(x) R (*x)(P1)
267
268 template <class R,
269 class P1>
270 Functor1<FP_T(NONAME), R, P1>
271 Bind(FP_T(function),
272 typename detail::identity<P1>::type p1) {
273 return Functor1<FP_T(NONAME), R, P1>(
274 function, p1);
275 }
276
277 #undef FP_T
278
279 template <class ObjectT, class MethodT, class R,
280 class P1,
281 class P2>
282 class MethodFunctor2 {
283 public:
284 MethodFunctor2(MethodT method, ObjectT* object,
285 P1 p1,
286 P2 p2)
287 : method_(method), object_(object),
288 p1_(p1),
289 p2_(p2) {}
290 R operator()() const {
291 return (object_->*method_)(p1_, p2_); }
292 private:
293 MethodT method_;
294 typename detail::PointerType<ObjectT>::type object_;
295 typename rtc::remove_reference<P1>::type p1_;
296 typename rtc::remove_reference<P2>::type p2_;
297 };
298
299 template <class FunctorT, class R,
300 class P1,
301 class P2>
302 class Functor2 {
303 public:
304 Functor2(const FunctorT& functor, P1 p1, P2 p2)
305 : functor_(functor),
306 p1_(p1),
307 p2_(p2) {}
308 R operator()() const {
309 return functor_(p1_, p2_); }
310 private:
311 FunctorT functor_;
312 typename rtc::remove_reference<P1>::type p1_;
313 typename rtc::remove_reference<P2>::type p2_;
314 };
315
316
317 #define FP_T(x) R (ObjectT::*x)(P1, P2)
318
319 template <class ObjectT, class R,
320 class P1,
321 class P2>
322 MethodFunctor2<ObjectT, FP_T(NONAME), R, P1, P2>
323 Bind(FP_T(method), ObjectT* object,
324 typename detail::identity<P1>::type p1,
325 typename detail::identity<P2>::type p2) {
326 return MethodFunctor2<ObjectT, FP_T(NONAME), R, P1, P2>(
327 method, object, p1, p2);
328 }
329
330 #undef FP_T
331 #define FP_T(x) R (ObjectT::*x)(P1, P2) const
332
333 template <class ObjectT, class R,
334 class P1,
335 class P2>
336 MethodFunctor2<const ObjectT, FP_T(NONAME), R, P1, P2>
337 Bind(FP_T(method), const ObjectT* object,
338 typename detail::identity<P1>::type p1,
339 typename detail::identity<P2>::type p2) {
340 return MethodFunctor2<const ObjectT, FP_T(NONAME), R, P1, P2>(
341 method, object, p1, p2);
342 }
343
344 #undef FP_T
345 #define FP_T(x) R (ObjectT::*x)(P1, P2)
346
347 template <class ObjectT, class R,
348 class P1,
349 class P2>
350 MethodFunctor2<ObjectT, FP_T(NONAME), R, P1, P2>
351 Bind(FP_T(method), const scoped_refptr<ObjectT>& object,
352 typename detail::identity<P1>::type p1,
353 typename detail::identity<P2>::type p2) {
354 return MethodFunctor2<ObjectT, FP_T(NONAME), R, P1, P2>(
355 method, object.get(), p1, p2);
356 }
357
358 #undef FP_T
359 #define FP_T(x) R (*x)(P1, P2)
360
361 template <class R,
362 class P1,
363 class P2>
364 Functor2<FP_T(NONAME), R, P1, P2>
365 Bind(FP_T(function),
366 typename detail::identity<P1>::type p1,
367 typename detail::identity<P2>::type p2) {
368 return Functor2<FP_T(NONAME), R, P1, P2>(
369 function, p1, p2);
370 }
371
372 #undef FP_T
373
374 template <class ObjectT, class MethodT, class R,
375 class P1,
376 class P2,
377 class P3>
378 class MethodFunctor3 {
379 public:
380 MethodFunctor3(MethodT method, ObjectT* object,
381 P1 p1,
382 P2 p2,
383 P3 p3)
384 : method_(method), object_(object),
385 p1_(p1),
386 p2_(p2),
387 p3_(p3) {}
388 R operator()() const {
389 return (object_->*method_)(p1_, p2_, p3_); }
390 private:
391 MethodT method_;
392 typename detail::PointerType<ObjectT>::type object_;
393 typename rtc::remove_reference<P1>::type p1_;
394 typename rtc::remove_reference<P2>::type p2_;
395 typename rtc::remove_reference<P3>::type p3_;
396 };
397
398 template <class FunctorT, class R,
399 class P1,
400 class P2,
401 class P3>
402 class Functor3 {
403 public:
404 Functor3(const FunctorT& functor, P1 p1, P2 p2, P3 p3)
405 : functor_(functor),
406 p1_(p1),
407 p2_(p2),
408 p3_(p3) {}
409 R operator()() const {
410 return functor_(p1_, p2_, p3_); }
411 private:
412 FunctorT functor_;
413 typename rtc::remove_reference<P1>::type p1_;
414 typename rtc::remove_reference<P2>::type p2_;
415 typename rtc::remove_reference<P3>::type p3_;
416 };
417
418
419 #define FP_T(x) R (ObjectT::*x)(P1, P2, P3)
420
421 template <class ObjectT, class R,
422 class P1,
423 class P2,
424 class P3>
425 MethodFunctor3<ObjectT, FP_T(NONAME), R, P1, P2, P3>
426 Bind(FP_T(method), ObjectT* object,
427 typename detail::identity<P1>::type p1,
428 typename detail::identity<P2>::type p2,
429 typename detail::identity<P3>::type p3) {
430 return MethodFunctor3<ObjectT, FP_T(NONAME), R, P1, P2, P3>(
431 method, object, p1, p2, p3);
432 }
433
434 #undef FP_T
435 #define FP_T(x) R (ObjectT::*x)(P1, P2, P3) const
436
437 template <class ObjectT, class R,
438 class P1,
439 class P2,
440 class P3>
441 MethodFunctor3<const ObjectT, FP_T(NONAME), R, P1, P2, P3>
442 Bind(FP_T(method), const ObjectT* object,
443 typename detail::identity<P1>::type p1,
444 typename detail::identity<P2>::type p2,
445 typename detail::identity<P3>::type p3) {
446 return MethodFunctor3<const ObjectT, FP_T(NONAME), R, P1, P2, P3>(
447 method, object, p1, p2, p3);
448 }
449
450 #undef FP_T
451 #define FP_T(x) R (ObjectT::*x)(P1, P2, P3)
452
453 template <class ObjectT, class R,
454 class P1,
455 class P2,
456 class P3>
457 MethodFunctor3<ObjectT, FP_T(NONAME), R, P1, P2, P3>
458 Bind(FP_T(method), const scoped_refptr<ObjectT>& object,
459 typename detail::identity<P1>::type p1,
460 typename detail::identity<P2>::type p2,
461 typename detail::identity<P3>::type p3) {
462 return MethodFunctor3<ObjectT, FP_T(NONAME), R, P1, P2, P3>(
463 method, object.get(), p1, p2, p3);
464 }
465
466 #undef FP_T
467 #define FP_T(x) R (*x)(P1, P2, P3)
468
469 template <class R,
470 class P1,
471 class P2,
472 class P3>
473 Functor3<FP_T(NONAME), R, P1, P2, P3>
474 Bind(FP_T(function),
475 typename detail::identity<P1>::type p1,
476 typename detail::identity<P2>::type p2,
477 typename detail::identity<P3>::type p3) {
478 return Functor3<FP_T(NONAME), R, P1, P2, P3>(
479 function, p1, p2, p3);
480 }
481
482 #undef FP_T
483
484 template <class ObjectT, class MethodT, class R,
485 class P1,
486 class P2,
487 class P3,
488 class P4>
489 class MethodFunctor4 {
490 public:
491 MethodFunctor4(MethodT method, ObjectT* object,
492 P1 p1,
493 P2 p2,
494 P3 p3,
495 P4 p4)
496 : method_(method), object_(object),
497 p1_(p1),
498 p2_(p2),
499 p3_(p3),
500 p4_(p4) {}
501 R operator()() const {
502 return (object_->*method_)(p1_, p2_, p3_, p4_); }
503 private:
504 MethodT method_;
505 typename detail::PointerType<ObjectT>::type object_;
506 typename rtc::remove_reference<P1>::type p1_;
507 typename rtc::remove_reference<P2>::type p2_;
508 typename rtc::remove_reference<P3>::type p3_;
509 typename rtc::remove_reference<P4>::type p4_;
510 };
511
512 template <class FunctorT, class R,
513 class P1,
514 class P2,
515 class P3,
516 class P4>
517 class Functor4 {
518 public:
519 Functor4(const FunctorT& functor, P1 p1, P2 p2, P3 p3, P4 p4)
520 : functor_(functor),
521 p1_(p1),
522 p2_(p2),
523 p3_(p3),
524 p4_(p4) {}
525 R operator()() const {
526 return functor_(p1_, p2_, p3_, p4_); }
527 private:
528 FunctorT functor_;
529 typename rtc::remove_reference<P1>::type p1_;
530 typename rtc::remove_reference<P2>::type p2_;
531 typename rtc::remove_reference<P3>::type p3_;
532 typename rtc::remove_reference<P4>::type p4_;
533 };
534
535
536 #define FP_T(x) R (ObjectT::*x)(P1, P2, P3, P4)
537
538 template <class ObjectT, class R,
539 class P1,
540 class P2,
541 class P3,
542 class P4>
543 MethodFunctor4<ObjectT, FP_T(NONAME), R, P1, P2, P3, P4>
544 Bind(FP_T(method), ObjectT* object,
545 typename detail::identity<P1>::type p1,
546 typename detail::identity<P2>::type p2,
547 typename detail::identity<P3>::type p3,
548 typename detail::identity<P4>::type p4) {
549 return MethodFunctor4<ObjectT, FP_T(NONAME), R, P1, P2, P3, P4>(
550 method, object, p1, p2, p3, p4);
551 }
552
553 #undef FP_T
554 #define FP_T(x) R (ObjectT::*x)(P1, P2, P3, P4) const
555
556 template <class ObjectT, class R,
557 class P1,
558 class P2,
559 class P3,
560 class P4>
561 MethodFunctor4<const ObjectT, FP_T(NONAME), R, P1, P2, P3, P4>
562 Bind(FP_T(method), const ObjectT* object,
563 typename detail::identity<P1>::type p1,
564 typename detail::identity<P2>::type p2,
565 typename detail::identity<P3>::type p3,
566 typename detail::identity<P4>::type p4) {
567 return MethodFunctor4<const ObjectT, FP_T(NONAME), R, P1, P2, P3, P4>(
568 method, object, p1, p2, p3, p4);
569 }
570
571 #undef FP_T
572 #define FP_T(x) R (ObjectT::*x)(P1, P2, P3, P4)
573
574 template <class ObjectT, class R,
575 class P1,
576 class P2,
577 class P3,
578 class P4>
579 MethodFunctor4<ObjectT, FP_T(NONAME), R, P1, P2, P3, P4>
580 Bind(FP_T(method), const scoped_refptr<ObjectT>& object,
581 typename detail::identity<P1>::type p1,
582 typename detail::identity<P2>::type p2,
583 typename detail::identity<P3>::type p3,
584 typename detail::identity<P4>::type p4) {
585 return MethodFunctor4<ObjectT, FP_T(NONAME), R, P1, P2, P3, P4>(
586 method, object.get(), p1, p2, p3, p4);
587 }
588
589 #undef FP_T
590 #define FP_T(x) R (*x)(P1, P2, P3, P4)
591
592 template <class R,
593 class P1,
594 class P2,
595 class P3,
596 class P4>
597 Functor4<FP_T(NONAME), R, P1, P2, P3, P4>
598 Bind(FP_T(function),
599 typename detail::identity<P1>::type p1,
600 typename detail::identity<P2>::type p2,
601 typename detail::identity<P3>::type p3,
602 typename detail::identity<P4>::type p4) {
603 return Functor4<FP_T(NONAME), R, P1, P2, P3, P4>(
604 function, p1, p2, p3, p4);
605 }
606
607 #undef FP_T
608
609 template <class ObjectT, class MethodT, class R,
610 class P1,
611 class P2,
612 class P3,
613 class P4,
614 class P5>
615 class MethodFunctor5 {
616 public:
617 MethodFunctor5(MethodT method, ObjectT* object,
618 P1 p1,
619 P2 p2,
620 P3 p3,
621 P4 p4,
622 P5 p5)
623 : method_(method), object_(object),
624 p1_(p1),
625 p2_(p2),
626 p3_(p3),
627 p4_(p4),
628 p5_(p5) {}
629 R operator()() const {
630 return (object_->*method_)(p1_, p2_, p3_, p4_, p5_); }
631 private:
632 MethodT method_;
633 typename detail::PointerType<ObjectT>::type object_;
634 typename rtc::remove_reference<P1>::type p1_;
635 typename rtc::remove_reference<P2>::type p2_;
636 typename rtc::remove_reference<P3>::type p3_;
637 typename rtc::remove_reference<P4>::type p4_;
638 typename rtc::remove_reference<P5>::type p5_;
639 };
640
641 template <class FunctorT, class R,
642 class P1,
643 class P2,
644 class P3,
645 class P4,
646 class P5>
647 class Functor5 {
648 public:
649 Functor5(const FunctorT& functor, P1 p1, P2 p2, P3 p3, P4 p4, P5 p5)
650 : functor_(functor),
651 p1_(p1),
652 p2_(p2),
653 p3_(p3),
654 p4_(p4),
655 p5_(p5) {}
656 R operator()() const {
657 return functor_(p1_, p2_, p3_, p4_, p5_); }
658 private:
659 FunctorT functor_;
660 typename rtc::remove_reference<P1>::type p1_;
661 typename rtc::remove_reference<P2>::type p2_;
662 typename rtc::remove_reference<P3>::type p3_;
663 typename rtc::remove_reference<P4>::type p4_;
664 typename rtc::remove_reference<P5>::type p5_;
665 };
666
667
668 #define FP_T(x) R (ObjectT::*x)(P1, P2, P3, P4, P5)
669
670 template <class ObjectT, class R,
671 class P1,
672 class P2,
673 class P3,
674 class P4,
675 class P5>
676 MethodFunctor5<ObjectT, FP_T(NONAME), R, P1, P2, P3, P4, P5>
677 Bind(FP_T(method), ObjectT* object,
678 typename detail::identity<P1>::type p1,
679 typename detail::identity<P2>::type p2,
680 typename detail::identity<P3>::type p3,
681 typename detail::identity<P4>::type p4,
682 typename detail::identity<P5>::type p5) {
683 return MethodFunctor5<ObjectT, FP_T(NONAME), R, P1, P2, P3, P4, P5>(
684 method, object, p1, p2, p3, p4, p5);
685 }
686
687 #undef FP_T
688 #define FP_T(x) R (ObjectT::*x)(P1, P2, P3, P4, P5) const
689
690 template <class ObjectT, class R,
691 class P1,
692 class P2,
693 class P3,
694 class P4,
695 class P5>
696 MethodFunctor5<const ObjectT, FP_T(NONAME), R, P1, P2, P3, P4, P5>
697 Bind(FP_T(method), const ObjectT* object,
698 typename detail::identity<P1>::type p1,
699 typename detail::identity<P2>::type p2,
700 typename detail::identity<P3>::type p3,
701 typename detail::identity<P4>::type p4,
702 typename detail::identity<P5>::type p5) {
703 return MethodFunctor5<const ObjectT, FP_T(NONAME), R, P1, P2, P3, P4, P5>(
704 method, object, p1, p2, p3, p4, p5);
705 }
706
707 #undef FP_T
708 #define FP_T(x) R (ObjectT::*x)(P1, P2, P3, P4, P5)
709
710 template <class ObjectT, class R,
711 class P1,
712 class P2,
713 class P3,
714 class P4,
715 class P5>
716 MethodFunctor5<ObjectT, FP_T(NONAME), R, P1, P2, P3, P4, P5>
717 Bind(FP_T(method), const scoped_refptr<ObjectT>& object,
718 typename detail::identity<P1>::type p1,
719 typename detail::identity<P2>::type p2,
720 typename detail::identity<P3>::type p3,
721 typename detail::identity<P4>::type p4,
722 typename detail::identity<P5>::type p5) {
723 return MethodFunctor5<ObjectT, FP_T(NONAME), R, P1, P2, P3, P4, P5>(
724 method, object.get(), p1, p2, p3, p4, p5);
725 }
726
727 #undef FP_T
728 #define FP_T(x) R (*x)(P1, P2, P3, P4, P5)
729
730 template <class R,
731 class P1,
732 class P2,
733 class P3,
734 class P4,
735 class P5>
736 Functor5<FP_T(NONAME), R, P1, P2, P3, P4, P5>
737 Bind(FP_T(function),
738 typename detail::identity<P1>::type p1,
739 typename detail::identity<P2>::type p2,
740 typename detail::identity<P3>::type p3,
741 typename detail::identity<P4>::type p4,
742 typename detail::identity<P5>::type p5) {
743 return Functor5<FP_T(NONAME), R, P1, P2, P3, P4, P5>(
744 function, p1, p2, p3, p4, p5);
745 }
746
747 #undef FP_T
748
749 template <class ObjectT, class MethodT, class R,
750 class P1,
751 class P2,
752 class P3,
753 class P4,
754 class P5,
755 class P6>
756 class MethodFunctor6 {
757 public:
758 MethodFunctor6(MethodT method, ObjectT* object,
759 P1 p1,
760 P2 p2,
761 P3 p3,
762 P4 p4,
763 P5 p5,
764 P6 p6)
765 : method_(method), object_(object),
766 p1_(p1),
767 p2_(p2),
768 p3_(p3),
769 p4_(p4),
770 p5_(p5),
771 p6_(p6) {}
772 R operator()() const {
773 return (object_->*method_)(p1_, p2_, p3_, p4_, p5_, p6_); }
774 private:
775 MethodT method_;
776 typename detail::PointerType<ObjectT>::type object_;
777 typename rtc::remove_reference<P1>::type p1_;
778 typename rtc::remove_reference<P2>::type p2_;
779 typename rtc::remove_reference<P3>::type p3_;
780 typename rtc::remove_reference<P4>::type p4_;
781 typename rtc::remove_reference<P5>::type p5_;
782 typename rtc::remove_reference<P6>::type p6_;
783 };
784
785 template <class FunctorT, class R,
786 class P1,
787 class P2,
788 class P3,
789 class P4,
790 class P5,
791 class P6>
792 class Functor6 {
793 public:
794 Functor6(const FunctorT& functor, P1 p1, P2 p2, P3 p3, P4 p4, P5 p5, P6 p6)
795 : functor_(functor),
796 p1_(p1),
797 p2_(p2),
798 p3_(p3),
799 p4_(p4),
800 p5_(p5),
801 p6_(p6) {}
802 R operator()() const {
803 return functor_(p1_, p2_, p3_, p4_, p5_, p6_); }
804 private:
805 FunctorT functor_;
806 typename rtc::remove_reference<P1>::type p1_;
807 typename rtc::remove_reference<P2>::type p2_;
808 typename rtc::remove_reference<P3>::type p3_;
809 typename rtc::remove_reference<P4>::type p4_;
810 typename rtc::remove_reference<P5>::type p5_;
811 typename rtc::remove_reference<P6>::type p6_;
812 };
813
814
815 #define FP_T(x) R (ObjectT::*x)(P1, P2, P3, P4, P5, P6)
816
817 template <class ObjectT, class R,
818 class P1,
819 class P2,
820 class P3,
821 class P4,
822 class P5,
823 class P6>
824 MethodFunctor6<ObjectT, FP_T(NONAME), R, P1, P2, P3, P4, P5, P6>
825 Bind(FP_T(method), ObjectT* object,
826 typename detail::identity<P1>::type p1,
827 typename detail::identity<P2>::type p2,
828 typename detail::identity<P3>::type p3,
829 typename detail::identity<P4>::type p4,
830 typename detail::identity<P5>::type p5,
831 typename detail::identity<P6>::type p6) {
832 return MethodFunctor6<ObjectT, FP_T(NONAME), R, P1, P2, P3, P4, P5, P6>(
833 method, object, p1, p2, p3, p4, p5, p6);
834 }
835
836 #undef FP_T
837 #define FP_T(x) R (ObjectT::*x)(P1, P2, P3, P4, P5, P6) const
838
839 template <class ObjectT, class R,
840 class P1,
841 class P2,
842 class P3,
843 class P4,
844 class P5,
845 class P6>
846 MethodFunctor6<const ObjectT, FP_T(NONAME), R, P1, P2, P3, P4, P5, P6>
847 Bind(FP_T(method), const ObjectT* object,
848 typename detail::identity<P1>::type p1,
849 typename detail::identity<P2>::type p2,
850 typename detail::identity<P3>::type p3,
851 typename detail::identity<P4>::type p4,
852 typename detail::identity<P5>::type p5,
853 typename detail::identity<P6>::type p6) {
854 return MethodFunctor6<const ObjectT, FP_T(NONAME), R, P1, P2, P3, P4, P5, P6>(
855 method, object, p1, p2, p3, p4, p5, p6);
856 }
857
858 #undef FP_T
859 #define FP_T(x) R (ObjectT::*x)(P1, P2, P3, P4, P5, P6)
860
861 template <class ObjectT, class R,
862 class P1,
863 class P2,
864 class P3,
865 class P4,
866 class P5,
867 class P6>
868 MethodFunctor6<ObjectT, FP_T(NONAME), R, P1, P2, P3, P4, P5, P6>
869 Bind(FP_T(method), const scoped_refptr<ObjectT>& object,
870 typename detail::identity<P1>::type p1,
871 typename detail::identity<P2>::type p2,
872 typename detail::identity<P3>::type p3,
873 typename detail::identity<P4>::type p4,
874 typename detail::identity<P5>::type p5,
875 typename detail::identity<P6>::type p6) {
876 return MethodFunctor6<ObjectT, FP_T(NONAME), R, P1, P2, P3, P4, P5, P6>(
877 method, object.get(), p1, p2, p3, p4, p5, p6);
878 }
879
880 #undef FP_T
881 #define FP_T(x) R (*x)(P1, P2, P3, P4, P5, P6)
882
883 template <class R,
884 class P1,
885 class P2,
886 class P3,
887 class P4,
888 class P5,
889 class P6>
890 Functor6<FP_T(NONAME), R, P1, P2, P3, P4, P5, P6>
891 Bind(FP_T(function),
892 typename detail::identity<P1>::type p1,
893 typename detail::identity<P2>::type p2,
894 typename detail::identity<P3>::type p3,
895 typename detail::identity<P4>::type p4,
896 typename detail::identity<P5>::type p5,
897 typename detail::identity<P6>::type p6) {
898 return Functor6<FP_T(NONAME), R, P1, P2, P3, P4, P5, P6>(
899 function, p1, p2, p3, p4, p5, p6);
900 }
901
902 #undef FP_T
903
904 template <class ObjectT,
905 class MethodT,
906 class R,
907 class P1,
908 class P2,
909 class P3,
910 class P4,
911 class P5,
912 class P6,
913 class P7>
914 class MethodFunctor7 {
915 public:
916 MethodFunctor7(MethodT method,
917 ObjectT* object,
918 P1 p1,
919 P2 p2,
920 P3 p3,
921 P4 p4,
922 P5 p5,
923 P6 p6,
924 P7 p7)
925 : method_(method),
926 object_(object),
927 p1_(p1),
928 p2_(p2),
929 p3_(p3),
930 p4_(p4),
931 p5_(p5),
932 p6_(p6),
933 p7_(p7) {}
934 R operator()() const {
935 return (object_->*method_)(p1_, p2_, p3_, p4_, p5_, p6_, p7_);
936 }
937
938 private:
939 MethodT method_;
940 typename detail::PointerType<ObjectT>::type object_;
941 typename rtc::remove_reference<P1>::type p1_;
942 typename rtc::remove_reference<P2>::type p2_;
943 typename rtc::remove_reference<P3>::type p3_;
944 typename rtc::remove_reference<P4>::type p4_;
945 typename rtc::remove_reference<P5>::type p5_;
946 typename rtc::remove_reference<P6>::type p6_;
947 typename rtc::remove_reference<P7>::type p7_;
948 };
949
950 template <class FunctorT,
951 class R,
952 class P1,
953 class P2,
954 class P3,
955 class P4,
956 class P5,
957 class P6,
958 class P7>
959 class Functor7 {
960 public:
961 Functor7(const FunctorT& functor,
962 P1 p1,
963 P2 p2,
964 P3 p3,
965 P4 p4,
966 P5 p5,
967 P6 p6,
968 P7 p7)
969 : functor_(functor),
970 p1_(p1),
971 p2_(p2),
972 p3_(p3),
973 p4_(p4),
974 p5_(p5),
975 p6_(p6),
976 p7_(p7) {}
977 R operator()() const { return functor_(p1_, p2_, p3_, p4_, p5_, p6_, p7_); }
978
979 private:
980 FunctorT functor_;
981 typename rtc::remove_reference<P1>::type p1_;
982 typename rtc::remove_reference<P2>::type p2_;
983 typename rtc::remove_reference<P3>::type p3_;
984 typename rtc::remove_reference<P4>::type p4_;
985 typename rtc::remove_reference<P5>::type p5_;
986 typename rtc::remove_reference<P6>::type p6_;
987 typename rtc::remove_reference<P7>::type p7_;
988 };
989
990 #define FP_T(x) R (ObjectT::*x)(P1, P2, P3, P4, P5, P6, P7)
991
992 template <class ObjectT,
993 class R,
994 class P1,
995 class P2,
996 class P3,
997 class P4,
998 class P5,
999 class P6,
1000 class P7>
1001 MethodFunctor7<ObjectT, FP_T(NONAME), R, P1, P2, P3, P4, P5, P6, P7> Bind(
1002 FP_T(method),
1003 ObjectT* object,
1004 typename detail::identity<P1>::type p1,
1005 typename detail::identity<P2>::type p2,
1006 typename detail::identity<P3>::type p3,
1007 typename detail::identity<P4>::type p4,
1008 typename detail::identity<P5>::type p5,
1009 typename detail::identity<P6>::type p6,
1010 typename detail::identity<P7>::type p7) {
1011 return MethodFunctor7<ObjectT, FP_T(NONAME), R, P1, P2, P3, P4, P5, P6, P7>(
1012 method, object, p1, p2, p3, p4, p5, p6, p7);
1013 }
1014
1015 #undef FP_T
1016 #define FP_T(x) R (ObjectT::*x)(P1, P2, P3, P4, P5, P6, P7) const
1017
1018 template <class ObjectT,
1019 class R,
1020 class P1,
1021 class P2,
1022 class P3,
1023 class P4,
1024 class P5,
1025 class P6,
1026 class P7>
1027 MethodFunctor7<const ObjectT, FP_T(NONAME), R, P1, P2, P3, P4, P5, P6, P7> Bind(
1028 FP_T(method),
1029 const ObjectT* object,
1030 typename detail::identity<P1>::type p1,
1031 typename detail::identity<P2>::type p2,
1032 typename detail::identity<P3>::type p3,
1033 typename detail::identity<P4>::type p4,
1034 typename detail::identity<P5>::type p5,
1035 typename detail::identity<P6>::type p6,
1036 typename detail::identity<P7>::type p7) {
1037 return MethodFunctor7<const ObjectT, FP_T(NONAME), R, P1, P2, P3, P4, P5, P6,
1038 P7>(method, object, p1, p2, p3, p4, p5, p6, p7);
1039 }
1040
1041 #undef FP_T
1042 #define FP_T(x) R (ObjectT::*x)(P1, P2, P3, P4, P5, P6, P7)
1043
1044 template <class ObjectT,
1045 class R,
1046 class P1,
1047 class P2,
1048 class P3,
1049 class P4,
1050 class P5,
1051 class P6,
1052 class P7>
1053 MethodFunctor7<ObjectT, FP_T(NONAME), R, P1, P2, P3, P4, P5, P6, P7> Bind(
1054 FP_T(method),
1055 const scoped_refptr<ObjectT>& object,
1056 typename detail::identity<P1>::type p1,
1057 typename detail::identity<P2>::type p2,
1058 typename detail::identity<P3>::type p3,
1059 typename detail::identity<P4>::type p4,
1060 typename detail::identity<P5>::type p5,
1061 typename detail::identity<P6>::type p6,
1062 typename detail::identity<P7>::type p7) {
1063 return MethodFunctor7<ObjectT, FP_T(NONAME), R, P1, P2, P3, P4, P5, P6, P7>(
1064 method, object.get(), p1, p2, p3, p4, p5, p6, p7);
1065 }
1066
1067 #undef FP_T
1068 #define FP_T(x) R (*x)(P1, P2, P3, P4, P5, P6, P7)
1069
1070 template <class R,
1071 class P1,
1072 class P2,
1073 class P3,
1074 class P4,
1075 class P5,
1076 class P6,
1077 class P7>
1078 Functor7<FP_T(NONAME), R, P1, P2, P3, P4, P5, P6, P7> Bind(
1079 FP_T(function),
1080 typename detail::identity<P1>::type p1,
1081 typename detail::identity<P2>::type p2,
1082 typename detail::identity<P3>::type p3,
1083 typename detail::identity<P4>::type p4,
1084 typename detail::identity<P5>::type p5,
1085 typename detail::identity<P6>::type p6,
1086 typename detail::identity<P7>::type p7) {
1087 return Functor7<FP_T(NONAME), R, P1, P2, P3, P4, P5, P6, P7>(
1088 function, p1, p2, p3, p4, p5, p6, p7);
1089 }
1090
1091 #undef FP_T
1092
1093 template <class ObjectT,
1094 class MethodT,
1095 class R,
1096 class P1,
1097 class P2,
1098 class P3,
1099 class P4,
1100 class P5,
1101 class P6,
1102 class P7,
1103 class P8>
1104 class MethodFunctor8 {
1105 public:
1106 MethodFunctor8(MethodT method,
1107 ObjectT* object,
1108 P1 p1,
1109 P2 p2,
1110 P3 p3,
1111 P4 p4,
1112 P5 p5,
1113 P6 p6,
1114 P7 p7,
1115 P8 p8)
1116 : method_(method),
1117 object_(object),
1118 p1_(p1),
1119 p2_(p2),
1120 p3_(p3),
1121 p4_(p4),
1122 p5_(p5),
1123 p6_(p6),
1124 p7_(p7),
1125 p8_(p8) {}
1126 R operator()() const {
1127 return (object_->*method_)(p1_, p2_, p3_, p4_, p5_, p6_, p7_, p8_);
1128 }
1129
1130 private:
1131 MethodT method_;
1132 typename detail::PointerType<ObjectT>::type object_;
1133 typename rtc::remove_reference<P1>::type p1_;
1134 typename rtc::remove_reference<P2>::type p2_;
1135 typename rtc::remove_reference<P3>::type p3_;
1136 typename rtc::remove_reference<P4>::type p4_;
1137 typename rtc::remove_reference<P5>::type p5_;
1138 typename rtc::remove_reference<P6>::type p6_;
1139 typename rtc::remove_reference<P7>::type p7_;
1140 typename rtc::remove_reference<P8>::type p8_;
1141 };
1142
1143 template <class FunctorT,
1144 class R,
1145 class P1,
1146 class P2,
1147 class P3,
1148 class P4,
1149 class P5,
1150 class P6,
1151 class P7,
1152 class P8>
1153 class Functor8 {
1154 public:
1155 Functor8(const FunctorT& functor,
1156 P1 p1,
1157 P2 p2,
1158 P3 p3,
1159 P4 p4,
1160 P5 p5,
1161 P6 p6,
1162 P7 p7,
1163 P8 p8)
1164 : functor_(functor),
1165 p1_(p1),
1166 p2_(p2),
1167 p3_(p3),
1168 p4_(p4),
1169 p5_(p5),
1170 p6_(p6),
1171 p7_(p7),
1172 p8_(p8) {}
1173 R operator()() const {
1174 return functor_(p1_, p2_, p3_, p4_, p5_, p6_, p7_, p8_);
1175 }
1176
1177 private:
1178 FunctorT functor_;
1179 typename rtc::remove_reference<P1>::type p1_;
1180 typename rtc::remove_reference<P2>::type p2_;
1181 typename rtc::remove_reference<P3>::type p3_;
1182 typename rtc::remove_reference<P4>::type p4_;
1183 typename rtc::remove_reference<P5>::type p5_;
1184 typename rtc::remove_reference<P6>::type p6_;
1185 typename rtc::remove_reference<P7>::type p7_;
1186 typename rtc::remove_reference<P8>::type p8_;
1187 };
1188
1189 #define FP_T(x) R (ObjectT::*x)(P1, P2, P3, P4, P5, P6, P7, P8)
1190
1191 template <class ObjectT,
1192 class R,
1193 class P1,
1194 class P2,
1195 class P3,
1196 class P4,
1197 class P5,
1198 class P6,
1199 class P7,
1200 class P8>
1201 MethodFunctor8<ObjectT, FP_T(NONAME), R, P1, P2, P3, P4, P5, P6, P7, P8> Bind(
1202 FP_T(method),
1203 ObjectT* object,
1204 typename detail::identity<P1>::type p1,
1205 typename detail::identity<P2>::type p2,
1206 typename detail::identity<P3>::type p3,
1207 typename detail::identity<P4>::type p4,
1208 typename detail::identity<P5>::type p5,
1209 typename detail::identity<P6>::type p6,
1210 typename detail::identity<P7>::type p7,
1211 typename detail::identity<P8>::type p8) {
1212 return MethodFunctor8<ObjectT, FP_T(NONAME), R, P1, P2, P3, P4, P5, P6, P7,
1213 P8>(method, object, p1, p2, p3, p4, p5, p6, p7, p8);
1214 }
1215
1216 #undef FP_T
1217 #define FP_T(x) R (ObjectT::*x)(P1, P2, P3, P4, P5, P6, P7, P8) const
1218
1219 template <class ObjectT,
1220 class R,
1221 class P1,
1222 class P2,
1223 class P3,
1224 class P4,
1225 class P5,
1226 class P6,
1227 class P7,
1228 class P8>
1229 MethodFunctor8<const ObjectT, FP_T(NONAME), R, P1, P2, P3, P4, P5, P6, P7, P8>
1230 Bind(FP_T(method),
1231 const ObjectT* object,
1232 typename detail::identity<P1>::type p1,
1233 typename detail::identity<P2>::type p2,
1234 typename detail::identity<P3>::type p3,
1235 typename detail::identity<P4>::type p4,
1236 typename detail::identity<P5>::type p5,
1237 typename detail::identity<P6>::type p6,
1238 typename detail::identity<P7>::type p7,
1239 typename detail::identity<P8>::type p8) {
1240 return MethodFunctor8<const ObjectT, FP_T(NONAME), R, P1, P2, P3, P4, P5, P6,
1241 P7, P8>(method, object, p1, p2, p3, p4, p5, p6, p7, p8);
1242 }
1243
1244 #undef FP_T
1245 #define FP_T(x) R (ObjectT::*x)(P1, P2, P3, P4, P5, P6, P7, P8)
1246
1247 template <class ObjectT,
1248 class R,
1249 class P1,
1250 class P2,
1251 class P3,
1252 class P4,
1253 class P5,
1254 class P6,
1255 class P7,
1256 class P8>
1257 MethodFunctor8<ObjectT, FP_T(NONAME), R, P1, P2, P3, P4, P5, P6, P7, P8> Bind(
1258 FP_T(method),
1259 const scoped_refptr<ObjectT>& object,
1260 typename detail::identity<P1>::type p1,
1261 typename detail::identity<P2>::type p2,
1262 typename detail::identity<P3>::type p3,
1263 typename detail::identity<P4>::type p4,
1264 typename detail::identity<P5>::type p5,
1265 typename detail::identity<P6>::type p6,
1266 typename detail::identity<P7>::type p7,
1267 typename detail::identity<P8>::type p8) {
1268 return MethodFunctor8<ObjectT, FP_T(NONAME), R, P1, P2, P3, P4, P5, P6, P7,
1269 P8>(method, object.get(), p1, p2, p3, p4, p5, p6, p7,
1270 p8);
1271 }
1272
1273 #undef FP_T
1274 #define FP_T(x) R (*x)(P1, P2, P3, P4, P5, P6, P7, P8)
1275
1276 template <class R,
1277 class P1,
1278 class P2,
1279 class P3,
1280 class P4,
1281 class P5,
1282 class P6,
1283 class P7,
1284 class P8>
1285 Functor8<FP_T(NONAME), R, P1, P2, P3, P4, P5, P6, P7, P8> Bind(
1286 FP_T(function),
1287 typename detail::identity<P1>::type p1,
1288 typename detail::identity<P2>::type p2,
1289 typename detail::identity<P3>::type p3,
1290 typename detail::identity<P4>::type p4,
1291 typename detail::identity<P5>::type p5,
1292 typename detail::identity<P6>::type p6,
1293 typename detail::identity<P7>::type p7,
1294 typename detail::identity<P8>::type p8) {
1295 return Functor8<FP_T(NONAME), R, P1, P2, P3, P4, P5, P6, P7, P8>(
1296 function, p1, p2, p3, p4, p5, p6, p7, p8);
1297 }
1298
1299 #undef FP_T
1300
1301 template <class ObjectT,
1302 class MethodT,
1303 class R,
1304 class P1,
1305 class P2,
1306 class P3,
1307 class P4,
1308 class P5,
1309 class P6,
1310 class P7,
1311 class P8,
1312 class P9>
1313 class MethodFunctor9 {
1314 public:
1315 MethodFunctor9(MethodT method,
1316 ObjectT* object,
1317 P1 p1,
1318 P2 p2,
1319 P3 p3,
1320 P4 p4,
1321 P5 p5,
1322 P6 p6,
1323 P7 p7,
1324 P8 p8,
1325 P9 p9)
1326 : method_(method),
1327 object_(object),
1328 p1_(p1),
1329 p2_(p2),
1330 p3_(p3),
1331 p4_(p4),
1332 p5_(p5),
1333 p6_(p6),
1334 p7_(p7),
1335 p8_(p8),
1336 p9_(p9) {}
1337 R operator()() const {
1338 return (object_->*method_)(p1_, p2_, p3_, p4_, p5_, p6_, p7_, p8_, p9_);
1339 }
1340
1341 private:
1342 MethodT method_;
1343 typename detail::PointerType<ObjectT>::type object_;
1344 typename rtc::remove_reference<P1>::type p1_;
1345 typename rtc::remove_reference<P2>::type p2_;
1346 typename rtc::remove_reference<P3>::type p3_;
1347 typename rtc::remove_reference<P4>::type p4_;
1348 typename rtc::remove_reference<P5>::type p5_;
1349 typename rtc::remove_reference<P6>::type p6_;
1350 typename rtc::remove_reference<P7>::type p7_;
1351 typename rtc::remove_reference<P8>::type p8_;
1352 typename rtc::remove_reference<P9>::type p9_;
1353 };
1354
1355 template <class FunctorT,
1356 class R,
1357 class P1,
1358 class P2,
1359 class P3,
1360 class P4,
1361 class P5,
1362 class P6,
1363 class P7,
1364 class P8,
1365 class P9>
1366 class Functor9 {
1367 public:
1368 Functor9(const FunctorT& functor,
1369 P1 p1,
1370 P2 p2,
1371 P3 p3,
1372 P4 p4,
1373 P5 p5,
1374 P6 p6,
1375 P7 p7,
1376 P8 p8,
1377 P9 p9)
1378 : functor_(functor),
1379 p1_(p1),
1380 p2_(p2),
1381 p3_(p3),
1382 p4_(p4),
1383 p5_(p5),
1384 p6_(p6),
1385 p7_(p7),
1386 p8_(p8),
1387 p9_(p9) {}
1388 R operator()() const {
1389 return functor_(p1_, p2_, p3_, p4_, p5_, p6_, p7_, p8_, p9_);
1390 }
1391
1392 private:
1393 FunctorT functor_;
1394 typename rtc::remove_reference<P1>::type p1_;
1395 typename rtc::remove_reference<P2>::type p2_;
1396 typename rtc::remove_reference<P3>::type p3_;
1397 typename rtc::remove_reference<P4>::type p4_;
1398 typename rtc::remove_reference<P5>::type p5_;
1399 typename rtc::remove_reference<P6>::type p6_;
1400 typename rtc::remove_reference<P7>::type p7_;
1401 typename rtc::remove_reference<P8>::type p8_;
1402 typename rtc::remove_reference<P9>::type p9_;
1403 };
1404
1405 #define FP_T(x) R (ObjectT::*x)(P1, P2, P3, P4, P5, P6, P7, P8, P9)
1406
1407 template <class ObjectT,
1408 class R,
1409 class P1,
1410 class P2,
1411 class P3,
1412 class P4,
1413 class P5,
1414 class P6,
1415 class P7,
1416 class P8,
1417 class P9>
1418 MethodFunctor9<ObjectT, FP_T(NONAME), R, P1, P2, P3, P4, P5, P6, P7, P8, P9>
1419 Bind(FP_T(method),
1420 ObjectT* object,
1421 typename detail::identity<P1>::type p1,
1422 typename detail::identity<P2>::type p2,
1423 typename detail::identity<P3>::type p3,
1424 typename detail::identity<P4>::type p4,
1425 typename detail::identity<P5>::type p5,
1426 typename detail::identity<P6>::type p6,
1427 typename detail::identity<P7>::type p7,
1428 typename detail::identity<P8>::type p8,
1429 typename detail::identity<P9>::type p9) {
1430 return MethodFunctor9<ObjectT, FP_T(NONAME), R, P1, P2, P3, P4, P5, P6, P7,
1431 P8, P9>(method, object, p1, p2, p3, p4, p5, p6, p7, p8,
1432 p9);
1433 }
1434
1435 #undef FP_T
1436 #define FP_T(x) R (ObjectT::*x)(P1, P2, P3, P4, P5, P6, P7, P8, P9) const
1437
1438 template <class ObjectT,
1439 class R,
1440 class P1,
1441 class P2,
1442 class P3,
1443 class P4,
1444 class P5,
1445 class P6,
1446 class P7,
1447 class P8,
1448 class P9>
1449 MethodFunctor9<const ObjectT,
1450 FP_T(NONAME),
1451 R,
1452 P1,
1453 P2,
1454 P3,
1455 P4,
1456 P5,
1457 P6,
1458 P7,
1459 P8,
1460 P9>
1461 Bind(FP_T(method),
1462 const ObjectT* object,
1463 typename detail::identity<P1>::type p1,
1464 typename detail::identity<P2>::type p2,
1465 typename detail::identity<P3>::type p3,
1466 typename detail::identity<P4>::type p4,
1467 typename detail::identity<P5>::type p5,
1468 typename detail::identity<P6>::type p6,
1469 typename detail::identity<P7>::type p7,
1470 typename detail::identity<P8>::type p8,
1471 typename detail::identity<P9>::type p9) {
1472 return MethodFunctor9<const ObjectT, FP_T(NONAME), R, P1, P2, P3, P4, P5, P6,
1473 P7, P8, P9>(method, object, p1, p2, p3, p4, p5, p6, p7,
1474 p8, p9);
1475 }
1476
1477 #undef FP_T
1478 #define FP_T(x) R (ObjectT::*x)(P1, P2, P3, P4, P5, P6, P7, P8, P9)
1479
1480 template <class ObjectT,
1481 class R,
1482 class P1,
1483 class P2,
1484 class P3,
1485 class P4,
1486 class P5,
1487 class P6,
1488 class P7,
1489 class P8,
1490 class P9>
1491 MethodFunctor9<ObjectT, FP_T(NONAME), R, P1, P2, P3, P4, P5, P6, P7, P8, P9>
1492 Bind(FP_T(method),
1493 const scoped_refptr<ObjectT>& object,
1494 typename detail::identity<P1>::type p1,
1495 typename detail::identity<P2>::type p2,
1496 typename detail::identity<P3>::type p3,
1497 typename detail::identity<P4>::type p4,
1498 typename detail::identity<P5>::type p5,
1499 typename detail::identity<P6>::type p6,
1500 typename detail::identity<P7>::type p7,
1501 typename detail::identity<P8>::type p8,
1502 typename detail::identity<P9>::type p9) {
1503 return MethodFunctor9<ObjectT, FP_T(NONAME), R, P1, P2, P3, P4, P5, P6, P7,
1504 P8, P9>(method, object.get(), p1, p2, p3, p4, p5, p6,
1505 p7, p8, p9);
1506 }
1507
1508 #undef FP_T
1509 #define FP_T(x) R (*x)(P1, P2, P3, P4, P5, P6, P7, P8, P9)
1510
1511 template <class R,
1512 class P1,
1513 class P2,
1514 class P3,
1515 class P4,
1516 class P5,
1517 class P6,
1518 class P7,
1519 class P8,
1520 class P9>
1521 Functor9<FP_T(NONAME), R, P1, P2, P3, P4, P5, P6, P7, P8, P9> Bind(
1522 FP_T(function),
1523 typename detail::identity<P1>::type p1,
1524 typename detail::identity<P2>::type p2,
1525 typename detail::identity<P3>::type p3,
1526 typename detail::identity<P4>::type p4,
1527 typename detail::identity<P5>::type p5,
1528 typename detail::identity<P6>::type p6,
1529 typename detail::identity<P7>::type p7,
1530 typename detail::identity<P8>::type p8,
1531 typename detail::identity<P9>::type p9) {
1532 return Functor9<FP_T(NONAME), R, P1, P2, P3, P4, P5, P6, P7, P8, P9>(
1533 function, p1, p2, p3, p4, p5, p6, p7, p8, p9);
1534 }
1535
1536 #undef FP_T
1537 221
1538 } // namespace rtc 222 } // namespace rtc
1539 223
1540 #undef NONAME 224 #undef NONAME
1541 225
1542 #endif // WEBRTC_BASE_BIND_H_ 226 #endif // WEBRTC_BASE_BIND_H_
OLDNEW
« no previous file with comments | « no previous file | webrtc/base/bind.h.pump » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698