
Hi,
I'd like to define an abstract state which reacts to a specific event
and calls a virtual hook function. In classes which inherit from my base
class, I'd like to define those hooks.
struct EvHeartBeat : boost::statechart::event<EvHeartBeat> {};
struct EvMyFoo : boost::statechart::event<EvMyFoo> {};
// this is my base class
template< class MostDerived,
class Context,
class InnerInitial = boost::mpl::list<>,
boost::statechart::history_mode historyMode =
boost::statechart::has_no_history >
struct BaseState :
public boost::statechart::simple_state<
MostDerived, Context, InnerInitial, historyMode >
{
typedef BaseState< MostDerived,
Context, InnerInitial, historyMode > base_state;
typedef boost::mpl::list<
boost::statechart::custom_reaction< EvHeartBeat > > reactions;
const std::string name;
virtual boost::statechart::result hook() = 0;
boost::statechart::result react ( const EvHeartBeat& e)
{
return hook();
}
};
// this is my derived class
struct B :
BaseState
{
typedef boost::mpl::list<
boost::statechart::custom_reaction<EvMyBar>
> my_reactions;
typedef boost::mpl::insert_range