Goby3  3.1.5a
2024.05.23
event.hpp
Go to the documentation of this file.
1 #ifndef BOOST_STATECHART_EVENT_HPP_INCLUDED
2 #define BOOST_STATECHART_EVENT_HPP_INCLUDED
3 // Copyright 2002-2007 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)
8 
9 
10 
11 #include <boost/statechart/event_base.hpp>
12 #include <boost/statechart/detail/rtti_policy.hpp>
13 #include <boost/statechart/detail/memory.hpp>
14 
15 #include <boost/polymorphic_cast.hpp> // boost::polymorphic_downcast
16 
17 #include <memory> // std::allocator
18 
19 
20 
21 namespace boost
22 {
23 namespace statechart
24 {
25 
26 
27 
29 template< class MostDerived, class Allocator = std::allocator< none > >
30 class event : public detail::rtti_policy::rtti_derived_type<
31  MostDerived, event_base >
32 {
33  public:
35  // Compiler-generated copy constructor and copy assignment operator are
36  // fine
37 
38  void * operator new( std::size_t size )
39  {
40  return detail::allocate< MostDerived, Allocator >( size );
41  }
42 
43  void * operator new( std::size_t, void * p )
44  {
45  return p;
46  }
47 
48  void operator delete( void * pEvent )
49  {
50  detail::deallocate< MostDerived, Allocator >( pEvent );
51  }
52 
53  void operator delete( void * pEvent, void * p )
54  {
55  }
56 
57  protected:
59  event() {}
60  virtual ~event() {}
61 
62  private:
64  virtual intrusive_ptr< const event_base > clone() const
65  {
66  return intrusive_ptr< const event_base >( new MostDerived(
67  *polymorphic_downcast< const MostDerived * >( this ) ) );
68  }
69 };
70 
71 
72 
73 } // namespace statechart
74 } // namespace boost
75 
76 
77 
78 #endif
boost::statechart::event::event
event()
Definition: event.hpp:59
boost
Definition: udp_driver.h:41
boost::statechart::event
Definition: event.hpp:30
boost::statechart::event::~event
virtual ~event()
Definition: event.hpp:60