Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-30 10:00:51

0001 #ifndef BOOST_STATECHART_EVENT_PROCESSOR_INCLUDED
0002 #define BOOST_STATECHART_EVENT_PROCESSOR_INCLUDED
0003 //////////////////////////////////////////////////////////////////////////////
0004 // Copyright 2002-2008 Andreas Huber Doenni
0005 // Distributed under the Boost Software License, Version 1.0. (See accompany-
0006 // ing file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
0007 //////////////////////////////////////////////////////////////////////////////
0008 
0009 
0010 
0011 namespace boost
0012 {
0013 namespace statechart
0014 {
0015 
0016 
0017   
0018 class event_base;
0019 
0020 
0021 
0022 //////////////////////////////////////////////////////////////////////////////
0023 template< class Scheduler >
0024 class event_processor
0025 {
0026   public:
0027     //////////////////////////////////////////////////////////////////////////
0028     virtual ~event_processor() {}
0029 
0030     Scheduler & my_scheduler() const
0031     {
0032       return myScheduler_;
0033     }
0034 
0035     typedef typename Scheduler::processor_handle processor_handle;
0036 
0037     processor_handle my_handle() const
0038     {
0039       return myHandle_;
0040     }
0041 
0042     void initiate()
0043     {
0044       initiate_impl();
0045     }
0046 
0047     void process_event( const event_base & evt )
0048     {
0049       process_event_impl( evt );
0050     }
0051 
0052     void terminate()
0053     {
0054       terminate_impl();
0055     }
0056 
0057   protected:
0058     //////////////////////////////////////////////////////////////////////////
0059     typedef const typename Scheduler::processor_context & my_context;
0060 
0061     event_processor( my_context ctx ) :
0062       myScheduler_( ctx.my_scheduler() ),
0063       myHandle_( ctx.my_handle() )
0064     {
0065     }
0066 
0067   private:
0068     //////////////////////////////////////////////////////////////////////////
0069     virtual void initiate_impl() = 0;
0070     virtual void process_event_impl( const event_base & evt ) = 0;
0071     virtual void terminate_impl() = 0;
0072 
0073     // avoids C4512 (assignment operator could not be generated)
0074     event_processor & operator=( const event_processor & );
0075 
0076     Scheduler & myScheduler_;
0077     const processor_handle myHandle_;
0078 };
0079 
0080 
0081 
0082 } // namespace statechart
0083 } // namespace boost
0084 
0085 
0086 
0087 #endif