operator.hpp 1.9 KB

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