Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r58693 - in branches/release: boost/statechart libs/statechart libs/statechart/test
From: ahd6974-boostorg_at_[hidden]
Date: 2010-01-04 18:27:47


Author: andreas_huber69
Date: 2010-01-04 18:27:46 EST (Mon, 04 Jan 2010)
New Revision: 58693
URL: http://svn.boost.org/trac/boost/changeset/58693

Log:
Merged triggering_event from trunk to branch.
Added:
   branches/release/libs/statechart/test/TriggeringEventTest.cpp
      - copied unchanged from r58692, /trunk/libs/statechart/test/TriggeringEventTest.cpp
   branches/release/libs/statechart/test/TriggeringEventTest.vcproj
      - copied unchanged from r58692, /trunk/libs/statechart/test/TriggeringEventTest.vcproj
Properties modified:
   branches/release/boost/statechart/ (props changed)
   branches/release/libs/statechart/ (props changed)
Text files modified:
   branches/release/boost/statechart/simple_state.hpp | 5 +
   branches/release/boost/statechart/state_machine.hpp | 127 +++++++++++++++++++++++----------------
   branches/release/libs/statechart/Statechart.sln | 8 ++
   branches/release/libs/statechart/test/Jamfile.v2 | 3
   4 files changed, 89 insertions(+), 54 deletions(-)

Modified: branches/release/boost/statechart/simple_state.hpp
==============================================================================
--- branches/release/boost/statechart/simple_state.hpp (original)
+++ branches/release/boost/statechart/simple_state.hpp 2010-01-04 18:27:46 EST (Mon, 04 Jan 2010)
@@ -347,6 +347,11 @@
         HistoryContext, orthogonalPosition >();
     }
 
+ const event_base * triggering_event() const
+ {
+ return outermost_context_base().triggering_event();
+ }
+
   protected:
     //////////////////////////////////////////////////////////////////////////
     simple_state() : pContext_( 0 ) {}

Modified: branches/release/boost/statechart/state_machine.hpp
==============================================================================
--- branches/release/boost/statechart/state_machine.hpp (original)
+++ branches/release/boost/statechart/state_machine.hpp 2010-01-04 18:27:46 EST (Mon, 04 Jan 2010)
@@ -229,7 +229,7 @@
 
 //////////////////////////////////////////////////////////////////////////////
 template< class MostDerived,
- class InitialState,
+ class InitialState,
           class Allocator = std::allocator< void >,
           class ExceptionTranslator = null_exception_translator >
 class state_machine : noncopyable
@@ -246,7 +246,7 @@
       terminate();
 
       {
- terminator guard( *this );
+ terminator guard( *this, 0 );
         detail::result_utility::get_result( translator_(
           initial_construct_function( *this ),
           exception_event_handler( *this ) ) );
@@ -258,7 +258,7 @@
 
     void terminate()
     {
- terminator guard( *this );
+ terminator guard( *this, 0 );
       detail::result_utility::get_result( translator_(
         terminate_function( *this ),
         exception_event_handler( *this ) ) );
@@ -411,7 +411,8 @@
       currentStatesEnd_( currentStates_.end() ),
       pOutermostState_( 0 ),
       isInnermostCommonOuter_( false ),
- performFullExit_( true )
+ performFullExit_( true ),
+ pTriggeringEvent_( 0 )
     {
     }
 
@@ -438,6 +439,57 @@
       post_event( evt.intrusive_from_this() );
     }
 
+ template<
+ class HistoryContext,
+ detail::orthogonal_position_type orthogonalPosition >
+ void clear_shallow_history()
+ {
+ // If you receive a
+ // "use of undefined type 'boost::STATIC_ASSERTION_FAILURE<x>'" or
+ // similar compiler error here then you tried to clear shallow history
+ // for a state that does not have shallow history. That is, the state
+ // does not pass either statechart::has_shallow_history or
+ // statechart::has_full_history to its base class template.
+ BOOST_STATIC_ASSERT( HistoryContext::shallow_history::value );
+
+ typedef typename mpl::at_c<
+ typename HistoryContext::inner_initial_list,
+ orthogonalPosition >::type historized_state;
+
+ store_history_impl(
+ shallowHistoryMap_,
+ history_key_type::make_history_key< historized_state >(),
+ 0 );
+ }
+
+ template<
+ class HistoryContext,
+ detail::orthogonal_position_type orthogonalPosition >
+ void clear_deep_history()
+ {
+ // If you receive a
+ // "use of undefined type 'boost::STATIC_ASSERTION_FAILURE<x>'" or
+ // similar compiler error here then you tried to clear deep history for
+ // a state that does not have deep history. That is, the state does not
+ // pass either statechart::has_deep_history or
+ // statechart::has_full_history to its base class template
+ BOOST_STATIC_ASSERT( HistoryContext::deep_history::value );
+
+ typedef typename mpl::at_c<
+ typename HistoryContext::inner_initial_list,
+ orthogonalPosition >::type historized_state;
+
+ store_history_impl(
+ deepHistoryMap_,
+ history_key_type::make_history_key< historized_state >(),
+ 0 );
+ }
+
+ const event_base_type * triggering_event() const
+ {
+ return pTriggeringEvent_;
+ }
+
   public:
     //////////////////////////////////////////////////////////////////////////
     // The following declarations should be private.
@@ -611,29 +663,6 @@
         reinterpret_cast< void (*)() >( &HistorizedState::deep_construct ) );
     }
 
- template<
- class HistoryContext,
- detail::orthogonal_position_type orthogonalPosition >
- void clear_shallow_history()
- {
- // If you receive a
- // "use of undefined type 'boost::STATIC_ASSERTION_FAILURE<x>'" or
- // similar compiler error here then you tried to clear shallow history
- // for a state that does not have shallow history. That is, the state
- // does not pass either statechart::has_shallow_history or
- // statechart::has_full_history to its base class template.
- BOOST_STATIC_ASSERT( HistoryContext::shallow_history::value );
-
- typedef typename mpl::at_c<
- typename HistoryContext::inner_initial_list,
- orthogonalPosition >::type historized_state;
-
- store_history_impl(
- shallowHistoryMap_,
- history_key_type::make_history_key< historized_state >(),
- 0 );
- }
-
     template< class DefaultState >
     void construct_with_shallow_history(
       const typename DefaultState::context_ptr_type & pContext )
@@ -660,29 +689,6 @@
         reinterpret_cast< void (*)() >( &constructor_type::construct ) );
     }
 
- template<
- class HistoryContext,
- detail::orthogonal_position_type orthogonalPosition >
- void clear_deep_history()
- {
- // If you receive a
- // "use of undefined type 'boost::STATIC_ASSERTION_FAILURE<x>'" or
- // similar compiler error here then you tried to clear deep history for
- // a state that does not have deep history. That is, the state does not
- // pass either statechart::has_deep_history or
- // statechart::has_full_history to its base class template
- BOOST_STATIC_ASSERT( HistoryContext::deep_history::value );
-
- typedef typename mpl::at_c<
- typename HistoryContext::inner_initial_list,
- orthogonalPosition >::type historized_state;
-
- store_history_impl(
- deepHistoryMap_,
- history_key_type::make_history_key< historized_state >(),
- 0 );
- }
-
     template< class DefaultState >
     void construct_with_deep_history(
       const typename DefaultState::context_ptr_type & pContext )
@@ -771,6 +777,10 @@
         pCurrentState : pOutermostUnstableState;
 
       BOOST_ASSERT( pHandlingState != 0 );
+ terminator guard( *this, &exceptionEvent );
+ // There is another scope guard up the call stack, which will terminate
+ // the machine. So this guard only sets the triggering event.
+ guard.dismiss();
 
       // Setting a member variable to a special value for the duration of a
       // call surely looks like a kludge (normally it should be a parameter of
@@ -831,12 +841,21 @@
     {
       public:
         //////////////////////////////////////////////////////////////////////
- terminator( state_machine & machine ) :
- machine_( machine ), dismissed_( false ) {}
+ terminator(
+ state_machine & machine, const event_base * pNewTriggeringEvent ) :
+ machine_( machine ),
+ pOldTriggeringEvent_(machine_.pTriggeringEvent_),
+ dismissed_( false )
+ {
+ machine_.pTriggeringEvent_ = pNewTriggeringEvent;
+ }
+
         ~terminator()
         {
           if ( !dismissed_ ) { machine_.terminate_impl( false ); }
+ machine_.pTriggeringEvent_ = pOldTriggeringEvent_;
         }
+
         void dismiss() { dismissed_ = true; }
 
       private:
@@ -845,6 +864,7 @@
         terminator & operator=( const terminator & );
 
         state_machine & machine_;
+ const event_base_type * const pOldTriggeringEvent_;
         bool dismissed_;
     };
     friend class terminator;
@@ -852,7 +872,7 @@
 
     void send_event( const event_base_type & evt )
     {
- terminator guard( *this );
+ terminator guard( *this, &evt );
       BOOST_ASSERT( get_pointer( pOutermostUnstableState_ ) == 0 );
       const typename rtti_policy_type::id_type eventType = evt.dynamic_type();
       detail::reaction_result reactionResult = detail::do_forward_event;
@@ -1055,6 +1075,7 @@
     bool performFullExit_;
     history_map_type shallowHistoryMap_;
     history_map_type deepHistoryMap_;
+ const event_base_type * pTriggeringEvent_;
 };
 
 

Modified: branches/release/libs/statechart/Statechart.sln
==============================================================================
--- branches/release/libs/statechart/Statechart.sln (original)
+++ branches/release/libs/statechart/Statechart.sln 2010-01-04 18:27:46 EST (Mon, 04 Jan 2010)
@@ -94,6 +94,8 @@
                 doc\uml_mapping.html = doc\uml_mapping.html
         EndProjectSection
 EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "TriggeringEventTest", "test\TriggeringEventTest.vcproj", "{DFE5C3C2-0CF9-4709-8393-96201E9A8181}"
+EndProject
 Global
         GlobalSection(SolutionConfigurationPlatforms) = preSolution
                 Debug|Win32 = Debug|Win32
@@ -318,6 +320,12 @@
                 {045411F0-A746-4DB3-85B9-C9AEDE6D5CBA}.Release|Win32.ActiveCfg = Release|Win32
                 {045411F0-A746-4DB3-85B9-C9AEDE6D5CBA}.Release|Win32.Build.0 = Release|Win32
                 {045411F0-A746-4DB3-85B9-C9AEDE6D5CBA}.ReleaseFail|Win32.ActiveCfg = Release|Win32
+ {DFE5C3C2-0CF9-4709-8393-96201E9A8181}.Debug|Win32.ActiveCfg = Debug|Win32
+ {DFE5C3C2-0CF9-4709-8393-96201E9A8181}.Debug|Win32.Build.0 = Debug|Win32
+ {DFE5C3C2-0CF9-4709-8393-96201E9A8181}.DebugFail|Win32.ActiveCfg = Debug|Win32
+ {DFE5C3C2-0CF9-4709-8393-96201E9A8181}.Release|Win32.ActiveCfg = Release|Win32
+ {DFE5C3C2-0CF9-4709-8393-96201E9A8181}.Release|Win32.Build.0 = Release|Win32
+ {DFE5C3C2-0CF9-4709-8393-96201E9A8181}.ReleaseFail|Win32.ActiveCfg = Release|Win32
         EndGlobalSection
         GlobalSection(SolutionProperties) = preSolution
                 HideSolutionNode = FALSE

Modified: branches/release/libs/statechart/test/Jamfile.v2
==============================================================================
--- branches/release/libs/statechart/test/Jamfile.v2 (original)
+++ branches/release/libs/statechart/test/Jamfile.v2 2010-01-04 18:27:46 EST (Mon, 04 Jan 2010)
@@ -1,5 +1,5 @@
 ##############################################################################
-# Copyright 2005-2006 Andreas Huber Doenni
+# Copyright 2005-2009 Andreas Huber Doenni
 # Distributed under the Boost Software License, Version 1.0. (See accompany-
 # ing file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
 ##############################################################################
@@ -137,6 +137,7 @@
     [ statechart-st-run-variants TypeInfoTest ]
     [ statechart-st-run-variants StateIterationTest ]
     [ statechart-st-run-variants FifoSchedulerTest ]
+ [ statechart-st-run-variants TriggeringEventTest ]
     [ statechart-st-lib-run LibTestNormal
         : TuTestMain : TuTest : <link>static $(normal) ]
     [ statechart-st-lib-run LibTestNative


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk