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