| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 // A Tuple is a generic templatized container, similar in concept to std::pair. | 5 // A Tuple is a generic templatized container, similar in concept to std::pair. |
| 6 // There are classes Tuple0 to Tuple6, cooresponding to the number of elements | 6 // There are classes Tuple0 to Tuple6, cooresponding to the number of elements |
| 7 // it contains. The convenient MakeTuple() function takes 0 to 6 arguments, | 7 // it contains. The convenient MakeTuple() function takes 0 to 6 arguments, |
| 8 // and will construct and return the appropriate Tuple object. The functions | 8 // and will construct and return the appropriate Tuple object. The functions |
| 9 // DispatchToMethod and DispatchToFunction take a function pointer or instance | 9 // DispatchToMethod and DispatchToFunction take a function pointer or instance |
| 10 // and method pointer, and unpack a tuple into arguments to the call. | 10 // and method pointer, and unpack a tuple into arguments to the call. |
| (...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 164 } | 164 } |
| 165 | 165 |
| 166 A a; | 166 A a; |
| 167 B b; | 167 B b; |
| 168 C c; | 168 C c; |
| 169 D d; | 169 D d; |
| 170 }; | 170 }; |
| 171 | 171 |
| 172 template <class A, class B, class C, class D, class E> | 172 template <class A, class B, class C, class D, class E> |
| 173 struct Tuple5 { | 173 struct Tuple5 { |
| 174 public: | 174 public: |
| 175 typedef A TypeA; | 175 typedef A TypeA; |
| 176 typedef B TypeB; | 176 typedef B TypeB; |
| 177 typedef C TypeC; | 177 typedef C TypeC; |
| 178 typedef D TypeD; | 178 typedef D TypeD; |
| 179 typedef E TypeE; | 179 typedef E TypeE; |
| 180 typedef Tuple5<typename TupleTraits<A>::ValueType, | 180 typedef Tuple5<typename TupleTraits<A>::ValueType, |
| 181 typename TupleTraits<B>::ValueType, | 181 typename TupleTraits<B>::ValueType, |
| 182 typename TupleTraits<C>::ValueType, | 182 typename TupleTraits<C>::ValueType, |
| 183 typename TupleTraits<D>::ValueType, | 183 typename TupleTraits<D>::ValueType, |
| 184 typename TupleTraits<E>::ValueType> ValueTuple; | 184 typename TupleTraits<E>::ValueType> ValueTuple; |
| (...skipping 19 matching lines...) Expand all Loading... |
| 204 | 204 |
| 205 A a; | 205 A a; |
| 206 B b; | 206 B b; |
| 207 C c; | 207 C c; |
| 208 D d; | 208 D d; |
| 209 E e; | 209 E e; |
| 210 }; | 210 }; |
| 211 | 211 |
| 212 template <class A, class B, class C, class D, class E, class F> | 212 template <class A, class B, class C, class D, class E, class F> |
| 213 struct Tuple6 { | 213 struct Tuple6 { |
| 214 public: | 214 public: |
| 215 typedef A TypeA; | 215 typedef A TypeA; |
| 216 typedef B TypeB; | 216 typedef B TypeB; |
| 217 typedef C TypeC; | 217 typedef C TypeC; |
| 218 typedef D TypeD; | 218 typedef D TypeD; |
| 219 typedef E TypeE; | 219 typedef E TypeE; |
| 220 typedef F TypeF; | 220 typedef F TypeF; |
| 221 typedef Tuple6<typename TupleTraits<A>::ValueType, | 221 typedef Tuple6<typename TupleTraits<A>::ValueType, |
| 222 typename TupleTraits<B>::ValueType, | 222 typename TupleTraits<B>::ValueType, |
| 223 typename TupleTraits<C>::ValueType, | 223 typename TupleTraits<C>::ValueType, |
| 224 typename TupleTraits<D>::ValueType, | 224 typename TupleTraits<D>::ValueType, |
| (...skipping 25 matching lines...) Expand all Loading... |
| 250 A a; | 250 A a; |
| 251 B b; | 251 B b; |
| 252 C c; | 252 C c; |
| 253 D d; | 253 D d; |
| 254 E e; | 254 E e; |
| 255 F f; | 255 F f; |
| 256 }; | 256 }; |
| 257 | 257 |
| 258 template <class A, class B, class C, class D, class E, class F, class G> | 258 template <class A, class B, class C, class D, class E, class F, class G> |
| 259 struct Tuple7 { | 259 struct Tuple7 { |
| 260 public: | 260 public: |
| 261 typedef A TypeA; | 261 typedef A TypeA; |
| 262 typedef B TypeB; | 262 typedef B TypeB; |
| 263 typedef C TypeC; | 263 typedef C TypeC; |
| 264 typedef D TypeD; | 264 typedef D TypeD; |
| 265 typedef E TypeE; | 265 typedef E TypeE; |
| 266 typedef F TypeF; | 266 typedef F TypeF; |
| 267 typedef G TypeG; | 267 typedef G TypeG; |
| 268 typedef Tuple7<typename TupleTraits<A>::ValueType, | 268 typedef Tuple7<typename TupleTraits<A>::ValueType, |
| 269 typename TupleTraits<B>::ValueType, | 269 typename TupleTraits<B>::ValueType, |
| 270 typename TupleTraits<C>::ValueType, | 270 typename TupleTraits<C>::ValueType, |
| (...skipping 331 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 602 } | 602 } |
| 603 | 603 |
| 604 template<class ObjT, class Method, class InA, class InB, class InC, class InD, | 604 template<class ObjT, class Method, class InA, class InB, class InC, class InD, |
| 605 class OutA> | 605 class OutA> |
| 606 inline void DispatchToMethod(ObjT* obj, Method method, | 606 inline void DispatchToMethod(ObjT* obj, Method method, |
| 607 const Tuple4<InA, InB, InC, InD>& in, | 607 const Tuple4<InA, InB, InC, InD>& in, |
| 608 Tuple1<OutA>* out) { | 608 Tuple1<OutA>* out) { |
| 609 (obj->*method)(in.a, in.b, in.c, in.d, &out->a); | 609 (obj->*method)(in.a, in.b, in.c, in.d, &out->a); |
| 610 } | 610 } |
| 611 | 611 |
| 612 template<class ObjT, class Method, class InA, class InB, class InC, class InD, | 612 template<class ObjT, class Method, |
| 613 class InE, class OutA> | 613 class InA, class InB, class InC, class InD, class InE, |
| 614 class OutA> |
| 614 inline void DispatchToMethod(ObjT* obj, Method method, | 615 inline void DispatchToMethod(ObjT* obj, Method method, |
| 615 const Tuple5<InA, InB, InC, InD, InE>& in, | 616 const Tuple5<InA, InB, InC, InD, InE>& in, |
| 616 Tuple1<OutA>* out) { | 617 Tuple1<OutA>* out) { |
| 617 (obj->*method)(in.a, in.b, in.c, in.d, in.e, &out->a); | 618 (obj->*method)(in.a, in.b, in.c, in.d, in.e, &out->a); |
| 618 } | 619 } |
| 619 | 620 |
| 620 template<class ObjT, class Method, | 621 template<class ObjT, class Method, |
| 621 class InA, class InB, class InC, class InD, class InE, class InF, | 622 class InA, class InB, class InC, class InD, class InE, class InF, |
| 622 class OutA> | 623 class OutA> |
| 623 inline void DispatchToMethod(ObjT* obj, Method method, | 624 inline void DispatchToMethod(ObjT* obj, Method method, |
| (...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 897 class InA, class InB, class InC, class InD, class InE, class InF, | 898 class InA, class InB, class InC, class InD, class InE, class InF, |
| 898 class OutA, class OutB, class OutC, class OutD, class OutE> | 899 class OutA, class OutB, class OutC, class OutD, class OutE> |
| 899 inline void DispatchToMethod(ObjT* obj, Method method, | 900 inline void DispatchToMethod(ObjT* obj, Method method, |
| 900 const Tuple6<InA, InB, InC, InD, InE, InF>& in, | 901 const Tuple6<InA, InB, InC, InD, InE, InF>& in, |
| 901 Tuple5<OutA, OutB, OutC, OutD, OutE>* out) { | 902 Tuple5<OutA, OutB, OutC, OutD, OutE>* out) { |
| 902 (obj->*method)(in.a, in.b, in.c, in.d, in.e, in.f, | 903 (obj->*method)(in.a, in.b, in.c, in.d, in.e, in.f, |
| 903 &out->a, &out->b, &out->c, &out->d, &out->e); | 904 &out->a, &out->b, &out->c, &out->d, &out->e); |
| 904 } | 905 } |
| 905 | 906 |
| 906 #endif // BASE_TUPLE_H__ | 907 #endif // BASE_TUPLE_H__ |
| OLD | NEW |