1 // Copyright 2010 Christophe Henry
2 // henry UNDERSCORE christophe AT hotmail DOT com
3 // This is an extended version of the state machine available in the boost::mpl library
4 // Distributed under the same license as the original.
5 // Copyright for the original version:
6 // Copyright 2005 David Abrahams and Aleksey Gurtovoy. Distributed
7 // under the Boost Software License, Version 1.0. (See accompanying
8 // file LICENSE_1_0.txt or copy at
9 // http://www.boost.org/LICENSE_1_0.txt)
11 #ifndef BOOST_MSM_CHAR_EVENT_DISPATCHER_HPP
12 #define BOOST_MSM_CHAR_EVENT_DISPATCHER_HPP
14 #include <boost/msm/back/common_types.hpp>
17 struct char_0 : public digit {};
18 struct char_1 : public digit {};
19 struct char_2 : public digit {};
20 struct char_3 : public digit {};
21 struct char_4 : public digit {};
22 struct char_5 : public digit {};
23 struct char_6 : public digit {};
24 struct char_7 : public digit {};
25 struct char_8 : public digit {};
26 struct char_9 : public digit {};
31 struct event_char<'0'> : public digit{};
33 struct event_char<'1'> : public digit{};
35 struct event_char<'2'> : public digit{};
37 struct event_char<'3'> : public digit{};
39 struct event_char<'4'> : public digit{};
41 struct event_char<'5'> : public digit{};
43 struct event_char<'6'> : public digit{};
45 struct event_char<'7'> : public digit{};
47 struct event_char<'8'> : public digit{};
49 struct event_char<'9'> : public digit{};
51 namespace boost { namespace msm { namespace back {
55 struct char_event_dispatcher
58 struct dispatch_event_helper
60 static execute_return apply(Fsm& fsm)
62 return fsm.process_event(event_char<c>());
65 char_event_dispatcher()
67 entries[0x30]=&dispatch_event_helper<'0'>::apply;
68 entries[0x31]=&dispatch_event_helper<'1'>::apply;
69 entries[0x32]=&dispatch_event_helper<'2'>::apply;
70 entries[0x33]=&dispatch_event_helper<'3'>::apply;
71 entries[0x34]=&dispatch_event_helper<'4'>::apply;
72 entries[0x35]=&dispatch_event_helper<'5'>::apply;
73 entries[0x36]=&dispatch_event_helper<'6'>::apply;
74 entries[0x37]=&dispatch_event_helper<'7'>::apply;
75 entries[0x38]=&dispatch_event_helper<'8'>::apply;
76 entries[0x39]=&dispatch_event_helper<'9'>::apply;
77 entries[0x2D]=&dispatch_event_helper<'-'>::apply;
78 entries[0x2B]=&dispatch_event_helper<'+'>::apply;
80 execute_return process_event(Fsm& fsm,char c) const
82 return entries[c](fsm);
85 // The singleton instance.
86 static const char_event_dispatcher instance;
87 typedef execute_return (*cell)(Fsm&);
91 }}} // boost::msm::back
92 #endif //BOOST_MSM_CHAR_EVENT_DISPATCHER_HPP