Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:52:31

0001 #ifndef BOOST_STATECHART_EVENT_HPP_INCLUDED
0002 #define BOOST_STATECHART_EVENT_HPP_INCLUDED
0003 //////////////////////////////////////////////////////////////////////////////
0004 // Copyright 2002-2007 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 #include <boost/statechart/event_base.hpp>
0012 #include <boost/statechart/detail/rtti_policy.hpp>
0013 #include <boost/statechart/detail/memory.hpp>
0014 
0015 #include <boost/polymorphic_cast.hpp> // boost::polymorphic_downcast
0016 
0017 #include <memory> // std::allocator
0018 
0019 
0020 
0021 namespace boost
0022 {
0023 namespace statechart
0024 {
0025 
0026 
0027 
0028 //////////////////////////////////////////////////////////////////////////////
0029 template< class MostDerived, class Allocator = std::allocator< none > >
0030 class event : public detail::rtti_policy::rtti_derived_type<
0031   MostDerived, event_base >
0032 {
0033   public:
0034     //////////////////////////////////////////////////////////////////////////
0035     // Compiler-generated copy constructor and copy assignment operator are
0036     // fine
0037 
0038     void * operator new( std::size_t size )
0039     {
0040       return detail::allocate< MostDerived, Allocator >( size );
0041     }
0042 
0043     void * operator new( std::size_t, void * p )
0044     {
0045       return p;
0046     }
0047 
0048     void operator delete( void * pEvent )
0049     {
0050       detail::deallocate< MostDerived, Allocator >( pEvent );
0051     }
0052 
0053     void operator delete( void * pEvent, void * p )
0054     {
0055     }
0056 
0057   protected:
0058     //////////////////////////////////////////////////////////////////////////
0059     event() {}
0060     virtual ~event() {}
0061 
0062   private:
0063     //////////////////////////////////////////////////////////////////////////
0064     virtual intrusive_ptr< const event_base > clone() const
0065     {
0066       return intrusive_ptr< const event_base >( new MostDerived(
0067         *polymorphic_downcast< const MostDerived * >( this ) ) );
0068     }
0069 };
0070 
0071 
0072 
0073 } // namespace statechart
0074 } // namespace boost
0075 
0076 
0077 
0078 #endif