/usr/include/boost/msm/front/euml
Edit: /usr/include/boost/msm/front/euml/operator.hpp (57632B)
// 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_OPERATOR_H
#define BOOST_MSM_FRONT_EUML_OPERATOR_H
#include
#include
#include
#include
#include
#include
#include
#include
BOOST_MPL_HAS_XXX_TRAIT_DEF(reference)
BOOST_MPL_HAS_XXX_TRAIT_DEF(key_type)
namespace boost { namespace msm { namespace front { namespace euml
{
template
struct Or_ : euml_action >
{
template
bool operator()(EVT const& evt, FSM& fsm,SourceState& src,TargetState& tgt)
{
return (T1()(evt,fsm,src,tgt) || T2()(evt,fsm,src,tgt));
}
template
bool operator()(Event const& evt,FSM& fsm,STATE& state)
{
return (T1()(evt,fsm,state) || T2()(evt,fsm,state));
}
};
template
struct And_ : euml_action >
{
template
bool operator()(EVT const& evt, FSM& fsm,SourceState& src,TargetState& tgt)
{
return (T1()(evt,fsm,src,tgt) && T2()(evt,fsm,src,tgt));
}
template
bool operator()(Event const& evt,FSM& fsm,STATE& state)
{
return (T1()(evt,fsm,state) && T2()(evt,fsm,state));
}
};
template
struct Not_ : euml_action >
{
template
bool operator()(EVT const& evt, FSM& fsm,SourceState& src,TargetState& tgt)
{
return !(T1()(evt,fsm,src,tgt));
}
template
bool operator()(Event const& evt,FSM& fsm,STATE& state)
{
return !(T1()(evt,fsm,state));
}
};
template
struct If_Else_ : euml_action > {};
template
struct If_Else_::type >::type>
: euml_action >
{
template
struct state_action_result
{
typedef typename get_result_type2::type type;
};
template
struct transition_action_result
{
typedef typename get_result_type::type type;
};
typedef ::boost::mpl::set tag_type;
template
typename ::boost::enable_if<
typename ::boost::mpl::has_key<
typename Action1::tag_type,action_tag>::type,
typename transition_action_result::type >::type
operator()(EVT const& evt, FSM& fsm,SourceState& src,TargetState& tgt)const
{
if (Condition()(evt,fsm,src,tgt))
{
return Action1()(evt,fsm,src,tgt);
}
return Action2()(evt,fsm,src,tgt);
}
template
typename ::boost::enable_if<
typename ::boost::mpl::has_key<
typename Action1::tag_type,state_action_tag>::type,
typename state_action_result::type >::type
operator()(Event const& evt,FSM& fsm,STATE& state )const
{
if (Condition()(evt,fsm,state))
{
return Action1()(evt,fsm,state);
}
return Action2()(evt,fsm,state);
}
};
template
struct If_Else_::type >::type>
: euml_action >
{
template
struct state_action_result
{
typedef bool type;
};
template
struct transition_action_result
{
typedef bool type;
};
typedef ::boost::mpl::set tag_type;
template
bool operator()(EVT const& evt, FSM& fsm,SourceState& src,TargetState& tgt)const
{
if (Condition()(evt,fsm,src,tgt))
{
return Action1()(evt,fsm,src,tgt);
}
return Action2()(evt,fsm,src,tgt);
}
template
bool operator()(Event const& evt,FSM& fsm,STATE& state )const
{
if (Condition()(evt,fsm,state))
{
return Action1()(evt,fsm,state);
}
return Action2()(evt,fsm,state);
}
};
struct if_tag
{
};
struct If : proto::extends::type, If, boost::msm::sm_domain>
{
If(){}
using proto::extends< proto::terminal::type, If, boost::msm::sm_domain>::operator=;
template
struct In
{
typedef If_Else_ type;
};
};
If const if_then_else_;
template
struct If_Then_ : euml_action > {};
template
struct If_Then_::type >::type>
: euml_action >
{
template
struct state_action_result
{
typedef typename get_result_type2::type type;
};
template
struct transition_action_result
{
typedef typename get_result_type::type type;
};
typedef ::boost::mpl::set tag_type;
template
typename ::boost::enable_if<
typename ::boost::mpl::has_key<
typename Action1::tag_type,action_tag>::type,
typename transition_action_result::type >::type
operator()(EVT const& evt, FSM& fsm,SourceState& src,TargetState& tgt)const
{
if (Condition()(evt,fsm,src,tgt))
{
return Action1()(evt,fsm,src,tgt);
}
}
template
typename ::boost::enable_if<
typename ::boost::mpl::has_key<
typename Action1::tag_type,state_action_tag>::type,
typename state_action_result::type >::type
operator()(Event const& evt,FSM& fsm,STATE& state )const
{
if (Condition()(evt,fsm,state))
{
return Action1()(evt,fsm,state);
}
}
};
template
struct If_Then_::type >::type>
: euml_action >
{
template
struct state_action_result
{
typedef bool type;
};
template
struct transition_action_result
{
typedef bool type;
};
typedef ::boost::mpl::set tag_type;
template
bool operator()(EVT const& evt, FSM& fsm,SourceState& src,TargetState& tgt)const
{
if (Condition()(evt,fsm,src,tgt))
{
return Action1()(evt,fsm,src,tgt);
}
}
template
bool operator()(Event const& evt,FSM& fsm,STATE& state )const
{
if (Condition()(evt,fsm,state))
{
return Action1()(evt,fsm,state);
}
}
};
struct if_then_tag
{
};
struct If_Then : proto::extends< proto::terminal::type, If_Then, boost::msm::sm_domain>
{
If_Then(){}
using proto::extends< proto::terminal::type, If_Then, boost::msm::sm_domain>::operator=;
template
struct In
{
typedef If_Then_ type;
};
};
If_Then const if_then_;
template
struct While_Do_ : euml_action >
{
template
struct state_action_result
{
typedef void type;
};
template
struct transition_action_result
{
typedef void type;
};
typedef ::boost::mpl::set tag_type;
template
void operator()(EVT const& evt, FSM& fsm,SourceState& src,TargetState& tgt)const
{
Body body_;
Condition cond_;
while (cond_(evt,fsm,src,tgt))
{
body_(evt,fsm,src,tgt);
}
}
template
void operator()(Event const& evt,FSM& fsm,STATE& state )const
{
Body body_;
Condition cond_;
while (cond_(evt,fsm,state))
{
body_(evt,fsm,state);
}
}
};
struct while_do_tag
{
};
struct While_Do_Helper : proto::extends< proto::terminal::type, While_Do_Helper, boost::msm::sm_domain>
{
While_Do_Helper(){}
using proto::extends< proto::terminal::type, While_Do_Helper, boost::msm::sm_domain>::operator=;
template
struct In
{
typedef While_Do_ type;
};
};
While_Do_Helper const while_;
template
struct Do_While_ : euml_action >
{
template
struct state_action_result
{
typedef void type;
};
template
struct transition_action_result
{
typedef void type;
};
typedef ::boost::mpl::set tag_type;
template
void operator()(EVT const& evt, FSM& fsm,SourceState& src,TargetState& tgt)const
{
Condition cond_;
Body body_;
do
{
body_(evt,fsm,src,tgt);
} while (cond_(evt,fsm,src,tgt));
}
template
void operator()(Event const& evt,FSM& fsm,STATE& state )const
{
Condition cond_;
Body body_;
do
{
body_(evt,fsm,state);
} while (cond_(evt,fsm,state));
}
};
struct do_while_tag
{
};
struct Do_While_Helper : proto::extends< proto::terminal::type, Do_While_Helper, boost::msm::sm_domain>
{
Do_While_Helper(){}
using proto::extends< proto::terminal::type, Do_While_Helper, boost::msm::sm_domain>::operator=;
template
struct In
{
typedef Do_While_ type;
};
};
Do_While_Helper const do_while_;
template
struct For_Loop_ : euml_action >
{
template
struct state_action_result
{
typedef void type;
};
template
struct transition_action_result
{
typedef void type;
};
typedef ::boost::mpl::set tag_type;
template
void operator()(EVT const& evt, FSM& fsm,SourceState& src,TargetState& tgt)const
{
End end_;
EndLoop end_loop_;
Body body_;
for(Begin()(evt,fsm,src,tgt);end_(evt,fsm,src,tgt);end_loop_(evt,fsm,src,tgt))
{
body_(evt,fsm,src,tgt);
}
}
template
void operator()(Event const& evt,FSM& fsm,STATE& state )const
{
End end_;
EndLoop end_loop_;
Body body_;
for(Begin()(evt,fsm,state);end_(evt,fsm,state);end_loop_(evt,fsm,state))
{
body_(evt,fsm,state);
}
}
};
struct for_loop_tag
{
};
struct For_Loop_Helper : proto::extends< proto::terminal::type, For_Loop_Helper, boost::msm::sm_domain>
{
For_Loop_Helper(){}
using proto::extends< proto::terminal::type, For_Loop_Helper, boost::msm::sm_domain>::operator=;
template
struct In
{
typedef For_Loop_ type;
};
};
For_Loop_Helper const for_;
template
struct Deref_ : euml_action >
{
Deref_(){}
using euml_action >::operator=;
template
struct state_action_result
{
typedef typename ::boost::add_reference<
typename std::iterator_traits <
typename ::boost::remove_reference<
typename get_result_type2::type>::type>::value_type>::type type;
};
template
struct transition_action_result
{
typedef typename ::boost::add_reference<
typename std::iterator_traits<
typename ::boost::remove_reference<
typename get_result_type::type>::type
>::value_type
>::type type;
};
typedef ::boost::mpl::set tag_type;
template
typename ::boost::enable_if<
typename ::boost::mpl::has_key<
typename T::tag_type,action_tag>::type,
typename transition_action_result::type >::type
operator()(EVT const& evt, FSM& fsm,SourceState& src,TargetState& tgt)const
{
return *(T()(evt,fsm,src,tgt));
}
template
typename ::boost::enable_if<
typename ::boost::mpl::has_key<
typename T::tag_type,state_action_tag>::type,
typename state_action_result::type >::type
operator()(Event const& evt,FSM& fsm,STATE& state )const
{
return *(T()(evt,fsm,state));
}
};
template
struct Pre_inc_ : euml_action >
{
using euml_action >::operator=;
template
struct state_action_result
{
typedef typename get_result_type2::type type;
};
template
struct transition_action_result
{
typedef typename get_result_type::type type;
};
typedef ::boost::mpl::set tag_type;
template
typename ::boost::enable_if<
typename ::boost::mpl::has_key<
typename T::tag_type,action_tag>::type,
typename transition_action_result::type >::type
operator()(EVT const& evt, FSM& fsm,SourceState& src,TargetState& tgt)const
{
return ++T()(evt,fsm,src,tgt);
}
template
typename ::boost::enable_if<
typename ::boost::mpl::has_key<
typename T::tag_type,state_action_tag>::type,
typename state_action_result::type >::type
operator()(Event const& evt,FSM& fsm,STATE& state )const
{
return ++T()(evt,fsm,state);
}
};
template
struct Pre_dec_ : euml_action >
{
using euml_action >::operator=;
template
struct state_action_result
{
typedef typename get_result_type2::type type;
};
template
struct transition_action_result
{
typedef typename get_result_type::type type;
};
typedef ::boost::mpl::set tag_type;
template
typename ::boost::enable_if<
typename ::boost::mpl::has_key<
typename T::tag_type,action_tag>::type,
typename transition_action_result::type >::type
operator()(EVT const& evt, FSM& fsm,SourceState& src,TargetState& tgt)const
{
return --T()(evt,fsm,src,tgt);
}
template
typename ::boost::enable_if<
typename ::boost::mpl::has_key<
typename T::tag_type,state_action_tag>::type,
typename state_action_result::type >::type
operator()(Event const& evt,FSM& fsm,STATE& state )const
{
return --T()(evt,fsm,state);
}
};
template
struct Post_inc_ : euml_action >
{
using euml_action >::operator=;
template
struct state_action_result
{
typedef typename ::boost::remove_reference<
typename get_result_type2::type>::type type;
};
template
struct transition_action_result
{
typedef typename ::boost::remove_reference<
typename get_result_type::type>::type type;
};
typedef ::boost::mpl::set tag_type;
template
typename ::boost::enable_if<
typename ::boost::mpl::has_key<
typename T::tag_type,action_tag>::type,
typename transition_action_result::type >::type
operator()(EVT const& evt, FSM& fsm,SourceState& src,TargetState& tgt)const
{
return T()(evt,fsm,src,tgt)++;
}
template
typename ::boost::enable_if<
typename ::boost::mpl::has_key<
typename T::tag_type,state_action_tag>::type,
typename state_action_result::type >::type
operator()(Event const& evt,FSM& fsm,STATE& state )const
{
return T()(evt,fsm,state)++;
}
};
template
struct Post_dec_ : euml_action >
{
using euml_action >::operator=;
template
struct state_action_result
{
typedef typename ::boost::remove_reference<
typename get_result_type2::type>::type type;
};
template
struct transition_action_result
{
typedef typename ::boost::remove_reference<
typename get_result_type::type>::type type;
};
typedef ::boost::mpl::set tag_type;
template
typename ::boost::enable_if<
typename ::boost::mpl::has_key<
typename T::tag_type,action_tag>::type,
typename transition_action_result::type >::type
operator()(EVT const& evt, FSM& fsm,SourceState& src,TargetState& tgt)const
{
return T()(evt,fsm,src,tgt)--;
}
template
typename ::boost::enable_if<
typename ::boost::mpl::has_key<
typename T::tag_type,state_action_tag>::type,
typename state_action_result::type >::type
operator()(Event const& evt,FSM& fsm,STATE& state )const
{
return T()(evt,fsm,state)--;
}
};
template
struct Plus_ : euml_action >
{
template
struct state_action_result
{
typedef typename ::boost::remove_reference<
typename get_result_type2::type>::type type;
};
template
struct transition_action_result
{
typedef typename ::boost::remove_reference<
typename get_result_type::type>::type type;
};
typedef ::boost::mpl::set tag_type;
template
typename ::boost::enable_if<
typename ::boost::mpl::has_key<
typename T1::tag_type,action_tag>::type,
typename transition_action_result::type >::type
operator()(EVT const& evt, FSM& fsm,SourceState& src,TargetState& tgt)const
{
return T1()(evt,fsm,src,tgt)+T2()(evt,fsm,src,tgt);
}
template
typename ::boost::enable_if<
typename ::boost::mpl::has_key<
typename T1::tag_type,state_action_tag>::type,
typename state_action_result::type >::type
operator()(Event const& evt,FSM& fsm,STATE& state )const
{
return T1()(evt,fsm,state)+T2()(evt,fsm,state);
}
};
template
struct Minus_ : euml_action >
{
template
struct state_action_result
{
typedef typename ::boost::remove_reference<
typename get_result_type2::type>::type type;
};
template
struct transition_action_result
{
typedef typename ::boost::remove_reference<
typename get_result_type::type>::type type;
};
typedef ::boost::mpl::set tag_type;
template
typename ::boost::enable_if<
typename ::boost::mpl::has_key<
typename T1::tag_type,action_tag>::type,
typename transition_action_result::type >::type
operator()(EVT const& evt, FSM& fsm,SourceState& src,TargetState& tgt)const
{
return T1()(evt,fsm,src,tgt)-T2()(evt,fsm,src,tgt);
}
template
typename ::boost::enable_if<
typename ::boost::mpl::has_key<
typename T1::tag_type,state_action_tag>::type,
typename state_action_result::type >::type
operator()(Event const& evt,FSM& fsm,STATE& state )const
{
return T1()(evt,fsm,state)-T2()(evt,fsm,state);
}
};
template
struct Multiplies_ : euml_action >
{
template
struct state_action_result
{
typedef typename ::boost::remove_reference<
typename get_result_type2::type>::type type;
};
template
struct transition_action_result
{
typedef typename ::boost::remove_reference<
typename get_result_type::type>::type type;
};
typedef ::boost::mpl::set tag_type;
template
typename ::boost::enable_if<
typename ::boost::mpl::has_key<
typename T1::tag_type,action_tag>::type,
typename transition_action_result::type >::type
operator()(EVT const& evt, FSM& fsm,SourceState& src,TargetState& tgt)const
{
return T1()(evt,fsm,src,tgt)*T2()(evt,fsm,src,tgt);
}
template
typename ::boost::enable_if<
typename ::boost::mpl::has_key<
typename T1::tag_type,state_action_tag>::type,
typename state_action_result::type >::type
operator()(Event const& evt,FSM& fsm,STATE& state )const
{
return T1()(evt,fsm,state)*T2()(evt,fsm,state);
}
};
template
struct Divides_ : euml_action >
{
template
struct state_action_result
{
typedef typename ::boost::remove_reference<
typename get_result_type2::type>::type type;
};
template
struct transition_action_result
{
typedef typename ::boost::remove_reference<
typename get_result_type::type>::type type;
};
typedef ::boost::mpl::set tag_type;
template
typename ::boost::enable_if<
typename ::boost::mpl::has_key<
typename T1::tag_type,action_tag>::type,
typename transition_action_result::type >::type
operator()(EVT const& evt, FSM& fsm,SourceState& src,TargetState& tgt)const
{
return T1()(evt,fsm,src,tgt)/T2()(evt,fsm,src,tgt);
}
template
typename ::boost::enable_if<
typename ::boost::mpl::has_key<
typename T1::tag_type,state_action_tag>::type,
typename state_action_result::type >::type
operator()(Event const& evt,FSM& fsm,STATE& state )const
{
return T1()(evt,fsm,state)/T2()(evt,fsm,state);
}
};
template
struct Modulus_ : euml_action >
{
template
struct state_action_result
{
typedef typename ::boost::remove_reference<
typename get_result_type2::type>::type type;
};
template
struct transition_action_result
{
typedef typename ::boost::remove_reference<
typename get_result_type::type>::type type;
};
typedef ::boost::mpl::set tag_type;
template
typename ::boost::enable_if<
typename ::boost::mpl::has_key<
typename T1::tag_type,action_tag>::type,
typename transition_action_result::type >::type
operator()(EVT const& evt, FSM& fsm,SourceState& src,TargetState& tgt)const
{
return T1()(evt,fsm,src,tgt)%T2()(evt,fsm,src,tgt);
}
template
typename ::boost::enable_if<
typename ::boost::mpl::has_key<
typename T1::tag_type,state_action_tag>::type,
typename state_action_result::type >::type
operator()(Event const& evt,FSM& fsm,STATE& state )const
{
return T1()(evt,fsm,state)%T2()(evt,fsm,state);
}
};
template
struct Bitwise_And_ : euml_action >
{
template
struct state_action_result
{
typedef typename ::boost::remove_reference<
typename get_result_type2::type>::type type;
};
template
struct transition_action_result
{
typedef typename ::boost::remove_reference<
typename get_result_type::type>::type type;
};
typedef ::boost::mpl::set tag_type;
template
typename ::boost::enable_if<
typename ::boost::mpl::has_key<
typename T1::tag_type,action_tag>::type,
typename transition_action_result::type >::type
operator()(EVT const& evt, FSM& fsm,SourceState& src,TargetState& tgt)const
{
return T1()(evt,fsm,src,tgt)&T2()(evt,fsm,src,tgt);
}
template
typename ::boost::enable_if<
typename ::boost::mpl::has_key<
typename T1::tag_type,state_action_tag>::type,
typename state_action_result::type >::type
operator()(Event const& evt,FSM& fsm,STATE& state )const
{
return T1()(evt,fsm,state)&T2()(evt,fsm,state);
}
};
template
struct Bitwise_Or_ : euml_action >
{
template
struct state_action_result
{
typedef typename ::boost::remove_reference<
typename get_result_type2::type>::type type;
};
template
struct transition_action_result
{
typedef typename ::boost::remove_reference<
typename get_result_type::type>::type type;
};
typedef ::boost::mpl::set tag_type;
template
typename ::boost::enable_if<
typename ::boost::mpl::has_key<
typename T1::tag_type,action_tag>::type,
typename transition_action_result::type >::type
operator()(EVT const& evt, FSM& fsm,SourceState& src,TargetState& tgt)const
{
return T1()(evt,fsm,src,tgt)|T2()(evt,fsm,src,tgt);
}
template
typename ::boost::enable_if<
typename ::boost::mpl::has_key<
typename T1::tag_type,state_action_tag>::type,
typename state_action_result::type >::type
operator()(Event const& evt,FSM& fsm,STATE& state )const
{
return T1()(evt,fsm,state)|T2()(evt,fsm,state);
}
};
template
struct Bitwise_Xor_ : euml_action >
{
template
struct state_action_result
{
typedef typename ::boost::remove_reference<
typename get_result_type2::type>::type type;
};
template
struct transition_action_result
{
typedef typename ::boost::remove_reference<
typename get_result_type::type>::type type;
};
typedef ::boost::mpl::set tag_type;
template
typename ::boost::enable_if<
typename ::boost::mpl::has_key<
typename T1::tag_type,action_tag>::type,
typename transition_action_result::type >::type
operator()(EVT const& evt, FSM& fsm,SourceState& src,TargetState& tgt)const
{
return T1()(evt,fsm,src,tgt)^T2()(evt,fsm,src,tgt);
}
template
typename ::boost::enable_if<
typename ::boost::mpl::has_key<
typename T1::tag_type,state_action_tag>::type,
typename state_action_result::type >::type
operator()(Event const& evt,FSM& fsm,STATE& state )const
{
return T1()(evt,fsm,state)^T2()(evt,fsm,state);
}
};
template