github.com/ckxng/wakeup@v0.0.0-20190105202853-90356a5f5a15/include/internal/cef_tuple.h (about) 1 // Copyright (c) 2006-2011 Google Inc. All rights reserved. 2 // 3 // Redistribution and use in source and binary forms, with or without 4 // modification, are permitted provided that the following conditions are 5 // met: 6 // 7 // * Redistributions of source code must retain the above copyright 8 // notice, this list of conditions and the following disclaimer. 9 // * Redistributions in binary form must reproduce the above 10 // copyright notice, this list of conditions and the following disclaimer 11 // in the documentation and/or other materials provided with the 12 // distribution. 13 // * Neither the name of Google Inc. nor the name Chromium Embedded 14 // Framework nor the names of its contributors may be used to endorse 15 // or promote products derived from this software without specific prior 16 // written permission. 17 // 18 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 // 30 // The contents of this file are identical to base/tuple.h 31 32 // A Tuple is a generic templatized container, similar in concept to std::pair. 33 // There are classes Tuple0 to Tuple6, cooresponding to the number of elements 34 // it contains. The convenient MakeTuple() function takes 0 to 6 arguments, 35 // and will construct and return the appropriate Tuple object. The functions 36 // DispatchToMethod and DispatchToFunction take a function pointer or instance 37 // and method pointer, and unpack a tuple into arguments to the call. 38 // 39 // Tuple elements are copied by value, and stored in the tuple. See the unit 40 // tests for more details of how/when the values are copied. 41 // 42 // Example usage: 43 // // These two methods of creating a Tuple are identical. 44 // Tuple2<int, const char*> tuple_a(1, "wee"); 45 // Tuple2<int, const char*> tuple_b = MakeTuple(1, "wee"); 46 // 47 // void SomeFunc(int a, const char* b) { } 48 // DispatchToFunction(&SomeFunc, tuple_a); // SomeFunc(1, "wee") 49 // DispatchToFunction( 50 // &SomeFunc, MakeTuple(10, "foo")); // SomeFunc(10, "foo") 51 // 52 // struct { void SomeMeth(int a, int b, int c) { } } foo; 53 // DispatchToMethod(&foo, &Foo::SomeMeth, MakeTuple(1, 2, 3)); 54 // // foo->SomeMeth(1, 2, 3); 55 56 #ifndef CEF_INCLUDE_INTERNAL_CEF_TUPLE_H_ 57 #define CEF_INCLUDE_INTERNAL_CEF_TUPLE_H_ 58 #pragma once 59 60 // If base/tuple.h is included first then exclude this file. This is to 61 // facilitate the use of both base/bind.h and cef_runnable.h in unit tests. 62 #ifndef BASE_TUPLE_H__ 63 64 #if defined(OS_CHROMEOS) 65 // To troubleshoot crosbug.com/7327. 66 #include "base/logging.h" 67 #endif 68 // Traits ---------------------------------------------------------------------- 69 // 70 // A simple traits class for tuple arguments. 71 // 72 // ValueType: the bare, nonref version of a type (same as the type for nonrefs). 73 // RefType: the ref version of a type (same as the type for refs). 74 // ParamType: what type to pass to functions (refs should not be constified). 75 76 template <class P> 77 struct TupleTraits { 78 typedef P ValueType; 79 typedef P& RefType; 80 typedef const P& ParamType; 81 }; 82 83 template <class P> 84 struct TupleTraits<P&> { 85 typedef P ValueType; 86 typedef P& RefType; 87 typedef P& ParamType; 88 }; 89 90 template <class P> 91 struct TupleTypes { }; 92 93 // Tuple ----------------------------------------------------------------------- 94 // 95 // This set of classes is useful for bundling 0 or more heterogeneous data types 96 // into a single variable. The advantage of this is that it greatly simplifies 97 // function objects that need to take an arbitrary number of parameters; see 98 // RunnableMethod and IPC::MessageWithTuple. 99 // 100 // Tuple0 is supplied to act as a 'void' type. It can be used, for example, 101 // when dispatching to a function that accepts no arguments (see the 102 // Dispatchers below). 103 // Tuple1<A> is rarely useful. One such use is when A is non-const ref that you 104 // want filled by the dispatchee, and the tuple is merely a container for that 105 // output (a "tier"). See MakeRefTuple and its usages. 106 107 struct Tuple0 { 108 typedef Tuple0 ValueTuple; 109 typedef Tuple0 RefTuple; 110 typedef Tuple0 ParamTuple; 111 }; 112 113 template <class A> 114 struct Tuple1 { 115 public: 116 typedef A TypeA; 117 118 Tuple1() {} 119 explicit Tuple1(typename TupleTraits<A>::ParamType a) : a(a) {} 120 121 A a; 122 }; 123 124 template <class A, class B> 125 struct Tuple2 { 126 public: 127 typedef A TypeA; 128 typedef B TypeB; 129 130 Tuple2() {} 131 Tuple2(typename TupleTraits<A>::ParamType a, 132 typename TupleTraits<B>::ParamType b) 133 : a(a), b(b) { 134 } 135 136 A a; 137 B b; 138 }; 139 140 template <class A, class B, class C> 141 struct Tuple3 { 142 public: 143 typedef A TypeA; 144 typedef B TypeB; 145 typedef C TypeC; 146 147 Tuple3() {} 148 Tuple3(typename TupleTraits<A>::ParamType a, 149 typename TupleTraits<B>::ParamType b, 150 typename TupleTraits<C>::ParamType c) 151 : a(a), b(b), c(c) { 152 } 153 154 A a; 155 B b; 156 C c; 157 }; 158 159 template <class A, class B, class C, class D> 160 struct Tuple4 { 161 public: 162 typedef A TypeA; 163 typedef B TypeB; 164 typedef C TypeC; 165 typedef D TypeD; 166 167 Tuple4() {} 168 Tuple4(typename TupleTraits<A>::ParamType a, 169 typename TupleTraits<B>::ParamType b, 170 typename TupleTraits<C>::ParamType c, 171 typename TupleTraits<D>::ParamType d) 172 : a(a), b(b), c(c), d(d) { 173 } 174 175 A a; 176 B b; 177 C c; 178 D d; 179 }; 180 181 template <class A, class B, class C, class D, class E> 182 struct Tuple5 { 183 public: 184 typedef A TypeA; 185 typedef B TypeB; 186 typedef C TypeC; 187 typedef D TypeD; 188 typedef E TypeE; 189 190 Tuple5() {} 191 Tuple5(typename TupleTraits<A>::ParamType a, 192 typename TupleTraits<B>::ParamType b, 193 typename TupleTraits<C>::ParamType c, 194 typename TupleTraits<D>::ParamType d, 195 typename TupleTraits<E>::ParamType e) 196 : a(a), b(b), c(c), d(d), e(e) { 197 } 198 199 A a; 200 B b; 201 C c; 202 D d; 203 E e; 204 }; 205 206 template <class A, class B, class C, class D, class E, class F> 207 struct Tuple6 { 208 public: 209 typedef A TypeA; 210 typedef B TypeB; 211 typedef C TypeC; 212 typedef D TypeD; 213 typedef E TypeE; 214 typedef F TypeF; 215 216 Tuple6() {} 217 Tuple6(typename TupleTraits<A>::ParamType a, 218 typename TupleTraits<B>::ParamType b, 219 typename TupleTraits<C>::ParamType c, 220 typename TupleTraits<D>::ParamType d, 221 typename TupleTraits<E>::ParamType e, 222 typename TupleTraits<F>::ParamType f) 223 : a(a), b(b), c(c), d(d), e(e), f(f) { 224 } 225 226 A a; 227 B b; 228 C c; 229 D d; 230 E e; 231 F f; 232 }; 233 234 template <class A, class B, class C, class D, class E, class F, class G> 235 struct Tuple7 { 236 public: 237 typedef A TypeA; 238 typedef B TypeB; 239 typedef C TypeC; 240 typedef D TypeD; 241 typedef E TypeE; 242 typedef F TypeF; 243 typedef G TypeG; 244 245 Tuple7() {} 246 Tuple7(typename TupleTraits<A>::ParamType a, 247 typename TupleTraits<B>::ParamType b, 248 typename TupleTraits<C>::ParamType c, 249 typename TupleTraits<D>::ParamType d, 250 typename TupleTraits<E>::ParamType e, 251 typename TupleTraits<F>::ParamType f, 252 typename TupleTraits<G>::ParamType g) 253 : a(a), b(b), c(c), d(d), e(e), f(f), g(g) { 254 } 255 256 A a; 257 B b; 258 C c; 259 D d; 260 E e; 261 F f; 262 G g; 263 }; 264 265 template <class A, class B, class C, class D, class E, class F, class G, 266 class H> 267 struct Tuple8 { 268 public: 269 typedef A TypeA; 270 typedef B TypeB; 271 typedef C TypeC; 272 typedef D TypeD; 273 typedef E TypeE; 274 typedef F TypeF; 275 typedef G TypeG; 276 typedef H TypeH; 277 278 Tuple8() {} 279 Tuple8(typename TupleTraits<A>::ParamType a, 280 typename TupleTraits<B>::ParamType b, 281 typename TupleTraits<C>::ParamType c, 282 typename TupleTraits<D>::ParamType d, 283 typename TupleTraits<E>::ParamType e, 284 typename TupleTraits<F>::ParamType f, 285 typename TupleTraits<G>::ParamType g, 286 typename TupleTraits<H>::ParamType h) 287 : a(a), b(b), c(c), d(d), e(e), f(f), g(g), h(h) { 288 } 289 290 A a; 291 B b; 292 C c; 293 D d; 294 E e; 295 F f; 296 G g; 297 H h; 298 }; 299 300 // Tuple types ---------------------------------------------------------------- 301 // 302 // Allows for selection of ValueTuple/RefTuple/ParamTuple without needing the 303 // definitions of class types the tuple takes as parameters. 304 305 template <> 306 struct TupleTypes< Tuple0 > { 307 typedef Tuple0 ValueTuple; 308 typedef Tuple0 RefTuple; 309 typedef Tuple0 ParamTuple; 310 }; 311 312 template <class A> 313 struct TupleTypes< Tuple1<A> > { 314 typedef Tuple1<typename TupleTraits<A>::ValueType> ValueTuple; 315 typedef Tuple1<typename TupleTraits<A>::RefType> RefTuple; 316 typedef Tuple1<typename TupleTraits<A>::ParamType> ParamTuple; 317 }; 318 319 template <class A, class B> 320 struct TupleTypes< Tuple2<A, B> > { 321 typedef Tuple2<typename TupleTraits<A>::ValueType, 322 typename TupleTraits<B>::ValueType> ValueTuple; 323 typedef Tuple2<typename TupleTraits<A>::RefType, 324 typename TupleTraits<B>::RefType> RefTuple; 325 typedef Tuple2<typename TupleTraits<A>::ParamType, 326 typename TupleTraits<B>::ParamType> ParamTuple; 327 }; 328 329 template <class A, class B, class C> 330 struct TupleTypes< Tuple3<A, B, C> > { 331 typedef Tuple3<typename TupleTraits<A>::ValueType, 332 typename TupleTraits<B>::ValueType, 333 typename TupleTraits<C>::ValueType> ValueTuple; 334 typedef Tuple3<typename TupleTraits<A>::RefType, 335 typename TupleTraits<B>::RefType, 336 typename TupleTraits<C>::RefType> RefTuple; 337 typedef Tuple3<typename TupleTraits<A>::ParamType, 338 typename TupleTraits<B>::ParamType, 339 typename TupleTraits<C>::ParamType> ParamTuple; 340 }; 341 342 template <class A, class B, class C, class D> 343 struct TupleTypes< Tuple4<A, B, C, D> > { 344 typedef Tuple4<typename TupleTraits<A>::ValueType, 345 typename TupleTraits<B>::ValueType, 346 typename TupleTraits<C>::ValueType, 347 typename TupleTraits<D>::ValueType> ValueTuple; 348 typedef Tuple4<typename TupleTraits<A>::RefType, 349 typename TupleTraits<B>::RefType, 350 typename TupleTraits<C>::RefType, 351 typename TupleTraits<D>::RefType> RefTuple; 352 typedef Tuple4<typename TupleTraits<A>::ParamType, 353 typename TupleTraits<B>::ParamType, 354 typename TupleTraits<C>::ParamType, 355 typename TupleTraits<D>::ParamType> ParamTuple; 356 }; 357 358 template <class A, class B, class C, class D, class E> 359 struct TupleTypes< Tuple5<A, B, C, D, E> > { 360 typedef Tuple5<typename TupleTraits<A>::ValueType, 361 typename TupleTraits<B>::ValueType, 362 typename TupleTraits<C>::ValueType, 363 typename TupleTraits<D>::ValueType, 364 typename TupleTraits<E>::ValueType> ValueTuple; 365 typedef Tuple5<typename TupleTraits<A>::RefType, 366 typename TupleTraits<B>::RefType, 367 typename TupleTraits<C>::RefType, 368 typename TupleTraits<D>::RefType, 369 typename TupleTraits<E>::RefType> RefTuple; 370 typedef Tuple5<typename TupleTraits<A>::ParamType, 371 typename TupleTraits<B>::ParamType, 372 typename TupleTraits<C>::ParamType, 373 typename TupleTraits<D>::ParamType, 374 typename TupleTraits<E>::ParamType> ParamTuple; 375 }; 376 377 template <class A, class B, class C, class D, class E, class F> 378 struct TupleTypes< Tuple6<A, B, C, D, E, F> > { 379 typedef Tuple6<typename TupleTraits<A>::ValueType, 380 typename TupleTraits<B>::ValueType, 381 typename TupleTraits<C>::ValueType, 382 typename TupleTraits<D>::ValueType, 383 typename TupleTraits<E>::ValueType, 384 typename TupleTraits<F>::ValueType> ValueTuple; 385 typedef Tuple6<typename TupleTraits<A>::RefType, 386 typename TupleTraits<B>::RefType, 387 typename TupleTraits<C>::RefType, 388 typename TupleTraits<D>::RefType, 389 typename TupleTraits<E>::RefType, 390 typename TupleTraits<F>::RefType> RefTuple; 391 typedef Tuple6<typename TupleTraits<A>::ParamType, 392 typename TupleTraits<B>::ParamType, 393 typename TupleTraits<C>::ParamType, 394 typename TupleTraits<D>::ParamType, 395 typename TupleTraits<E>::ParamType, 396 typename TupleTraits<F>::ParamType> ParamTuple; 397 }; 398 399 template <class A, class B, class C, class D, class E, class F, class G> 400 struct TupleTypes< Tuple7<A, B, C, D, E, F, G> > { 401 typedef Tuple7<typename TupleTraits<A>::ValueType, 402 typename TupleTraits<B>::ValueType, 403 typename TupleTraits<C>::ValueType, 404 typename TupleTraits<D>::ValueType, 405 typename TupleTraits<E>::ValueType, 406 typename TupleTraits<F>::ValueType, 407 typename TupleTraits<G>::ValueType> ValueTuple; 408 typedef Tuple7<typename TupleTraits<A>::RefType, 409 typename TupleTraits<B>::RefType, 410 typename TupleTraits<C>::RefType, 411 typename TupleTraits<D>::RefType, 412 typename TupleTraits<E>::RefType, 413 typename TupleTraits<F>::RefType, 414 typename TupleTraits<G>::RefType> RefTuple; 415 typedef Tuple7<typename TupleTraits<A>::ParamType, 416 typename TupleTraits<B>::ParamType, 417 typename TupleTraits<C>::ParamType, 418 typename TupleTraits<D>::ParamType, 419 typename TupleTraits<E>::ParamType, 420 typename TupleTraits<F>::ParamType, 421 typename TupleTraits<G>::ParamType> ParamTuple; 422 }; 423 424 template <class A, class B, class C, class D, class E, class F, class G, 425 class H> 426 struct TupleTypes< Tuple8<A, B, C, D, E, F, G, H> > { 427 typedef Tuple8<typename TupleTraits<A>::ValueType, 428 typename TupleTraits<B>::ValueType, 429 typename TupleTraits<C>::ValueType, 430 typename TupleTraits<D>::ValueType, 431 typename TupleTraits<E>::ValueType, 432 typename TupleTraits<F>::ValueType, 433 typename TupleTraits<G>::ValueType, 434 typename TupleTraits<H>::ValueType> ValueTuple; 435 typedef Tuple8<typename TupleTraits<A>::RefType, 436 typename TupleTraits<B>::RefType, 437 typename TupleTraits<C>::RefType, 438 typename TupleTraits<D>::RefType, 439 typename TupleTraits<E>::RefType, 440 typename TupleTraits<F>::RefType, 441 typename TupleTraits<G>::RefType, 442 typename TupleTraits<H>::RefType> RefTuple; 443 typedef Tuple8<typename TupleTraits<A>::ParamType, 444 typename TupleTraits<B>::ParamType, 445 typename TupleTraits<C>::ParamType, 446 typename TupleTraits<D>::ParamType, 447 typename TupleTraits<E>::ParamType, 448 typename TupleTraits<F>::ParamType, 449 typename TupleTraits<G>::ParamType, 450 typename TupleTraits<H>::ParamType> ParamTuple; 451 }; 452 453 // Tuple creators ------------------------------------------------------------- 454 // 455 // Helper functions for constructing tuples while inferring the template 456 // argument types. 457 458 inline Tuple0 MakeTuple() { 459 return Tuple0(); 460 } 461 462 template <class A> 463 inline Tuple1<A> MakeTuple(const A& a) { 464 return Tuple1<A>(a); 465 } 466 467 template <class A, class B> 468 inline Tuple2<A, B> MakeTuple(const A& a, const B& b) { 469 return Tuple2<A, B>(a, b); 470 } 471 472 template <class A, class B, class C> 473 inline Tuple3<A, B, C> MakeTuple(const A& a, const B& b, const C& c) { 474 return Tuple3<A, B, C>(a, b, c); 475 } 476 477 template <class A, class B, class C, class D> 478 inline Tuple4<A, B, C, D> MakeTuple(const A& a, const B& b, const C& c, 479 const D& d) { 480 return Tuple4<A, B, C, D>(a, b, c, d); 481 } 482 483 template <class A, class B, class C, class D, class E> 484 inline Tuple5<A, B, C, D, E> MakeTuple(const A& a, const B& b, const C& c, 485 const D& d, const E& e) { 486 return Tuple5<A, B, C, D, E>(a, b, c, d, e); 487 } 488 489 template <class A, class B, class C, class D, class E, class F> 490 inline Tuple6<A, B, C, D, E, F> MakeTuple(const A& a, const B& b, const C& c, 491 const D& d, const E& e, const F& f) { 492 return Tuple6<A, B, C, D, E, F>(a, b, c, d, e, f); 493 } 494 495 template <class A, class B, class C, class D, class E, class F, class G> 496 inline Tuple7<A, B, C, D, E, F, G> MakeTuple(const A& a, const B& b, const C& c, 497 const D& d, const E& e, const F& f, 498 const G& g) { 499 return Tuple7<A, B, C, D, E, F, G>(a, b, c, d, e, f, g); 500 } 501 502 template <class A, class B, class C, class D, class E, class F, class G, 503 class H> 504 inline Tuple8<A, B, C, D, E, F, G, H> MakeTuple(const A& a, const B& b, 505 const C& c, const D& d, 506 const E& e, const F& f, 507 const G& g, const H& h) { 508 return Tuple8<A, B, C, D, E, F, G, H>(a, b, c, d, e, f, g, h); 509 } 510 511 // The following set of helpers make what Boost refers to as "Tiers" - a tuple 512 // of references. 513 514 template <class A> 515 inline Tuple1<A&> MakeRefTuple(A& a) { 516 return Tuple1<A&>(a); 517 } 518 519 template <class A, class B> 520 inline Tuple2<A&, B&> MakeRefTuple(A& a, B& b) { 521 return Tuple2<A&, B&>(a, b); 522 } 523 524 template <class A, class B, class C> 525 inline Tuple3<A&, B&, C&> MakeRefTuple(A& a, B& b, C& c) { 526 return Tuple3<A&, B&, C&>(a, b, c); 527 } 528 529 template <class A, class B, class C, class D> 530 inline Tuple4<A&, B&, C&, D&> MakeRefTuple(A& a, B& b, C& c, D& d) { 531 return Tuple4<A&, B&, C&, D&>(a, b, c, d); 532 } 533 534 template <class A, class B, class C, class D, class E> 535 inline Tuple5<A&, B&, C&, D&, E&> MakeRefTuple(A& a, B& b, C& c, D& d, E& e) { 536 return Tuple5<A&, B&, C&, D&, E&>(a, b, c, d, e); 537 } 538 539 template <class A, class B, class C, class D, class E, class F> 540 inline Tuple6<A&, B&, C&, D&, E&, F&> MakeRefTuple(A& a, B& b, C& c, D& d, E& e, 541 F& f) { 542 return Tuple6<A&, B&, C&, D&, E&, F&>(a, b, c, d, e, f); 543 } 544 545 template <class A, class B, class C, class D, class E, class F, class G> 546 inline Tuple7<A&, B&, C&, D&, E&, F&, G&> MakeRefTuple(A& a, B& b, C& c, D& d, 547 E& e, F& f, G& g) { 548 return Tuple7<A&, B&, C&, D&, E&, F&, G&>(a, b, c, d, e, f, g); 549 } 550 551 template <class A, class B, class C, class D, class E, class F, class G, 552 class H> 553 inline Tuple8<A&, B&, C&, D&, E&, F&, G&, H&> MakeRefTuple(A& a, B& b, C& c, 554 D& d, E& e, F& f, 555 G& g, H& h) { 556 return Tuple8<A&, B&, C&, D&, E&, F&, G&, H&>(a, b, c, d, e, f, g, h); 557 } 558 559 // Dispatchers ---------------------------------------------------------------- 560 // 561 // Helper functions that call the given method on an object, with the unpacked 562 // tuple arguments. Notice that they all have the same number of arguments, 563 // so you need only write: 564 // DispatchToMethod(object, &Object::method, args); 565 // This is very useful for templated dispatchers, since they don't need to know 566 // what type |args| is. 567 568 // Non-Static Dispatchers with no out params. 569 570 template <class ObjT, class Method> 571 inline void DispatchToMethod(ObjT* obj, Method method, const Tuple0& arg) { 572 (obj->*method)(); 573 } 574 575 template <class ObjT, class Method, class A> 576 inline void DispatchToMethod(ObjT* obj, Method method, const A& arg) { 577 (obj->*method)(arg); 578 } 579 580 template <class ObjT, class Method, class A> 581 inline void DispatchToMethod(ObjT* obj, Method method, const Tuple1<A>& arg) { 582 #if defined(OS_CHROMEOS) 583 // To troubleshoot crosbug.com/7327. 584 CHECK(obj); 585 CHECK(&arg); 586 CHECK(method); 587 #endif 588 (obj->*method)(arg.a); 589 } 590 591 template<class ObjT, class Method, class A, class B> 592 inline void DispatchToMethod(ObjT* obj, 593 Method method, 594 const Tuple2<A, B>& arg) { 595 (obj->*method)(arg.a, arg.b); 596 } 597 598 template<class ObjT, class Method, class A, class B, class C> 599 inline void DispatchToMethod(ObjT* obj, Method method, 600 const Tuple3<A, B, C>& arg) { 601 (obj->*method)(arg.a, arg.b, arg.c); 602 } 603 604 template<class ObjT, class Method, class A, class B, class C, class D> 605 inline void DispatchToMethod(ObjT* obj, Method method, 606 const Tuple4<A, B, C, D>& arg) { 607 (obj->*method)(arg.a, arg.b, arg.c, arg.d); 608 } 609 610 template<class ObjT, class Method, class A, class B, class C, class D, class E> 611 inline void DispatchToMethod(ObjT* obj, Method method, 612 const Tuple5<A, B, C, D, E>& arg) { 613 (obj->*method)(arg.a, arg.b, arg.c, arg.d, arg.e); 614 } 615 616 template<class ObjT, class Method, class A, class B, class C, class D, class E, 617 class F> 618 inline void DispatchToMethod(ObjT* obj, Method method, 619 const Tuple6<A, B, C, D, E, F>& arg) { 620 (obj->*method)(arg.a, arg.b, arg.c, arg.d, arg.e, arg.f); 621 } 622 623 template<class ObjT, class Method, class A, class B, class C, class D, class E, 624 class F, class G> 625 inline void DispatchToMethod(ObjT* obj, Method method, 626 const Tuple7<A, B, C, D, E, F, G>& arg) { 627 (obj->*method)(arg.a, arg.b, arg.c, arg.d, arg.e, arg.f, arg.g); 628 } 629 630 // Static Dispatchers with no out params. 631 632 template <class Function> 633 inline void DispatchToFunction(Function function, const Tuple0& arg) { 634 (*function)(); 635 } 636 637 template <class Function, class A> 638 inline void DispatchToFunction(Function function, const A& arg) { 639 (*function)(arg); 640 } 641 642 template <class Function, class A> 643 inline void DispatchToFunction(Function function, const Tuple1<A>& arg) { 644 (*function)(arg.a); 645 } 646 647 template<class Function, class A, class B> 648 inline void DispatchToFunction(Function function, const Tuple2<A, B>& arg) { 649 (*function)(arg.a, arg.b); 650 } 651 652 template<class Function, class A, class B, class C> 653 inline void DispatchToFunction(Function function, const Tuple3<A, B, C>& arg) { 654 (*function)(arg.a, arg.b, arg.c); 655 } 656 657 template<class Function, class A, class B, class C, class D> 658 inline void DispatchToFunction(Function function, 659 const Tuple4<A, B, C, D>& arg) { 660 (*function)(arg.a, arg.b, arg.c, arg.d); 661 } 662 663 template<class Function, class A, class B, class C, class D, class E> 664 inline void DispatchToFunction(Function function, 665 const Tuple5<A, B, C, D, E>& arg) { 666 (*function)(arg.a, arg.b, arg.c, arg.d, arg.e); 667 } 668 669 template<class Function, class A, class B, class C, class D, class E, class F> 670 inline void DispatchToFunction(Function function, 671 const Tuple6<A, B, C, D, E, F>& arg) { 672 (*function)(arg.a, arg.b, arg.c, arg.d, arg.e, arg.f); 673 } 674 675 template<class Function, class A, class B, class C, class D, class E, class F, 676 class G> 677 inline void DispatchToFunction(Function function, 678 const Tuple7<A, B, C, D, E, F, G>& arg) { 679 (*function)(arg.a, arg.b, arg.c, arg.d, arg.e, arg.f, arg.g); 680 } 681 682 template<class Function, class A, class B, class C, class D, class E, class F, 683 class G, class H> 684 inline void DispatchToFunction(Function function, 685 const Tuple8<A, B, C, D, E, F, G, H>& arg) { 686 (*function)(arg.a, arg.b, arg.c, arg.d, arg.e, arg.f, arg.g, arg.h); 687 } 688 689 // Dispatchers with 0 out param (as a Tuple0). 690 691 template <class ObjT, class Method> 692 inline void DispatchToMethod(ObjT* obj, 693 Method method, 694 const Tuple0& arg, Tuple0*) { 695 (obj->*method)(); 696 } 697 698 template <class ObjT, class Method, class A> 699 inline void DispatchToMethod(ObjT* obj, Method method, const A& arg, Tuple0*) { 700 (obj->*method)(arg); 701 } 702 703 template <class ObjT, class Method, class A> 704 inline void DispatchToMethod(ObjT* obj, 705 Method method, 706 const Tuple1<A>& arg, Tuple0*) { 707 (obj->*method)(arg.a); 708 } 709 710 template<class ObjT, class Method, class A, class B> 711 inline void DispatchToMethod(ObjT* obj, 712 Method method, 713 const Tuple2<A, B>& arg, Tuple0*) { 714 (obj->*method)(arg.a, arg.b); 715 } 716 717 template<class ObjT, class Method, class A, class B, class C> 718 inline void DispatchToMethod(ObjT* obj, Method method, 719 const Tuple3<A, B, C>& arg, Tuple0*) { 720 (obj->*method)(arg.a, arg.b, arg.c); 721 } 722 723 template<class ObjT, class Method, class A, class B, class C, class D> 724 inline void DispatchToMethod(ObjT* obj, Method method, 725 const Tuple4<A, B, C, D>& arg, Tuple0*) { 726 (obj->*method)(arg.a, arg.b, arg.c, arg.d); 727 } 728 729 template<class ObjT, class Method, class A, class B, class C, class D, class E> 730 inline void DispatchToMethod(ObjT* obj, Method method, 731 const Tuple5<A, B, C, D, E>& arg, Tuple0*) { 732 (obj->*method)(arg.a, arg.b, arg.c, arg.d, arg.e); 733 } 734 735 template<class ObjT, class Method, class A, class B, class C, class D, class E, 736 class F> 737 inline void DispatchToMethod(ObjT* obj, Method method, 738 const Tuple6<A, B, C, D, E, F>& arg, Tuple0*) { 739 (obj->*method)(arg.a, arg.b, arg.c, arg.d, arg.e, arg.f); 740 } 741 742 // Dispatchers with 1 out param. 743 744 template<class ObjT, class Method, 745 class OutA> 746 inline void DispatchToMethod(ObjT* obj, Method method, 747 const Tuple0& in, 748 Tuple1<OutA>* out) { 749 (obj->*method)(&out->a); 750 } 751 752 template<class ObjT, class Method, class InA, 753 class OutA> 754 inline void DispatchToMethod(ObjT* obj, Method method, 755 const InA& in, 756 Tuple1<OutA>* out) { 757 (obj->*method)(in, &out->a); 758 } 759 760 template<class ObjT, class Method, class InA, 761 class OutA> 762 inline void DispatchToMethod(ObjT* obj, Method method, 763 const Tuple1<InA>& in, 764 Tuple1<OutA>* out) { 765 (obj->*method)(in.a, &out->a); 766 } 767 768 template<class ObjT, class Method, class InA, class InB, 769 class OutA> 770 inline void DispatchToMethod(ObjT* obj, Method method, 771 const Tuple2<InA, InB>& in, 772 Tuple1<OutA>* out) { 773 (obj->*method)(in.a, in.b, &out->a); 774 } 775 776 template<class ObjT, class Method, class InA, class InB, class InC, 777 class OutA> 778 inline void DispatchToMethod(ObjT* obj, Method method, 779 const Tuple3<InA, InB, InC>& in, 780 Tuple1<OutA>* out) { 781 (obj->*method)(in.a, in.b, in.c, &out->a); 782 } 783 784 template<class ObjT, class Method, class InA, class InB, class InC, class InD, 785 class OutA> 786 inline void DispatchToMethod(ObjT* obj, Method method, 787 const Tuple4<InA, InB, InC, InD>& in, 788 Tuple1<OutA>* out) { 789 (obj->*method)(in.a, in.b, in.c, in.d, &out->a); 790 } 791 792 template<class ObjT, class Method, class InA, class InB, class InC, class InD, 793 class InE, class OutA> 794 inline void DispatchToMethod(ObjT* obj, Method method, 795 const Tuple5<InA, InB, InC, InD, InE>& in, 796 Tuple1<OutA>* out) { 797 (obj->*method)(in.a, in.b, in.c, in.d, in.e, &out->a); 798 } 799 800 template<class ObjT, class Method, 801 class InA, class InB, class InC, class InD, class InE, class InF, 802 class OutA> 803 inline void DispatchToMethod(ObjT* obj, Method method, 804 const Tuple6<InA, InB, InC, InD, InE, InF>& in, 805 Tuple1<OutA>* out) { 806 (obj->*method)(in.a, in.b, in.c, in.d, in.e, in.f, &out->a); 807 } 808 809 // Dispatchers with 2 out params. 810 811 template<class ObjT, class Method, 812 class OutA, class OutB> 813 inline void DispatchToMethod(ObjT* obj, Method method, 814 const Tuple0& in, 815 Tuple2<OutA, OutB>* out) { 816 (obj->*method)(&out->a, &out->b); 817 } 818 819 template<class ObjT, class Method, class InA, 820 class OutA, class OutB> 821 inline void DispatchToMethod(ObjT* obj, Method method, 822 const InA& in, 823 Tuple2<OutA, OutB>* out) { 824 (obj->*method)(in, &out->a, &out->b); 825 } 826 827 template<class ObjT, class Method, class InA, 828 class OutA, class OutB> 829 inline void DispatchToMethod(ObjT* obj, Method method, 830 const Tuple1<InA>& in, 831 Tuple2<OutA, OutB>* out) { 832 (obj->*method)(in.a, &out->a, &out->b); 833 } 834 835 template<class ObjT, class Method, class InA, class InB, 836 class OutA, class OutB> 837 inline void DispatchToMethod(ObjT* obj, Method method, 838 const Tuple2<InA, InB>& in, 839 Tuple2<OutA, OutB>* out) { 840 (obj->*method)(in.a, in.b, &out->a, &out->b); 841 } 842 843 template<class ObjT, class Method, class InA, class InB, class InC, 844 class OutA, class OutB> 845 inline void DispatchToMethod(ObjT* obj, Method method, 846 const Tuple3<InA, InB, InC>& in, 847 Tuple2<OutA, OutB>* out) { 848 (obj->*method)(in.a, in.b, in.c, &out->a, &out->b); 849 } 850 851 template<class ObjT, class Method, class InA, class InB, class InC, class InD, 852 class OutA, class OutB> 853 inline void DispatchToMethod(ObjT* obj, Method method, 854 const Tuple4<InA, InB, InC, InD>& in, 855 Tuple2<OutA, OutB>* out) { 856 (obj->*method)(in.a, in.b, in.c, in.d, &out->a, &out->b); 857 } 858 859 template<class ObjT, class Method, 860 class InA, class InB, class InC, class InD, class InE, 861 class OutA, class OutB> 862 inline void DispatchToMethod(ObjT* obj, Method method, 863 const Tuple5<InA, InB, InC, InD, InE>& in, 864 Tuple2<OutA, OutB>* out) { 865 (obj->*method)(in.a, in.b, in.c, in.d, in.e, &out->a, &out->b); 866 } 867 868 template<class ObjT, class Method, 869 class InA, class InB, class InC, class InD, class InE, class InF, 870 class OutA, class OutB> 871 inline void DispatchToMethod(ObjT* obj, Method method, 872 const Tuple6<InA, InB, InC, InD, InE, InF>& in, 873 Tuple2<OutA, OutB>* out) { 874 (obj->*method)(in.a, in.b, in.c, in.d, in.e, in.f, &out->a, &out->b); 875 } 876 877 // Dispatchers with 3 out params. 878 879 template<class ObjT, class Method, 880 class OutA, class OutB, class OutC> 881 inline void DispatchToMethod(ObjT* obj, Method method, 882 const Tuple0& in, 883 Tuple3<OutA, OutB, OutC>* out) { 884 (obj->*method)(&out->a, &out->b, &out->c); 885 } 886 887 template<class ObjT, class Method, class InA, 888 class OutA, class OutB, class OutC> 889 inline void DispatchToMethod(ObjT* obj, Method method, 890 const InA& in, 891 Tuple3<OutA, OutB, OutC>* out) { 892 (obj->*method)(in, &out->a, &out->b, &out->c); 893 } 894 895 template<class ObjT, class Method, class InA, 896 class OutA, class OutB, class OutC> 897 inline void DispatchToMethod(ObjT* obj, Method method, 898 const Tuple1<InA>& in, 899 Tuple3<OutA, OutB, OutC>* out) { 900 (obj->*method)(in.a, &out->a, &out->b, &out->c); 901 } 902 903 template<class ObjT, class Method, class InA, class InB, 904 class OutA, class OutB, class OutC> 905 inline void DispatchToMethod(ObjT* obj, Method method, 906 const Tuple2<InA, InB>& in, 907 Tuple3<OutA, OutB, OutC>* out) { 908 (obj->*method)(in.a, in.b, &out->a, &out->b, &out->c); 909 } 910 911 template<class ObjT, class Method, class InA, class InB, class InC, 912 class OutA, class OutB, class OutC> 913 inline void DispatchToMethod(ObjT* obj, Method method, 914 const Tuple3<InA, InB, InC>& in, 915 Tuple3<OutA, OutB, OutC>* out) { 916 (obj->*method)(in.a, in.b, in.c, &out->a, &out->b, &out->c); 917 } 918 919 template<class ObjT, class Method, class InA, class InB, class InC, class InD, 920 class OutA, class OutB, class OutC> 921 inline void DispatchToMethod(ObjT* obj, Method method, 922 const Tuple4<InA, InB, InC, InD>& in, 923 Tuple3<OutA, OutB, OutC>* out) { 924 (obj->*method)(in.a, in.b, in.c, in.d, &out->a, &out->b, &out->c); 925 } 926 927 template<class ObjT, class Method, 928 class InA, class InB, class InC, class InD, class InE, 929 class OutA, class OutB, class OutC> 930 inline void DispatchToMethod(ObjT* obj, Method method, 931 const Tuple5<InA, InB, InC, InD, InE>& in, 932 Tuple3<OutA, OutB, OutC>* out) { 933 (obj->*method)(in.a, in.b, in.c, in.d, in.e, &out->a, &out->b, &out->c); 934 } 935 936 template<class ObjT, class Method, 937 class InA, class InB, class InC, class InD, class InE, class InF, 938 class OutA, class OutB, class OutC> 939 inline void DispatchToMethod(ObjT* obj, Method method, 940 const Tuple6<InA, InB, InC, InD, InE, InF>& in, 941 Tuple3<OutA, OutB, OutC>* out) { 942 (obj->*method)(in.a, in.b, in.c, in.d, in.e, in.f, &out->a, &out->b, &out->c); 943 } 944 945 // Dispatchers with 4 out params. 946 947 template<class ObjT, class Method, 948 class OutA, class OutB, class OutC, class OutD> 949 inline void DispatchToMethod(ObjT* obj, Method method, 950 const Tuple0& in, 951 Tuple4<OutA, OutB, OutC, OutD>* out) { 952 (obj->*method)(&out->a, &out->b, &out->c, &out->d); 953 } 954 955 template<class ObjT, class Method, class InA, 956 class OutA, class OutB, class OutC, class OutD> 957 inline void DispatchToMethod(ObjT* obj, Method method, 958 const InA& in, 959 Tuple4<OutA, OutB, OutC, OutD>* out) { 960 (obj->*method)(in, &out->a, &out->b, &out->c, &out->d); 961 } 962 963 template<class ObjT, class Method, class InA, 964 class OutA, class OutB, class OutC, class OutD> 965 inline void DispatchToMethod(ObjT* obj, Method method, 966 const Tuple1<InA>& in, 967 Tuple4<OutA, OutB, OutC, OutD>* out) { 968 (obj->*method)(in.a, &out->a, &out->b, &out->c, &out->d); 969 } 970 971 template<class ObjT, class Method, class InA, class InB, 972 class OutA, class OutB, class OutC, class OutD> 973 inline void DispatchToMethod(ObjT* obj, Method method, 974 const Tuple2<InA, InB>& in, 975 Tuple4<OutA, OutB, OutC, OutD>* out) { 976 (obj->*method)(in.a, in.b, &out->a, &out->b, &out->c, &out->d); 977 } 978 979 template<class ObjT, class Method, class InA, class InB, class InC, 980 class OutA, class OutB, class OutC, class OutD> 981 inline void DispatchToMethod(ObjT* obj, Method method, 982 const Tuple3<InA, InB, InC>& in, 983 Tuple4<OutA, OutB, OutC, OutD>* out) { 984 (obj->*method)(in.a, in.b, in.c, &out->a, &out->b, &out->c, &out->d); 985 } 986 987 template<class ObjT, class Method, class InA, class InB, class InC, class InD, 988 class OutA, class OutB, class OutC, class OutD> 989 inline void DispatchToMethod(ObjT* obj, Method method, 990 const Tuple4<InA, InB, InC, InD>& in, 991 Tuple4<OutA, OutB, OutC, OutD>* out) { 992 (obj->*method)(in.a, in.b, in.c, in.d, &out->a, &out->b, &out->c, &out->d); 993 } 994 995 template<class ObjT, class Method, 996 class InA, class InB, class InC, class InD, class InE, 997 class OutA, class OutB, class OutC, class OutD> 998 inline void DispatchToMethod(ObjT* obj, Method method, 999 const Tuple5<InA, InB, InC, InD, InE>& in, 1000 Tuple4<OutA, OutB, OutC, OutD>* out) { 1001 (obj->*method)(in.a, in.b, in.c, in.d, in.e, 1002 &out->a, &out->b, &out->c, &out->d); 1003 } 1004 1005 template<class ObjT, class Method, 1006 class InA, class InB, class InC, class InD, class InE, class InF, 1007 class OutA, class OutB, class OutC, class OutD> 1008 inline void DispatchToMethod(ObjT* obj, Method method, 1009 const Tuple6<InA, InB, InC, InD, InE, InF>& in, 1010 Tuple4<OutA, OutB, OutC, OutD>* out) { 1011 (obj->*method)(in.a, in.b, in.c, in.d, in.e, in.f, 1012 &out->a, &out->b, &out->c, &out->d); 1013 } 1014 1015 // Dispatchers with 5 out params. 1016 1017 template<class ObjT, class Method, 1018 class OutA, class OutB, class OutC, class OutD, class OutE> 1019 inline void DispatchToMethod(ObjT* obj, Method method, 1020 const Tuple0& in, 1021 Tuple5<OutA, OutB, OutC, OutD, OutE>* out) { 1022 (obj->*method)(&out->a, &out->b, &out->c, &out->d, &out->e); 1023 } 1024 1025 template<class ObjT, class Method, class InA, 1026 class OutA, class OutB, class OutC, class OutD, class OutE> 1027 inline void DispatchToMethod(ObjT* obj, Method method, 1028 const InA& in, 1029 Tuple5<OutA, OutB, OutC, OutD, OutE>* out) { 1030 (obj->*method)(in, &out->a, &out->b, &out->c, &out->d, &out->e); 1031 } 1032 1033 template<class ObjT, class Method, class InA, 1034 class OutA, class OutB, class OutC, class OutD, class OutE> 1035 inline void DispatchToMethod(ObjT* obj, Method method, 1036 const Tuple1<InA>& in, 1037 Tuple5<OutA, OutB, OutC, OutD, OutE>* out) { 1038 (obj->*method)(in.a, &out->a, &out->b, &out->c, &out->d, &out->e); 1039 } 1040 1041 template<class ObjT, class Method, class InA, class InB, 1042 class OutA, class OutB, class OutC, class OutD, class OutE> 1043 inline void DispatchToMethod(ObjT* obj, Method method, 1044 const Tuple2<InA, InB>& in, 1045 Tuple5<OutA, OutB, OutC, OutD, OutE>* out) { 1046 (obj->*method)(in.a, in.b, &out->a, &out->b, &out->c, &out->d, &out->e); 1047 } 1048 1049 template<class ObjT, class Method, class InA, class InB, class InC, 1050 class OutA, class OutB, class OutC, class OutD, class OutE> 1051 inline void DispatchToMethod(ObjT* obj, Method method, 1052 const Tuple3<InA, InB, InC>& in, 1053 Tuple5<OutA, OutB, OutC, OutD, OutE>* out) { 1054 (obj->*method)(in.a, in.b, in.c, &out->a, &out->b, &out->c, &out->d, &out->e); 1055 } 1056 1057 template<class ObjT, class Method, class InA, class InB, class InC, class InD, 1058 class OutA, class OutB, class OutC, class OutD, class OutE> 1059 inline void DispatchToMethod(ObjT* obj, Method method, 1060 const Tuple4<InA, InB, InC, InD>& in, 1061 Tuple5<OutA, OutB, OutC, OutD, OutE>* out) { 1062 (obj->*method)(in.a, in.b, in.c, in.d, &out->a, &out->b, &out->c, &out->d, 1063 &out->e); 1064 } 1065 1066 template<class ObjT, class Method, 1067 class InA, class InB, class InC, class InD, class InE, 1068 class OutA, class OutB, class OutC, class OutD, class OutE> 1069 inline void DispatchToMethod(ObjT* obj, Method method, 1070 const Tuple5<InA, InB, InC, InD, InE>& in, 1071 Tuple5<OutA, OutB, OutC, OutD, OutE>* out) { 1072 (obj->*method)(in.a, in.b, in.c, in.d, in.e, 1073 &out->a, &out->b, &out->c, &out->d, &out->e); 1074 } 1075 1076 template<class ObjT, class Method, 1077 class InA, class InB, class InC, class InD, class InE, class InF, 1078 class OutA, class OutB, class OutC, class OutD, class OutE> 1079 inline void DispatchToMethod(ObjT* obj, Method method, 1080 const Tuple6<InA, InB, InC, InD, InE, InF>& in, 1081 Tuple5<OutA, OutB, OutC, OutD, OutE>* out) { 1082 (obj->*method)(in.a, in.b, in.c, in.d, in.e, in.f, 1083 &out->a, &out->b, &out->c, &out->d, &out->e); 1084 } 1085 1086 #endif // BASE_TUPLE_H__ 1087 1088 #endif // CEF_INCLUDE_INTERNAL_CEF_TUPLE_H_