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

Unified Diff: webrtc/base/bind.h

Issue 1226153003: Improvements to rtc::Bind (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Created 5 years, 5 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | webrtc/base/messagehandler.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webrtc/base/bind.h
diff --git a/webrtc/base/bind.h b/webrtc/base/bind.h
index 2e3104edfd3c70f75df673217a56c73538724539..0db11747aaef6657a9f98d53a0da4faa11dd3f33 100644
--- a/webrtc/base/bind.h
+++ b/webrtc/base/bind.h
@@ -579,6 +579,142 @@ Bind(FP_T(function),
}
#undef FP_T
+template <class ObjectT,
+ class MethodT,
+ class R,
+ class P1,
+ class P2,
+ class P3,
+ class P4,
+ class P5,
+ class P6>
+class MethodFunctor6 {
+ public:
+ MethodFunctor6(MethodT method,
+ ObjectT* object,
+ P1 p1,
+ P2 p2,
+ P3 p3,
+ P4 p4,
+ P5 p5,
+ P6 p6)
+ : method_(method),
+ object_(object),
+ p1_(p1),
+ p2_(p2),
+ p3_(p3),
+ p4_(p4),
+ p5_(p5),
+ p6_(p6) {}
+ R operator()() const {
+ return (object_->*method_)(p1_, p2_, p3_, p4_, p5_, p6_);
+ }
+
+ private:
+ MethodT method_;
+ ObjectT* object_;
+ P1 p1_;
+ P2 p2_;
+ P3 p3_;
+ P4 p4_;
+ P5 p5_;
+ P6 p6_;
+};
+
+template <class FunctorT,
+ class R,
+ class P1,
+ class P2,
+ class P3,
+ class P4,
+ class P5,
+ class P6>
+class Functor6 {
+ public:
+ Functor6(const FunctorT& functor, P1 p1, P2 p2, P3 p3, P4 p4, P5 p5, P6 p6)
+ : functor_(functor),
+ p1_(p1),
+ p2_(p2),
+ p3_(p3),
+ p4_(p4),
+ p5_(p5),
+ p6_(p6) {}
+ R operator()() const { return functor_(p1_, p2_, p3_, p4_, p5_, p6_); }
+
+ private:
+ FunctorT functor_;
+ P1 p1_;
+ P2 p2_;
+ P3 p3_;
+ P4 p4_;
+ P5 p5_;
+ P6 p6_;
+};
+
+#define FP_T(x) R (ObjectT::*x)(P1, P2, P3, P4, P5, P6)
+
+template <class ObjectT,
+ class R,
+ class P1,
+ class P2,
+ class P3,
+ class P4,
+ class P5,
+ class P6>
+MethodFunctor6<ObjectT, FP_T(NONAME), R, P1, P2, P3, P4, P5, P6> Bind(
+ FP_T(method),
+ ObjectT* object,
+ typename detail::identity<P1>::type p1,
+ typename detail::identity<P2>::type p2,
+ typename detail::identity<P3>::type p3,
+ typename detail::identity<P4>::type p4,
+ typename detail::identity<P5>::type p5,
+ typename detail::identity<P6>::type p6) {
+ return MethodFunctor6<ObjectT, FP_T(NONAME), R, P1, P2, P3, P4, P5, P6>(
+ method, object, p1, p2, p3, p4, p5, p6);
+}
+
+#undef FP_T
+#define FP_T(x) R (ObjectT::*x)(P1, P2, P3, P4, P5, P6) const
+
+template <class ObjectT,
+ class R,
+ class P1,
+ class P2,
+ class P3,
+ class P4,
+ class P5,
+ class P6>
+MethodFunctor6<const ObjectT, FP_T(NONAME), R, P1, P2, P3, P4, P5, P6> Bind(
+ FP_T(method),
+ const ObjectT* object,
+ typename detail::identity<P1>::type p1,
+ typename detail::identity<P2>::type p2,
+ typename detail::identity<P3>::type p3,
+ typename detail::identity<P4>::type p4,
+ typename detail::identity<P5>::type p5,
+ typename detail::identity<P6>::type p6) {
+ return MethodFunctor6<const ObjectT, FP_T(NONAME), R, P1, P2, P3, P4, P5, P6>(
+ method, object, p1, p2, p3, p4, p5, p6);
+}
+
+#undef FP_T
+#define FP_T(x) R (*x)(P1, P2, P3, P4, P5, P6)
+
+template <class R, class P1, class P2, class P3, class P4, class P5, class P6>
+Functor6<FP_T(NONAME), R, P1, P2, P3, P4, P5, P6> Bind(
+ FP_T(function),
+ typename detail::identity<P1>::type p1,
+ typename detail::identity<P2>::type p2,
+ typename detail::identity<P3>::type p3,
+ typename detail::identity<P4>::type p4,
+ typename detail::identity<P5>::type p5,
+ typename detail::identity<P5>::type p6) {
+ return Functor6<FP_T(NONAME), R, P1, P2, P3, P4, P5, P6>(function, p1, p2, p3,
+ p4, p5, p6);
+}
+
+#undef FP_T
} // namespace rtc
« no previous file with comments | « no previous file | webrtc/base/messagehandler.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698