blob: a515830acfa0b595862b36a431e5e141c74f94d7 [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
initial.commitd7cae122008-07-26 21:49:38236// Tuple creators -------------------------------------------------------------
237//
238// Helper functions for constructing tuples while inferring the template
239// argument types.
240
241inline Tuple0 MakeTuple() {
242 return Tuple0();
243}
244
245template <class A>
246inline Tuple1<A> MakeTuple(const A& a) {
247 return Tuple1<A>(a);
248}
249
250template <class A, class B>
251inline Tuple2<A, B> MakeTuple(const A& a, const B& b) {
252 return Tuple2<A, B>(a, b);
253}
254
255template <class A, class B, class C>
256inline Tuple3<A, B, C> MakeTuple(const A& a, const B& b, const C& c) {
257 return Tuple3<A, B, C>(a, b, c);
258}
259
260template <class A, class B, class C, class D>
261inline Tuple4<A, B, C, D> MakeTuple(const A& a, const B& b, const C& c,
262 const D& d) {
263 return Tuple4<A, B, C, D>(a, b, c, d);
264}
265
266template <class A, class B, class C, class D, class E>
267inline Tuple5<A, B, C, D, E> MakeTuple(const A& a, const B& b, const C& c,
268 const D& d, const E& e) {
269 return Tuple5<A, B, C, D, E>(a, b, c, d, e);
270}
271
[email protected]8a2820a2008-10-09 21:58:05272template <class A, class B, class C, class D, class E, class F>
273inline Tuple6<A, B, C, D, E, F> MakeTuple(const A& a, const B& b, const C& c,
274 const D& d, const E& e, const F& f) {
275 return Tuple6<A, B, C, D, E, F>(a, b, c, d, e, f);
276}
277
initial.commitd7cae122008-07-26 21:49:38278// The following set of helpers make what Boost refers to as "Tiers" - a tuple
279// of references.
280
281template <class A>
282inline Tuple1<A&> MakeRefTuple(A& a) {
283 return Tuple1<A&>(a);
284}
285
286template <class A, class B>
287inline Tuple2<A&, B&> MakeRefTuple(A& a, B& b) {
288 return Tuple2<A&, B&>(a, b);
289}
290
291template <class A, class B, class C>
292inline Tuple3<A&, B&, C&> MakeRefTuple(A& a, B& b, C& c) {
293 return Tuple3<A&, B&, C&>(a, b, c);
294}
295
296template <class A, class B, class C, class D>
297inline Tuple4<A&, B&, C&, D&> MakeRefTuple(A& a, B& b, C& c, D& d) {
298 return Tuple4<A&, B&, C&, D&>(a, b, c, d);
299}
300
301template <class A, class B, class C, class D, class E>
302inline Tuple5<A&, B&, C&, D&, E&> MakeRefTuple(A& a, B& b, C& c, D& d, E& e) {
303 return Tuple5<A&, B&, C&, D&, E&>(a, b, c, d, e);
304}
305
[email protected]8a2820a2008-10-09 21:58:05306template <class A, class B, class C, class D, class E, class F>
307inline Tuple6<A&, B&, C&, D&, E&, F&> MakeRefTuple(A& a, B& b, C& c, D& d, E& e,
308 F& f) {
309 return Tuple6<A&, B&, C&, D&, E&, F&>(a, b, c, d, e, f);
310}
311
initial.commitd7cae122008-07-26 21:49:38312// Dispatchers ----------------------------------------------------------------
313//
314// Helper functions that call the given method on an object, with the unpacked
315// tuple arguments. Notice that they all have the same number of arguments,
316// so you need only write:
317// DispatchToMethod(object, &Object::method, args);
318// This is very useful for templated dispatchers, since they don't need to know
319// what type |args| is.
320
321// Non-Static Dispatchers with no out params.
322
323template <class ObjT, class Method>
324inline void DispatchToMethod(ObjT* obj, Method method, const Tuple0& arg) {
325 (obj->*method)();
326}
327
328template <class ObjT, class Method, class A>
329inline void DispatchToMethod(ObjT* obj, Method method, const A& arg) {
330 (obj->*method)(arg);
331}
332
333template <class ObjT, class Method, class A>
334inline void DispatchToMethod(ObjT* obj, Method method, const Tuple1<A>& arg) {
335 (obj->*method)(arg.a);
336}
337
338template<class ObjT, class Method, class A, class B>
339inline void DispatchToMethod(ObjT* obj, Method method, const Tuple2<A, B>& arg) {
340 (obj->*method)(arg.a, arg.b);
341}
342
343template<class ObjT, class Method, class A, class B, class C>
344inline void DispatchToMethod(ObjT* obj, Method method,
345 const Tuple3<A, B, C>& arg) {
346 (obj->*method)(arg.a, arg.b, arg.c);
347}
348
349template<class ObjT, class Method, class A, class B, class C, class D>
350inline void DispatchToMethod(ObjT* obj, Method method,
351 const Tuple4<A, B, C, D>& arg) {
352 (obj->*method)(arg.a, arg.b, arg.c, arg.d);
353}
354
355template<class ObjT, class Method, class A, class B, class C, class D, class E>
356inline void DispatchToMethod(ObjT* obj, Method method,
357 const Tuple5<A, B, C, D, E>& arg) {
358 (obj->*method)(arg.a, arg.b, arg.c, arg.d, arg.e);
359}
360
[email protected]8a2820a2008-10-09 21:58:05361template<class ObjT, class Method, class A, class B, class C, class D, class E,
362 class F>
363inline void DispatchToMethod(ObjT* obj, Method method,
364 const Tuple6<A, B, C, D, E, F>& arg) {
365 (obj->*method)(arg.a, arg.b, arg.c, arg.d, arg.e, arg.f);
366}
367
initial.commitd7cae122008-07-26 21:49:38368// Static Dispatchers with no out params.
369
370template <class Function>
371inline void DispatchToFunction(Function function, const Tuple0& arg) {
372 (*function)();
373}
374
375template <class Function, class A>
376inline void DispatchToFunction(Function function, const A& arg) {
377 (*function)(arg);
378}
379
380template <class Function, class A>
381inline void DispatchToFunction(Function function, const Tuple1<A>& arg) {
382 (*function)(arg.a);
383}
384
385template<class Function, class A, class B>
386inline void DispatchToFunction(Function function, const Tuple2<A, B>& arg) {
387 (*function)(arg.a, arg.b);
388}
389
390template<class Function, class A, class B, class C>
391inline void DispatchToFunction(Function function, const Tuple3<A, B, C>& arg) {
392 (*function)(arg.a, arg.b, arg.c);
393}
394
395template<class Function, class A, class B, class C, class D>
396inline void DispatchToFunction(Function function,
397 const Tuple4<A, B, C, D>& arg) {
398 (*function)(arg.a, arg.b, arg.c, arg.d);
399}
400
401template<class Function, class A, class B, class C, class D, class E>
402inline void DispatchToFunction(Function function,
403 const Tuple5<A, B, C, D, E>& arg) {
404 (*function)(arg.a, arg.b, arg.c, arg.d, arg.e);
405}
406
[email protected]8a2820a2008-10-09 21:58:05407template<class Function, class A, class B, class C, class D, class E, class F>
408inline void DispatchToFunction(Function function,
409 const Tuple6<A, B, C, D, E, F>& arg) {
410 (*function)(arg.a, arg.b, arg.c, arg.d, arg.e, arg.f);
411}
412
initial.commitd7cae122008-07-26 21:49:38413// Dispatchers with 0 out param (as a Tuple0).
414
415template <class ObjT, class Method>
416inline void DispatchToMethod(ObjT* obj, Method method, const Tuple0& arg, Tuple0*) {
417 (obj->*method)();
418}
419
420template <class ObjT, class Method, class A>
421inline void DispatchToMethod(ObjT* obj, Method method, const A& arg, Tuple0*) {
422 (obj->*method)(arg);
423}
424
425template <class ObjT, class Method, class A>
426inline void DispatchToMethod(ObjT* obj, Method method, const Tuple1<A>& arg, Tuple0*) {
427 (obj->*method)(arg.a);
428}
429
430template<class ObjT, class Method, class A, class B>
431inline void DispatchToMethod(ObjT* obj, Method method, const Tuple2<A, B>& arg, Tuple0*) {
432 (obj->*method)(arg.a, arg.b);
433}
434
435template<class ObjT, class Method, class A, class B, class C>
436inline void DispatchToMethod(ObjT* obj, Method method,
437 const Tuple3<A, B, C>& arg, Tuple0*) {
438 (obj->*method)(arg.a, arg.b, arg.c);
439}
440
441template<class ObjT, class Method, class A, class B, class C, class D>
442inline void DispatchToMethod(ObjT* obj, Method method,
443 const Tuple4<A, B, C, D>& arg, Tuple0*) {
444 (obj->*method)(arg.a, arg.b, arg.c, arg.d);
445}
446
447template<class ObjT, class Method, class A, class B, class C, class D, class E>
448inline void DispatchToMethod(ObjT* obj, Method method,
449 const Tuple5<A, B, C, D, E>& arg, Tuple0*) {
450 (obj->*method)(arg.a, arg.b, arg.c, arg.d, arg.e);
451}
452
[email protected]8a2820a2008-10-09 21:58:05453template<class ObjT, class Method, class A, class B, class C, class D, class E,
454 class F>
455inline void DispatchToMethod(ObjT* obj, Method method,
456 const Tuple6<A, B, C, D, E, F>& arg, Tuple0*) {
457 (obj->*method)(arg.a, arg.b, arg.c, arg.d, arg.e, arg.f);
458}
459
initial.commitd7cae122008-07-26 21:49:38460// Dispatchers with 1 out param.
461
462template<class ObjT, class Method,
463 class OutA>
464inline void DispatchToMethod(ObjT* obj, Method method,
465 const Tuple0& in,
466 Tuple1<OutA>* out) {
467 (obj->*method)(&out->a);
468}
469
470template<class ObjT, class Method, class InA,
471 class OutA>
472inline void DispatchToMethod(ObjT* obj, Method method,
473 const InA& in,
474 Tuple1<OutA>* out) {
475 (obj->*method)(in, &out->a);
476}
477
478template<class ObjT, class Method, class InA,
479 class OutA>
480inline void DispatchToMethod(ObjT* obj, Method method,
481 const Tuple1<InA>& in,
482 Tuple1<OutA>* out) {
483 (obj->*method)(in.a, &out->a);
484}
485
486template<class ObjT, class Method, class InA, class InB,
487 class OutA>
488inline void DispatchToMethod(ObjT* obj, Method method,
489 const Tuple2<InA, InB>& in,
490 Tuple1<OutA>* out) {
491 (obj->*method)(in.a, in.b, &out->a);
492}
493
494template<class ObjT, class Method, class InA, class InB, class InC,
495 class OutA>
496inline void DispatchToMethod(ObjT* obj, Method method,
497 const Tuple3<InA, InB, InC>& in,
498 Tuple1<OutA>* out) {
499 (obj->*method)(in.a, in.b, in.c, &out->a);
500}
501
502template<class ObjT, class Method, class InA, class InB, class InC, class InD,
503 class OutA>
504inline void DispatchToMethod(ObjT* obj, Method method,
505 const Tuple4<InA, InB, InC, InD>& in,
506 Tuple1<OutA>* out) {
507 (obj->*method)(in.a, in.b, in.c, in.d, &out->a);
508}
509
510template<class ObjT, class Method,
511 class InA, class InB, class InC, class InD, class InE,
512 class OutA>
513inline void DispatchToMethod(ObjT* obj, Method method,
514 const Tuple5<InA, InB, InC, InD, InE>& in,
515 Tuple1<OutA>* out) {
516 (obj->*method)(in.a, in.b, in.c, in.d, in.e, &out->a);
517}
518
[email protected]8a2820a2008-10-09 21:58:05519template<class ObjT, class Method,
520 class InA, class InB, class InC, class InD, class InE, class InF,
521 class OutA>
522inline void DispatchToMethod(ObjT* obj, Method method,
523 const Tuple6<InA, InB, InC, InD, InE, InF>& in,
524 Tuple1<OutA>* out) {
525 (obj->*method)(in.a, in.b, in.c, in.d, in.e, in.f, &out->a);
526}
527
initial.commitd7cae122008-07-26 21:49:38528// Dispatchers with 2 out params.
529
530template<class ObjT, class Method,
531 class OutA, class OutB>
532inline void DispatchToMethod(ObjT* obj, Method method,
533 const Tuple0& in,
534 Tuple2<OutA, OutB>* out) {
535 (obj->*method)(&out->a, &out->b);
536}
537
538template<class ObjT, class Method, class InA,
539 class OutA, class OutB>
540inline void DispatchToMethod(ObjT* obj, Method method,
541 const InA& in,
542 Tuple2<OutA, OutB>* out) {
543 (obj->*method)(in, &out->a, &out->b);
544}
545
546template<class ObjT, class Method, class InA,
547 class OutA, class OutB>
548inline void DispatchToMethod(ObjT* obj, Method method,
549 const Tuple1<InA>& in,
550 Tuple2<OutA, OutB>* out) {
551 (obj->*method)(in.a, &out->a, &out->b);
552}
553
554template<class ObjT, class Method, class InA, class InB,
555 class OutA, class OutB>
556inline void DispatchToMethod(ObjT* obj, Method method,
557 const Tuple2<InA, InB>& in,
558 Tuple2<OutA, OutB>* out) {
559 (obj->*method)(in.a, in.b, &out->a, &out->b);
560}
561
562template<class ObjT, class Method, class InA, class InB, class InC,
563 class OutA, class OutB>
564inline void DispatchToMethod(ObjT* obj, Method method,
565 const Tuple3<InA, InB, InC>& in,
566 Tuple2<OutA, OutB>* out) {
567 (obj->*method)(in.a, in.b, in.c, &out->a, &out->b);
568}
569
570template<class ObjT, class Method, class InA, class InB, class InC, class InD,
571 class OutA, class OutB>
572inline void DispatchToMethod(ObjT* obj, Method method,
573 const Tuple4<InA, InB, InC, InD>& in,
574 Tuple2<OutA, OutB>* out) {
575 (obj->*method)(in.a, in.b, in.c, in.d, &out->a, &out->b);
576}
577
578template<class ObjT, class Method,
579 class InA, class InB, class InC, class InD, class InE,
580 class OutA, class OutB>
581inline void DispatchToMethod(ObjT* obj, Method method,
582 const Tuple5<InA, InB, InC, InD, InE>& in,
583 Tuple2<OutA, OutB>* out) {
584 (obj->*method)(in.a, in.b, in.c, in.d, in.e, &out->a, &out->b);
585}
586
[email protected]8a2820a2008-10-09 21:58:05587template<class ObjT, class Method,
588 class InA, class InB, class InC, class InD, class InE, class InF,
589 class OutA, class OutB>
590inline void DispatchToMethod(ObjT* obj, Method method,
591 const Tuple6<InA, InB, InC, InD, InE, InF>& in,
592 Tuple2<OutA, OutB>* out) {
593 (obj->*method)(in.a, in.b, in.c, in.d, in.e, in.f, &out->a, &out->b);
594}
595
initial.commitd7cae122008-07-26 21:49:38596// Dispatchers with 3 out params.
597
598template<class ObjT, class Method,
599 class OutA, class OutB, class OutC>
600inline void DispatchToMethod(ObjT* obj, Method method,
601 const Tuple0& in,
602 Tuple3<OutA, OutB, OutC>* out) {
603 (obj->*method)(&out->a, &out->b, &out->c);
604}
605
606template<class ObjT, class Method, class InA,
607 class OutA, class OutB, class OutC>
608inline void DispatchToMethod(ObjT* obj, Method method,
609 const InA& in,
610 Tuple3<OutA, OutB, OutC>* out) {
611 (obj->*method)(in, &out->a, &out->b, &out->c);
612}
613
614template<class ObjT, class Method, class InA,
615 class OutA, class OutB, class OutC>
616inline void DispatchToMethod(ObjT* obj, Method method,
617 const Tuple1<InA>& in,
618 Tuple3<OutA, OutB, OutC>* out) {
619 (obj->*method)(in.a, &out->a, &out->b, &out->c);
620}
621
622template<class ObjT, class Method, class InA, class InB,
623 class OutA, class OutB, class OutC>
624inline void DispatchToMethod(ObjT* obj, Method method,
625 const Tuple2<InA, InB>& in,
626 Tuple3<OutA, OutB, OutC>* out) {
627 (obj->*method)(in.a, in.b, &out->a, &out->b, &out->c);
628}
629
630template<class ObjT, class Method, class InA, class InB, class InC,
631 class OutA, class OutB, class OutC>
632inline void DispatchToMethod(ObjT* obj, Method method,
633 const Tuple3<InA, InB, InC>& in,
634 Tuple3<OutA, OutB, OutC>* out) {
635 (obj->*method)(in.a, in.b, in.c, &out->a, &out->b, &out->c);
636}
637
638template<class ObjT, class Method, class InA, class InB, class InC, class InD,
639 class OutA, class OutB, class OutC>
640inline void DispatchToMethod(ObjT* obj, Method method,
641 const Tuple4<InA, InB, InC, InD>& in,
642 Tuple3<OutA, OutB, OutC>* out) {
643 (obj->*method)(in.a, in.b, in.c, in.d, &out->a, &out->b, &out->c);
644}
645
646template<class ObjT, class Method,
647 class InA, class InB, class InC, class InD, class InE,
648 class OutA, class OutB, class OutC>
649inline void DispatchToMethod(ObjT* obj, Method method,
650 const Tuple5<InA, InB, InC, InD, InE>& in,
651 Tuple3<OutA, OutB, OutC>* out) {
652 (obj->*method)(in.a, in.b, in.c, in.d, in.e, &out->a, &out->b, &out->c);
653}
654
[email protected]8a2820a2008-10-09 21:58:05655template<class ObjT, class Method,
656 class InA, class InB, class InC, class InD, class InE, class InF,
657 class OutA, class OutB, class OutC>
658inline void DispatchToMethod(ObjT* obj, Method method,
659 const Tuple6<InA, InB, InC, InD, InE, InF>& in,
660 Tuple3<OutA, OutB, OutC>* out) {
661 (obj->*method)(in.a, in.b, in.c, in.d, in.e, in.f, &out->a, &out->b, &out->c);
662}
663
initial.commitd7cae122008-07-26 21:49:38664// Dispatchers with 4 out params.
665
666template<class ObjT, class Method,
667 class OutA, class OutB, class OutC, class OutD>
668inline void DispatchToMethod(ObjT* obj, Method method,
669 const Tuple0& in,
670 Tuple4<OutA, OutB, OutC, OutD>* out) {
671 (obj->*method)(&out->a, &out->b, &out->c, &out->d);
672}
673
674template<class ObjT, class Method, class InA,
675 class OutA, class OutB, class OutC, class OutD>
676inline void DispatchToMethod(ObjT* obj, Method method,
677 const InA& in,
678 Tuple4<OutA, OutB, OutC, OutD>* out) {
679 (obj->*method)(in, &out->a, &out->b, &out->c, &out->d);
680}
681
682template<class ObjT, class Method, class InA,
683 class OutA, class OutB, class OutC, class OutD>
684inline void DispatchToMethod(ObjT* obj, Method method,
685 const Tuple1<InA>& in,
686 Tuple4<OutA, OutB, OutC, OutD>* out) {
687 (obj->*method)(in.a, &out->a, &out->b, &out->c, &out->d);
688}
689
690template<class ObjT, class Method, class InA, class InB,
691 class OutA, class OutB, class OutC, class OutD>
692inline void DispatchToMethod(ObjT* obj, Method method,
693 const Tuple2<InA, InB>& in,
694 Tuple4<OutA, OutB, OutC, OutD>* out) {
695 (obj->*method)(in.a, in.b, &out->a, &out->b, &out->c, &out->d);
696}
697
698template<class ObjT, class Method, class InA, class InB, class InC,
699 class OutA, class OutB, class OutC, class OutD>
700inline void DispatchToMethod(ObjT* obj, Method method,
701 const Tuple3<InA, InB, InC>& in,
702 Tuple4<OutA, OutB, OutC, OutD>* out) {
703 (obj->*method)(in.a, in.b, in.c, &out->a, &out->b, &out->c, &out->d);
704}
705
706template<class ObjT, class Method, class InA, class InB, class InC, class InD,
707 class OutA, class OutB, class OutC, class OutD>
708inline void DispatchToMethod(ObjT* obj, Method method,
709 const Tuple4<InA, InB, InC, InD>& in,
710 Tuple4<OutA, OutB, OutC, OutD>* out) {
711 (obj->*method)(in.a, in.b, in.c, in.d, &out->a, &out->b, &out->c, &out->d);
712}
713
714template<class ObjT, class Method,
715 class InA, class InB, class InC, class InD, class InE,
716 class OutA, class OutB, class OutC, class OutD>
717inline void DispatchToMethod(ObjT* obj, Method method,
718 const Tuple5<InA, InB, InC, InD, InE>& in,
719 Tuple4<OutA, OutB, OutC, OutD>* out) {
720 (obj->*method)(in.a, in.b, in.c, in.d, in.e,
721 &out->a, &out->b, &out->c, &out->d);
722}
723
[email protected]8a2820a2008-10-09 21:58:05724template<class ObjT, class Method,
725 class InA, class InB, class InC, class InD, class InE, class InF,
726 class OutA, class OutB, class OutC, class OutD>
727inline void DispatchToMethod(ObjT* obj, Method method,
728 const Tuple6<InA, InB, InC, InD, InE, InF>& in,
729 Tuple4<OutA, OutB, OutC, OutD>* out) {
730 (obj->*method)(in.a, in.b, in.c, in.d, in.e, in.f,
731 &out->a, &out->b, &out->c, &out->d);
732}
733
initial.commitd7cae122008-07-26 21:49:38734// Dispatchers with 5 out params.
735
736template<class ObjT, class Method,
737 class OutA, class OutB, class OutC, class OutD, class OutE>
738inline void DispatchToMethod(ObjT* obj, Method method,
739 const Tuple0& in,
740 Tuple5<OutA, OutB, OutC, OutD, OutE>* out) {
741 (obj->*method)(&out->a, &out->b, &out->c, &out->d, &out->e);
742}
743
744template<class ObjT, class Method, class InA,
745 class OutA, class OutB, class OutC, class OutD, class OutE>
746inline void DispatchToMethod(ObjT* obj, Method method,
747 const InA& in,
748 Tuple5<OutA, OutB, OutC, OutD, OutE>* out) {
749 (obj->*method)(in, &out->a, &out->b, &out->c, &out->d, &out->e);
750}
751
752template<class ObjT, class Method, class InA,
753 class OutA, class OutB, class OutC, class OutD, class OutE>
754inline void DispatchToMethod(ObjT* obj, Method method,
755 const Tuple1<InA>& in,
756 Tuple5<OutA, OutB, OutC, OutD, OutE>* out) {
757 (obj->*method)(in.a, &out->a, &out->b, &out->c, &out->d, &out->e);
758}
759
760template<class ObjT, class Method, class InA, class InB,
761 class OutA, class OutB, class OutC, class OutD, class OutE>
762inline void DispatchToMethod(ObjT* obj, Method method,
763 const Tuple2<InA, InB>& in,
764 Tuple5<OutA, OutB, OutC, OutD, OutE>* out) {
765 (obj->*method)(in.a, in.b, &out->a, &out->b, &out->c, &out->d, &out->e);
766}
767
768template<class ObjT, class Method, class InA, class InB, class InC,
769 class OutA, class OutB, class OutC, class OutD, class OutE>
770inline void DispatchToMethod(ObjT* obj, Method method,
771 const Tuple3<InA, InB, InC>& in,
772 Tuple5<OutA, OutB, OutC, OutD, OutE>* out) {
773 (obj->*method)(in.a, in.b, in.c, &out->a, &out->b, &out->c, &out->d, &out->e);
774}
775
776template<class ObjT, class Method, class InA, class InB, class InC, class InD,
777 class OutA, class OutB, class OutC, class OutD, class OutE>
778inline void DispatchToMethod(ObjT* obj, Method method,
779 const Tuple4<InA, InB, InC, InD>& in,
780 Tuple5<OutA, OutB, OutC, OutD, OutE>* out) {
781 (obj->*method)(in.a, in.b, in.c, in.d, &out->a, &out->b, &out->c, &out->d,
782 &out->e);
783}
784
785template<class ObjT, class Method,
786 class InA, class InB, class InC, class InD, class InE,
787 class OutA, class OutB, class OutC, class OutD, class OutE>
788inline void DispatchToMethod(ObjT* obj, Method method,
789 const Tuple5<InA, InB, InC, InD, InE>& in,
790 Tuple5<OutA, OutB, OutC, OutD, OutE>* out) {
791 (obj->*method)(in.a, in.b, in.c, in.d, in.e,
792 &out->a, &out->b, &out->c, &out->d, &out->e);
793}
794
[email protected]8a2820a2008-10-09 21:58:05795template<class ObjT, class Method,
796 class InA, class InB, class InC, class InD, class InE, class InF,
797 class OutA, class OutB, class OutC, class OutD, class OutE>
798inline void DispatchToMethod(ObjT* obj, Method method,
799 const Tuple6<InA, InB, InC, InD, InE, InF>& in,
800 Tuple5<OutA, OutB, OutC, OutD, OutE>* out) {
801 (obj->*method)(in.a, in.b, in.c, in.d, in.e, in.f,
802 &out->a, &out->b, &out->c, &out->d, &out->e);
803}
804
initial.commitd7cae122008-07-26 21:49:38805#endif // BASE_TUPLE_H__
license.botbf09a502008-08-24 00:55:55806