|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r74187 - trunk/boost/msm/back
From: christophe.j.henry_at_[hidden]
Date: 2011-09-01 16:37:27
Author: chenry
Date: 2011-09-01 16:37:26 EDT (Thu, 01 Sep 2011)
New Revision: 74187
URL: http://svn.boost.org/trac/boost/changeset/74187
Log:
reverted back favor_compile_time policy to rev. 67897 as later versions were broken
Removed:
trunk/boost/msm/back/any_event.hpp
Text files modified:
trunk/boost/msm/back/favor_compile_time.hpp | 46 ++++++++++++++++++++++++++-------------
trunk/boost/msm/back/state_machine.hpp | 8 +++++-
2 files changed, 36 insertions(+), 18 deletions(-)
Deleted: trunk/boost/msm/back/any_event.hpp
==============================================================================
--- trunk/boost/msm/back/any_event.hpp 2011-09-01 16:37:26 EDT (Thu, 01 Sep 2011)
+++ (empty file)
@@ -1,56 +0,0 @@
-// Copyright 2008 Christophe Henry
-// henry UNDERSCORE christophe AT hotmail DOT com
-// This is an extended version of the state machine available in the boost::mpl library
-// Distributed under the same license as the original.
-// Copyright for the original version:
-// Copyright 2005 David Abrahams and Aleksey Gurtovoy. Distributed
-// under the Boost Software License, Version 1.0. (See accompanying
-// file LICENSE_1_0.txt or copy at
-// http://www.boost.org/LICENSE_1_0.txt)
-
-#ifndef BOOST_MSM_BACK_ANY_EVENT_H
-#define BOOST_MSM_BACK_ANY_EVENT_H
-
-#include <boost/smart_ptr/scoped_ptr.hpp>
-#include <boost/msm/back/common_types.hpp>
-
-namespace boost { namespace msm { namespace back
-{
-class placeholder
-{
-public:
- virtual ~placeholder(){}
- virtual ::boost::msm::back::HandledEnum process_event() const =0;
-};
-template<class EventType,class FsmType>
-class holder : public placeholder
-{
-public:
- virtual ~holder(){}
- holder(EventType const& evt, FsmType& fsm){}
- virtual ::boost::msm::back::HandledEnum process_event() const
- {
- //default. Will not be called
- return HANDLED_TRUE;
- }
-private:
-};
-
-class any_event
-{
-public:
- template <class EventType,class FsmType>
- any_event(EventType const& evt,FsmType& fsm):content_(new holder<EventType,FsmType>(evt,fsm)){}
- ::boost::msm::back::HandledEnum process_event() const
- {
- return content_->process_event();
- }
-private:
-
- ::boost::scoped_ptr<placeholder> content_;
-};
-
-}}}
-
-#endif //BOOST_MSM_BACK_ANY_EVENT_H
-
Modified: trunk/boost/msm/back/favor_compile_time.hpp
==============================================================================
--- trunk/boost/msm/back/favor_compile_time.hpp (original)
+++ trunk/boost/msm/back/favor_compile_time.hpp 2011-09-01 16:37:26 EDT (Thu, 01 Sep 2011)
@@ -17,33 +17,48 @@
#include <boost/mpl/filter_view.hpp>
#include <boost/mpl/for_each.hpp>
#include <boost/mpl/bool.hpp>
+#include <boost/any.hpp>
#include <boost/msm/common.hpp>
#include <boost/msm/back/metafunctions.hpp>
#include <boost/msm/back/common_types.hpp>
#include <boost/msm/back/dispatch_table.hpp>
-#include <boost/msm/back/any_event.hpp>
namespace boost { namespace msm { namespace back
{
+template <class Fsm>
+struct process_any_event_helper
+{
+ process_any_event_helper(msm::back::HandledEnum& res_,Fsm* self_,::boost::any any_event_):
+ res(res_),self(self_),any_event(any_event_),finished(false){}
+ template <class Event>
+ void operator()(boost::msm::wrap<Event> const&)
+ {
+ if ( ! finished && ::boost::any_cast<Event>(&any_event)!=0)
+ {
+ finished = true;
+ res = self->process_event(::boost::any_cast<Event>(any_event));
+ }
+ }
+private:
+ msm::back::HandledEnum& res;
+ Fsm* self;
+ ::boost::any any_event;
+ bool finished;
+};
+
#define BOOST_MSM_BACK_GENERATE_PROCESS_EVENT(fsmname) \
namespace boost { namespace msm { namespace back{ \
- template<class EventType> \
- class holder<EventType,fsmname> : public placeholder \
- { \
- public: \
- holder(EventType const& evt, fsmname& fsm): event_(evt),fsm_(fsm){} \
- virtual ::boost::msm::back::HandledEnum process_event() const \
- {return fsm_.process_event(event_);} \
- private: \
- EventType const& event_; \
- fsmname& fsm_; \
- }; \
template<> \
- ::boost::msm::back::HandledEnum fsmname::process_any_event( any_event const& evt)const \
+ ::boost::msm::back::HandledEnum fsmname::process_any_event( ::boost::any const& any_event) \
{ \
- return evt.process_event(); \
+ typedef ::boost::msm::back::recursive_get_transition_table<fsmname>::type stt; \
+ typedef ::boost::msm::back::generate_event_set<stt>::type all_events; \
+ ::boost::msm::back::HandledEnum res= ::boost::msm::back::HANDLED_FALSE; \
+ ::boost::mpl::for_each<all_events, ::boost::msm::wrap< ::boost::mpl::placeholders::_1> > \
+ (::boost::msm::back::process_any_event_helper<fsmname>(res,this,any_event)); \
+ return res; \
} \
}}}
@@ -92,8 +107,7 @@
template <class TransitionState>
static HandledEnum call_submachine(Fsm& fsm, int region, int state, Event const& evt)
{
- return (fsm.template get_state<TransitionState&>()).process_any_event
- ( any_event(evt,fsm.template get_state<TransitionState&>()) );
+ return (fsm.template get_state<TransitionState&>()).process_any_event( ::boost::any(evt));
}
// A function object for use with mpl::for_each that stuffs
// transitions into cells.
Modified: trunk/boost/msm/back/state_machine.hpp
==============================================================================
--- trunk/boost/msm/back/state_machine.hpp (original)
+++ trunk/boost/msm/back/state_machine.hpp 2011-09-01 16:37:26 EDT (Thu, 01 Sep 2011)
@@ -42,6 +42,9 @@
#include <boost/bind.hpp>
#include <boost/bind/apply.hpp>
#include <boost/function.hpp>
+#ifndef BOOST_NO_RTTI
+#include <boost/any.hpp>
+#endif
#include <boost/serialization/base_object.hpp>
@@ -59,7 +62,6 @@
#include <boost/msm/back/dispatch_table.hpp>
#include <boost/msm/back/no_fsm_check.hpp>
#include <boost/msm/back/queue_container_deque.hpp>
-#include <boost/msm/back/any_event.hpp>
BOOST_MPL_HAS_XXX_TRAIT_DEF(accept_sig)
BOOST_MPL_HAS_XXX_TRAIT_DEF(no_automatic_create)
@@ -1826,7 +1828,9 @@
template <class Event>
void no_action(Event const&){}
- HandledEnum process_any_event( any_event const& evt) const;
+#ifndef BOOST_NO_RTTI
+ HandledEnum process_any_event( ::boost::any const& evt);
+#endif
private:
// composite accept implementation. First calls accept on the composite, then accept on all its active states.
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