OLD | NEW |
1 // This file was GENERATED by command: | |
2 // pump.py callback.h.pump | |
3 // DO NOT EDIT BY HAND!!! | |
4 | |
5 | |
6 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
7 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
8 // found in the LICENSE file. | 3 // found in the LICENSE file. |
9 | 4 |
10 #ifndef BASE_CALLBACK_H_ | 5 #ifndef BASE_CALLBACK_H_ |
11 #define BASE_CALLBACK_H_ | 6 #define BASE_CALLBACK_H_ |
12 | 7 |
13 #include "base/callback_forward.h" | 8 #include "base/callback_forward.h" |
14 #include "base/callback_internal.h" | 9 #include "base/callback_internal.h" |
15 #include "base/template_util.h" | 10 #include "base/template_util.h" |
(...skipping 344 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
360 // If you are thinking of forward declaring Callback in your own header file, | 355 // If you are thinking of forward declaring Callback in your own header file, |
361 // please include "base/callback_forward.h" instead. | 356 // please include "base/callback_forward.h" instead. |
362 template <typename Sig> | 357 template <typename Sig> |
363 class Callback; | 358 class Callback; |
364 | 359 |
365 namespace internal { | 360 namespace internal { |
366 template <typename Runnable, typename RunType, typename BoundArgsType> | 361 template <typename Runnable, typename RunType, typename BoundArgsType> |
367 struct BindState; | 362 struct BindState; |
368 } // namespace internal | 363 } // namespace internal |
369 | 364 |
370 template <typename R> | 365 template <typename R, typename... Args> |
371 class Callback<R(void)> : public internal::CallbackBase { | 366 class Callback<R(Args...)> : public internal::CallbackBase { |
372 public: | 367 public: |
373 typedef R(RunType)(); | 368 typedef R(RunType)(Args...); |
374 | 369 |
375 Callback() : CallbackBase(NULL) { } | 370 Callback() : CallbackBase(NULL) { } |
376 | 371 |
377 // Note that this constructor CANNOT be explicit, and that Bind() CANNOT | 372 // Note that this constructor CANNOT be explicit, and that Bind() CANNOT |
378 // return the exact Callback<> type. See base/bind.h for details. | 373 // return the exact Callback<> type. See base/bind.h for details. |
379 template <typename Runnable, typename BindRunType, typename BoundArgsType> | 374 template <typename Runnable, typename BindRunType, typename BoundArgsType> |
380 Callback(internal::BindState<Runnable, BindRunType, | 375 Callback(internal::BindState<Runnable, BindRunType, |
381 BoundArgsType>* bind_state) | 376 BoundArgsType>* bind_state) |
382 : CallbackBase(bind_state) { | 377 : CallbackBase(bind_state) { |
383 | |
384 // Force the assignment to a local variable of PolymorphicInvoke | 378 // Force the assignment to a local variable of PolymorphicInvoke |
385 // so the compiler will typecheck that the passed in Run() method has | 379 // so the compiler will typecheck that the passed in Run() method has |
386 // the correct type. | 380 // the correct type. |
387 PolymorphicInvoke invoke_func = | 381 PolymorphicInvoke invoke_func = |
388 &internal::BindState<Runnable, BindRunType, BoundArgsType> | 382 &internal::BindState<Runnable, BindRunType, BoundArgsType> |
389 ::InvokerType::Run; | 383 ::InvokerType::Run; |
390 polymorphic_invoke_ = reinterpret_cast<InvokeFuncStorage>(invoke_func); | 384 polymorphic_invoke_ = reinterpret_cast<InvokeFuncStorage>(invoke_func); |
391 } | 385 } |
392 | 386 |
393 bool Equals(const Callback& other) const { | 387 bool Equals(const Callback& other) const { |
394 return CallbackBase::Equals(other); | 388 return CallbackBase::Equals(other); |
395 } | 389 } |
396 | 390 |
397 R Run() const { | 391 R Run(typename internal::CallbackParamTraits<Args>::ForwardType... args) |
| 392 const { |
398 PolymorphicInvoke f = | 393 PolymorphicInvoke f = |
399 reinterpret_cast<PolymorphicInvoke>(polymorphic_invoke_); | 394 reinterpret_cast<PolymorphicInvoke>(polymorphic_invoke_); |
400 | 395 |
401 return f(bind_state_.get()); | 396 return f(bind_state_.get(), internal::CallbackForward(args)...); |
402 } | |
403 | |
404 private: | |
405 typedef R(*PolymorphicInvoke)( | |
406 internal::BindStateBase*); | |
407 | |
408 }; | |
409 | |
410 template <typename R, typename A1> | |
411 class Callback<R(A1)> : public internal::CallbackBase { | |
412 public: | |
413 typedef R(RunType)(A1); | |
414 | |
415 Callback() : CallbackBase(NULL) { } | |
416 | |
417 // Note that this constructor CANNOT be explicit, and that Bind() CANNOT | |
418 // return the exact Callback<> type. See base/bind.h for details. | |
419 template <typename Runnable, typename BindRunType, typename BoundArgsType> | |
420 Callback(internal::BindState<Runnable, BindRunType, | |
421 BoundArgsType>* bind_state) | |
422 : CallbackBase(bind_state) { | |
423 | |
424 // Force the assignment to a local variable of PolymorphicInvoke | |
425 // so the compiler will typecheck that the passed in Run() method has | |
426 // the correct type. | |
427 PolymorphicInvoke invoke_func = | |
428 &internal::BindState<Runnable, BindRunType, BoundArgsType> | |
429 ::InvokerType::Run; | |
430 polymorphic_invoke_ = reinterpret_cast<InvokeFuncStorage>(invoke_func); | |
431 } | |
432 | |
433 bool Equals(const Callback& other) const { | |
434 return CallbackBase::Equals(other); | |
435 } | |
436 | |
437 R Run(typename internal::CallbackParamTraits<A1>::ForwardType a1) const { | |
438 PolymorphicInvoke f = | |
439 reinterpret_cast<PolymorphicInvoke>(polymorphic_invoke_); | |
440 | |
441 return f(bind_state_.get(), internal::CallbackForward(a1)); | |
442 } | 397 } |
443 | 398 |
444 private: | 399 private: |
445 typedef R(*PolymorphicInvoke)( | 400 typedef R(*PolymorphicInvoke)( |
446 internal::BindStateBase*, | 401 internal::BindStateBase*, |
447 typename internal::CallbackParamTraits<A1>::ForwardType); | 402 typename internal::CallbackParamTraits<Args>::ForwardType...); |
448 | |
449 }; | 403 }; |
450 | 404 |
451 template <typename R, typename A1, typename A2> | |
452 class Callback<R(A1, A2)> : public internal::CallbackBase { | |
453 public: | |
454 typedef R(RunType)(A1, A2); | |
455 | |
456 Callback() : CallbackBase(NULL) { } | |
457 | |
458 // Note that this constructor CANNOT be explicit, and that Bind() CANNOT | |
459 // return the exact Callback<> type. See base/bind.h for details. | |
460 template <typename Runnable, typename BindRunType, typename BoundArgsType> | |
461 Callback(internal::BindState<Runnable, BindRunType, | |
462 BoundArgsType>* bind_state) | |
463 : CallbackBase(bind_state) { | |
464 | |
465 // Force the assignment to a local variable of PolymorphicInvoke | |
466 // so the compiler will typecheck that the passed in Run() method has | |
467 // the correct type. | |
468 PolymorphicInvoke invoke_func = | |
469 &internal::BindState<Runnable, BindRunType, BoundArgsType> | |
470 ::InvokerType::Run; | |
471 polymorphic_invoke_ = reinterpret_cast<InvokeFuncStorage>(invoke_func); | |
472 } | |
473 | |
474 bool Equals(const Callback& other) const { | |
475 return CallbackBase::Equals(other); | |
476 } | |
477 | |
478 R Run(typename internal::CallbackParamTraits<A1>::ForwardType a1, | |
479 typename internal::CallbackParamTraits<A2>::ForwardType a2) const { | |
480 PolymorphicInvoke f = | |
481 reinterpret_cast<PolymorphicInvoke>(polymorphic_invoke_); | |
482 | |
483 return f(bind_state_.get(), internal::CallbackForward(a1), | |
484 internal::CallbackForward(a2)); | |
485 } | |
486 | |
487 private: | |
488 typedef R(*PolymorphicInvoke)( | |
489 internal::BindStateBase*, | |
490 typename internal::CallbackParamTraits<A1>::ForwardType, | |
491 typename internal::CallbackParamTraits<A2>::ForwardType); | |
492 | |
493 }; | |
494 | |
495 template <typename R, typename A1, typename A2, typename A3> | |
496 class Callback<R(A1, A2, A3)> : public internal::CallbackBase { | |
497 public: | |
498 typedef R(RunType)(A1, A2, A3); | |
499 | |
500 Callback() : CallbackBase(NULL) { } | |
501 | |
502 // Note that this constructor CANNOT be explicit, and that Bind() CANNOT | |
503 // return the exact Callback<> type. See base/bind.h for details. | |
504 template <typename Runnable, typename BindRunType, typename BoundArgsType> | |
505 Callback(internal::BindState<Runnable, BindRunType, | |
506 BoundArgsType>* bind_state) | |
507 : CallbackBase(bind_state) { | |
508 | |
509 // Force the assignment to a local variable of PolymorphicInvoke | |
510 // so the compiler will typecheck that the passed in Run() method has | |
511 // the correct type. | |
512 PolymorphicInvoke invoke_func = | |
513 &internal::BindState<Runnable, BindRunType, BoundArgsType> | |
514 ::InvokerType::Run; | |
515 polymorphic_invoke_ = reinterpret_cast<InvokeFuncStorage>(invoke_func); | |
516 } | |
517 | |
518 bool Equals(const Callback& other) const { | |
519 return CallbackBase::Equals(other); | |
520 } | |
521 | |
522 R Run(typename internal::CallbackParamTraits<A1>::ForwardType a1, | |
523 typename internal::CallbackParamTraits<A2>::ForwardType a2, | |
524 typename internal::CallbackParamTraits<A3>::ForwardType a3) const { | |
525 PolymorphicInvoke f = | |
526 reinterpret_cast<PolymorphicInvoke>(polymorphic_invoke_); | |
527 | |
528 return f(bind_state_.get(), internal::CallbackForward(a1), | |
529 internal::CallbackForward(a2), | |
530 internal::CallbackForward(a3)); | |
531 } | |
532 | |
533 private: | |
534 typedef R(*PolymorphicInvoke)( | |
535 internal::BindStateBase*, | |
536 typename internal::CallbackParamTraits<A1>::ForwardType, | |
537 typename internal::CallbackParamTraits<A2>::ForwardType, | |
538 typename internal::CallbackParamTraits<A3>::ForwardType); | |
539 | |
540 }; | |
541 | |
542 template <typename R, typename A1, typename A2, typename A3, typename A4> | |
543 class Callback<R(A1, A2, A3, A4)> : public internal::CallbackBase { | |
544 public: | |
545 typedef R(RunType)(A1, A2, A3, A4); | |
546 | |
547 Callback() : CallbackBase(NULL) { } | |
548 | |
549 // Note that this constructor CANNOT be explicit, and that Bind() CANNOT | |
550 // return the exact Callback<> type. See base/bind.h for details. | |
551 template <typename Runnable, typename BindRunType, typename BoundArgsType> | |
552 Callback(internal::BindState<Runnable, BindRunType, | |
553 BoundArgsType>* bind_state) | |
554 : CallbackBase(bind_state) { | |
555 | |
556 // Force the assignment to a local variable of PolymorphicInvoke | |
557 // so the compiler will typecheck that the passed in Run() method has | |
558 // the correct type. | |
559 PolymorphicInvoke invoke_func = | |
560 &internal::BindState<Runnable, BindRunType, BoundArgsType> | |
561 ::InvokerType::Run; | |
562 polymorphic_invoke_ = reinterpret_cast<InvokeFuncStorage>(invoke_func); | |
563 } | |
564 | |
565 bool Equals(const Callback& other) const { | |
566 return CallbackBase::Equals(other); | |
567 } | |
568 | |
569 R Run(typename internal::CallbackParamTraits<A1>::ForwardType a1, | |
570 typename internal::CallbackParamTraits<A2>::ForwardType a2, | |
571 typename internal::CallbackParamTraits<A3>::ForwardType a3, | |
572 typename internal::CallbackParamTraits<A4>::ForwardType a4) const { | |
573 PolymorphicInvoke f = | |
574 reinterpret_cast<PolymorphicInvoke>(polymorphic_invoke_); | |
575 | |
576 return f(bind_state_.get(), internal::CallbackForward(a1), | |
577 internal::CallbackForward(a2), | |
578 internal::CallbackForward(a3), | |
579 internal::CallbackForward(a4)); | |
580 } | |
581 | |
582 private: | |
583 typedef R(*PolymorphicInvoke)( | |
584 internal::BindStateBase*, | |
585 typename internal::CallbackParamTraits<A1>::ForwardType, | |
586 typename internal::CallbackParamTraits<A2>::ForwardType, | |
587 typename internal::CallbackParamTraits<A3>::ForwardType, | |
588 typename internal::CallbackParamTraits<A4>::ForwardType); | |
589 | |
590 }; | |
591 | |
592 template <typename R, typename A1, typename A2, typename A3, typename A4, | |
593 typename A5> | |
594 class Callback<R(A1, A2, A3, A4, A5)> : public internal::CallbackBase { | |
595 public: | |
596 typedef R(RunType)(A1, A2, A3, A4, A5); | |
597 | |
598 Callback() : CallbackBase(NULL) { } | |
599 | |
600 // Note that this constructor CANNOT be explicit, and that Bind() CANNOT | |
601 // return the exact Callback<> type. See base/bind.h for details. | |
602 template <typename Runnable, typename BindRunType, typename BoundArgsType> | |
603 Callback(internal::BindState<Runnable, BindRunType, | |
604 BoundArgsType>* bind_state) | |
605 : CallbackBase(bind_state) { | |
606 | |
607 // Force the assignment to a local variable of PolymorphicInvoke | |
608 // so the compiler will typecheck that the passed in Run() method has | |
609 // the correct type. | |
610 PolymorphicInvoke invoke_func = | |
611 &internal::BindState<Runnable, BindRunType, BoundArgsType> | |
612 ::InvokerType::Run; | |
613 polymorphic_invoke_ = reinterpret_cast<InvokeFuncStorage>(invoke_func); | |
614 } | |
615 | |
616 bool Equals(const Callback& other) const { | |
617 return CallbackBase::Equals(other); | |
618 } | |
619 | |
620 R Run(typename internal::CallbackParamTraits<A1>::ForwardType a1, | |
621 typename internal::CallbackParamTraits<A2>::ForwardType a2, | |
622 typename internal::CallbackParamTraits<A3>::ForwardType a3, | |
623 typename internal::CallbackParamTraits<A4>::ForwardType a4, | |
624 typename internal::CallbackParamTraits<A5>::ForwardType a5) const { | |
625 PolymorphicInvoke f = | |
626 reinterpret_cast<PolymorphicInvoke>(polymorphic_invoke_); | |
627 | |
628 return f(bind_state_.get(), internal::CallbackForward(a1), | |
629 internal::CallbackForward(a2), | |
630 internal::CallbackForward(a3), | |
631 internal::CallbackForward(a4), | |
632 internal::CallbackForward(a5)); | |
633 } | |
634 | |
635 private: | |
636 typedef R(*PolymorphicInvoke)( | |
637 internal::BindStateBase*, | |
638 typename internal::CallbackParamTraits<A1>::ForwardType, | |
639 typename internal::CallbackParamTraits<A2>::ForwardType, | |
640 typename internal::CallbackParamTraits<A3>::ForwardType, | |
641 typename internal::CallbackParamTraits<A4>::ForwardType, | |
642 typename internal::CallbackParamTraits<A5>::ForwardType); | |
643 | |
644 }; | |
645 | |
646 template <typename R, typename A1, typename A2, typename A3, typename A4, | |
647 typename A5, typename A6> | |
648 class Callback<R(A1, A2, A3, A4, A5, A6)> : public internal::CallbackBase { | |
649 public: | |
650 typedef R(RunType)(A1, A2, A3, A4, A5, A6); | |
651 | |
652 Callback() : CallbackBase(NULL) { } | |
653 | |
654 // Note that this constructor CANNOT be explicit, and that Bind() CANNOT | |
655 // return the exact Callback<> type. See base/bind.h for details. | |
656 template <typename Runnable, typename BindRunType, typename BoundArgsType> | |
657 Callback(internal::BindState<Runnable, BindRunType, | |
658 BoundArgsType>* bind_state) | |
659 : CallbackBase(bind_state) { | |
660 | |
661 // Force the assignment to a local variable of PolymorphicInvoke | |
662 // so the compiler will typecheck that the passed in Run() method has | |
663 // the correct type. | |
664 PolymorphicInvoke invoke_func = | |
665 &internal::BindState<Runnable, BindRunType, BoundArgsType> | |
666 ::InvokerType::Run; | |
667 polymorphic_invoke_ = reinterpret_cast<InvokeFuncStorage>(invoke_func); | |
668 } | |
669 | |
670 bool Equals(const Callback& other) const { | |
671 return CallbackBase::Equals(other); | |
672 } | |
673 | |
674 R Run(typename internal::CallbackParamTraits<A1>::ForwardType a1, | |
675 typename internal::CallbackParamTraits<A2>::ForwardType a2, | |
676 typename internal::CallbackParamTraits<A3>::ForwardType a3, | |
677 typename internal::CallbackParamTraits<A4>::ForwardType a4, | |
678 typename internal::CallbackParamTraits<A5>::ForwardType a5, | |
679 typename internal::CallbackParamTraits<A6>::ForwardType a6) const { | |
680 PolymorphicInvoke f = | |
681 reinterpret_cast<PolymorphicInvoke>(polymorphic_invoke_); | |
682 | |
683 return f(bind_state_.get(), internal::CallbackForward(a1), | |
684 internal::CallbackForward(a2), | |
685 internal::CallbackForward(a3), | |
686 internal::CallbackForward(a4), | |
687 internal::CallbackForward(a5), | |
688 internal::CallbackForward(a6)); | |
689 } | |
690 | |
691 private: | |
692 typedef R(*PolymorphicInvoke)( | |
693 internal::BindStateBase*, | |
694 typename internal::CallbackParamTraits<A1>::ForwardType, | |
695 typename internal::CallbackParamTraits<A2>::ForwardType, | |
696 typename internal::CallbackParamTraits<A3>::ForwardType, | |
697 typename internal::CallbackParamTraits<A4>::ForwardType, | |
698 typename internal::CallbackParamTraits<A5>::ForwardType, | |
699 typename internal::CallbackParamTraits<A6>::ForwardType); | |
700 | |
701 }; | |
702 | |
703 template <typename R, typename A1, typename A2, typename A3, typename A4, | |
704 typename A5, typename A6, typename A7> | |
705 class Callback<R(A1, A2, A3, A4, A5, A6, A7)> : public internal::CallbackBase { | |
706 public: | |
707 typedef R(RunType)(A1, A2, A3, A4, A5, A6, A7); | |
708 | |
709 Callback() : CallbackBase(NULL) { } | |
710 | |
711 // Note that this constructor CANNOT be explicit, and that Bind() CANNOT | |
712 // return the exact Callback<> type. See base/bind.h for details. | |
713 template <typename Runnable, typename BindRunType, typename BoundArgsType> | |
714 Callback(internal::BindState<Runnable, BindRunType, | |
715 BoundArgsType>* bind_state) | |
716 : CallbackBase(bind_state) { | |
717 | |
718 // Force the assignment to a local variable of PolymorphicInvoke | |
719 // so the compiler will typecheck that the passed in Run() method has | |
720 // the correct type. | |
721 PolymorphicInvoke invoke_func = | |
722 &internal::BindState<Runnable, BindRunType, BoundArgsType> | |
723 ::InvokerType::Run; | |
724 polymorphic_invoke_ = reinterpret_cast<InvokeFuncStorage>(invoke_func); | |
725 } | |
726 | |
727 bool Equals(const Callback& other) const { | |
728 return CallbackBase::Equals(other); | |
729 } | |
730 | |
731 R Run(typename internal::CallbackParamTraits<A1>::ForwardType a1, | |
732 typename internal::CallbackParamTraits<A2>::ForwardType a2, | |
733 typename internal::CallbackParamTraits<A3>::ForwardType a3, | |
734 typename internal::CallbackParamTraits<A4>::ForwardType a4, | |
735 typename internal::CallbackParamTraits<A5>::ForwardType a5, | |
736 typename internal::CallbackParamTraits<A6>::ForwardType a6, | |
737 typename internal::CallbackParamTraits<A7>::ForwardType a7) const { | |
738 PolymorphicInvoke f = | |
739 reinterpret_cast<PolymorphicInvoke>(polymorphic_invoke_); | |
740 | |
741 return f(bind_state_.get(), internal::CallbackForward(a1), | |
742 internal::CallbackForward(a2), | |
743 internal::CallbackForward(a3), | |
744 internal::CallbackForward(a4), | |
745 internal::CallbackForward(a5), | |
746 internal::CallbackForward(a6), | |
747 internal::CallbackForward(a7)); | |
748 } | |
749 | |
750 private: | |
751 typedef R(*PolymorphicInvoke)( | |
752 internal::BindStateBase*, | |
753 typename internal::CallbackParamTraits<A1>::ForwardType, | |
754 typename internal::CallbackParamTraits<A2>::ForwardType, | |
755 typename internal::CallbackParamTraits<A3>::ForwardType, | |
756 typename internal::CallbackParamTraits<A4>::ForwardType, | |
757 typename internal::CallbackParamTraits<A5>::ForwardType, | |
758 typename internal::CallbackParamTraits<A6>::ForwardType, | |
759 typename internal::CallbackParamTraits<A7>::ForwardType); | |
760 | |
761 }; | |
762 | |
763 | |
764 // Syntactic sugar to make Callback<void(void)> easier to declare since it | 405 // Syntactic sugar to make Callback<void(void)> easier to declare since it |
765 // will be used in a lot of APIs with delayed execution. | 406 // will be used in a lot of APIs with delayed execution. |
766 typedef Callback<void(void)> Closure; | 407 typedef Callback<void(void)> Closure; |
767 | 408 |
768 } // namespace base | 409 } // namespace base |
769 | 410 |
770 #endif // BASE_CALLBACK_H | 411 #endif // BASE_CALLBACK_H_ |
OLD | NEW |