#include <FXGenericTools.h>
This generates at compile-time a jump table within the read-only section of the binary consisting of addresses of the static function instance<type>::Do
where type is the type within the typelist from index 0 to the length of the typelist. At run-time the index specified is used to lookup the address of the function and to call it with any set of parameters. This allows you to very efficiently call type specialised code where the type is known only at run time and is a boon for writing modular extensible code which is both type safe and efficient. It also totally removes the bloat associated with sets of if...else statements as there is one routine & table reused by all instances of usage throughout a binary.
If the search does not match (eg; the index is out of range), instance::Do instantiated with NullType
is called. Note that like instantiateH parameters are always passed by value.
Usage looks like as follows:
template<typename type> struct Impl { static void Do(<pars>); } Generic::TL::dynamicAt<typelist, Impl>(typeIdx, <pars>);
Public Member Functions | |
dynamicAt (FXuint idx) | |
template<typename P1> | |
dynamicAt (FXuint idx, P1 p1) | |
template<typename P1, typename P2> | |
dynamicAt (FXuint idx, P1 p1, P2 p2) | |
template<typename P1, typename P2, typename P3> | |
dynamicAt (FXuint idx, P1 p1, P2 p2, P3 p3) | |
template<typename P1, typename P2, typename P3, typename P4> | |
dynamicAt (FXuint idx, P1 p1, P2 p2, P3 p3, P4 p4) | |
Static Public Attributes | |
static const FXuint | MaxEntries |
static const FXuint | DisableMagicIdx |
FX::Generic::TL::dynamicAt< typelist, instance >::dynamicAt | ( | FXuint | idx | ) | [inline] |
Invoke instance with the type idx in the typelist.
FX::Generic::TL::dynamicAt< typelist, instance >::dynamicAt | ( | FXuint | idx, | |
P1 | p1 | |||
) | [inline] |
Invoke instance with the type idx in the typelist with parameters.
const FXuint FX::Generic::TL::dynamicAt< typelist, instance >::MaxEntries [static] |
Currently the maximum members permitted in a typelist.
const FXuint FX::Generic::TL::dynamicAt< typelist, instance >::DisableMagicIdx [static] |
The magic idx value to disable dispatch