00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012 #ifndef MTL_MULTI_ACTION_BLOCK_INCLUDE
00013 #define MTL_MULTI_ACTION_BLOCK_INCLUDE
00014
00015 namespace mtl {
00016
00017
00018
00019
00020
00021
00022 template <typename MultiAction, unsigned Steps> struct multi_action_block;
00023
00024
00025 template <typename MultiAction, unsigned MaxSteps, unsigned RemainingSteps>
00026 struct multi_action_helper
00027 {
00028 static unsigned const step= MaxSteps - RemainingSteps;
00029
00030 void operator() (MultiAction const& action) const
00031 {
00032 action(step);
00033 multi_action_helper<MultiAction, MaxSteps, RemainingSteps-1>()(action);
00034 }
00035
00036 void operator() (MultiAction& action) const
00037 {
00038 action(step);
00039 multi_action_helper<MultiAction, MaxSteps, RemainingSteps-1>()(action);
00040 }
00041 };
00042
00043
00044 template <typename MultiAction, unsigned MaxSteps>
00045 struct multi_action_helper<MultiAction, MaxSteps, 1>
00046 {
00047 static unsigned const step= MaxSteps - 1;
00048
00049 void operator() (MultiAction const& action) const
00050 {
00051 action(step);
00052 }
00053
00054 void operator() (MultiAction& action) const
00055 {
00056 action(step);
00057 }
00058 };
00059
00060
00061 template <typename MultiAction, unsigned Steps>
00062 struct multi_action_block
00063 {
00064 void operator() (MultiAction const& action) const
00065 {
00066 multi_action_helper<MultiAction, Steps, Steps>()(action);
00067 }
00068
00069 void operator() (MultiAction& action) const
00070 {
00071 multi_action_helper<MultiAction, Steps, Steps>()(action);
00072 }
00073 };
00074
00075
00076
00077 }
00078
00079 #endif // MTL_MULTI_ACTION_BLOCK_INCLUDE