]> git.proxmox.com Git - ceph.git/blame - ceph/src/boost/libs/msm/doc/HTML/examples/char_event_dispatcher.hpp
bump version to 12.2.2-pve1
[ceph.git] / ceph / src / boost / libs / msm / doc / HTML / examples / char_event_dispatcher.hpp
CommitLineData
7c673cae
FG
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)
10
11#ifndef BOOST_MSM_CHAR_EVENT_DISPATCHER_HPP
12#define BOOST_MSM_CHAR_EVENT_DISPATCHER_HPP
13
14#include <boost/msm/back/common_types.hpp>
15
16struct digit {};
17struct char_0 : public digit {};
18struct char_1 : public digit {};
19struct char_2 : public digit {};
20struct char_3 : public digit {};
21struct char_4 : public digit {};
22struct char_5 : public digit {};
23struct char_6 : public digit {};
24struct char_7 : public digit {};
25struct char_8 : public digit {};
26struct char_9 : public digit {};
27struct minus_char {};
28template <char c>
29struct event_char{};
30template <>
31struct event_char<'0'> : public digit{};
32template <>
33struct event_char<'1'> : public digit{};
34template <>
35struct event_char<'2'> : public digit{};
36template <>
37struct event_char<'3'> : public digit{};
38template <>
39struct event_char<'4'> : public digit{};
40template <>
41struct event_char<'5'> : public digit{};
42template <>
43struct event_char<'6'> : public digit{};
44template <>
45struct event_char<'7'> : public digit{};
46template <>
47struct event_char<'8'> : public digit{};
48template <>
49struct event_char<'9'> : public digit{};
50
51namespace boost { namespace msm { namespace back {
52
53
54template <class Fsm>
55struct char_event_dispatcher
56{
57 template <char c>
58 struct dispatch_event_helper
59 {
60 static execute_return apply(Fsm& fsm)
61 {
62 return fsm.process_event(event_char<c>());
63 }
64 };
65 char_event_dispatcher()
66 {
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;
79 }
80 execute_return process_event(Fsm& fsm,char c) const
81 {
82 return entries[c](fsm);
83 }
84
85 // The singleton instance.
86 static const char_event_dispatcher instance;
87 typedef execute_return (*cell)(Fsm&);
88 cell entries[255];
89};
90
91}}} // boost::msm::back
92#endif //BOOST_MSM_CHAR_EVENT_DISPATCHER_HPP