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