annotate DEPENDENCIES/generic/include/boost/msm/front/detail/common_states.hpp @ 133:4acb5d8d80b6 tip

Don't fail environmental check if README.md exists (but .txt and no-suffix don't)
author Chris Cannam
date Tue, 30 Jul 2019 12:25:44 +0100
parents 2665513ce2d3
children
rev   line source
Chris@16 1 // Copyright 2008 Christophe Henry
Chris@16 2 // henry UNDERSCORE christophe AT hotmail DOT com
Chris@16 3 // This is an extended version of the state machine available in the boost::mpl library
Chris@16 4 // Distributed under the same license as the original.
Chris@16 5 // Copyright for the original version:
Chris@16 6 // Copyright 2005 David Abrahams and Aleksey Gurtovoy. Distributed
Chris@16 7 // under the Boost Software License, Version 1.0. (See accompanying
Chris@16 8 // file LICENSE_1_0.txt or copy at
Chris@16 9 // http://www.boost.org/LICENSE_1_0.txt)
Chris@16 10
Chris@16 11 #ifndef BOOST_MSM_FRONT_DETAILS_COMMON_STATES_H
Chris@16 12 #define BOOST_MSM_FRONT_DETAILS_COMMON_STATES_H
Chris@16 13
Chris@16 14 #include <boost/mpl/int.hpp>
Chris@16 15
Chris@16 16 #include <boost/mpl/vector.hpp>
Chris@16 17 #include <boost/fusion/container/map.hpp>
Chris@16 18 #include <boost/fusion/include/at_key.hpp>
Chris@16 19 #include <boost/type_traits/add_const.hpp>
Chris@16 20
Chris@16 21 namespace boost { namespace msm { namespace front {namespace detail
Chris@16 22 {
Chris@16 23 template <class Attributes= ::boost::fusion::map<> >
Chris@16 24 struct inherit_attributes
Chris@16 25 {
Chris@16 26 inherit_attributes():m_attributes(){}
Chris@16 27 inherit_attributes(Attributes const& the_attributes):m_attributes(the_attributes){}
Chris@16 28 // on the fly attribute creation capability
Chris@16 29 typedef Attributes attributes_type;
Chris@16 30 template <class Index>
Chris@16 31 typename ::boost::fusion::result_of::at_key<attributes_type,
Chris@16 32 Index>::type
Chris@16 33 get_attribute(Index const&)
Chris@16 34 {
Chris@16 35 return ::boost::fusion::at_key<Index>(m_attributes);
Chris@16 36 }
Chris@16 37
Chris@16 38 template <class Index>
Chris@16 39 typename ::boost::add_const<
Chris@16 40 typename ::boost::fusion::result_of::at_key<attributes_type,
Chris@16 41 Index>::type>::type
Chris@16 42 get_attribute(Index const&)const
Chris@16 43 {
Chris@16 44 return const_cast<
Chris@16 45 typename ::boost::add_const<
Chris@16 46 typename ::boost::fusion::result_of::at_key< attributes_type,
Chris@16 47 Index >::type>::type>
Chris@16 48 (::boost::fusion::at_key<Index>(m_attributes));
Chris@16 49 }
Chris@16 50
Chris@16 51 private:
Chris@16 52 // attributes
Chris@16 53 Attributes m_attributes;
Chris@16 54 };
Chris@16 55
Chris@16 56 // the interface for all states. Defines entry and exit functions. Overwrite to implement for any state needing it.
Chris@16 57 template<class USERBASE,class Attributes= ::boost::fusion::map<> >
Chris@16 58 struct state_base : public inherit_attributes<Attributes>, USERBASE
Chris@16 59 {
Chris@16 60 typedef USERBASE user_state_base;
Chris@16 61 typedef Attributes attributes_type;
Chris@16 62
Chris@16 63 // empty implementation for the states not wishing to define an entry condition
Chris@16 64 // will not be called polymorphic way
Chris@16 65 template <class Event,class FSM>
Chris@16 66 void on_entry(Event const& ,FSM&){}
Chris@16 67 template <class Event,class FSM>
Chris@16 68 void on_exit(Event const&,FSM& ){}
Chris@16 69 // default (empty) transition table;
Chris@16 70 typedef ::boost::mpl::vector0<> internal_transition_table;
Chris@16 71 typedef ::boost::mpl::vector0<> transition_table;
Chris@16 72 };
Chris@16 73
Chris@16 74 }}}}
Chris@16 75
Chris@16 76 #endif //BOOST_MSM_FRONT_DETAILS_COMMON_STATES_H
Chris@16 77