/usr/include/boost/msm/front/euml
Edit: /usr/include/boost/msm/front/euml/common.hpp (140806B)
// Copyright 2008 Christophe Henry
// henry UNDERSCORE christophe AT hotmail DOT com
// This is an extended version of the state machine available in the boost::mpl library
// Distributed under the same license as the original.
// Copyright for the original version:
// Copyright 2005 David Abrahams and Aleksey Gurtovoy. Distributed
// under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
#ifndef BOOST_MSM_FRONT_EUML_COMMON_H
#define BOOST_MSM_FRONT_EUML_COMMON_H
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#if BOOST_VERSION >= 104000
#include
#endif
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
namespace proto = boost::proto;
BOOST_MPL_HAS_XXX_TRAIT_DEF(tag_type)
BOOST_MPL_HAS_XXX_TRAIT_DEF(action_name)
BOOST_MPL_HAS_XXX_TRAIT_DEF(not_intern_euml_state)
namespace boost { namespace msm { namespace front { namespace euml
{
template
struct get_iterator
{
typedef typename T::iterator type;
};
template
struct get_reverse_iterator
{
typedef typename T::reverse_iterator type;
};
template
struct get_reference
{
typedef typename T::reference type;
};
template
struct get_size_type
{
typedef typename T::size_type type;
};
template
struct get_value_type
{
typedef typename T::value_type type;
};
template
struct get_first_type
{
typedef typename T::first_type type;
};
template
struct get_second_type
{
typedef typename T::second_type type;
};
template
struct get_action_tag_type
{
typedef typename ::boost::mpl::has_key<
typename T::tag_type,action_tag>::type type;
};
template
struct get_state_action_tag_type
{
typedef typename ::boost::mpl::has_key<
typename T::tag_type,state_action_tag>::type type;
};
template
struct get_result_type
{
typedef typename T::template transition_action_result::type type;
};
template
struct get_result_type2
{
typedef typename T::template state_action_result::type type;
};
template
struct get_sequence
{
typedef typename SEQ::sequence type;
};
template
struct get_attributes_type
{
typedef typename T::attributes_type type;
};
template
struct get_euml_tag_type
{
typedef typename T::euml_tag_type type;
};
template
struct get_fct
{
typedef typename T::template In::type type;
};
// used to differentiate between different types of euml_state's
template
struct get_state_name
{
typedef T type;
};
template
struct get_state_name >::type>
{
typedef typename T::In::type type;
};
template
struct get_action_name
{
typedef typename T::action_name type;
};
template
struct get_event_name
{
typedef typename T::event_name type;
};
template
struct euml_event: proto::extends::type, EVT, boost::msm::sm_domain>
{
typedef event_tag euml_tag_type;
typedef EVT event_name;
using proto::extends::type, EVT, boost::msm::sm_domain>::operator=;
template
struct In
{
typedef EVT type;
};
};
template
struct euml_state_intern: proto::extends::type, STATE, boost::msm::state_domain>
{
typedef state_tag euml_tag_type;
using proto::extends::type, STATE, boost::msm::state_domain>::operator=;
template
struct In
{
typedef STATE type;
};
};
template
struct euml_state: proto::extends::type, STATE, boost::msm::state_domain>
{
typedef state_tag euml_tag_type;
typedef int not_intern_euml_state;
using proto::extends::type, STATE, boost::msm::state_domain>::operator=;
struct In
{
typedef STATE type;
};
};
template
struct euml_action: proto::extends::type, ACTION, boost::msm::sm_domain>
{
typedef action_tag euml_tag_type;
typedef ACTION action_name;
using proto::extends::type, ACTION, boost::msm::sm_domain>::operator=;
template
struct In
{
typedef ACTION type;
};
};
template
struct euml_flag: proto::extends::type, FLAG, boost::msm::sm_domain>
{
typedef flag_tag euml_tag_type;
using proto::extends::type, FLAG, boost::msm::sm_domain>::operator=;
template
struct In
{
typedef FLAG type;
};
};
template
struct euml_config: proto::extends::type, CONFIG, boost::msm::sm_domain>
{
typedef config_tag euml_tag_type;
using proto::extends::type, CONFIG, boost::msm::sm_domain>::operator=;
template
struct In
{
typedef CONFIG type;
};
};
struct No_Exception : euml_config
{
typedef int no_exception_thrown;
No_Exception(){}
};
struct No_Msg_Queue : euml_config
{
typedef int no_message_queue;
No_Msg_Queue(){}
};
struct Deferred_Events : euml_config
{
typedef int activate_deferred_events;
Deferred_Events(){}
};
No_Exception const no_exception=No_Exception();
No_Msg_Queue const no_msg_queue=No_Msg_Queue();
Deferred_Events const deferred_events=Deferred_Events();
struct ActiveStateSwitchBeforeTransition : euml_config
{
typedef boost::msm::active_state_switch_before_transition active_state_switch_policy;
ActiveStateSwitchBeforeTransition(){}
};
ActiveStateSwitchBeforeTransition const switch_active_before_transition = ActiveStateSwitchBeforeTransition();
struct ActiveStateSwitchAfterExit : euml_config
{
typedef boost::msm::active_state_switch_after_exit active_state_switch_policy;
ActiveStateSwitchAfterExit(){}
};
ActiveStateSwitchAfterExit const switch_active_after_exit = ActiveStateSwitchAfterExit();
struct ActiveStateSwitchAfterAction : euml_config
{
typedef boost::msm::active_state_switch_after_transition_action active_state_switch_policy;
ActiveStateSwitchAfterAction(){}
};
ActiveStateSwitchAfterAction const switch_active_after_action = ActiveStateSwitchAfterAction();
struct invalid_type{};
struct make_invalid_type
{
typedef invalid_type type;
};
template
struct make_vector_one_row
{
typedef boost::mpl::vector type;
};
template
T make_T(T t) {return t;}
struct make_vector_no_row
{
typedef boost::mpl::vector0<> type;
};
struct NoAction : euml_action
{
NoAction(){}
// return value if used inside a state action (entry/exit)
template
struct state_action_result
{
typedef bool type;
};
// return value if used inside a transition (action/guard)
template
struct transition_action_result
{
typedef bool type;
};
// this functor can be used in both modes, state action and transition action
typedef ::boost::mpl::set tag_type;
template
bool operator()(Event const&,FSM&,STATE& )
{
// does nothing
return true;
}
template
bool operator()(EVT const& ,FSM& ,SourceState& ,TargetState&)const
{
// does nothing
return true;
}
};
NoAction const no_action = NoAction();
struct fsm_artefact_tag {};
template
struct GetSource_ : euml_action >
{
template
struct transition_action_result
{
typedef typename ::boost::fusion::result_of::at_key::type type;
};
typedef ::boost::mpl::set tag_type;
template
typename transition_action_result::type
operator()(EVT const& ,FSM& ,SourceState& src,TargetState&)const
{
return src.get_attribute(Index());
}
};
template<>
struct GetSource_ : euml_action >
{
template
struct transition_action_result
{
typedef SourceState& type;
};
typedef ::boost::mpl::set tag_type;
template
typename transition_action_result::type
operator()(EVT const& , FSM&,SourceState& src,TargetState& )const
{
return src;
}
};
struct GetSource_Helper: proto::extends< proto::terminal::type, GetSource_Helper, boost::msm::sm_domain>
{
GetSource_Helper(){}
template
struct In
{
typedef GetSource_ type;
};
};
GetSource_Helper const source_ = GetSource_Helper();
template
struct GetTarget_ : euml_action >
{
template
struct transition_action_result
{
typedef typename ::boost::fusion::result_of::at_key::type type;
};
typedef ::boost::mpl::set tag_type;
template
typename transition_action_result::type
operator()(EVT const& ,FSM& ,SourceState& ,TargetState& tgt)const
{
return tgt.get_attribute(Index());
}
};
template<>
struct GetTarget_ : euml_action >
{
template
struct transition_action_result
{
typedef TargetState& type;
};
typedef ::boost::mpl::set tag_type;
template
typename transition_action_result::type
operator()(EVT const& , FSM&,SourceState& ,TargetState& tgt)const
{
return tgt;
}
};
struct GetTarget_Helper: proto::extends< proto::terminal::type, GetTarget_Helper, boost::msm::sm_domain>
{
GetTarget_Helper(){}
template
struct In
{
typedef GetTarget_ type;
};
};
GetTarget_Helper const target_ = GetTarget_Helper();
template
struct GetState_ : euml_action >
{
template
struct state_action_result
{
typedef typename ::boost::fusion::result_of::at_key::type type;
};
typedef ::boost::mpl::set tag_type;
template
typename state_action_result::type
operator()(Event const&,FSM& ,STATE& state )
{
return state.get_attribute(Index());
}
};
template<>
struct GetState_ : euml_action >
{
using euml_action::operator=;
template
struct state_action_result
{
typedef STATE& type;
};
typedef ::boost::mpl::set tag_type;
template
typename state_action_result::type
operator()(Event const&,FSM& ,STATE& state )
{
return state;
}
};
struct GetState_Helper: proto::extends< proto::terminal::type, GetState_Helper, boost::msm::sm_domain>
{
GetState_Helper(){}
template
struct In
{
typedef GetState_ type;
};
};
GetState_Helper const state_ = GetState_Helper();
template
struct GetEvent_ : euml_action >
{
template
struct state_action_result
{
typedef typename ::boost::add_const<
typename ::boost::fusion::result_of::at_key::type>::type type;
};
template
struct transition_action_result
{
typedef typename ::boost::add_const<
typename ::boost::fusion::result_of::at_key::type>::type type;
};
typedef ::boost::mpl::set tag_type;
template
typename state_action_result::type
operator()(Event const& evt,FSM& ,STATE& )
{
return evt.get_attribute(Index());
}
template
typename transition_action_result::type
operator()(EVT const& evt ,FSM& ,SourceState& ,TargetState&)const
{
return evt.get_attribute(Index());
}
};
template <>
struct GetEvent_ : euml_action >
{
template
struct state_action_result
{
typedef Event const& type;
};
template
struct transition_action_result
{
typedef EVT const& type;
};
typedef ::boost::mpl::set tag_type;
template
typename state_action_result::type
operator()(Event const& evt,FSM& ,STATE& )
{
return evt;
}
template
typename transition_action_result::type
operator()(EVT const& evt ,FSM& ,SourceState& ,TargetState&)const
{
return evt;
}
};
struct GetEvent_Helper: proto::extends< proto::terminal::type, GetEvent_Helper, boost::msm::sm_domain>
{
GetEvent_Helper(){}
template
struct In
{
typedef GetEvent_ type;
};
};
GetEvent_Helper const event_ = GetEvent_Helper();
template
struct GetFsm_ : euml_action >
{
template
struct state_action_result
{
typedef typename ::boost::fusion::result_of::at_key::type type;
};
template
struct transition_action_result
{
typedef typename ::boost::fusion::result_of::at_key::type type;
};
typedef ::boost::mpl::set tag_type;
template
typename state_action_result::type
operator()(Event const&,FSM& fsm,STATE& )
{
return fsm.get_attribute(Index());
}
template
typename transition_action_result::type
operator()(EVT const& ,FSM& fsm,SourceState& ,TargetState&)const
{
return fsm.get_attribute(Index());
}
};
template<>
struct GetFsm_ : euml_action >
{
using euml_action::operator=;
template
struct state_action_result
{
typedef FSM& type;
};
template
struct transition_action_result
{
typedef FSM& type;
};
typedef ::boost::mpl::set tag_type;
template
typename state_action_result::type
operator()(Event const&,FSM& fsm,STATE& )
{
return fsm;
}
template
typename transition_action_result::type
operator()(EVT const& ,FSM& fsm,SourceState& ,TargetState&)const
{
return fsm;
}
};
struct GetFsm_Helper: proto::extends< proto::terminal::type, GetFsm_Helper, boost::msm::sm_domain>
{
GetFsm_Helper(){}
template
struct In
{
typedef GetFsm_ type;
};
};
GetFsm_Helper const fsm_ = GetFsm_Helper();
template
struct SubState_ : euml_action >
{
template
struct state_action_result
{
typedef StateName& type;
};
template
struct transition_action_result
{
typedef StateName& type;
};
typedef ::boost::mpl::set tag_type;
template
StateName& operator()(EVT const& evt,FSM& fsm,SourceState& src,TargetState& tgt)const
{
return (Param1()(evt,fsm,src,tgt)).template get_state();
}
template
StateName& operator()(Event const& evt,FSM& fsm,STATE& state)const
{
return (Param1()(evt,fsm,state)).template get_state();
}
};
template
struct SubState_
: euml_action >
{
template
struct state_action_result
{
typedef StateName& type;
};
template
struct transition_action_result
{
typedef StateName& type;
};
typedef ::boost::mpl::set tag_type;
template
StateName& operator()(EVT const&,FSM& fsm,SourceState& ,TargetState& )const
{
return fsm.template get_state();
}
template
StateName& operator()(Event const& ,FSM& fsm,STATE& )const
{
return fsm.template get_state();
}
};
struct SubState_Helper: proto::extends< proto::terminal::type, SubState_Helper, boost::msm::sm_domain>
{
SubState_Helper(){}
using proto::extends< proto::terminal::type, SubState_Helper, boost::msm::sm_domain>::operator=;
template
struct In
{
typedef SubState_ type;
};
};
SubState_Helper const substate_ = SubState_Helper();
template
struct GetAttribute_ : euml_action >
{
using euml_action >::operator=;
template
struct state_action_result
{
typedef typename
::boost::fusion::result_of::at_key<
typename get_attributes_type<
typename ::boost::remove_reference<
typename get_result_type2::type>::type>::type,
Index >::type type;
};
template
struct transition_action_result
{
typedef typename
::boost::fusion::result_of::at_key<
typename get_attributes_type<
typename ::boost::remove_reference<
typename get_result_type::type>::type>::type,
Index >::type type;
};
typedef ::boost::mpl::set tag_type;
template
typename ::boost::enable_if<
typename ::boost::mpl::has_key<
typename Target::tag_type,action_tag>::type,
typename transition_action_result::type >::type
operator()(EVT const& evt, FSM& fsm,SourceState& src,TargetState& tgt)const
{
return (Target()(evt,fsm,src,tgt)).get_attribute(Index());
}
template
typename ::boost::enable_if<
typename ::boost::mpl::has_key<
typename Target::tag_type,state_action_tag>::type,
typename state_action_result::type >::type
operator()(Event const& evt,FSM& fsm,STATE& state )const
{
return (Target()(evt,fsm,state)).get_attribute(Index());
}
};
struct GetAttribute_Helper: proto::extends< proto::terminal::type, GetAttribute_Helper, boost::msm::sm_domain>
{
GetAttribute_Helper(){}
template
struct In
{
typedef GetAttribute_ type;
};
};
GetAttribute_Helper const attribute_ = GetAttribute_Helper();
template
struct Source_ : euml_action >
{
using euml_action >::operator=;
template
struct transition_action_result
{
typedef typename
::boost::fusion::result_of::at_key::type type;
};
typedef ::boost::mpl::set tag_type;
template
typename transition_action_result::type
operator()(EVT const& , FSM&,SourceState& src,TargetState& )const
{
return src.get_attribute(Index());
}
};
template
struct Target_ : euml_action >
{
using euml_action >::operator=;
template
struct transition_action_result
{
typedef typename
::boost::fusion::result_of::at_key::type type;
};
typedef ::boost::mpl::set tag_type;
template
typename transition_action_result::type
operator()(EVT const& ,FSM& ,SourceState& ,TargetState& tgt)const
{
return tgt.get_attribute(Index());
}
};
template
struct State_ : euml_action >
{
using euml_action >::operator=;
template