I have here a proprietary implementation of a generic state machine that uses a std::tr1::tuple
as a transition table:
template<State StartState, Event TriggerEvent, State TargetState>
struct transition {...};
typedef std::tr1::tuple< transition< ready , run , running >
, transition< running , terminate, terminating >
, transition< terminating, finish , terminated >
> transition_table;
There's a function
template<typename Transitions>
State find_next_state( State current
, Event event
, const Transitions& transition_table );
to find the next state in the transition table given a current state and an event.
This all works fine except for this platform's tuple
implementation not supporting more than 10 items. The same seems to be true for boost::tuple
, so I am trying to employ boost::fusion::vector
instead. But it seems fusion's find_if
only takes "a unary MPL Lambda Expression" — which, I suppose, only works at compile time.
So given the above, how can I implement find_next_state()
?
Note:
This a proprietary embedded platform that supplies only GCC 4.1.2, so we're stuck with C++03+TR1.