Boost logo

Boost-Commit :

From: ahd6974-boostorg_at_[hidden]
Date: 2008-01-03 18:17:01


Author: andreas_huber69
Date: 2008-01-03 18:17:00 EST (Thu, 03 Jan 2008)
New Revision: 42447
URL: http://svn.boost.org/trac/boost/changeset/42447

Log:
- Updated copyright years
- Factored out transition dispatching logic
Added:
   trunk/boost/statechart/detail/reaction_dispatcher.hpp (contents, props changed)
Text files modified:
   trunk/boost/statechart/detail/rtti_policy.hpp | 2
   trunk/boost/statechart/detail/state_base.hpp | 2
   trunk/boost/statechart/event.hpp | 2
   trunk/boost/statechart/event_processor.hpp | 2
   trunk/boost/statechart/fifo_worker.hpp | 2
   trunk/boost/statechart/in_state_reaction.hpp | 4
   trunk/boost/statechart/processor_container.hpp | 2
   trunk/boost/statechart/simple_state.hpp | 2
   trunk/boost/statechart/state_machine.hpp | 2
   trunk/boost/statechart/transition.hpp | 97 +++++----------------------------------
   trunk/libs/statechart/example/Performance/Performance.cpp | 2
   trunk/libs/statechart/example/PingPong/PingPong.cpp | 2
   trunk/libs/statechart/test/FifoSchedulerTest.cpp | 2
   trunk/libs/statechart/test/TuTest.cpp | 2
   14 files changed, 28 insertions(+), 97 deletions(-)

Added: trunk/boost/statechart/detail/reaction_dispatcher.hpp
==============================================================================
--- (empty file)
+++ trunk/boost/statechart/detail/reaction_dispatcher.hpp 2008-01-03 18:17:00 EST (Thu, 03 Jan 2008)
@@ -0,0 +1,121 @@
+#ifndef BOOST_STATECHART_REACTION_DISPATCHER_HPP_INCLUDED
+#define BOOST_STATECHART_REACTION_DISPATCHER_HPP_INCLUDED
+//////////////////////////////////////////////////////////////////////////////
+// Copyright 2008 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)
+//////////////////////////////////////////////////////////////////////////////
+
+
+
+#include <boost/statechart/result.hpp>
+
+#include <boost/mpl/if.hpp>
+
+#include <boost/cast.hpp> // boost::polymorphic_downcast
+#include <boost/type_traits/is_same.hpp>
+
+
+
+namespace boost
+{
+namespace statechart
+{
+namespace detail
+{
+
+
+
+//////////////////////////////////////////////////////////////////////////////
+template< class Event >
+struct no_context
+{
+ void no_function( const Event & );
+};
+
+//////////////////////////////////////////////////////////////////////////////
+template<
+ class Reactions, class State, class EventBase, class Event,
+ class ActionContext, class IdType >
+class reaction_dispatcher
+{
+ private:
+ struct without_action
+ {
+ static result react( State & stt, const EventBase & )
+ {
+ return Reactions::react_without_action( stt );
+ }
+ };
+
+ struct base_with_action
+ {
+ static result react( State & stt, const EventBase & evt )
+ {
+ return Reactions::react_with_action( stt, evt );
+ }
+ };
+
+ struct base
+ {
+ static result react(
+ State & stt, const EventBase & evt, const IdType & )
+ {
+ typedef typename mpl::if_<
+ is_same< ActionContext, detail::no_context< Event > >,
+ without_action, base_with_action
+ >::type reaction;
+ return reaction::react( stt, evt );
+ }
+ };
+
+ struct derived_with_action
+ {
+ static result react( State & stt, const EventBase & evt )
+ {
+ return Reactions::react_with_action(
+ stt, *polymorphic_downcast< const Event * >( &evt ) );
+ }
+ };
+
+ struct derived
+ {
+ static result react(
+ State & stt, const EventBase & evt, const IdType & eventType )
+ {
+ if ( eventType == Event::static_type() )
+ {
+ typedef typename mpl::if_<
+ is_same< ActionContext, detail::no_context< Event > >,
+ without_action, derived_with_action
+ >::type reaction;
+ return reaction::react( stt, evt );
+ }
+ else
+ {
+ return detail::result_utility::make_result( detail::no_reaction );
+ }
+ }
+ };
+
+ public:
+ static reaction_result react(
+ State & stt, const EventBase & evt, const IdType & eventType )
+ {
+ typedef typename mpl::if_<
+ is_same< Event, EventBase >, base, derived
+ >::type reaction;
+ return result_utility::get_result(
+ reaction::react( stt, evt, eventType ) );
+ }
+};
+
+
+
+} // namespace detail
+} // namespace statechart
+} // namespace boost
+
+
+
+#endif

Modified: trunk/boost/statechart/detail/rtti_policy.hpp
==============================================================================
--- trunk/boost/statechart/detail/rtti_policy.hpp (original)
+++ trunk/boost/statechart/detail/rtti_policy.hpp 2008-01-03 18:17:00 EST (Thu, 03 Jan 2008)
@@ -1,7 +1,7 @@
 #ifndef BOOST_STATECHART_DETAIL_RTTI_POLICY_HPP_INCLUDED
 #define BOOST_STATECHART_DETAIL_RTTI_POLICY_HPP_INCLUDED
 //////////////////////////////////////////////////////////////////////////////
-// Copyright 2002-2006 Andreas Huber Doenni
+// Copyright 2002-2008 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)
 //////////////////////////////////////////////////////////////////////////////

Modified: trunk/boost/statechart/detail/state_base.hpp
==============================================================================
--- trunk/boost/statechart/detail/state_base.hpp (original)
+++ trunk/boost/statechart/detail/state_base.hpp 2008-01-03 18:17:00 EST (Thu, 03 Jan 2008)
@@ -1,7 +1,7 @@
 #ifndef BOOST_STATECHART_DETAIL_STATE_BASE_HPP_INCLUDED
 #define BOOST_STATECHART_DETAIL_STATE_BASE_HPP_INCLUDED
 //////////////////////////////////////////////////////////////////////////////
-// Copyright 2002-2006 Andreas Huber Doenni
+// Copyright 2002-2008 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)
 //////////////////////////////////////////////////////////////////////////////

Modified: trunk/boost/statechart/event.hpp
==============================================================================
--- trunk/boost/statechart/event.hpp (original)
+++ trunk/boost/statechart/event.hpp 2008-01-03 18:17:00 EST (Thu, 03 Jan 2008)
@@ -1,7 +1,7 @@
 #ifndef BOOST_STATECHART_EVENT_HPP_INCLUDED
 #define BOOST_STATECHART_EVENT_HPP_INCLUDED
 //////////////////////////////////////////////////////////////////////////////
-// Copyright 2002-2006 Andreas Huber Doenni
+// Copyright 2002-2007 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)
 //////////////////////////////////////////////////////////////////////////////

Modified: trunk/boost/statechart/event_processor.hpp
==============================================================================
--- trunk/boost/statechart/event_processor.hpp (original)
+++ trunk/boost/statechart/event_processor.hpp 2008-01-03 18:17:00 EST (Thu, 03 Jan 2008)
@@ -1,7 +1,7 @@
 #ifndef BOOST_STATECHART_EVENT_PROCESSOR_INCLUDED
 #define BOOST_STATECHART_EVENT_PROCESSOR_INCLUDED
 //////////////////////////////////////////////////////////////////////////////
-// Copyright 2002-2006 Andreas Huber Doenni
+// Copyright 2002-2008 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)
 //////////////////////////////////////////////////////////////////////////////

Modified: trunk/boost/statechart/fifo_worker.hpp
==============================================================================
--- trunk/boost/statechart/fifo_worker.hpp (original)
+++ trunk/boost/statechart/fifo_worker.hpp 2008-01-03 18:17:00 EST (Thu, 03 Jan 2008)
@@ -1,7 +1,7 @@
 #ifndef BOOST_STATECHART_FIFO_WORKER_HPP_INCLUDED
 #define BOOST_STATECHART_FIFO_WORKER_HPP_INCLUDED
 //////////////////////////////////////////////////////////////////////////////
-// Copyright 2002-2007 Andreas Huber Doenni
+// Copyright 2002-2008 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)
 //////////////////////////////////////////////////////////////////////////////

Modified: trunk/boost/statechart/in_state_reaction.hpp
==============================================================================
--- trunk/boost/statechart/in_state_reaction.hpp (original)
+++ trunk/boost/statechart/in_state_reaction.hpp 2008-01-03 18:17:00 EST (Thu, 03 Jan 2008)
@@ -1,7 +1,7 @@
 #ifndef BOOST_STATECHART_IN_STATE_REACTION_HPP_INCLUDED
 #define BOOST_STATECHART_IN_STATE_REACTION_HPP_INCLUDED
 //////////////////////////////////////////////////////////////////////////////
-// Copyright 2005-2006 Andreas Huber Doenni
+// Copyright 2005-2008 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)
 //////////////////////////////////////////////////////////////////////////////
@@ -27,7 +27,7 @@
 class event_base;
 
 //////////////////////////////////////////////////////////////////////////////
-template< class Event,
+template< class Event,
           class ReactionContext,
           void ( ReactionContext::*pAction )( const Event & ) >
 class in_state_reaction

Modified: trunk/boost/statechart/processor_container.hpp
==============================================================================
--- trunk/boost/statechart/processor_container.hpp (original)
+++ trunk/boost/statechart/processor_container.hpp 2008-01-03 18:17:00 EST (Thu, 03 Jan 2008)
@@ -1,7 +1,7 @@
 #ifndef BOOST_STATECHART_PROCESSOR_CONTAINER_HPP_INCLUDED
 #define BOOST_STATECHART_PROCESSOR_CONTAINER_HPP_INCLUDED
 //////////////////////////////////////////////////////////////////////////////
-// Copyright 2002-2006 Andreas Huber Doenni
+// Copyright 2002-2008 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)
 //////////////////////////////////////////////////////////////////////////////

Modified: trunk/boost/statechart/simple_state.hpp
==============================================================================
--- trunk/boost/statechart/simple_state.hpp (original)
+++ trunk/boost/statechart/simple_state.hpp 2008-01-03 18:17:00 EST (Thu, 03 Jan 2008)
@@ -1,7 +1,7 @@
 #ifndef BOOST_STATECHART_SIMPLE_STATE_HPP_INCLUDED
 #define BOOST_STATECHART_SIMPLE_STATE_HPP_INCLUDED
 //////////////////////////////////////////////////////////////////////////////
-// Copyright 2002-2006 Andreas Huber Doenni
+// Copyright 2002-2008 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)
 //////////////////////////////////////////////////////////////////////////////

Modified: trunk/boost/statechart/state_machine.hpp
==============================================================================
--- trunk/boost/statechart/state_machine.hpp (original)
+++ trunk/boost/statechart/state_machine.hpp 2008-01-03 18:17:00 EST (Thu, 03 Jan 2008)
@@ -1,7 +1,7 @@
 #ifndef BOOST_STATECHART_STATE_MACHINE_HPP_INCLUDED
 #define BOOST_STATECHART_STATE_MACHINE_HPP_INCLUDED
 //////////////////////////////////////////////////////////////////////////////
-// Copyright 2002-2006 Andreas Huber Doenni
+// Copyright 2002-2008 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)
 //////////////////////////////////////////////////////////////////////////////

Modified: trunk/boost/statechart/transition.hpp
==============================================================================
--- trunk/boost/statechart/transition.hpp (original)
+++ trunk/boost/statechart/transition.hpp 2008-01-03 18:17:00 EST (Thu, 03 Jan 2008)
@@ -1,7 +1,7 @@
 #ifndef BOOST_STATECHART_TRANSITION_HPP_INCLUDED
 #define BOOST_STATECHART_TRANSITION_HPP_INCLUDED
 //////////////////////////////////////////////////////////////////////////////
-// Copyright 2002-2006 Andreas Huber Doenni
+// Copyright 2002-2008 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)
 //////////////////////////////////////////////////////////////////////////////
@@ -10,10 +10,7 @@
 
 #include <boost/statechart/result.hpp>
 
-#include <boost/mpl/if.hpp>
-
-#include <boost/cast.hpp> // boost::polymorphic_downcast
-#include <boost/type_traits/is_same.hpp>
+#include <boost/statechart/detail/reaction_dispatcher.hpp>
 
 
 
@@ -21,27 +18,10 @@
 {
 namespace statechart
 {
-namespace detail
-{
 
 
 
 //////////////////////////////////////////////////////////////////////////////
-template< class Event >
-struct no_context
-{
- void no_function( const Event & );
-};
-
-
-
-} // namespace detail
-
-
-
-class event_base;
-
-//////////////////////////////////////////////////////////////////////////////
 template< class Event, class Destination,
           class TransitionContext = detail::no_context< Event >,
           void ( TransitionContext::*pTransitionAction )( const Event & ) =
@@ -50,67 +30,20 @@
 {
   private:
     //////////////////////////////////////////////////////////////////////////
- struct react_without_transition_action_impl
+ template<
+ class State, class ActionContext,
+ void ( ActionContext::*pAction )( const Event & ), class Destination >
+ struct reactions
     {
- template< class State, class EventBase >
- static result react( State & stt, const EventBase & )
+ static result react_without_action( State & stt )
       {
         return stt.template transit< Destination >();
       }
- };
-
- struct react_base_with_transition_action_impl
- {
- template< class State, class EventBase >
- static result react( State & stt, const EventBase & evt )
- {
- return stt.template transit< Destination >( pTransitionAction, evt );
- }
- };
 
- struct react_base
- {
- template< class State, class EventBase, class IdType >
- static result react( State & stt, const EventBase & evt, const IdType & )
+ template< class Event >
+ static result react_with_action( State & stt, const Event & evt )
       {
- typedef typename mpl::if_<
- is_same< TransitionContext, detail::no_context< Event > >,
- react_without_transition_action_impl,
- react_base_with_transition_action_impl
- >::type impl;
- return impl::react( stt, evt );
- }
- };
-
- struct react_derived_with_transition_action_impl
- {
- template< class State, class EventBase >
- static result react( State & stt, const EventBase & evt )
- {
- return stt.template transit< Destination >(
- pTransitionAction, *polymorphic_downcast< const Event * >( &evt ) );
- }
- };
-
- struct react_derived
- {
- template< class State, class EventBase, class IdType >
- static result react(
- State & stt, const EventBase & evt, const IdType & eventType )
- {
- if ( eventType == Event::static_type() )
- {
- typedef typename mpl::if_<
- is_same< TransitionContext, detail::no_context< Event > >,
- react_without_transition_action_impl,
- react_derived_with_transition_action_impl
- >::type impl;
- return impl::react( stt, evt );
- }
- else
- {
- return detail::result_utility::make_result( detail::no_reaction );
- }
+ return stt.template transit< Destination >( pAction, evt );
       }
     };
 
@@ -123,12 +56,10 @@
     static detail::reaction_result react(
       State & stt, const EventBase & evt, const IdType & eventType )
     {
- typedef typename mpl::if_<
- is_same< Event, event_base >, react_base, react_derived
- >::type impl;
-
- return detail::result_utility::get_result(
- impl::react( stt, evt, eventType ) );
+ typedef detail::reaction_dispatcher<
+ reactions< State, TransitionContext, pTransitionAction, Destination >,
+ State, EventBase, Event, TransitionContext, IdType > dispatcher;
+ return dispatcher::react( stt, evt, eventType );
     }
 };
 

Modified: trunk/libs/statechart/example/Performance/Performance.cpp
==============================================================================
--- trunk/libs/statechart/example/Performance/Performance.cpp (original)
+++ trunk/libs/statechart/example/Performance/Performance.cpp 2008-01-03 18:17:00 EST (Thu, 03 Jan 2008)
@@ -1,5 +1,5 @@
 //////////////////////////////////////////////////////////////////////////////
-// Copyright 2005-2006 Andreas Huber Doenni
+// Copyright 2005-2008 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)
 //////////////////////////////////////////////////////////////////////////////

Modified: trunk/libs/statechart/example/PingPong/PingPong.cpp
==============================================================================
--- trunk/libs/statechart/example/PingPong/PingPong.cpp (original)
+++ trunk/libs/statechart/example/PingPong/PingPong.cpp 2008-01-03 18:17:00 EST (Thu, 03 Jan 2008)
@@ -1,5 +1,5 @@
 //////////////////////////////////////////////////////////////////////////////
-// Copyright 2002-2007 Andreas Huber Doenni
+// Copyright 2002-2008 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)
 //////////////////////////////////////////////////////////////////////////////

Modified: trunk/libs/statechart/test/FifoSchedulerTest.cpp
==============================================================================
--- trunk/libs/statechart/test/FifoSchedulerTest.cpp (original)
+++ trunk/libs/statechart/test/FifoSchedulerTest.cpp 2008-01-03 18:17:00 EST (Thu, 03 Jan 2008)
@@ -1,5 +1,5 @@
 //////////////////////////////////////////////////////////////////////////////
-// Copyright 2005-2006 Andreas Huber Doenni
+// Copyright 2005-2008 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)
 //////////////////////////////////////////////////////////////////////////////

Modified: trunk/libs/statechart/test/TuTest.cpp
==============================================================================
--- trunk/libs/statechart/test/TuTest.cpp (original)
+++ trunk/libs/statechart/test/TuTest.cpp 2008-01-03 18:17:00 EST (Thu, 03 Jan 2008)
@@ -1,5 +1,5 @@
 //////////////////////////////////////////////////////////////////////////////
-// Copyright 2005-2006 Andreas Huber Doenni
+// Copyright 2005-2008 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)
 //////////////////////////////////////////////////////////////////////////////


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