Apply patch for [CVE-2012-2677][boost] ordered_malloc() overflow
[external/boost.git] / boost / statechart / asynchronous_state_machine.hpp
1 #ifndef BOOST_STATECHART_ASYNCHRONOUS_STATE_MACHINE_HPP_INCLUDED
2 #define BOOST_STATECHART_ASYNCHRONOUS_STATE_MACHINE_HPP_INCLUDED
3 //////////////////////////////////////////////////////////////////////////////
4 // Copyright 2002-2006 Andreas Huber Doenni
5 // Distributed under the Boost Software License, Version 1.0. (See accompany-
6 // ing file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
7 //////////////////////////////////////////////////////////////////////////////
8
9
10
11 #include <boost/statechart/state_machine.hpp>
12 #include <boost/statechart/fifo_scheduler.hpp>
13 #include <boost/statechart/null_exception_translator.hpp>
14 #include <boost/statechart/event_processor.hpp>
15
16 #include <memory>   // std::allocator
17
18
19 namespace boost
20 {
21 namespace statechart
22 {
23
24
25
26 class event_base;
27
28
29
30 //////////////////////////////////////////////////////////////////////////////
31 template< class MostDerived,
32           class InitialState,
33           class Scheduler = fifo_scheduler<>,
34           class Allocator = std::allocator< void >,
35           class ExceptionTranslator = null_exception_translator >
36 class asynchronous_state_machine : public state_machine<
37   MostDerived, InitialState, Allocator, ExceptionTranslator >,
38   public event_processor< Scheduler >
39 {
40   typedef state_machine< MostDerived,
41     InitialState, Allocator, ExceptionTranslator > machine_base;
42   typedef event_processor< Scheduler > processor_base;
43   protected:
44     //////////////////////////////////////////////////////////////////////////
45     typedef asynchronous_state_machine my_base;
46
47     asynchronous_state_machine( typename processor_base::my_context ctx ) :
48       processor_base( ctx )
49     {
50     }
51
52     virtual ~asynchronous_state_machine() {}
53
54   public:
55     //////////////////////////////////////////////////////////////////////////
56     // The following declarations should be private.
57     // They are only public because many compilers lack template friends.
58     //////////////////////////////////////////////////////////////////////////
59     void terminate()
60     {
61       processor_base::terminate();
62     }
63
64   private:
65     //////////////////////////////////////////////////////////////////////////
66     virtual void initiate_impl()
67     {
68       machine_base::initiate();
69     }
70
71     virtual void process_event_impl( const event_base & evt )
72     {
73       machine_base::process_event( evt );
74     }
75
76     virtual void terminate_impl()
77     {
78       machine_base::terminate();
79     }
80 };
81
82
83
84 } // namespace statechart
85 } // namespace boost
86
87
88
89 #endif