Chris@16: // Copyright 2008 Christophe Henry Chris@16: // henry UNDERSCORE christophe AT hotmail DOT com Chris@16: // This is an extended version of the state machine available in the boost::mpl library Chris@16: // Distributed under the same license as the original. Chris@16: // Copyright for the original version: Chris@16: // Copyright 2005 David Abrahams and Aleksey Gurtovoy. Distributed Chris@16: // under the Boost Software License, Version 1.0. (See accompanying Chris@16: // file LICENSE_1_0.txt or copy at Chris@16: // http://www.boost.org/LICENSE_1_0.txt) Chris@16: Chris@16: #ifndef BOOST_MSM_FRONT_DETAILS_COMMON_STATES_H Chris@16: #define BOOST_MSM_FRONT_DETAILS_COMMON_STATES_H Chris@16: Chris@16: #include Chris@16: Chris@16: #include Chris@16: #include Chris@16: #include Chris@16: #include Chris@16: Chris@16: namespace boost { namespace msm { namespace front {namespace detail Chris@16: { Chris@16: template > Chris@16: struct inherit_attributes Chris@16: { Chris@16: inherit_attributes():m_attributes(){} Chris@16: inherit_attributes(Attributes const& the_attributes):m_attributes(the_attributes){} Chris@16: // on the fly attribute creation capability Chris@16: typedef Attributes attributes_type; Chris@16: template Chris@16: typename ::boost::fusion::result_of::at_key::type Chris@16: get_attribute(Index const&) Chris@16: { Chris@16: return ::boost::fusion::at_key(m_attributes); Chris@16: } Chris@16: Chris@16: template Chris@16: typename ::boost::add_const< Chris@16: typename ::boost::fusion::result_of::at_key::type>::type Chris@16: get_attribute(Index const&)const Chris@16: { Chris@16: return const_cast< Chris@16: typename ::boost::add_const< Chris@16: typename ::boost::fusion::result_of::at_key< attributes_type, Chris@16: Index >::type>::type> Chris@16: (::boost::fusion::at_key(m_attributes)); Chris@16: } Chris@16: Chris@16: private: Chris@16: // attributes Chris@16: Attributes m_attributes; Chris@16: }; Chris@16: Chris@16: // the interface for all states. Defines entry and exit functions. Overwrite to implement for any state needing it. Chris@16: template > Chris@16: struct state_base : public inherit_attributes, USERBASE Chris@16: { Chris@16: typedef USERBASE user_state_base; Chris@16: typedef Attributes attributes_type; Chris@16: Chris@16: // empty implementation for the states not wishing to define an entry condition Chris@16: // will not be called polymorphic way Chris@16: template Chris@16: void on_entry(Event const& ,FSM&){} Chris@16: template Chris@16: void on_exit(Event const&,FSM& ){} Chris@16: // default (empty) transition table; Chris@16: typedef ::boost::mpl::vector0<> internal_transition_table; Chris@16: typedef ::boost::mpl::vector0<> transition_table; Chris@16: }; Chris@16: Chris@16: }}}} Chris@16: Chris@16: #endif //BOOST_MSM_FRONT_DETAILS_COMMON_STATES_H Chris@16: