1 #ifndef BOOST_STATECHART_EVENT_PROCESSOR_INCLUDED
2 #define BOOST_STATECHART_EVENT_PROCESSOR_INCLUDED
3 //////////////////////////////////////////////////////////////////////////////
4 // Copyright 2002-2008 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 namespace boost
12 {
13 namespace statechart
14 {
15 
16 
17 
18 class event_base;
19 
20 
21 
22 //////////////////////////////////////////////////////////////////////////////
23 template< class Scheduler >
24 class event_processor
25 {
26   public:
27     //////////////////////////////////////////////////////////////////////////
~event_processor()28     virtual ~event_processor() {}
29 
my_scheduler() const30     Scheduler & my_scheduler() const
31     {
32       return myScheduler_;
33     }
34 
35     typedef typename Scheduler::processor_handle processor_handle;
36 
my_handle() const37     processor_handle my_handle() const
38     {
39       return myHandle_;
40     }
41 
initiate()42     void initiate()
43     {
44       initiate_impl();
45     }
46 
process_event(const event_base & evt)47     void process_event( const event_base & evt )
48     {
49       process_event_impl( evt );
50     }
51 
terminate()52     void terminate()
53     {
54       terminate_impl();
55     }
56 
57   protected:
58     //////////////////////////////////////////////////////////////////////////
59     typedef const typename Scheduler::processor_context & my_context;
60 
event_processor(my_context ctx)61     event_processor( my_context ctx ) :
62       myScheduler_( ctx.my_scheduler() ),
63       myHandle_( ctx.my_handle() )
64     {
65     }
66 
67   private:
68     //////////////////////////////////////////////////////////////////////////
69     virtual void initiate_impl() = 0;
70     virtual void process_event_impl( const event_base & evt ) = 0;
71     virtual void terminate_impl() = 0;
72 
73     // avoids C4512 (assignment operator could not be generated)
74     event_processor & operator=( const event_processor & );
75 
76     Scheduler & myScheduler_;
77     const processor_handle myHandle_;
78 };
79 
80 
81 
82 } // namespace statechart
83 } // namespace boost
84 
85 
86 
87 #endif
88