1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/ossrv/ossrv_pub/boost_apis/boost/statechart/event_base.hpp Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,127 @@
1.4 +#ifndef BOOST_STATECHART_EVENT_BASE_HPP_INCLUDED
1.5 +#define BOOST_STATECHART_EVENT_BASE_HPP_INCLUDED
1.6 +//////////////////////////////////////////////////////////////////////////////
1.7 +// Copyright 2002-2006 Andreas Huber Doenni
1.8 +// Distributed under the Boost Software License, Version 1.0. (See accompany-
1.9 +// ing file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
1.10 +//////////////////////////////////////////////////////////////////////////////
1.11 +
1.12 +
1.13 +
1.14 +#include <boost/statechart/detail/rtti_policy.hpp>
1.15 +#include <boost/statechart/detail/counted_base.hpp>
1.16 +
1.17 +#include <boost/assert.hpp>
1.18 +#include <boost/intrusive_ptr.hpp>
1.19 +#include <boost/config.hpp>
1.20 +
1.21 +
1.22 +
1.23 +namespace boost
1.24 +{
1.25 +namespace statechart
1.26 +{
1.27 +namespace detail
1.28 +{
1.29 +
1.30 +
1.31 +
1.32 +// This helper is necessary because there doesn't seem to be consensus among
1.33 +// compilers on how a friend declaration for a function in another namespace
1.34 +// has to look like.
1.35 +class delete_helper
1.36 +{
1.37 + public:
1.38 + template< class T >
1.39 + static void delete_object( const T * pObject )
1.40 + {
1.41 + delete pObject;
1.42 + }
1.43 +};
1.44 +
1.45 +
1.46 +
1.47 +} // namespace detail
1.48 +
1.49 +
1.50 +
1.51 +//////////////////////////////////////////////////////////////////////////////
1.52 +class event_base : public detail::rtti_policy::rtti_base_type<
1.53 + detail::counted_base<> >
1.54 +{
1.55 + typedef detail::rtti_policy::rtti_base_type<
1.56 + detail::counted_base<> > base_type;
1.57 + public:
1.58 + //////////////////////////////////////////////////////////////////////////
1.59 + intrusive_ptr< const event_base > intrusive_from_this() const;
1.60 +
1.61 + protected:
1.62 + //////////////////////////////////////////////////////////////////////////
1.63 + event_base( detail::rtti_policy::id_provider_type idProvider ) :
1.64 + base_type( idProvider )
1.65 + {
1.66 + }
1.67 +
1.68 + virtual ~event_base() {}
1.69 +
1.70 + private:
1.71 + //////////////////////////////////////////////////////////////////////////
1.72 + virtual intrusive_ptr< const event_base > clone() const = 0;
1.73 +
1.74 + friend class detail::delete_helper;
1.75 +};
1.76 +
1.77 +
1.78 +
1.79 +#ifdef BOOST_NO_ARGUMENT_DEPENDENT_LOOKUP
1.80 +} // namespace statechart
1.81 +#endif
1.82 +
1.83 +
1.84 +
1.85 +inline void intrusive_ptr_add_ref( const ::boost::statechart::event_base * pBase )
1.86 +{
1.87 + pBase->add_ref();
1.88 +}
1.89 +
1.90 +inline void intrusive_ptr_release( const ::boost::statechart::event_base * pBase )
1.91 +{
1.92 + if ( pBase->release() )
1.93 + {
1.94 + ::boost::statechart::detail::delete_helper::delete_object( pBase );
1.95 + }
1.96 +}
1.97 +
1.98 +
1.99 +
1.100 +#ifndef BOOST_NO_ARGUMENT_DEPENDENT_LOOKUP
1.101 +} // namespace statechart
1.102 +#endif
1.103 +namespace statechart
1.104 +{
1.105 +
1.106 +
1.107 +
1.108 +// We're implementing this here so that GCC3.4.2 can find
1.109 +// intrusive_ptr_add_ref, which is indirectly called from the intrusive_ptr
1.110 +// ctor.
1.111 +inline intrusive_ptr< const event_base > event_base::intrusive_from_this() const
1.112 +{
1.113 + if ( base_type::ref_counted() )
1.114 + {
1.115 + return intrusive_ptr< const event_base >( this );
1.116 + }
1.117 + else
1.118 + {
1.119 + return clone();
1.120 + }
1.121 +}
1.122 +
1.123 +
1.124 +
1.125 +} // namespace statechart
1.126 +} // namespace boost
1.127 +
1.128 +
1.129 +
1.130 +#endif