Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-07-11 08:17:12

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/vector.hpp>
0018 #include <boost/fusion/container/map.hpp>
0019 #include <boost/fusion/include/at_key.hpp>
0020 #include <boost/type_traits/add_const.hpp>
0021 
0022 namespace boost { namespace msm { namespace front {namespace detail
0023 {
0024 template <class Attributes= ::boost::fusion::map<> >
0025 struct inherit_attributes
0026 {
0027     inherit_attributes():m_attributes(){}
0028     inherit_attributes(Attributes const& the_attributes):m_attributes(the_attributes){}
0029     // on the fly attribute creation capability
0030     typedef Attributes      attributes_type;
0031     template <class Index>
0032     typename ::boost::fusion::result_of::at_key<attributes_type, 
0033                                                 Index>::type
0034     get_attribute(Index const&) 
0035     {
0036         return ::boost::fusion::at_key<Index>(m_attributes);
0037     }
0038     
0039     template <class Index>
0040     typename ::boost::add_const<
0041         typename ::boost::fusion::result_of::at_key<attributes_type,
0042                                                     Index>::type>::type
0043     get_attribute(Index const&)const 
0044     {
0045         return const_cast< 
0046             typename ::boost::add_const< 
0047                 typename ::boost::fusion::result_of::at_key< attributes_type,
0048                                                              Index >::type>::type>
0049                                 (::boost::fusion::at_key<Index>(m_attributes));
0050     }
0051 
0052 private:
0053     // attributes
0054     Attributes m_attributes;
0055 };
0056 
0057 // the interface for all states. Defines entry and exit functions. Overwrite to implement for any state needing it.
0058 template<class USERBASE,class Attributes= ::boost::fusion::map<> >
0059 struct state_base : public inherit_attributes<Attributes>, USERBASE
0060 {
0061     typedef USERBASE        user_state_base;
0062     typedef Attributes      attributes_type;
0063 
0064     // empty implementation for the states not wishing to define an entry condition
0065     // will not be called polymorphic way
0066     template <class Event,class FSM>
0067     void on_entry(Event const& ,FSM&){}
0068     template <class Event,class FSM>
0069     void on_exit(Event const&,FSM& ){}
0070     // default (empty) transition table;
0071     typedef ::boost::mpl::vector<>  internal_transition_table;
0072     typedef ::boost::fusion::vector<>  internal_transition_table11;
0073     typedef ::boost::fusion::vector<>  transition_table;
0074 };
0075 
0076 }}}}
0077 
0078 #endif //BOOST_MSM_FRONT_DETAILS_COMMON_STATES_H
0079