File indexing completed on 2025-01-18 09:52:31
0001 #ifndef BOOST_STATECHART_EVENT_BASE_HPP_INCLUDED
0002 #define BOOST_STATECHART_EVENT_BASE_HPP_INCLUDED
0003
0004
0005
0006
0007
0008
0009
0010
0011 #include <boost/statechart/detail/rtti_policy.hpp>
0012 #include <boost/statechart/detail/counted_base.hpp>
0013
0014 #include <boost/assert.hpp>
0015 #include <boost/intrusive_ptr.hpp>
0016 #include <boost/config.hpp>
0017
0018
0019
0020 namespace boost
0021 {
0022 namespace statechart
0023 {
0024 namespace detail
0025 {
0026
0027
0028
0029
0030
0031
0032 class delete_helper
0033 {
0034 public:
0035 template< class T >
0036 static void delete_object( const T * pObject )
0037 {
0038 delete pObject;
0039 }
0040 };
0041
0042
0043
0044 }
0045
0046
0047
0048
0049 class event_base : public detail::rtti_policy::rtti_base_type<
0050 detail::counted_base<> >
0051 {
0052 typedef detail::rtti_policy::rtti_base_type<
0053 detail::counted_base<> > base_type;
0054 public:
0055
0056 intrusive_ptr< const event_base > intrusive_from_this() const;
0057
0058 protected:
0059
0060 event_base( detail::rtti_policy::id_provider_type idProvider ) :
0061 base_type( idProvider )
0062 {
0063 }
0064
0065 virtual ~event_base() {}
0066
0067 private:
0068
0069 virtual intrusive_ptr< const event_base > clone() const = 0;
0070
0071 friend class detail::delete_helper;
0072 };
0073
0074
0075
0076 #ifdef BOOST_NO_ARGUMENT_DEPENDENT_LOOKUP
0077 }
0078 #endif
0079
0080
0081
0082 inline void intrusive_ptr_add_ref( const ::boost::statechart::event_base * pBase )
0083 {
0084 pBase->add_ref();
0085 }
0086
0087 inline void intrusive_ptr_release( const ::boost::statechart::event_base * pBase )
0088 {
0089 if ( pBase->release() )
0090 {
0091 ::boost::statechart::detail::delete_helper::delete_object( pBase );
0092 }
0093 }
0094
0095
0096
0097 #ifndef BOOST_NO_ARGUMENT_DEPENDENT_LOOKUP
0098 }
0099 #endif
0100 namespace statechart
0101 {
0102
0103
0104
0105
0106
0107
0108 inline intrusive_ptr< const event_base > event_base::intrusive_from_this() const
0109 {
0110 if ( base_type::ref_counted() )
0111 {
0112 return intrusive_ptr< const event_base >( this );
0113 }
0114 else
0115 {
0116 return clone();
0117 }
0118 }
0119
0120
0121
0122 }
0123 }
0124
0125
0126
0127 #endif