| 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_OPERATOR_H |
| 12 | #define BOOST_MSM_FRONT_OPERATOR_H |
| 13 | |
| 14 | |
| 15 | |
| 16 | namespace boost { namespace msm { namespace front |
| 17 | { |
| 18 | |
| 19 | template <class T1,class T2> |
| 20 | struct Or_ |
| 21 | { |
| 22 | template <class EVT,class FSM,class SourceState,class TargetState> |
| 23 | bool operator()(EVT const& evt, FSM& fsm,SourceState& src,TargetState& tgt) |
| 24 | { |
| 25 | return (T1()(evt,fsm,src,tgt) || T2()(evt,fsm,src,tgt)); |
| 26 | } |
| 27 | template <class Event,class FSM,class STATE> |
| 28 | bool operator()(Event const& evt,FSM& fsm,STATE& state) |
| 29 | { |
| 30 | return (T1()(evt,fsm,state) || T2()(evt,fsm,state)); |
| 31 | } |
| 32 | }; |
| 33 | template <class T1,class T2> |
| 34 | struct And_ |
| 35 | { |
| 36 | template <class EVT,class FSM,class SourceState,class TargetState> |
| 37 | bool operator()(EVT const& evt, FSM& fsm,SourceState& src,TargetState& tgt) |
| 38 | { |
| 39 | return (T1()(evt,fsm,src,tgt) && T2()(evt,fsm,src,tgt)); |
| 40 | } |
| 41 | template <class Event,class FSM,class STATE> |
| 42 | bool operator()(Event const& evt,FSM& fsm,STATE& state) |
| 43 | { |
| 44 | return (T1()(evt,fsm,state) && T2()(evt,fsm,state)); |
| 45 | } |
| 46 | }; |
| 47 | template <class T1> |
| 48 | struct Not_ |
| 49 | { |
| 50 | template <class EVT,class FSM,class SourceState,class TargetState> |
| 51 | bool operator()(EVT const& evt, FSM& fsm,SourceState& src,TargetState& tgt) |
| 52 | { |
| 53 | return !(T1()(evt,fsm,src,tgt)); |
| 54 | } |
| 55 | template <class Event,class FSM,class STATE> |
| 56 | bool operator()(Event const& evt,FSM& fsm,STATE& state) |
| 57 | { |
| 58 | return !(T1()(evt,fsm,state)); |
| 59 | } |
| 60 | }; |
| 61 | |
| 62 | |
| 63 | }}} |
| 64 | |
| 65 | #endif // BOOST_MSM_FRONT_OPERATOR_H |
| 66 | |