My Project
result.hpp
Go to the documentation of this file.
1 #ifndef BOOST_STATECHART_RESULT_HPP_INCLUDED
2 #define BOOST_STATECHART_RESULT_HPP_INCLUDED
3 // Copyright 2002-2010 Andreas Huber Doenni
5 // Distributed under the Boost Software License, Version 1.0. (See accompany-
6 // ing file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
8 
9 
10 
11 #include <boost/assert.hpp>
12 
13 
14 
15 namespace boost
16 {
17 namespace statechart
18 {
19 namespace detail
20 {
21 
22 
23 
26 {
31  consumed
32 };
33 
34 struct result_utility;
35 
38 {
39  public:
42  reactionResult_( other.reactionResult_ )
43  {
44  // This assert fails when an attempt is made to make multiple copies of
45  // a result value. This makes little sense, given the requirement that
46  // an obtained result value must be returned out of the react function.
47  BOOST_ASSERT( reactionResult_ != consumed );
48  other.reactionResult_ = consumed;
49  }
50 
52  {
53  // This assert fails when an obtained result value is not returned out
54  // of the react() function. This can happen if the user accidentally
55  // makes more than one call to reaction functions inside react() or
56  // accidentally makes one or more calls to reaction functions outside
57  // react()
58  BOOST_ASSERT( reactionResult_ == consumed );
59  }
60 
61  private:
63  safe_reaction_result( reaction_result reactionResult ) :
64  reactionResult_( reactionResult )
65  {
66  }
67 
68  operator reaction_result() const
69  {
70  const reaction_result val = reactionResult_;
71  reactionResult_ = consumed;
72  return val;
73  }
74 
75  safe_reaction_result & operator=( const safe_reaction_result & );
76 
77  mutable reaction_result reactionResult_;
78 
79  friend struct result_utility;
80 };
81 
82 
83 
84 } // namespace detail
85 
86 
87 
88 #ifdef NDEBUG
90 #else
92 #endif
93 
94 
95 namespace detail
96 {
97 
98 
99 
102 {
104  {
105  return value;
106  }
107 
109  {
110  return value;
111  }
112 };
113 
114 
115 
116 } // namespace detail
117 } // namespace statechart
118 } // namespace boost
119 
120 
121 
122 #endif
boost::statechart::detail::result_utility::get_result
static reaction_result get_result(::boost::statechart::result value)
Definition: result.hpp:108
boost::statechart::detail::do_defer_event
@ do_defer_event
Definition: result.hpp:30
boost::statechart::result
detail::safe_reaction_result result
Definition: result.hpp:91
boost::statechart::detail::safe_reaction_result
Definition: result.hpp:38
boost
Definition: asynchronous_state_machine.hpp:20
boost::statechart::detail::reaction_result
reaction_result
Definition: result.hpp:26
boost::statechart::detail::consumed
@ consumed
Definition: result.hpp:31
boost::statechart::detail::result_utility
Definition: result.hpp:102
boost::statechart::detail::result_utility::make_result
::boost::statechart::result make_result(reaction_result value)
Definition: result.hpp:103
boost::statechart::detail::safe_reaction_result::safe_reaction_result
safe_reaction_result(const safe_reaction_result &other)
Definition: result.hpp:41
boost::statechart::detail::no_reaction
@ no_reaction
Definition: result.hpp:27
boost::statechart::detail::safe_reaction_result::~safe_reaction_result
~safe_reaction_result()
Definition: result.hpp:51
boost::statechart::detail::do_forward_event
@ do_forward_event
Definition: result.hpp:28
boost::statechart::detail::do_discard_event
@ do_discard_event
Definition: result.hpp:29