Back to home page

EIC code displayed by LXR

 
 

    


Warning, file /include/boost/msm/front/detail/common_states.hpp was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).

0001 // Copyright 2008 Christophe Henry
0002 // henry UNDERSCORE christophe AT hotmail DOT com
0003 // This is an extended version of the state machine available in the boost::mpl library
0004 // Distributed under the same license as the original.
0005 // Copyright for the original version:
0006 // Copyright 2005 David Abrahams and Aleksey Gurtovoy. Distributed
0007 // under the Boost Software License, Version 1.0. (See accompanying
0008 // file LICENSE_1_0.txt or copy at
0009 // http://www.boost.org/LICENSE_1_0.txt)
0010 
0011 #ifndef BOOST_MSM_FRONT_DETAILS_COMMON_STATES_H
0012 #define BOOST_MSM_FRONT_DETAILS_COMMON_STATES_H
0013 
0014 #include <boost/mpl/int.hpp>
0015 
0016 #include <boost/mpl/vector.hpp>
0017 #include <boost/fusion/container/map.hpp>
0018 #include <boost/fusion/include/at_key.hpp>
0019 #include <boost/type_traits/add_const.hpp>
0020 
0021 namespace boost { namespace msm { namespace front {namespace detail
0022 {
0023 template <class Attributes= ::boost::fusion::map<> >
0024 struct inherit_attributes
0025 {
0026     inherit_attributes():m_attributes(){}
0027     inherit_attributes(Attributes const& the_attributes):m_attributes(the_attributes){}
0028     // on the fly attribute creation capability
0029     typedef Attributes      attributes_type;
0030     template <class Index>
0031     typename ::boost::fusion::result_of::at_key<attributes_type, 
0032                                                 Index>::type
0033     get_attribute(Index const&) 
0034     {
0035         return ::boost::fusion::at_key<Index>(m_attributes);
0036     }
0037     
0038     template <class Index>
0039     typename ::boost::add_const<
0040         typename ::boost::fusion::result_of::at_key<attributes_type,
0041                                                     Index>::type>::type
0042     get_attribute(Index const&)const 
0043     {
0044         return const_cast< 
0045             typename ::boost::add_const< 
0046                 typename ::boost::fusion::result_of::at_key< attributes_type,
0047                                                              Index >::type>::type>
0048                                 (::boost::fusion::at_key<Index>(m_attributes));
0049     }
0050 
0051 private:
0052     // attributes
0053     Attributes m_attributes;
0054 };
0055 
0056 // the interface for all states. Defines entry and exit functions. Overwrite to implement for any state needing it.
0057 template<class USERBASE,class Attributes= ::boost::fusion::map<> >
0058 struct state_base : public inherit_attributes<Attributes>, USERBASE
0059 {
0060     typedef USERBASE        user_state_base;
0061     typedef Attributes      attributes_type;
0062 
0063     // empty implementation for the states not wishing to define an entry condition
0064     // will not be called polymorphic way
0065     template <class Event,class FSM>
0066     void on_entry(Event const& ,FSM&){}
0067     template <class Event,class FSM>
0068     void on_exit(Event const&,FSM& ){}
0069     // default (empty) transition table;
0070     typedef ::boost::mpl::vector0<>  internal_transition_table;
0071     typedef ::boost::mpl::vector0<>  transition_table;
0072 };
0073 
0074 }}}}
0075 
0076 #endif //BOOST_MSM_FRONT_DETAILS_COMMON_STATES_H
0077