blob: 7cb77fb3d6301bf8ac7805f1f5115fb0399f3d87 [file] [log] [blame]
license.botbf09a502008-08-24 00:55:551// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
initial.commitd7cae122008-07-26 21:49:384
[email protected]302bdc132008-08-25 13:42:075// A Tuple is a generic templatized container, similar in concept to std::pair.
[email protected]8a2820a2008-10-09 21:58:056// There are classes Tuple0 to Tuple6, cooresponding to the number of elements
7// it contains. The convenient MakeTuple() function takes 0 to 6 arguments,
[email protected]302bdc132008-08-25 13:42:078// and will construct and return the appropriate Tuple object. The functions
9// DispatchToMethod and DispatchToFunction take a function pointer or instance
10// and method pointer, and unpack a tuple into arguments to the call.
11//
12// Tuple elements are copied by value, and stored in the tuple. See the unit
13// tests for more details of how/when the values are copied.
14//
15// Example usage:
16// // These two methods of creating a Tuple are identical.
17// Tuple2<int, const char*> tuple_a(1, "wee");
18// Tuple2<int, const char*> tuple_b = MakeTuple(1, "wee");
19//
20// void SomeFunc(int a, const char* b) { }
21// DispatchToFunction(&SomeFunc, tuple_a); // SomeFunc(1, "wee")
22// DispatchToFunction(
23// &SomeFunc, MakeTuple(10, "foo")); // SomeFunc(10, "foo")
24//
25// struct { void SomeMeth(int a, int b, int c) { } } foo;
26// DispatchToMethod(&foo, &Foo::SomeMeth, MakeTuple(1, 2, 3));
27// // foo->SomeMeth(1, 2, 3);
28
initial.commitd7cae122008-07-26 21:49:3829#ifndef BASE_TUPLE_H__
30#define BASE_TUPLE_H__
31
32// Traits ----------------------------------------------------------------------
33//
34// A simple traits class for tuple arguments.
35//
36// ValueType: the bare, nonref version of a type (same as the type for nonrefs).
37// RefType: the ref version of a type (same as the type for refs).
38// ParamType: what type to pass to functions (refs should not be constified).
39
40template <class P>
41struct TupleTraits {
42 typedef P ValueType;
43 typedef P& RefType;
44 typedef const P& ParamType;
45};
46
47template <class P>
48struct TupleTraits<P&> {
49 typedef P ValueType;
50 typedef P& RefType;
51 typedef P& ParamType;
52};
53
54// Tuple -----------------------------------------------------------------------
55//
56// This set of classes is useful for bundling 0 or more heterogeneous data types
57// into a single variable. The advantage of this is that it greatly simplifies
58// function objects that need to take an arbitrary number of parameters; see
59// RunnableMethod and IPC::MessageWithTuple.
60//
[email protected]458711982008-08-21 10:58:0861// Tuple0 is supplied to act as a 'void' type. It can be used, for example,
62// when dispatching to a function that accepts no arguments (see the
63// Dispatchers below).
initial.commitd7cae122008-07-26 21:49:3864// Tuple1<A> is rarely useful. One such use is when A is non-const ref that you
65// want filled by the dispatchee, and the tuple is merely a container for that
66// output (a "tier"). See MakeRefTuple and its usages.
67
68struct Tuple0 {
69 typedef Tuple0 ValueTuple;
70 typedef Tuple0 RefTuple;
71};
72
73template <class A>
74struct Tuple1 {
75 public:
76 typedef A TypeA;
77 typedef Tuple1<typename TupleTraits<A>::ValueType> ValueTuple;
78 typedef Tuple1<typename TupleTraits<A>::RefType> RefTuple;
79
80 Tuple1() {}
81 explicit Tuple1(typename TupleTraits<A>::ParamType a) : a(a) {}
82
83 A a;
84};
85
86template <class A, class B>
87struct Tuple2 {
88 public:
89 typedef A TypeA;
90 typedef B TypeB;
91 typedef Tuple2<typename TupleTraits<A>::ValueType,
92 typename TupleTraits<B>::ValueType> ValueTuple;
93 typedef Tuple2<typename TupleTraits<A>::RefType,
94 typename TupleTraits<B>::RefType> RefTuple;
95
96 Tuple2() {}
97 Tuple2(typename TupleTraits<A>::ParamType a,
98 typename TupleTraits<B>::ParamType b)
99 : a(a), b(b) {
100 }
101
102 A a;
103 B b;
104};
105
106template <class A, class B, class C>
107struct Tuple3 {
108 public:
109 typedef A TypeA;
110 typedef B TypeB;
111 typedef C TypeC;
112 typedef Tuple3<typename TupleTraits<A>::ValueType,
113 typename TupleTraits<B>::ValueType,
114 typename TupleTraits<C>::ValueType> ValueTuple;
115 typedef Tuple3<typename TupleTraits<A>::RefType,
116 typename TupleTraits<B>::RefType,
117 typename TupleTraits<C>::RefType> RefTuple;
118
119 Tuple3() {}
120 Tuple3(typename TupleTraits<A>::ParamType a,
121 typename TupleTraits<B>::ParamType b,
122 typename TupleTraits<C>::ParamType c)
123 : a(a), b(b), c(c){
124 }
125
126 A a;
127 B b;
128 C c;
129};
130
131template <class A, class B, class C, class D>
132struct Tuple4 {
133 public:
134 typedef A TypeA;
135 typedef B TypeB;
136 typedef C TypeC;
137 typedef D TypeD;
138 typedef Tuple4<typename TupleTraits<A>::ValueType,
139 typename TupleTraits<B>::ValueType,
140 typename TupleTraits<C>::ValueType,
141 typename TupleTraits<D>::ValueType> ValueTuple;
142 typedef Tuple4<typename TupleTraits<A>::RefType,
143 typename TupleTraits<B>::RefType,
144 typename TupleTraits<C>::RefType,
145 typename TupleTraits<D>::RefType> RefTuple;
146
147 Tuple4() {}
148 Tuple4(typename TupleTraits<A>::ParamType a,
149 typename TupleTraits<B>::ParamType b,
150 typename TupleTraits<C>::ParamType c,
151 typename TupleTraits<D>::ParamType d)
152 : a(a), b(b), c(c), d(d) {
153 }
154
155 A a;
156 B b;
157 C c;
158 D d;
159};
160
161template <class A, class B, class C, class D, class E>
162struct Tuple5 {
163public:
164 typedef A TypeA;
165 typedef B TypeB;
166 typedef C TypeC;
167 typedef D TypeD;
168 typedef E TypeE;
169 typedef Tuple5<typename TupleTraits<A>::ValueType,
170 typename TupleTraits<B>::ValueType,
171 typename TupleTraits<C>::ValueType,
172 typename TupleTraits<D>::ValueType,
173 typename TupleTraits<E>::ValueType> ValueTuple;
174 typedef Tuple5<typename TupleTraits<A>::RefType,
175 typename TupleTraits<B>::RefType,
176 typename TupleTraits<C>::RefType,
177 typename TupleTraits<D>::RefType,
178 typename TupleTraits<E>::RefType> RefTuple;
179
180 Tuple5() {}
181 Tuple5(typename TupleTraits<A>::ParamType a,
182 typename TupleTraits<B>::ParamType b,
183 typename TupleTraits<C>::ParamType c,
184 typename TupleTraits<D>::ParamType d,
185 typename TupleTraits<E>::ParamType e)
186 : a(a), b(b), c(c), d(d), e(e) {
187 }
188
189 A a;
190 B b;
191 C c;
192 D d;
193 E e;
194};
195
[email protected]8a2820a2008-10-09 21:58:05196template <class A, class B, class C, class D, class E, class F>
197struct Tuple6 {
198public:
199 typedef A TypeA;
200 typedef B TypeB;
201 typedef C TypeC;
202 typedef D TypeD;
203 typedef E TypeE;
204 typedef F TypeF;
205 typedef Tuple6<typename TupleTraits<A>::ValueType,
206 typename TupleTraits<B>::ValueType,
207 typename TupleTraits<C>::ValueType,
208 typename TupleTraits<D>::ValueType,
209 typename TupleTraits<E>::ValueType,
210 typename TupleTraits<F>::ValueType> ValueTuple;
211 typedef Tuple6<typename TupleTraits<A>::RefType,
212 typename TupleTraits<B>::RefType,
213 typename TupleTraits<C>::RefType,
214 typename TupleTraits<D>::RefType,
215 typename TupleTraits<E>::RefType,
216 typename TupleTraits<F>::RefType> RefTuple;
217
218 Tuple6() {}
219 Tuple6(typename TupleTraits<A>::ParamType a,
220 typename TupleTraits<B>::ParamType b,
221 typename TupleTraits<C>::ParamType c,
222 typename TupleTraits<D>::ParamType d,
223 typename TupleTraits<E>::ParamType e,
224 typename TupleTraits<F>::ParamType f)
225 : a(a), b(b), c(c), d(d), e(e), f(f) {
226 }
227
228 A a;
229 B b;
230 C c;
231 D d;
232 E e;
233 F f;
234};
235
[email protected]39a248b02008-11-12 22:10:20236template <class A, class B, class C, class D, class E, class F, class G>
237struct Tuple7 {
238public:
239 typedef A TypeA;
240 typedef B TypeB;
241 typedef C TypeC;
242 typedef D TypeD;
243 typedef E TypeE;
244 typedef F TypeF;
245 typedef G TypeG;
246 typedef Tuple7<typename TupleTraits<A>::ValueType,
247 typename TupleTraits<B>::ValueType,
248 typename TupleTraits<C>::ValueType,
249 typename TupleTraits<D>::ValueType,
250 typename TupleTraits<E>::ValueType,
251 typename TupleTraits<F>::ValueType,
252 typename TupleTraits<G>::ValueType> ValueTuple;
253 typedef Tuple7<typename TupleTraits<A>::RefType,
254 typename TupleTraits<B>::RefType,
255 typename TupleTraits<C>::RefType,
256 typename TupleTraits<D>::RefType,
257 typename TupleTraits<E>::RefType,
258 typename TupleTraits<F>::RefType,
259 typename TupleTraits<G>::RefType> RefTuple;
260
261 Tuple7() {}
262 Tuple7(typename TupleTraits<A>::ParamType a,
263 typename TupleTraits<B>::ParamType b,
264 typename TupleTraits<C>::ParamType c,
265 typename TupleTraits<D>::ParamType d,
266 typename TupleTraits<E>::ParamType e,
267 typename TupleTraits<F>::ParamType f,
268 typename TupleTraits<G>::ParamType g)
269 : a(a), b(b), c(c), d(d), e(e), f(f), g(g) {
270 }
271
272 A a;
273 B b;
274 C c;
275 D d;
276 E e;
277 F f;
278 G g;
279};
280
initial.commitd7cae122008-07-26 21:49:38281// Tuple creators -------------------------------------------------------------
282//
283// Helper functions for constructing tuples while inferring the template
284// argument types.
285
286inline Tuple0 MakeTuple() {
287 return Tuple0();
288}
289
290template <class A>
291inline Tuple1<A> MakeTuple(const A& a) {
292 return Tuple1<A>(a);
293}
294
295template <class A, class B>
296inline Tuple2<A, B> MakeTuple(const A& a, const B& b) {
297 return Tuple2<A, B>(a, b);
298}
299
300template <class A, class B, class C>
301inline Tuple3<A, B, C> MakeTuple(const A& a, const B& b, const C& c) {
302 return Tuple3<A, B, C>(a, b, c);
303}
304
305template <class A, class B, class C, class D>
306inline Tuple4<A, B, C, D> MakeTuple(const A& a, const B& b, const C& c,
307 const D& d) {
308 return Tuple4<A, B, C, D>(a, b, c, d);
309}
310
311template <class A, class B, class C, class D, class E>
312inline Tuple5<A, B, C, D, E> MakeTuple(const A& a, const B& b, const C& c,
313 const D& d, const E& e) {
314 return Tuple5<A, B, C, D, E>(a, b, c, d, e);
315}
316
[email protected]8a2820a2008-10-09 21:58:05317template <class A, class B, class C, class D, class E, class F>
318inline Tuple6<A, B, C, D, E, F> MakeTuple(const A& a, const B& b, const C& c,
319 const D& d, const E& e, const F& f) {
320 return Tuple6<A, B, C, D, E, F>(a, b, c, d, e, f);
321}
322
[email protected]39a248b02008-11-12 22:10:20323template <class A, class B, class C, class D, class E, class F, class G>
324inline Tuple7<A, B, C, D, E, F, G> MakeTuple(const A& a, const B& b, const C& c,
325 const D& d, const E& e, const F& f,
326 const G& g) {
327 return Tuple7<A, B, C, D, E, F, G>(a, b, c, d, e, f, g);
328}
329
initial.commitd7cae122008-07-26 21:49:38330// The following set of helpers make what Boost refers to as "Tiers" - a tuple
331// of references.
332
333template <class A>
334inline Tuple1<A&> MakeRefTuple(A& a) {
335 return Tuple1<A&>(a);
336}
337
338template <class A, class B>
339inline Tuple2<A&, B&> MakeRefTuple(A& a, B& b) {
340 return Tuple2<A&, B&>(a, b);
341}
342
343template <class A, class B, class C>
344inline Tuple3<A&, B&, C&> MakeRefTuple(A& a, B& b, C& c) {
345 return Tuple3<A&, B&, C&>(a, b, c);
346}
347
348template <class A, class B, class C, class D>
349inline Tuple4<A&, B&, C&, D&> MakeRefTuple(A& a, B& b, C& c, D& d) {
350 return Tuple4<A&, B&, C&, D&>(a, b, c, d);
351}
352
353template <class A, class B, class C, class D, class E>
354inline Tuple5<A&, B&, C&, D&, E&> MakeRefTuple(A& a, B& b, C& c, D& d, E& e) {
355 return Tuple5<A&, B&, C&, D&, E&>(a, b, c, d, e);
356}
357
[email protected]8a2820a2008-10-09 21:58:05358template <class A, class B, class C, class D, class E, class F>
359inline Tuple6<A&, B&, C&, D&, E&, F&> MakeRefTuple(A& a, B& b, C& c, D& d, E& e,
360 F& f) {
361 return Tuple6<A&, B&, C&, D&, E&, F&>(a, b, c, d, e, f);
362}
363
[email protected]39a248b02008-11-12 22:10:20364template <class A, class B, class C, class D, class E, class F, class G>
365inline Tuple7<A&, B&, C&, D&, E&, F&, G&> MakeRefTuple(A& a, B& b, C& c, D& d,
366 E& e, F& f, G& g) {
367 return Tuple7<A&, B&, C&, D&, E&, F&, G&>(a, b, c, d, e, f, g);
368}
369
initial.commitd7cae122008-07-26 21:49:38370// Dispatchers ----------------------------------------------------------------
371//
372// Helper functions that call the given method on an object, with the unpacked
373// tuple arguments. Notice that they all have the same number of arguments,
374// so you need only write:
375// DispatchToMethod(object, &Object::method, args);
376// This is very useful for templated dispatchers, since they don't need to know
377// what type |args| is.
378
379// Non-Static Dispatchers with no out params.
380
381template <class ObjT, class Method>
382inline void DispatchToMethod(ObjT* obj, Method method, const Tuple0& arg) {
383 (obj->*method)();
384}
385
386template <class ObjT, class Method, class A>
387inline void DispatchToMethod(ObjT* obj, Method method, const A& arg) {
388 (obj->*method)(arg);
389}
390
391template <class ObjT, class Method, class A>
392inline void DispatchToMethod(ObjT* obj, Method method, const Tuple1<A>& arg) {
393 (obj->*method)(arg.a);
394}
395
396template<class ObjT, class Method, class A, class B>
[email protected]52a261f2009-03-03 15:01:12397inline void DispatchToMethod(ObjT* obj,
398 Method method,
399 const Tuple2<A, B>& arg) {
initial.commitd7cae122008-07-26 21:49:38400 (obj->*method)(arg.a, arg.b);
401}
402
403template<class ObjT, class Method, class A, class B, class C>
404inline void DispatchToMethod(ObjT* obj, Method method,
405 const Tuple3<A, B, C>& arg) {
406 (obj->*method)(arg.a, arg.b, arg.c);
407}
408
409template<class ObjT, class Method, class A, class B, class C, class D>
410inline void DispatchToMethod(ObjT* obj, Method method,
411 const Tuple4<A, B, C, D>& arg) {
412 (obj->*method)(arg.a, arg.b, arg.c, arg.d);
413}
414
415template<class ObjT, class Method, class A, class B, class C, class D, class E>
416inline void DispatchToMethod(ObjT* obj, Method method,
417 const Tuple5<A, B, C, D, E>& arg) {
418 (obj->*method)(arg.a, arg.b, arg.c, arg.d, arg.e);
419}
420
[email protected]8a2820a2008-10-09 21:58:05421template<class ObjT, class Method, class A, class B, class C, class D, class E,
422 class F>
423inline void DispatchToMethod(ObjT* obj, Method method,
424 const Tuple6<A, B, C, D, E, F>& arg) {
425 (obj->*method)(arg.a, arg.b, arg.c, arg.d, arg.e, arg.f);
426}
427
[email protected]39a248b02008-11-12 22:10:20428template<class ObjT, class Method, class A, class B, class C, class D, class E,
429 class F, class G>
430inline void DispatchToMethod(ObjT* obj, Method method,
431 const Tuple7<A, B, C, D, E, F, G>& arg) {
432 (obj->*method)(arg.a, arg.b, arg.c, arg.d, arg.e, arg.f, arg.g);
433}
434
initial.commitd7cae122008-07-26 21:49:38435// Static Dispatchers with no out params.
436
437template <class Function>
438inline void DispatchToFunction(Function function, const Tuple0& arg) {
439 (*function)();
440}
441
442template <class Function, class A>
443inline void DispatchToFunction(Function function, const A& arg) {
444 (*function)(arg);
445}
446
447template <class Function, class A>
448inline void DispatchToFunction(Function function, const Tuple1<A>& arg) {
449 (*function)(arg.a);
450}
451
452template<class Function, class A, class B>
453inline void DispatchToFunction(Function function, const Tuple2<A, B>& arg) {
454 (*function)(arg.a, arg.b);
455}
456
457template<class Function, class A, class B, class C>
458inline void DispatchToFunction(Function function, const Tuple3<A, B, C>& arg) {
459 (*function)(arg.a, arg.b, arg.c);
460}
461
462template<class Function, class A, class B, class C, class D>
463inline void DispatchToFunction(Function function,
464 const Tuple4<A, B, C, D>& arg) {
465 (*function)(arg.a, arg.b, arg.c, arg.d);
466}
467
468template<class Function, class A, class B, class C, class D, class E>
469inline void DispatchToFunction(Function function,
470 const Tuple5<A, B, C, D, E>& arg) {
471 (*function)(arg.a, arg.b, arg.c, arg.d, arg.e);
472}
473
[email protected]8a2820a2008-10-09 21:58:05474template<class Function, class A, class B, class C, class D, class E, class F>
475inline void DispatchToFunction(Function function,
476 const Tuple6<A, B, C, D, E, F>& arg) {
477 (*function)(arg.a, arg.b, arg.c, arg.d, arg.e, arg.f);
478}
479
initial.commitd7cae122008-07-26 21:49:38480// Dispatchers with 0 out param (as a Tuple0).
481
482template <class ObjT, class Method>
[email protected]52a261f2009-03-03 15:01:12483inline void DispatchToMethod(ObjT* obj,
484 Method method,
485 const Tuple0& arg, Tuple0*) {
initial.commitd7cae122008-07-26 21:49:38486 (obj->*method)();
487}
488
489template <class ObjT, class Method, class A>
490inline void DispatchToMethod(ObjT* obj, Method method, const A& arg, Tuple0*) {
491 (obj->*method)(arg);
492}
493
494template <class ObjT, class Method, class A>
[email protected]52a261f2009-03-03 15:01:12495inline void DispatchToMethod(ObjT* obj,
496 Method method,
497 const Tuple1<A>& arg, Tuple0*) {
initial.commitd7cae122008-07-26 21:49:38498 (obj->*method)(arg.a);
499}
500
501template<class ObjT, class Method, class A, class B>
[email protected]52a261f2009-03-03 15:01:12502inline void DispatchToMethod(ObjT* obj,
503 Method method,
504 const Tuple2<A, B>& arg, Tuple0*) {
initial.commitd7cae122008-07-26 21:49:38505 (obj->*method)(arg.a, arg.b);
506}
507
508template<class ObjT, class Method, class A, class B, class C>
509inline void DispatchToMethod(ObjT* obj, Method method,
510 const Tuple3<A, B, C>& arg, Tuple0*) {
511 (obj->*method)(arg.a, arg.b, arg.c);
512}
513
514template<class ObjT, class Method, class A, class B, class C, class D>
515inline void DispatchToMethod(ObjT* obj, Method method,
516 const Tuple4<A, B, C, D>& arg, Tuple0*) {
517 (obj->*method)(arg.a, arg.b, arg.c, arg.d);
518}
519
520template<class ObjT, class Method, class A, class B, class C, class D, class E>
521inline void DispatchToMethod(ObjT* obj, Method method,
522 const Tuple5<A, B, C, D, E>& arg, Tuple0*) {
523 (obj->*method)(arg.a, arg.b, arg.c, arg.d, arg.e);
524}
525
[email protected]8a2820a2008-10-09 21:58:05526template<class ObjT, class Method, class A, class B, class C, class D, class E,
527 class F>
528inline void DispatchToMethod(ObjT* obj, Method method,
529 const Tuple6<A, B, C, D, E, F>& arg, Tuple0*) {
530 (obj->*method)(arg.a, arg.b, arg.c, arg.d, arg.e, arg.f);
531}
532
initial.commitd7cae122008-07-26 21:49:38533// Dispatchers with 1 out param.
534
535template<class ObjT, class Method,
536 class OutA>
537inline void DispatchToMethod(ObjT* obj, Method method,
538 const Tuple0& in,
539 Tuple1<OutA>* out) {
540 (obj->*method)(&out->a);
541}
542
543template<class ObjT, class Method, class InA,
544 class OutA>
545inline void DispatchToMethod(ObjT* obj, Method method,
546 const InA& in,
547 Tuple1<OutA>* out) {
548 (obj->*method)(in, &out->a);
549}
550
551template<class ObjT, class Method, class InA,
552 class OutA>
553inline void DispatchToMethod(ObjT* obj, Method method,
554 const Tuple1<InA>& in,
555 Tuple1<OutA>* out) {
556 (obj->*method)(in.a, &out->a);
557}
558
559template<class ObjT, class Method, class InA, class InB,
560 class OutA>
561inline void DispatchToMethod(ObjT* obj, Method method,
562 const Tuple2<InA, InB>& in,
563 Tuple1<OutA>* out) {
564 (obj->*method)(in.a, in.b, &out->a);
565}
566
567template<class ObjT, class Method, class InA, class InB, class InC,
568 class OutA>
569inline void DispatchToMethod(ObjT* obj, Method method,
570 const Tuple3<InA, InB, InC>& in,
571 Tuple1<OutA>* out) {
572 (obj->*method)(in.a, in.b, in.c, &out->a);
573}
574
575template<class ObjT, class Method, class InA, class InB, class InC, class InD,
576 class OutA>
577inline void DispatchToMethod(ObjT* obj, Method method,
578 const Tuple4<InA, InB, InC, InD>& in,
579 Tuple1<OutA>* out) {
580 (obj->*method)(in.a, in.b, in.c, in.d, &out->a);
581}
582
583template<class ObjT, class Method,
584 class InA, class InB, class InC, class InD, class InE,
585 class OutA>
586inline void DispatchToMethod(ObjT* obj, Method method,
587 const Tuple5<InA, InB, InC, InD, InE>& in,
588 Tuple1<OutA>* out) {
589 (obj->*method)(in.a, in.b, in.c, in.d, in.e, &out->a);
590}
591
[email protected]8a2820a2008-10-09 21:58:05592template<class ObjT, class Method,
593 class InA, class InB, class InC, class InD, class InE, class InF,
594 class OutA>
595inline void DispatchToMethod(ObjT* obj, Method method,
596 const Tuple6<InA, InB, InC, InD, InE, InF>& in,
597 Tuple1<OutA>* out) {
598 (obj->*method)(in.a, in.b, in.c, in.d, in.e, in.f, &out->a);
599}
600
initial.commitd7cae122008-07-26 21:49:38601// Dispatchers with 2 out params.
602
603template<class ObjT, class Method,
604 class OutA, class OutB>
605inline void DispatchToMethod(ObjT* obj, Method method,
606 const Tuple0& in,
607 Tuple2<OutA, OutB>* out) {
608 (obj->*method)(&out->a, &out->b);
609}
610
611template<class ObjT, class Method, class InA,
612 class OutA, class OutB>
613inline void DispatchToMethod(ObjT* obj, Method method,
614 const InA& in,
615 Tuple2<OutA, OutB>* out) {
616 (obj->*method)(in, &out->a, &out->b);
617}
618
619template<class ObjT, class Method, class InA,
620 class OutA, class OutB>
621inline void DispatchToMethod(ObjT* obj, Method method,
622 const Tuple1<InA>& in,
623 Tuple2<OutA, OutB>* out) {
624 (obj->*method)(in.a, &out->a, &out->b);
625}
626
627template<class ObjT, class Method, class InA, class InB,
628 class OutA, class OutB>
629inline void DispatchToMethod(ObjT* obj, Method method,
630 const Tuple2<InA, InB>& in,
631 Tuple2<OutA, OutB>* out) {
632 (obj->*method)(in.a, in.b, &out->a, &out->b);
633}
634
635template<class ObjT, class Method, class InA, class InB, class InC,
636 class OutA, class OutB>
637inline void DispatchToMethod(ObjT* obj, Method method,
638 const Tuple3<InA, InB, InC>& in,
639 Tuple2<OutA, OutB>* out) {
640 (obj->*method)(in.a, in.b, in.c, &out->a, &out->b);
641}
642
643template<class ObjT, class Method, class InA, class InB, class InC, class InD,
644 class OutA, class OutB>
645inline void DispatchToMethod(ObjT* obj, Method method,
646 const Tuple4<InA, InB, InC, InD>& in,
647 Tuple2<OutA, OutB>* out) {
648 (obj->*method)(in.a, in.b, in.c, in.d, &out->a, &out->b);
649}
650
651template<class ObjT, class Method,
652 class InA, class InB, class InC, class InD, class InE,
653 class OutA, class OutB>
654inline void DispatchToMethod(ObjT* obj, Method method,
655 const Tuple5<InA, InB, InC, InD, InE>& in,
656 Tuple2<OutA, OutB>* out) {
657 (obj->*method)(in.a, in.b, in.c, in.d, in.e, &out->a, &out->b);
658}
659
[email protected]8a2820a2008-10-09 21:58:05660template<class ObjT, class Method,
661 class InA, class InB, class InC, class InD, class InE, class InF,
662 class OutA, class OutB>
663inline void DispatchToMethod(ObjT* obj, Method method,
664 const Tuple6<InA, InB, InC, InD, InE, InF>& in,
665 Tuple2<OutA, OutB>* out) {
666 (obj->*method)(in.a, in.b, in.c, in.d, in.e, in.f, &out->a, &out->b);
667}
668
initial.commitd7cae122008-07-26 21:49:38669// Dispatchers with 3 out params.
670
671template<class ObjT, class Method,
672 class OutA, class OutB, class OutC>
673inline void DispatchToMethod(ObjT* obj, Method method,
674 const Tuple0& in,
675 Tuple3<OutA, OutB, OutC>* out) {
676 (obj->*method)(&out->a, &out->b, &out->c);
677}
678
679template<class ObjT, class Method, class InA,
680 class OutA, class OutB, class OutC>
681inline void DispatchToMethod(ObjT* obj, Method method,
682 const InA& in,
683 Tuple3<OutA, OutB, OutC>* out) {
684 (obj->*method)(in, &out->a, &out->b, &out->c);
685}
686
687template<class ObjT, class Method, class InA,
688 class OutA, class OutB, class OutC>
689inline void DispatchToMethod(ObjT* obj, Method method,
690 const Tuple1<InA>& in,
691 Tuple3<OutA, OutB, OutC>* out) {
692 (obj->*method)(in.a, &out->a, &out->b, &out->c);
693}
694
695template<class ObjT, class Method, class InA, class InB,
696 class OutA, class OutB, class OutC>
697inline void DispatchToMethod(ObjT* obj, Method method,
698 const Tuple2<InA, InB>& in,
699 Tuple3<OutA, OutB, OutC>* out) {
700 (obj->*method)(in.a, in.b, &out->a, &out->b, &out->c);
701}
702
703template<class ObjT, class Method, class InA, class InB, class InC,
704 class OutA, class OutB, class OutC>
705inline void DispatchToMethod(ObjT* obj, Method method,
706 const Tuple3<InA, InB, InC>& in,
707 Tuple3<OutA, OutB, OutC>* out) {
708 (obj->*method)(in.a, in.b, in.c, &out->a, &out->b, &out->c);
709}
710
711template<class ObjT, class Method, class InA, class InB, class InC, class InD,
712 class OutA, class OutB, class OutC>
713inline void DispatchToMethod(ObjT* obj, Method method,
714 const Tuple4<InA, InB, InC, InD>& in,
715 Tuple3<OutA, OutB, OutC>* out) {
716 (obj->*method)(in.a, in.b, in.c, in.d, &out->a, &out->b, &out->c);
717}
718
719template<class ObjT, class Method,
720 class InA, class InB, class InC, class InD, class InE,
721 class OutA, class OutB, class OutC>
722inline void DispatchToMethod(ObjT* obj, Method method,
723 const Tuple5<InA, InB, InC, InD, InE>& in,
724 Tuple3<OutA, OutB, OutC>* out) {
725 (obj->*method)(in.a, in.b, in.c, in.d, in.e, &out->a, &out->b, &out->c);
726}
727
[email protected]8a2820a2008-10-09 21:58:05728template<class ObjT, class Method,
729 class InA, class InB, class InC, class InD, class InE, class InF,
730 class OutA, class OutB, class OutC>
731inline void DispatchToMethod(ObjT* obj, Method method,
732 const Tuple6<InA, InB, InC, InD, InE, InF>& in,
733 Tuple3<OutA, OutB, OutC>* out) {
734 (obj->*method)(in.a, in.b, in.c, in.d, in.e, in.f, &out->a, &out->b, &out->c);
735}
736
initial.commitd7cae122008-07-26 21:49:38737// Dispatchers with 4 out params.
738
739template<class ObjT, class Method,
740 class OutA, class OutB, class OutC, class OutD>
741inline void DispatchToMethod(ObjT* obj, Method method,
742 const Tuple0& in,
743 Tuple4<OutA, OutB, OutC, OutD>* out) {
744 (obj->*method)(&out->a, &out->b, &out->c, &out->d);
745}
746
747template<class ObjT, class Method, class InA,
748 class OutA, class OutB, class OutC, class OutD>
749inline void DispatchToMethod(ObjT* obj, Method method,
750 const InA& in,
751 Tuple4<OutA, OutB, OutC, OutD>* out) {
752 (obj->*method)(in, &out->a, &out->b, &out->c, &out->d);
753}
754
755template<class ObjT, class Method, class InA,
756 class OutA, class OutB, class OutC, class OutD>
757inline void DispatchToMethod(ObjT* obj, Method method,
758 const Tuple1<InA>& in,
759 Tuple4<OutA, OutB, OutC, OutD>* out) {
760 (obj->*method)(in.a, &out->a, &out->b, &out->c, &out->d);
761}
762
763template<class ObjT, class Method, class InA, class InB,
764 class OutA, class OutB, class OutC, class OutD>
765inline void DispatchToMethod(ObjT* obj, Method method,
766 const Tuple2<InA, InB>& in,
767 Tuple4<OutA, OutB, OutC, OutD>* out) {
768 (obj->*method)(in.a, in.b, &out->a, &out->b, &out->c, &out->d);
769}
770
771template<class ObjT, class Method, class InA, class InB, class InC,
772 class OutA, class OutB, class OutC, class OutD>
773inline void DispatchToMethod(ObjT* obj, Method method,
774 const Tuple3<InA, InB, InC>& in,
775 Tuple4<OutA, OutB, OutC, OutD>* out) {
776 (obj->*method)(in.a, in.b, in.c, &out->a, &out->b, &out->c, &out->d);
777}
778
779template<class ObjT, class Method, class InA, class InB, class InC, class InD,
780 class OutA, class OutB, class OutC, class OutD>
781inline void DispatchToMethod(ObjT* obj, Method method,
782 const Tuple4<InA, InB, InC, InD>& in,
783 Tuple4<OutA, OutB, OutC, OutD>* out) {
784 (obj->*method)(in.a, in.b, in.c, in.d, &out->a, &out->b, &out->c, &out->d);
785}
786
787template<class ObjT, class Method,
788 class InA, class InB, class InC, class InD, class InE,
789 class OutA, class OutB, class OutC, class OutD>
790inline void DispatchToMethod(ObjT* obj, Method method,
791 const Tuple5<InA, InB, InC, InD, InE>& in,
792 Tuple4<OutA, OutB, OutC, OutD>* out) {
793 (obj->*method)(in.a, in.b, in.c, in.d, in.e,
794 &out->a, &out->b, &out->c, &out->d);
795}
796
[email protected]8a2820a2008-10-09 21:58:05797template<class ObjT, class Method,
798 class InA, class InB, class InC, class InD, class InE, class InF,
799 class OutA, class OutB, class OutC, class OutD>
800inline void DispatchToMethod(ObjT* obj, Method method,
801 const Tuple6<InA, InB, InC, InD, InE, InF>& in,
802 Tuple4<OutA, OutB, OutC, OutD>* out) {
803 (obj->*method)(in.a, in.b, in.c, in.d, in.e, in.f,
804 &out->a, &out->b, &out->c, &out->d);
805}
806
initial.commitd7cae122008-07-26 21:49:38807// Dispatchers with 5 out params.
808
809template<class ObjT, class Method,
810 class OutA, class OutB, class OutC, class OutD, class OutE>
811inline void DispatchToMethod(ObjT* obj, Method method,
812 const Tuple0& in,
813 Tuple5<OutA, OutB, OutC, OutD, OutE>* out) {
814 (obj->*method)(&out->a, &out->b, &out->c, &out->d, &out->e);
815}
816
817template<class ObjT, class Method, class InA,
818 class OutA, class OutB, class OutC, class OutD, class OutE>
819inline void DispatchToMethod(ObjT* obj, Method method,
820 const InA& in,
821 Tuple5<OutA, OutB, OutC, OutD, OutE>* out) {
822 (obj->*method)(in, &out->a, &out->b, &out->c, &out->d, &out->e);
823}
824
825template<class ObjT, class Method, class InA,
826 class OutA, class OutB, class OutC, class OutD, class OutE>
827inline void DispatchToMethod(ObjT* obj, Method method,
828 const Tuple1<InA>& in,
829 Tuple5<OutA, OutB, OutC, OutD, OutE>* out) {
830 (obj->*method)(in.a, &out->a, &out->b, &out->c, &out->d, &out->e);
831}
832
833template<class ObjT, class Method, class InA, class InB,
834 class OutA, class OutB, class OutC, class OutD, class OutE>
835inline void DispatchToMethod(ObjT* obj, Method method,
836 const Tuple2<InA, InB>& in,
837 Tuple5<OutA, OutB, OutC, OutD, OutE>* out) {
838 (obj->*method)(in.a, in.b, &out->a, &out->b, &out->c, &out->d, &out->e);
839}
840
841template<class ObjT, class Method, class InA, class InB, class InC,
842 class OutA, class OutB, class OutC, class OutD, class OutE>
843inline void DispatchToMethod(ObjT* obj, Method method,
844 const Tuple3<InA, InB, InC>& in,
845 Tuple5<OutA, OutB, OutC, OutD, OutE>* out) {
846 (obj->*method)(in.a, in.b, in.c, &out->a, &out->b, &out->c, &out->d, &out->e);
847}
848
849template<class ObjT, class Method, class InA, class InB, class InC, class InD,
850 class OutA, class OutB, class OutC, class OutD, class OutE>
851inline void DispatchToMethod(ObjT* obj, Method method,
852 const Tuple4<InA, InB, InC, InD>& in,
853 Tuple5<OutA, OutB, OutC, OutD, OutE>* out) {
854 (obj->*method)(in.a, in.b, in.c, in.d, &out->a, &out->b, &out->c, &out->d,
855 &out->e);
856}
857
858template<class ObjT, class Method,
859 class InA, class InB, class InC, class InD, class InE,
860 class OutA, class OutB, class OutC, class OutD, class OutE>
861inline void DispatchToMethod(ObjT* obj, Method method,
862 const Tuple5<InA, InB, InC, InD, InE>& in,
863 Tuple5<OutA, OutB, OutC, OutD, OutE>* out) {
864 (obj->*method)(in.a, in.b, in.c, in.d, in.e,
865 &out->a, &out->b, &out->c, &out->d, &out->e);
866}
867
[email protected]8a2820a2008-10-09 21:58:05868template<class ObjT, class Method,
869 class InA, class InB, class InC, class InD, class InE, class InF,
870 class OutA, class OutB, class OutC, class OutD, class OutE>
871inline void DispatchToMethod(ObjT* obj, Method method,
872 const Tuple6<InA, InB, InC, InD, InE, InF>& in,
873 Tuple5<OutA, OutB, OutC, OutD, OutE>* out) {
874 (obj->*method)(in.a, in.b, in.c, in.d, in.e, in.f,
875 &out->a, &out->b, &out->c, &out->d, &out->e);
876}
877
initial.commitd7cae122008-07-26 21:49:38878#endif // BASE_TUPLE_H__
license.botbf09a502008-08-24 00:55:55879