michael@0: // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. michael@0: // Use of this source code is governed by a BSD-style license that can be michael@0: // found in the LICENSE file. michael@0: michael@0: // A Tuple is a generic templatized container, similar in concept to std::pair. michael@0: // There are classes Tuple0 to Tuple6, cooresponding to the number of elements michael@0: // it contains. The convenient MakeTuple() function takes 0 to 6 arguments, michael@0: // and will construct and return the appropriate Tuple object. The functions michael@0: // DispatchToMethod and DispatchToFunction take a function pointer or instance michael@0: // and method pointer, and unpack a tuple into arguments to the call. michael@0: // michael@0: // Tuple elements are copied by value, and stored in the tuple. See the unit michael@0: // tests for more details of how/when the values are copied. michael@0: // michael@0: // Example usage: michael@0: // // These two methods of creating a Tuple are identical. michael@0: // Tuple2 tuple_a(1, "wee"); michael@0: // Tuple2 tuple_b = MakeTuple(1, "wee"); michael@0: // michael@0: // void SomeFunc(int a, const char* b) { } michael@0: // DispatchToFunction(&SomeFunc, tuple_a); // SomeFunc(1, "wee") michael@0: // DispatchToFunction( michael@0: // &SomeFunc, MakeTuple(10, "foo")); // SomeFunc(10, "foo") michael@0: // michael@0: // struct { void SomeMeth(int a, int b, int c) { } } foo; michael@0: // DispatchToMethod(&foo, &Foo::SomeMeth, MakeTuple(1, 2, 3)); michael@0: // // foo->SomeMeth(1, 2, 3); michael@0: michael@0: #ifndef BASE_TUPLE_H__ michael@0: #define BASE_TUPLE_H__ michael@0: michael@0: // Traits ---------------------------------------------------------------------- michael@0: // michael@0: // A simple traits class for tuple arguments. michael@0: // michael@0: // ValueType: the bare, nonref version of a type (same as the type for nonrefs). michael@0: // RefType: the ref version of a type (same as the type for refs). michael@0: // ParamType: what type to pass to functions (refs should not be constified). michael@0: michael@0: template michael@0: struct TupleTraits { michael@0: typedef P ValueType; michael@0: typedef P& RefType; michael@0: typedef const P& ParamType; michael@0: }; michael@0: michael@0: template michael@0: struct TupleTraits { michael@0: typedef P ValueType; michael@0: typedef P& RefType; michael@0: typedef P& ParamType; michael@0: }; michael@0: michael@0: // Tuple ----------------------------------------------------------------------- michael@0: // michael@0: // This set of classes is useful for bundling 0 or more heterogeneous data types michael@0: // into a single variable. The advantage of this is that it greatly simplifies michael@0: // function objects that need to take an arbitrary number of parameters; see michael@0: // RunnableMethod and IPC::MessageWithTuple. michael@0: // michael@0: // Tuple0 is supplied to act as a 'void' type. It can be used, for example, michael@0: // when dispatching to a function that accepts no arguments (see the michael@0: // Dispatchers below). michael@0: // Tuple1 is rarely useful. One such use is when A is non-const ref that you michael@0: // want filled by the dispatchee, and the tuple is merely a container for that michael@0: // output (a "tier"). See MakeRefTuple and its usages. michael@0: michael@0: struct Tuple0 { michael@0: typedef Tuple0 ValueTuple; michael@0: typedef Tuple0 RefTuple; michael@0: }; michael@0: michael@0: template michael@0: struct Tuple1 { michael@0: public: michael@0: typedef A TypeA; michael@0: typedef Tuple1::ValueType> ValueTuple; michael@0: typedef Tuple1::RefType> RefTuple; michael@0: michael@0: Tuple1() {} michael@0: explicit Tuple1(typename TupleTraits::ParamType a) : a(a) {} michael@0: michael@0: A a; michael@0: }; michael@0: michael@0: template michael@0: struct Tuple2 { michael@0: public: michael@0: typedef A TypeA; michael@0: typedef B TypeB; michael@0: typedef Tuple2::ValueType, michael@0: typename TupleTraits::ValueType> ValueTuple; michael@0: typedef Tuple2::RefType, michael@0: typename TupleTraits::RefType> RefTuple; michael@0: michael@0: Tuple2() {} michael@0: Tuple2(typename TupleTraits::ParamType a, michael@0: typename TupleTraits::ParamType b) michael@0: : a(a), b(b) { michael@0: } michael@0: michael@0: A a; michael@0: B b; michael@0: }; michael@0: michael@0: template michael@0: struct Tuple3 { michael@0: public: michael@0: typedef A TypeA; michael@0: typedef B TypeB; michael@0: typedef C TypeC; michael@0: typedef Tuple3::ValueType, michael@0: typename TupleTraits::ValueType, michael@0: typename TupleTraits::ValueType> ValueTuple; michael@0: typedef Tuple3::RefType, michael@0: typename TupleTraits::RefType, michael@0: typename TupleTraits::RefType> RefTuple; michael@0: michael@0: Tuple3() {} michael@0: Tuple3(typename TupleTraits::ParamType a, michael@0: typename TupleTraits::ParamType b, michael@0: typename TupleTraits::ParamType c) michael@0: : a(a), b(b), c(c){ michael@0: } michael@0: michael@0: A a; michael@0: B b; michael@0: C c; michael@0: }; michael@0: michael@0: template michael@0: struct Tuple4 { michael@0: public: michael@0: typedef A TypeA; michael@0: typedef B TypeB; michael@0: typedef C TypeC; michael@0: typedef D TypeD; michael@0: typedef Tuple4::ValueType, michael@0: typename TupleTraits::ValueType, michael@0: typename TupleTraits::ValueType, michael@0: typename TupleTraits::ValueType> ValueTuple; michael@0: typedef Tuple4::RefType, michael@0: typename TupleTraits::RefType, michael@0: typename TupleTraits::RefType, michael@0: typename TupleTraits::RefType> RefTuple; michael@0: michael@0: Tuple4() {} michael@0: Tuple4(typename TupleTraits::ParamType a, michael@0: typename TupleTraits::ParamType b, michael@0: typename TupleTraits::ParamType c, michael@0: typename TupleTraits::ParamType d) michael@0: : a(a), b(b), c(c), d(d) { michael@0: } michael@0: michael@0: A a; michael@0: B b; michael@0: C c; michael@0: D d; michael@0: }; michael@0: michael@0: template michael@0: struct Tuple5 { michael@0: public: michael@0: typedef A TypeA; michael@0: typedef B TypeB; michael@0: typedef C TypeC; michael@0: typedef D TypeD; michael@0: typedef E TypeE; michael@0: typedef Tuple5::ValueType, michael@0: typename TupleTraits::ValueType, michael@0: typename TupleTraits::ValueType, michael@0: typename TupleTraits::ValueType, michael@0: typename TupleTraits::ValueType> ValueTuple; michael@0: typedef Tuple5::RefType, michael@0: typename TupleTraits::RefType, michael@0: typename TupleTraits::RefType, michael@0: typename TupleTraits::RefType, michael@0: typename TupleTraits::RefType> RefTuple; michael@0: michael@0: Tuple5() {} michael@0: Tuple5(typename TupleTraits::ParamType a, michael@0: typename TupleTraits::ParamType b, michael@0: typename TupleTraits::ParamType c, michael@0: typename TupleTraits::ParamType d, michael@0: typename TupleTraits::ParamType e) michael@0: : a(a), b(b), c(c), d(d), e(e) { michael@0: } michael@0: michael@0: A a; michael@0: B b; michael@0: C c; michael@0: D d; michael@0: E e; michael@0: }; michael@0: michael@0: template michael@0: struct Tuple6 { michael@0: public: michael@0: typedef A TypeA; michael@0: typedef B TypeB; michael@0: typedef C TypeC; michael@0: typedef D TypeD; michael@0: typedef E TypeE; michael@0: typedef F TypeF; michael@0: typedef Tuple6::ValueType, michael@0: typename TupleTraits::ValueType, michael@0: typename TupleTraits::ValueType, michael@0: typename TupleTraits::ValueType, michael@0: typename TupleTraits::ValueType, michael@0: typename TupleTraits::ValueType> ValueTuple; michael@0: typedef Tuple6::RefType, michael@0: typename TupleTraits::RefType, michael@0: typename TupleTraits::RefType, michael@0: typename TupleTraits::RefType, michael@0: typename TupleTraits::RefType, michael@0: typename TupleTraits::RefType> RefTuple; michael@0: michael@0: Tuple6() {} michael@0: Tuple6(typename TupleTraits::ParamType a, michael@0: typename TupleTraits::ParamType b, michael@0: typename TupleTraits::ParamType c, michael@0: typename TupleTraits::ParamType d, michael@0: typename TupleTraits::ParamType e, michael@0: typename TupleTraits::ParamType f) michael@0: : a(a), b(b), c(c), d(d), e(e), f(f) { michael@0: } michael@0: michael@0: A a; michael@0: B b; michael@0: C c; michael@0: D d; michael@0: E e; michael@0: F f; michael@0: }; michael@0: michael@0: template michael@0: struct Tuple7 { michael@0: public: michael@0: typedef A TypeA; michael@0: typedef B TypeB; michael@0: typedef C TypeC; michael@0: typedef D TypeD; michael@0: typedef E TypeE; michael@0: typedef F TypeF; michael@0: typedef G TypeG; michael@0: typedef Tuple7::ValueType, michael@0: typename TupleTraits::ValueType, michael@0: typename TupleTraits::ValueType, michael@0: typename TupleTraits::ValueType, michael@0: typename TupleTraits::ValueType, michael@0: typename TupleTraits::ValueType, michael@0: typename TupleTraits::ValueType> ValueTuple; michael@0: typedef Tuple7::RefType, michael@0: typename TupleTraits::RefType, michael@0: typename TupleTraits::RefType, michael@0: typename TupleTraits::RefType, michael@0: typename TupleTraits::RefType, michael@0: typename TupleTraits::RefType, michael@0: typename TupleTraits::RefType> RefTuple; michael@0: michael@0: Tuple7() {} michael@0: Tuple7(typename TupleTraits::ParamType a, michael@0: typename TupleTraits::ParamType b, michael@0: typename TupleTraits::ParamType c, michael@0: typename TupleTraits::ParamType d, michael@0: typename TupleTraits::ParamType e, michael@0: typename TupleTraits::ParamType f, michael@0: typename TupleTraits::ParamType g) michael@0: : a(a), b(b), c(c), d(d), e(e), f(f), g(g) { michael@0: } michael@0: michael@0: A a; michael@0: B b; michael@0: C c; michael@0: D d; michael@0: E e; michael@0: F f; michael@0: G g; michael@0: }; michael@0: michael@0: // Tuple creators ------------------------------------------------------------- michael@0: // michael@0: // Helper functions for constructing tuples while inferring the template michael@0: // argument types. michael@0: michael@0: inline Tuple0 MakeTuple() { michael@0: return Tuple0(); michael@0: } michael@0: michael@0: template michael@0: inline Tuple1 MakeTuple(const A& a) { michael@0: return Tuple1(a); michael@0: } michael@0: michael@0: template michael@0: inline Tuple2 MakeTuple(const A& a, const B& b) { michael@0: return Tuple2(a, b); michael@0: } michael@0: michael@0: template michael@0: inline Tuple3 MakeTuple(const A& a, const B& b, const C& c) { michael@0: return Tuple3(a, b, c); michael@0: } michael@0: michael@0: template michael@0: inline Tuple4 MakeTuple(const A& a, const B& b, const C& c, michael@0: const D& d) { michael@0: return Tuple4(a, b, c, d); michael@0: } michael@0: michael@0: template michael@0: inline Tuple5 MakeTuple(const A& a, const B& b, const C& c, michael@0: const D& d, const E& e) { michael@0: return Tuple5(a, b, c, d, e); michael@0: } michael@0: michael@0: template michael@0: inline Tuple6 MakeTuple(const A& a, const B& b, const C& c, michael@0: const D& d, const E& e, const F& f) { michael@0: return Tuple6(a, b, c, d, e, f); michael@0: } michael@0: michael@0: template michael@0: inline Tuple7 MakeTuple(const A& a, const B& b, const C& c, michael@0: const D& d, const E& e, const F& f, michael@0: const G& g) { michael@0: return Tuple7(a, b, c, d, e, f, g); michael@0: } michael@0: michael@0: // The following set of helpers make what Boost refers to as "Tiers" - a tuple michael@0: // of references. michael@0: michael@0: template michael@0: inline Tuple1 MakeRefTuple(A& a) { michael@0: return Tuple1(a); michael@0: } michael@0: michael@0: template michael@0: inline Tuple2 MakeRefTuple(A& a, B& b) { michael@0: return Tuple2(a, b); michael@0: } michael@0: michael@0: template michael@0: inline Tuple3 MakeRefTuple(A& a, B& b, C& c) { michael@0: return Tuple3(a, b, c); michael@0: } michael@0: michael@0: template michael@0: inline Tuple4 MakeRefTuple(A& a, B& b, C& c, D& d) { michael@0: return Tuple4(a, b, c, d); michael@0: } michael@0: michael@0: template michael@0: inline Tuple5 MakeRefTuple(A& a, B& b, C& c, D& d, E& e) { michael@0: return Tuple5(a, b, c, d, e); michael@0: } michael@0: michael@0: template michael@0: inline Tuple6 MakeRefTuple(A& a, B& b, C& c, D& d, E& e, michael@0: F& f) { michael@0: return Tuple6(a, b, c, d, e, f); michael@0: } michael@0: michael@0: template michael@0: inline Tuple7 MakeRefTuple(A& a, B& b, C& c, D& d, michael@0: E& e, F& f, G& g) { michael@0: return Tuple7(a, b, c, d, e, f, g); michael@0: } michael@0: michael@0: // Dispatchers ---------------------------------------------------------------- michael@0: // michael@0: // Helper functions that call the given method on an object, with the unpacked michael@0: // tuple arguments. Notice that they all have the same number of arguments, michael@0: // so you need only write: michael@0: // DispatchToMethod(object, &Object::method, args); michael@0: // This is very useful for templated dispatchers, since they don't need to know michael@0: // what type |args| is. michael@0: michael@0: // Non-Static Dispatchers with no out params. michael@0: michael@0: template michael@0: inline void DispatchToMethod(ObjT* obj, Method method, const Tuple0& arg) { michael@0: (obj->*method)(); michael@0: } michael@0: michael@0: template michael@0: inline void DispatchToMethod(ObjT* obj, Method method, const A& arg) { michael@0: (obj->*method)(arg); michael@0: } michael@0: michael@0: template michael@0: inline void DispatchToMethod(ObjT* obj, Method method, const Tuple1& arg) { michael@0: (obj->*method)(arg.a); michael@0: } michael@0: michael@0: template michael@0: inline void DispatchToMethod(ObjT* obj, michael@0: Method method, michael@0: const Tuple2& arg) { michael@0: (obj->*method)(arg.a, arg.b); michael@0: } michael@0: michael@0: template michael@0: inline void DispatchToMethod(ObjT* obj, Method method, michael@0: const Tuple3& arg) { michael@0: (obj->*method)(arg.a, arg.b, arg.c); michael@0: } michael@0: michael@0: template michael@0: inline void DispatchToMethod(ObjT* obj, Method method, michael@0: const Tuple4& arg) { michael@0: (obj->*method)(arg.a, arg.b, arg.c, arg.d); michael@0: } michael@0: michael@0: template michael@0: inline void DispatchToMethod(ObjT* obj, Method method, michael@0: const Tuple5& arg) { michael@0: (obj->*method)(arg.a, arg.b, arg.c, arg.d, arg.e); michael@0: } michael@0: michael@0: template michael@0: inline void DispatchToMethod(ObjT* obj, Method method, michael@0: const Tuple6& arg) { michael@0: (obj->*method)(arg.a, arg.b, arg.c, arg.d, arg.e, arg.f); michael@0: } michael@0: michael@0: template michael@0: inline void DispatchToMethod(ObjT* obj, Method method, michael@0: const Tuple7& arg) { michael@0: (obj->*method)(arg.a, arg.b, arg.c, arg.d, arg.e, arg.f, arg.g); michael@0: } michael@0: michael@0: // Static Dispatchers with no out params. michael@0: michael@0: template michael@0: inline void DispatchToFunction(Function function, const Tuple0& arg) { michael@0: (*function)(); michael@0: } michael@0: michael@0: template michael@0: inline void DispatchToFunction(Function function, const A& arg) { michael@0: (*function)(arg); michael@0: } michael@0: michael@0: template michael@0: inline void DispatchToFunction(Function function, const Tuple1& arg) { michael@0: (*function)(arg.a); michael@0: } michael@0: michael@0: template michael@0: inline void DispatchToFunction(Function function, const Tuple2& arg) { michael@0: (*function)(arg.a, arg.b); michael@0: } michael@0: michael@0: template michael@0: inline void DispatchToFunction(Function function, const Tuple3& arg) { michael@0: (*function)(arg.a, arg.b, arg.c); michael@0: } michael@0: michael@0: template michael@0: inline void DispatchToFunction(Function function, michael@0: const Tuple4& arg) { michael@0: (*function)(arg.a, arg.b, arg.c, arg.d); michael@0: } michael@0: michael@0: template michael@0: inline void DispatchToFunction(Function function, michael@0: const Tuple5& arg) { michael@0: (*function)(arg.a, arg.b, arg.c, arg.d, arg.e); michael@0: } michael@0: michael@0: template michael@0: inline void DispatchToFunction(Function function, michael@0: const Tuple6& arg) { michael@0: (*function)(arg.a, arg.b, arg.c, arg.d, arg.e, arg.f); michael@0: } michael@0: michael@0: // Dispatchers with 0 out param (as a Tuple0). michael@0: michael@0: template michael@0: inline void DispatchToMethod(ObjT* obj, michael@0: Method method, michael@0: const Tuple0& arg, Tuple0*) { michael@0: (obj->*method)(); michael@0: } michael@0: michael@0: template michael@0: inline void DispatchToMethod(ObjT* obj, Method method, const A& arg, Tuple0*) { michael@0: (obj->*method)(arg); michael@0: } michael@0: michael@0: template michael@0: inline void DispatchToMethod(ObjT* obj, michael@0: Method method, michael@0: const Tuple1& arg, Tuple0*) { michael@0: (obj->*method)(arg.a); michael@0: } michael@0: michael@0: template michael@0: inline void DispatchToMethod(ObjT* obj, michael@0: Method method, michael@0: const Tuple2& arg, Tuple0*) { michael@0: (obj->*method)(arg.a, arg.b); michael@0: } michael@0: michael@0: template michael@0: inline void DispatchToMethod(ObjT* obj, Method method, michael@0: const Tuple3& arg, Tuple0*) { michael@0: (obj->*method)(arg.a, arg.b, arg.c); michael@0: } michael@0: michael@0: template michael@0: inline void DispatchToMethod(ObjT* obj, Method method, michael@0: const Tuple4& arg, Tuple0*) { michael@0: (obj->*method)(arg.a, arg.b, arg.c, arg.d); michael@0: } michael@0: michael@0: template michael@0: inline void DispatchToMethod(ObjT* obj, Method method, michael@0: const Tuple5& arg, Tuple0*) { michael@0: (obj->*method)(arg.a, arg.b, arg.c, arg.d, arg.e); michael@0: } michael@0: michael@0: template michael@0: inline void DispatchToMethod(ObjT* obj, Method method, michael@0: const Tuple6& arg, Tuple0*) { michael@0: (obj->*method)(arg.a, arg.b, arg.c, arg.d, arg.e, arg.f); michael@0: } michael@0: michael@0: // Dispatchers with 1 out param. michael@0: michael@0: template michael@0: inline void DispatchToMethod(ObjT* obj, Method method, michael@0: const Tuple0& in, michael@0: Tuple1* out) { michael@0: (obj->*method)(&out->a); michael@0: } michael@0: michael@0: template michael@0: inline void DispatchToMethod(ObjT* obj, Method method, michael@0: const InA& in, michael@0: Tuple1* out) { michael@0: (obj->*method)(in, &out->a); michael@0: } michael@0: michael@0: template michael@0: inline void DispatchToMethod(ObjT* obj, Method method, michael@0: const Tuple1& in, michael@0: Tuple1* out) { michael@0: (obj->*method)(in.a, &out->a); michael@0: } michael@0: michael@0: template michael@0: inline void DispatchToMethod(ObjT* obj, Method method, michael@0: const Tuple2& in, michael@0: Tuple1* out) { michael@0: (obj->*method)(in.a, in.b, &out->a); michael@0: } michael@0: michael@0: template michael@0: inline void DispatchToMethod(ObjT* obj, Method method, michael@0: const Tuple3& in, michael@0: Tuple1* out) { michael@0: (obj->*method)(in.a, in.b, in.c, &out->a); michael@0: } michael@0: michael@0: template michael@0: inline void DispatchToMethod(ObjT* obj, Method method, michael@0: const Tuple4& in, michael@0: Tuple1* out) { michael@0: (obj->*method)(in.a, in.b, in.c, in.d, &out->a); michael@0: } michael@0: michael@0: template michael@0: inline void DispatchToMethod(ObjT* obj, Method method, michael@0: const Tuple5& in, michael@0: Tuple1* out) { michael@0: (obj->*method)(in.a, in.b, in.c, in.d, in.e, &out->a); michael@0: } michael@0: michael@0: template michael@0: inline void DispatchToMethod(ObjT* obj, Method method, michael@0: const Tuple6& in, michael@0: Tuple1* out) { michael@0: (obj->*method)(in.a, in.b, in.c, in.d, in.e, in.f, &out->a); michael@0: } michael@0: michael@0: // Dispatchers with 2 out params. michael@0: michael@0: template michael@0: inline void DispatchToMethod(ObjT* obj, Method method, michael@0: const Tuple0& in, michael@0: Tuple2* out) { michael@0: (obj->*method)(&out->a, &out->b); michael@0: } michael@0: michael@0: template michael@0: inline void DispatchToMethod(ObjT* obj, Method method, michael@0: const InA& in, michael@0: Tuple2* out) { michael@0: (obj->*method)(in, &out->a, &out->b); michael@0: } michael@0: michael@0: template michael@0: inline void DispatchToMethod(ObjT* obj, Method method, michael@0: const Tuple1& in, michael@0: Tuple2* out) { michael@0: (obj->*method)(in.a, &out->a, &out->b); michael@0: } michael@0: michael@0: template michael@0: inline void DispatchToMethod(ObjT* obj, Method method, michael@0: const Tuple2& in, michael@0: Tuple2* out) { michael@0: (obj->*method)(in.a, in.b, &out->a, &out->b); michael@0: } michael@0: michael@0: template michael@0: inline void DispatchToMethod(ObjT* obj, Method method, michael@0: const Tuple3& in, michael@0: Tuple2* out) { michael@0: (obj->*method)(in.a, in.b, in.c, &out->a, &out->b); michael@0: } michael@0: michael@0: template michael@0: inline void DispatchToMethod(ObjT* obj, Method method, michael@0: const Tuple4& in, michael@0: Tuple2* out) { michael@0: (obj->*method)(in.a, in.b, in.c, in.d, &out->a, &out->b); michael@0: } michael@0: michael@0: template michael@0: inline void DispatchToMethod(ObjT* obj, Method method, michael@0: const Tuple5& in, michael@0: Tuple2* out) { michael@0: (obj->*method)(in.a, in.b, in.c, in.d, in.e, &out->a, &out->b); michael@0: } michael@0: michael@0: template michael@0: inline void DispatchToMethod(ObjT* obj, Method method, michael@0: const Tuple6& in, michael@0: Tuple2* out) { michael@0: (obj->*method)(in.a, in.b, in.c, in.d, in.e, in.f, &out->a, &out->b); michael@0: } michael@0: michael@0: // Dispatchers with 3 out params. michael@0: michael@0: template michael@0: inline void DispatchToMethod(ObjT* obj, Method method, michael@0: const Tuple0& in, michael@0: Tuple3* out) { michael@0: (obj->*method)(&out->a, &out->b, &out->c); michael@0: } michael@0: michael@0: template michael@0: inline void DispatchToMethod(ObjT* obj, Method method, michael@0: const InA& in, michael@0: Tuple3* out) { michael@0: (obj->*method)(in, &out->a, &out->b, &out->c); michael@0: } michael@0: michael@0: template michael@0: inline void DispatchToMethod(ObjT* obj, Method method, michael@0: const Tuple1& in, michael@0: Tuple3* out) { michael@0: (obj->*method)(in.a, &out->a, &out->b, &out->c); michael@0: } michael@0: michael@0: template michael@0: inline void DispatchToMethod(ObjT* obj, Method method, michael@0: const Tuple2& in, michael@0: Tuple3* out) { michael@0: (obj->*method)(in.a, in.b, &out->a, &out->b, &out->c); michael@0: } michael@0: michael@0: template michael@0: inline void DispatchToMethod(ObjT* obj, Method method, michael@0: const Tuple3& in, michael@0: Tuple3* out) { michael@0: (obj->*method)(in.a, in.b, in.c, &out->a, &out->b, &out->c); michael@0: } michael@0: michael@0: template michael@0: inline void DispatchToMethod(ObjT* obj, Method method, michael@0: const Tuple4& in, michael@0: Tuple3* out) { michael@0: (obj->*method)(in.a, in.b, in.c, in.d, &out->a, &out->b, &out->c); michael@0: } michael@0: michael@0: template michael@0: inline void DispatchToMethod(ObjT* obj, Method method, michael@0: const Tuple5& in, michael@0: Tuple3* out) { michael@0: (obj->*method)(in.a, in.b, in.c, in.d, in.e, &out->a, &out->b, &out->c); michael@0: } michael@0: michael@0: template michael@0: inline void DispatchToMethod(ObjT* obj, Method method, michael@0: const Tuple6& in, michael@0: Tuple3* out) { michael@0: (obj->*method)(in.a, in.b, in.c, in.d, in.e, in.f, &out->a, &out->b, &out->c); michael@0: } michael@0: michael@0: // Dispatchers with 4 out params. michael@0: michael@0: template michael@0: inline void DispatchToMethod(ObjT* obj, Method method, michael@0: const Tuple0& in, michael@0: Tuple4* out) { michael@0: (obj->*method)(&out->a, &out->b, &out->c, &out->d); michael@0: } michael@0: michael@0: template michael@0: inline void DispatchToMethod(ObjT* obj, Method method, michael@0: const InA& in, michael@0: Tuple4* out) { michael@0: (obj->*method)(in, &out->a, &out->b, &out->c, &out->d); michael@0: } michael@0: michael@0: template michael@0: inline void DispatchToMethod(ObjT* obj, Method method, michael@0: const Tuple1& in, michael@0: Tuple4* out) { michael@0: (obj->*method)(in.a, &out->a, &out->b, &out->c, &out->d); michael@0: } michael@0: michael@0: template michael@0: inline void DispatchToMethod(ObjT* obj, Method method, michael@0: const Tuple2& in, michael@0: Tuple4* out) { michael@0: (obj->*method)(in.a, in.b, &out->a, &out->b, &out->c, &out->d); michael@0: } michael@0: michael@0: template michael@0: inline void DispatchToMethod(ObjT* obj, Method method, michael@0: const Tuple3& in, michael@0: Tuple4* out) { michael@0: (obj->*method)(in.a, in.b, in.c, &out->a, &out->b, &out->c, &out->d); michael@0: } michael@0: michael@0: template michael@0: inline void DispatchToMethod(ObjT* obj, Method method, michael@0: const Tuple4& in, michael@0: Tuple4* out) { michael@0: (obj->*method)(in.a, in.b, in.c, in.d, &out->a, &out->b, &out->c, &out->d); michael@0: } michael@0: michael@0: template michael@0: inline void DispatchToMethod(ObjT* obj, Method method, michael@0: const Tuple5& in, michael@0: Tuple4* out) { michael@0: (obj->*method)(in.a, in.b, in.c, in.d, in.e, michael@0: &out->a, &out->b, &out->c, &out->d); michael@0: } michael@0: michael@0: template michael@0: inline void DispatchToMethod(ObjT* obj, Method method, michael@0: const Tuple6& in, michael@0: Tuple4* out) { michael@0: (obj->*method)(in.a, in.b, in.c, in.d, in.e, in.f, michael@0: &out->a, &out->b, &out->c, &out->d); michael@0: } michael@0: michael@0: // Dispatchers with 5 out params. michael@0: michael@0: template michael@0: inline void DispatchToMethod(ObjT* obj, Method method, michael@0: const Tuple0& in, michael@0: Tuple5* out) { michael@0: (obj->*method)(&out->a, &out->b, &out->c, &out->d, &out->e); michael@0: } michael@0: michael@0: template michael@0: inline void DispatchToMethod(ObjT* obj, Method method, michael@0: const InA& in, michael@0: Tuple5* out) { michael@0: (obj->*method)(in, &out->a, &out->b, &out->c, &out->d, &out->e); michael@0: } michael@0: michael@0: template michael@0: inline void DispatchToMethod(ObjT* obj, Method method, michael@0: const Tuple1& in, michael@0: Tuple5* out) { michael@0: (obj->*method)(in.a, &out->a, &out->b, &out->c, &out->d, &out->e); michael@0: } michael@0: michael@0: template michael@0: inline void DispatchToMethod(ObjT* obj, Method method, michael@0: const Tuple2& in, michael@0: Tuple5* out) { michael@0: (obj->*method)(in.a, in.b, &out->a, &out->b, &out->c, &out->d, &out->e); michael@0: } michael@0: michael@0: template michael@0: inline void DispatchToMethod(ObjT* obj, Method method, michael@0: const Tuple3& in, michael@0: Tuple5* out) { michael@0: (obj->*method)(in.a, in.b, in.c, &out->a, &out->b, &out->c, &out->d, &out->e); michael@0: } michael@0: michael@0: template michael@0: inline void DispatchToMethod(ObjT* obj, Method method, michael@0: const Tuple4& in, michael@0: Tuple5* out) { michael@0: (obj->*method)(in.a, in.b, in.c, in.d, &out->a, &out->b, &out->c, &out->d, michael@0: &out->e); michael@0: } michael@0: michael@0: template michael@0: inline void DispatchToMethod(ObjT* obj, Method method, michael@0: const Tuple5& in, michael@0: Tuple5* out) { michael@0: (obj->*method)(in.a, in.b, in.c, in.d, in.e, michael@0: &out->a, &out->b, &out->c, &out->d, &out->e); michael@0: } michael@0: michael@0: template michael@0: inline void DispatchToMethod(ObjT* obj, Method method, michael@0: const Tuple6& in, michael@0: Tuple5* out) { michael@0: (obj->*method)(in.a, in.b, in.c, in.d, in.e, in.f, michael@0: &out->a, &out->b, &out->c, &out->d, &out->e); michael@0: } michael@0: michael@0: #endif // BASE_TUPLE_H__