File indexing completed on 2025-01-18 09:52:32
0001 #ifndef BOOST_STATECHART_RESULT_HPP_INCLUDED
0002 #define BOOST_STATECHART_RESULT_HPP_INCLUDED
0003
0004
0005
0006
0007
0008
0009
0010
0011 #include <boost/assert.hpp>
0012
0013
0014
0015 namespace boost
0016 {
0017 namespace statechart
0018 {
0019 namespace detail
0020 {
0021
0022
0023
0024
0025 enum reaction_result
0026 {
0027 no_reaction,
0028 do_forward_event,
0029 do_discard_event,
0030 do_defer_event,
0031 consumed
0032 };
0033
0034 struct result_utility;
0035
0036
0037 class safe_reaction_result
0038 {
0039 public:
0040
0041 safe_reaction_result( const safe_reaction_result & other ) :
0042 reactionResult_( other.reactionResult_ )
0043 {
0044
0045
0046
0047 BOOST_ASSERT( reactionResult_ != consumed );
0048 other.reactionResult_ = consumed;
0049 }
0050
0051 ~safe_reaction_result()
0052 {
0053
0054
0055
0056
0057
0058 BOOST_ASSERT( reactionResult_ == consumed );
0059 }
0060
0061 private:
0062
0063 safe_reaction_result( reaction_result reactionResult ) :
0064 reactionResult_( reactionResult )
0065 {
0066 }
0067
0068 operator reaction_result() const
0069 {
0070 const reaction_result val = reactionResult_;
0071 reactionResult_ = consumed;
0072 return val;
0073 }
0074
0075 safe_reaction_result & operator=( const safe_reaction_result & );
0076
0077 mutable reaction_result reactionResult_;
0078
0079 friend struct result_utility;
0080 };
0081
0082
0083
0084 }
0085
0086
0087
0088 #ifdef NDEBUG
0089 typedef detail::reaction_result result;
0090 #else
0091 typedef detail::safe_reaction_result result;
0092 #endif
0093
0094
0095 namespace detail
0096 {
0097
0098
0099
0100
0101 struct result_utility
0102 {
0103 static ::boost::statechart::result make_result( reaction_result value )
0104 {
0105 return value;
0106 }
0107
0108 static reaction_result get_result( ::boost::statechart::result value )
0109 {
0110 return value;
0111 }
0112 };
0113
0114
0115
0116 }
0117 }
0118 }
0119
0120
0121
0122 #endif