sl@0
|
1 |
#ifndef BOOST_STATECHART_EVENT_HPP_INCLUDED
|
sl@0
|
2 |
#define BOOST_STATECHART_EVENT_HPP_INCLUDED
|
sl@0
|
3 |
//////////////////////////////////////////////////////////////////////////////
|
sl@0
|
4 |
// Copyright 2002-2006 Andreas Huber Doenni
|
sl@0
|
5 |
// Distributed under the Boost Software License, Version 1.0. (See accompany-
|
sl@0
|
6 |
// ing file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
sl@0
|
7 |
//////////////////////////////////////////////////////////////////////////////
|
sl@0
|
8 |
|
sl@0
|
9 |
|
sl@0
|
10 |
|
sl@0
|
11 |
#include <boost/statechart/event_base.hpp>
|
sl@0
|
12 |
#include <boost/statechart/detail/rtti_policy.hpp>
|
sl@0
|
13 |
#include <boost/statechart/detail/memory.hpp>
|
sl@0
|
14 |
|
sl@0
|
15 |
#include <boost/cast.hpp> // boost::polymorphic_downcast
|
sl@0
|
16 |
|
sl@0
|
17 |
#include <memory> // std::allocator
|
sl@0
|
18 |
|
sl@0
|
19 |
|
sl@0
|
20 |
|
sl@0
|
21 |
namespace boost
|
sl@0
|
22 |
{
|
sl@0
|
23 |
namespace statechart
|
sl@0
|
24 |
{
|
sl@0
|
25 |
|
sl@0
|
26 |
|
sl@0
|
27 |
|
sl@0
|
28 |
//////////////////////////////////////////////////////////////////////////////
|
sl@0
|
29 |
template< class MostDerived, class Allocator = std::allocator< void > >
|
sl@0
|
30 |
class event : public detail::rtti_policy::rtti_derived_type<
|
sl@0
|
31 |
MostDerived, event_base >
|
sl@0
|
32 |
{
|
sl@0
|
33 |
public:
|
sl@0
|
34 |
//////////////////////////////////////////////////////////////////////////
|
sl@0
|
35 |
// Compiler-generated copy constructor and copy assignment operator are
|
sl@0
|
36 |
// fine
|
sl@0
|
37 |
|
sl@0
|
38 |
void * operator new( std::size_t size )
|
sl@0
|
39 |
{
|
sl@0
|
40 |
return detail::allocate< MostDerived, Allocator >( size );
|
sl@0
|
41 |
}
|
sl@0
|
42 |
|
sl@0
|
43 |
void operator delete( void * pEvent )
|
sl@0
|
44 |
{
|
sl@0
|
45 |
detail::deallocate< MostDerived, Allocator >( pEvent );
|
sl@0
|
46 |
}
|
sl@0
|
47 |
|
sl@0
|
48 |
protected:
|
sl@0
|
49 |
//////////////////////////////////////////////////////////////////////////
|
sl@0
|
50 |
event() {}
|
sl@0
|
51 |
virtual ~event() {}
|
sl@0
|
52 |
|
sl@0
|
53 |
private:
|
sl@0
|
54 |
//////////////////////////////////////////////////////////////////////////
|
sl@0
|
55 |
virtual intrusive_ptr< const event_base > clone() const
|
sl@0
|
56 |
{
|
sl@0
|
57 |
return intrusive_ptr< const event_base >( new MostDerived(
|
sl@0
|
58 |
*polymorphic_downcast< const MostDerived * >( this ) ) );
|
sl@0
|
59 |
}
|
sl@0
|
60 |
};
|
sl@0
|
61 |
|
sl@0
|
62 |
|
sl@0
|
63 |
|
sl@0
|
64 |
} // namespace statechart
|
sl@0
|
65 |
} // namespace boost
|
sl@0
|
66 |
|
sl@0
|
67 |
|
sl@0
|
68 |
|
sl@0
|
69 |
#endif
|