blob: c54b5797e810643bb8fd96e0a0b19144c4d42ca6 [file] [log] [blame]
license.botf003cfe2008-08-24 09:55:55 +09001// 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.commit3f4a7322008-07-27 06:49:38 +09004
deanm@google.com96aac0a2008-08-25 22:42:07 +09005// A Tuple is a generic templatized container, similar in concept to std::pair.
6// There are classes Tuple0 to Tuple5, cooresponding to the number of elements
7// it contains. The convenient MakeTuple() function takes 0 to 5 arguments,
8// 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.commit3f4a7322008-07-27 06:49:38 +090029#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//
deanm@google.comff4b7292008-08-21 19:58:08 +090061// 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.commit3f4a7322008-07-27 06:49:38 +090064// 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
196// Tuple creators -------------------------------------------------------------
197//
198// Helper functions for constructing tuples while inferring the template
199// argument types.
200
201inline Tuple0 MakeTuple() {
202 return Tuple0();
203}
204
205template <class A>
206inline Tuple1<A> MakeTuple(const A& a) {
207 return Tuple1<A>(a);
208}
209
210template <class A, class B>
211inline Tuple2<A, B> MakeTuple(const A& a, const B& b) {
212 return Tuple2<A, B>(a, b);
213}
214
215template <class A, class B, class C>
216inline Tuple3<A, B, C> MakeTuple(const A& a, const B& b, const C& c) {
217 return Tuple3<A, B, C>(a, b, c);
218}
219
220template <class A, class B, class C, class D>
221inline Tuple4<A, B, C, D> MakeTuple(const A& a, const B& b, const C& c,
222 const D& d) {
223 return Tuple4<A, B, C, D>(a, b, c, d);
224}
225
226template <class A, class B, class C, class D, class E>
227inline Tuple5<A, B, C, D, E> MakeTuple(const A& a, const B& b, const C& c,
228 const D& d, const E& e) {
229 return Tuple5<A, B, C, D, E>(a, b, c, d, e);
230}
231
232// The following set of helpers make what Boost refers to as "Tiers" - a tuple
233// of references.
234
235template <class A>
236inline Tuple1<A&> MakeRefTuple(A& a) {
237 return Tuple1<A&>(a);
238}
239
240template <class A, class B>
241inline Tuple2<A&, B&> MakeRefTuple(A& a, B& b) {
242 return Tuple2<A&, B&>(a, b);
243}
244
245template <class A, class B, class C>
246inline Tuple3<A&, B&, C&> MakeRefTuple(A& a, B& b, C& c) {
247 return Tuple3<A&, B&, C&>(a, b, c);
248}
249
250template <class A, class B, class C, class D>
251inline Tuple4<A&, B&, C&, D&> MakeRefTuple(A& a, B& b, C& c, D& d) {
252 return Tuple4<A&, B&, C&, D&>(a, b, c, d);
253}
254
255template <class A, class B, class C, class D, class E>
256inline Tuple5<A&, B&, C&, D&, E&> MakeRefTuple(A& a, B& b, C& c, D& d, E& e) {
257 return Tuple5<A&, B&, C&, D&, E&>(a, b, c, d, e);
258}
259
260// Dispatchers ----------------------------------------------------------------
261//
262// Helper functions that call the given method on an object, with the unpacked
263// tuple arguments. Notice that they all have the same number of arguments,
264// so you need only write:
265// DispatchToMethod(object, &Object::method, args);
266// This is very useful for templated dispatchers, since they don't need to know
267// what type |args| is.
268
269// Non-Static Dispatchers with no out params.
270
271template <class ObjT, class Method>
272inline void DispatchToMethod(ObjT* obj, Method method, const Tuple0& arg) {
273 (obj->*method)();
274}
275
276template <class ObjT, class Method, class A>
277inline void DispatchToMethod(ObjT* obj, Method method, const A& arg) {
278 (obj->*method)(arg);
279}
280
281template <class ObjT, class Method, class A>
282inline void DispatchToMethod(ObjT* obj, Method method, const Tuple1<A>& arg) {
283 (obj->*method)(arg.a);
284}
285
286template<class ObjT, class Method, class A, class B>
287inline void DispatchToMethod(ObjT* obj, Method method, const Tuple2<A, B>& arg) {
288 (obj->*method)(arg.a, arg.b);
289}
290
291template<class ObjT, class Method, class A, class B, class C>
292inline void DispatchToMethod(ObjT* obj, Method method,
293 const Tuple3<A, B, C>& arg) {
294 (obj->*method)(arg.a, arg.b, arg.c);
295}
296
297template<class ObjT, class Method, class A, class B, class C, class D>
298inline void DispatchToMethod(ObjT* obj, Method method,
299 const Tuple4<A, B, C, D>& arg) {
300 (obj->*method)(arg.a, arg.b, arg.c, arg.d);
301}
302
303template<class ObjT, class Method, class A, class B, class C, class D, class E>
304inline void DispatchToMethod(ObjT* obj, Method method,
305 const Tuple5<A, B, C, D, E>& arg) {
306 (obj->*method)(arg.a, arg.b, arg.c, arg.d, arg.e);
307}
308
309// Static Dispatchers with no out params.
310
311template <class Function>
312inline void DispatchToFunction(Function function, const Tuple0& arg) {
313 (*function)();
314}
315
316template <class Function, class A>
317inline void DispatchToFunction(Function function, const A& arg) {
318 (*function)(arg);
319}
320
321template <class Function, class A>
322inline void DispatchToFunction(Function function, const Tuple1<A>& arg) {
323 (*function)(arg.a);
324}
325
326template<class Function, class A, class B>
327inline void DispatchToFunction(Function function, const Tuple2<A, B>& arg) {
328 (*function)(arg.a, arg.b);
329}
330
331template<class Function, class A, class B, class C>
332inline void DispatchToFunction(Function function, const Tuple3<A, B, C>& arg) {
333 (*function)(arg.a, arg.b, arg.c);
334}
335
336template<class Function, class A, class B, class C, class D>
337inline void DispatchToFunction(Function function,
338 const Tuple4<A, B, C, D>& arg) {
339 (*function)(arg.a, arg.b, arg.c, arg.d);
340}
341
342template<class Function, class A, class B, class C, class D, class E>
343inline void DispatchToFunction(Function function,
344 const Tuple5<A, B, C, D, E>& arg) {
345 (*function)(arg.a, arg.b, arg.c, arg.d, arg.e);
346}
347
348// Dispatchers with 0 out param (as a Tuple0).
349
350template <class ObjT, class Method>
351inline void DispatchToMethod(ObjT* obj, Method method, const Tuple0& arg, Tuple0*) {
352 (obj->*method)();
353}
354
355template <class ObjT, class Method, class A>
356inline void DispatchToMethod(ObjT* obj, Method method, const A& arg, Tuple0*) {
357 (obj->*method)(arg);
358}
359
360template <class ObjT, class Method, class A>
361inline void DispatchToMethod(ObjT* obj, Method method, const Tuple1<A>& arg, Tuple0*) {
362 (obj->*method)(arg.a);
363}
364
365template<class ObjT, class Method, class A, class B>
366inline void DispatchToMethod(ObjT* obj, Method method, const Tuple2<A, B>& arg, Tuple0*) {
367 (obj->*method)(arg.a, arg.b);
368}
369
370template<class ObjT, class Method, class A, class B, class C>
371inline void DispatchToMethod(ObjT* obj, Method method,
372 const Tuple3<A, B, C>& arg, Tuple0*) {
373 (obj->*method)(arg.a, arg.b, arg.c);
374}
375
376template<class ObjT, class Method, class A, class B, class C, class D>
377inline void DispatchToMethod(ObjT* obj, Method method,
378 const Tuple4<A, B, C, D>& arg, Tuple0*) {
379 (obj->*method)(arg.a, arg.b, arg.c, arg.d);
380}
381
382template<class ObjT, class Method, class A, class B, class C, class D, class E>
383inline void DispatchToMethod(ObjT* obj, Method method,
384 const Tuple5<A, B, C, D, E>& arg, Tuple0*) {
385 (obj->*method)(arg.a, arg.b, arg.c, arg.d, arg.e);
386}
387
388// Dispatchers with 1 out param.
389
390template<class ObjT, class Method,
391 class OutA>
392inline void DispatchToMethod(ObjT* obj, Method method,
393 const Tuple0& in,
394 Tuple1<OutA>* out) {
395 (obj->*method)(&out->a);
396}
397
398template<class ObjT, class Method, class InA,
399 class OutA>
400inline void DispatchToMethod(ObjT* obj, Method method,
401 const InA& in,
402 Tuple1<OutA>* out) {
403 (obj->*method)(in, &out->a);
404}
405
406template<class ObjT, class Method, class InA,
407 class OutA>
408inline void DispatchToMethod(ObjT* obj, Method method,
409 const Tuple1<InA>& in,
410 Tuple1<OutA>* out) {
411 (obj->*method)(in.a, &out->a);
412}
413
414template<class ObjT, class Method, class InA, class InB,
415 class OutA>
416inline void DispatchToMethod(ObjT* obj, Method method,
417 const Tuple2<InA, InB>& in,
418 Tuple1<OutA>* out) {
419 (obj->*method)(in.a, in.b, &out->a);
420}
421
422template<class ObjT, class Method, class InA, class InB, class InC,
423 class OutA>
424inline void DispatchToMethod(ObjT* obj, Method method,
425 const Tuple3<InA, InB, InC>& in,
426 Tuple1<OutA>* out) {
427 (obj->*method)(in.a, in.b, in.c, &out->a);
428}
429
430template<class ObjT, class Method, class InA, class InB, class InC, class InD,
431 class OutA>
432inline void DispatchToMethod(ObjT* obj, Method method,
433 const Tuple4<InA, InB, InC, InD>& in,
434 Tuple1<OutA>* out) {
435 (obj->*method)(in.a, in.b, in.c, in.d, &out->a);
436}
437
438template<class ObjT, class Method,
439 class InA, class InB, class InC, class InD, class InE,
440 class OutA>
441inline void DispatchToMethod(ObjT* obj, Method method,
442 const Tuple5<InA, InB, InC, InD, InE>& in,
443 Tuple1<OutA>* out) {
444 (obj->*method)(in.a, in.b, in.c, in.d, in.e, &out->a);
445}
446
447// Dispatchers with 2 out params.
448
449template<class ObjT, class Method,
450 class OutA, class OutB>
451inline void DispatchToMethod(ObjT* obj, Method method,
452 const Tuple0& in,
453 Tuple2<OutA, OutB>* out) {
454 (obj->*method)(&out->a, &out->b);
455}
456
457template<class ObjT, class Method, class InA,
458 class OutA, class OutB>
459inline void DispatchToMethod(ObjT* obj, Method method,
460 const InA& in,
461 Tuple2<OutA, OutB>* out) {
462 (obj->*method)(in, &out->a, &out->b);
463}
464
465template<class ObjT, class Method, class InA,
466 class OutA, class OutB>
467inline void DispatchToMethod(ObjT* obj, Method method,
468 const Tuple1<InA>& in,
469 Tuple2<OutA, OutB>* out) {
470 (obj->*method)(in.a, &out->a, &out->b);
471}
472
473template<class ObjT, class Method, class InA, class InB,
474 class OutA, class OutB>
475inline void DispatchToMethod(ObjT* obj, Method method,
476 const Tuple2<InA, InB>& in,
477 Tuple2<OutA, OutB>* out) {
478 (obj->*method)(in.a, in.b, &out->a, &out->b);
479}
480
481template<class ObjT, class Method, class InA, class InB, class InC,
482 class OutA, class OutB>
483inline void DispatchToMethod(ObjT* obj, Method method,
484 const Tuple3<InA, InB, InC>& in,
485 Tuple2<OutA, OutB>* out) {
486 (obj->*method)(in.a, in.b, in.c, &out->a, &out->b);
487}
488
489template<class ObjT, class Method, class InA, class InB, class InC, class InD,
490 class OutA, class OutB>
491inline void DispatchToMethod(ObjT* obj, Method method,
492 const Tuple4<InA, InB, InC, InD>& in,
493 Tuple2<OutA, OutB>* out) {
494 (obj->*method)(in.a, in.b, in.c, in.d, &out->a, &out->b);
495}
496
497template<class ObjT, class Method,
498 class InA, class InB, class InC, class InD, class InE,
499 class OutA, class OutB>
500inline void DispatchToMethod(ObjT* obj, Method method,
501 const Tuple5<InA, InB, InC, InD, InE>& in,
502 Tuple2<OutA, OutB>* out) {
503 (obj->*method)(in.a, in.b, in.c, in.d, in.e, &out->a, &out->b);
504}
505
506// Dispatchers with 3 out params.
507
508template<class ObjT, class Method,
509 class OutA, class OutB, class OutC>
510inline void DispatchToMethod(ObjT* obj, Method method,
511 const Tuple0& in,
512 Tuple3<OutA, OutB, OutC>* out) {
513 (obj->*method)(&out->a, &out->b, &out->c);
514}
515
516template<class ObjT, class Method, class InA,
517 class OutA, class OutB, class OutC>
518inline void DispatchToMethod(ObjT* obj, Method method,
519 const InA& in,
520 Tuple3<OutA, OutB, OutC>* out) {
521 (obj->*method)(in, &out->a, &out->b, &out->c);
522}
523
524template<class ObjT, class Method, class InA,
525 class OutA, class OutB, class OutC>
526inline void DispatchToMethod(ObjT* obj, Method method,
527 const Tuple1<InA>& in,
528 Tuple3<OutA, OutB, OutC>* out) {
529 (obj->*method)(in.a, &out->a, &out->b, &out->c);
530}
531
532template<class ObjT, class Method, class InA, class InB,
533 class OutA, class OutB, class OutC>
534inline void DispatchToMethod(ObjT* obj, Method method,
535 const Tuple2<InA, InB>& in,
536 Tuple3<OutA, OutB, OutC>* out) {
537 (obj->*method)(in.a, in.b, &out->a, &out->b, &out->c);
538}
539
540template<class ObjT, class Method, class InA, class InB, class InC,
541 class OutA, class OutB, class OutC>
542inline void DispatchToMethod(ObjT* obj, Method method,
543 const Tuple3<InA, InB, InC>& in,
544 Tuple3<OutA, OutB, OutC>* out) {
545 (obj->*method)(in.a, in.b, in.c, &out->a, &out->b, &out->c);
546}
547
548template<class ObjT, class Method, class InA, class InB, class InC, class InD,
549 class OutA, class OutB, class OutC>
550inline void DispatchToMethod(ObjT* obj, Method method,
551 const Tuple4<InA, InB, InC, InD>& in,
552 Tuple3<OutA, OutB, OutC>* out) {
553 (obj->*method)(in.a, in.b, in.c, in.d, &out->a, &out->b, &out->c);
554}
555
556template<class ObjT, class Method,
557 class InA, class InB, class InC, class InD, class InE,
558 class OutA, class OutB, class OutC>
559inline void DispatchToMethod(ObjT* obj, Method method,
560 const Tuple5<InA, InB, InC, InD, InE>& in,
561 Tuple3<OutA, OutB, OutC>* out) {
562 (obj->*method)(in.a, in.b, in.c, in.d, in.e, &out->a, &out->b, &out->c);
563}
564
565// Dispatchers with 4 out params.
566
567template<class ObjT, class Method,
568 class OutA, class OutB, class OutC, class OutD>
569inline void DispatchToMethod(ObjT* obj, Method method,
570 const Tuple0& in,
571 Tuple4<OutA, OutB, OutC, OutD>* out) {
572 (obj->*method)(&out->a, &out->b, &out->c, &out->d);
573}
574
575template<class ObjT, class Method, class InA,
576 class OutA, class OutB, class OutC, class OutD>
577inline void DispatchToMethod(ObjT* obj, Method method,
578 const InA& in,
579 Tuple4<OutA, OutB, OutC, OutD>* out) {
580 (obj->*method)(in, &out->a, &out->b, &out->c, &out->d);
581}
582
583template<class ObjT, class Method, class InA,
584 class OutA, class OutB, class OutC, class OutD>
585inline void DispatchToMethod(ObjT* obj, Method method,
586 const Tuple1<InA>& in,
587 Tuple4<OutA, OutB, OutC, OutD>* out) {
588 (obj->*method)(in.a, &out->a, &out->b, &out->c, &out->d);
589}
590
591template<class ObjT, class Method, class InA, class InB,
592 class OutA, class OutB, class OutC, class OutD>
593inline void DispatchToMethod(ObjT* obj, Method method,
594 const Tuple2<InA, InB>& in,
595 Tuple4<OutA, OutB, OutC, OutD>* out) {
596 (obj->*method)(in.a, in.b, &out->a, &out->b, &out->c, &out->d);
597}
598
599template<class ObjT, class Method, class InA, class InB, class InC,
600 class OutA, class OutB, class OutC, class OutD>
601inline void DispatchToMethod(ObjT* obj, Method method,
602 const Tuple3<InA, InB, InC>& in,
603 Tuple4<OutA, OutB, OutC, OutD>* out) {
604 (obj->*method)(in.a, in.b, in.c, &out->a, &out->b, &out->c, &out->d);
605}
606
607template<class ObjT, class Method, class InA, class InB, class InC, class InD,
608 class OutA, class OutB, class OutC, class OutD>
609inline void DispatchToMethod(ObjT* obj, Method method,
610 const Tuple4<InA, InB, InC, InD>& in,
611 Tuple4<OutA, OutB, OutC, OutD>* out) {
612 (obj->*method)(in.a, in.b, in.c, in.d, &out->a, &out->b, &out->c, &out->d);
613}
614
615template<class ObjT, class Method,
616 class InA, class InB, class InC, class InD, class InE,
617 class OutA, class OutB, class OutC, class OutD>
618inline void DispatchToMethod(ObjT* obj, Method method,
619 const Tuple5<InA, InB, InC, InD, InE>& in,
620 Tuple4<OutA, OutB, OutC, OutD>* out) {
621 (obj->*method)(in.a, in.b, in.c, in.d, in.e,
622 &out->a, &out->b, &out->c, &out->d);
623}
624
625// Dispatchers with 5 out params.
626
627template<class ObjT, class Method,
628 class OutA, class OutB, class OutC, class OutD, class OutE>
629inline void DispatchToMethod(ObjT* obj, Method method,
630 const Tuple0& in,
631 Tuple5<OutA, OutB, OutC, OutD, OutE>* out) {
632 (obj->*method)(&out->a, &out->b, &out->c, &out->d, &out->e);
633}
634
635template<class ObjT, class Method, class InA,
636 class OutA, class OutB, class OutC, class OutD, class OutE>
637inline void DispatchToMethod(ObjT* obj, Method method,
638 const InA& in,
639 Tuple5<OutA, OutB, OutC, OutD, OutE>* out) {
640 (obj->*method)(in, &out->a, &out->b, &out->c, &out->d, &out->e);
641}
642
643template<class ObjT, class Method, class InA,
644 class OutA, class OutB, class OutC, class OutD, class OutE>
645inline void DispatchToMethod(ObjT* obj, Method method,
646 const Tuple1<InA>& in,
647 Tuple5<OutA, OutB, OutC, OutD, OutE>* out) {
648 (obj->*method)(in.a, &out->a, &out->b, &out->c, &out->d, &out->e);
649}
650
651template<class ObjT, class Method, class InA, class InB,
652 class OutA, class OutB, class OutC, class OutD, class OutE>
653inline void DispatchToMethod(ObjT* obj, Method method,
654 const Tuple2<InA, InB>& in,
655 Tuple5<OutA, OutB, OutC, OutD, OutE>* out) {
656 (obj->*method)(in.a, in.b, &out->a, &out->b, &out->c, &out->d, &out->e);
657}
658
659template<class ObjT, class Method, class InA, class InB, class InC,
660 class OutA, class OutB, class OutC, class OutD, class OutE>
661inline void DispatchToMethod(ObjT* obj, Method method,
662 const Tuple3<InA, InB, InC>& in,
663 Tuple5<OutA, OutB, OutC, OutD, OutE>* out) {
664 (obj->*method)(in.a, in.b, in.c, &out->a, &out->b, &out->c, &out->d, &out->e);
665}
666
667template<class ObjT, class Method, class InA, class InB, class InC, class InD,
668 class OutA, class OutB, class OutC, class OutD, class OutE>
669inline void DispatchToMethod(ObjT* obj, Method method,
670 const Tuple4<InA, InB, InC, InD>& in,
671 Tuple5<OutA, OutB, OutC, OutD, OutE>* out) {
672 (obj->*method)(in.a, in.b, in.c, in.d, &out->a, &out->b, &out->c, &out->d,
673 &out->e);
674}
675
676template<class ObjT, class Method,
677 class InA, class InB, class InC, class InD, class InE,
678 class OutA, class OutB, class OutC, class OutD, class OutE>
679inline void DispatchToMethod(ObjT* obj, Method method,
680 const Tuple5<InA, InB, InC, InD, InE>& in,
681 Tuple5<OutA, OutB, OutC, OutD, OutE>* out) {
682 (obj->*method)(in.a, in.b, in.c, in.d, in.e,
683 &out->a, &out->b, &out->c, &out->d, &out->e);
684}
685
686#endif // BASE_TUPLE_H__
license.botf003cfe2008-08-24 09:55:55 +0900687