Files
boost_mpl/example/fsm/aux_/transition.hpp
T

47 lines
1.0 KiB
C++
Raw Normal View History

2002-11-15 11:57:18 +00:00
#ifndef BOOST_FSM_TRANSITION_INCLUDED
#define BOOST_FSM_TRANSITION_INCLUDED
2004-09-02 15:41:37 +00:00
// Copyright Aleksey Gurtovoy 2002-2004
//
// 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)
//
// See http://www.boost.org/libs/mpl for documentation.
2008-10-10 09:21:07 +00:00
// $Id$
2004-09-02 15:41:37 +00:00
// $Date$
// $Revision$
2002-11-15 11:57:18 +00:00
#include <cassert>
2004-09-02 15:41:37 +00:00
namespace fsm { namespace aux {
2002-11-15 11:57:18 +00:00
// represent a signle transition between states |From| and |To|
template<
typename T
, typename From
, typename Event
, typename To
, bool (T::* transition_func)(Event const&)
>
struct transition
{
typedef T fsm_t;
2002-12-27 09:08:30 +00:00
typedef From from_state_t;
2002-11-15 11:57:18 +00:00
typedef Event event_t;
2002-12-27 09:08:30 +00:00
typedef To to_state_t;
2002-11-15 11:57:18 +00:00
2002-12-27 09:08:30 +00:00
typedef typename Event::base_t base_event_t;
2002-11-15 11:57:18 +00:00
static bool do_transition(T& x, base_event_t const& e)
{
assert(dynamic_cast<event_t const*>(&e) == &e);
return (x.*transition_func)(static_cast<event_t const &>(e));
}
};
2004-09-02 15:41:37 +00:00
}}
2002-11-15 11:57:18 +00:00
#endif // BOOST_FSM_TRANSITION_INCLUDED