1 // Boost.Signals2 library
3 // Copyright Frank Mori Hess 2007,2009.
4 // Copyright Timmo Stange 2007.
5 // Copyright Douglas Gregor 2001-2004. Use, modification and
6 // distribution is subject to the Boost Software License, Version
7 // 1.0. (See accompanying file LICENSE_1_0.txt or copy at
8 // http://www.boost.org/LICENSE_1_0.txt)
10 // Compatibility class to ease porting from the original
11 // Boost.Signals library. However,
12 // boost::signals2::trackable is NOT thread-safe.
14 // For more information, see http://www.boost.org
16 #ifndef BOOST_SIGNALS2_TRACKABLE_HPP
17 #define BOOST_SIGNALS2_TRACKABLE_HPP
19 #include <boost/assert.hpp>
20 #include <boost/shared_ptr.hpp>
21 #include <boost/weak_ptr.hpp>
27 class tracked_objects_visitor;
29 // trackable_pointee is used to identify the tracked shared_ptr
30 // originating from the signals2::trackable class. These tracked
31 // shared_ptr are special in that we shouldn't bother to
32 // increment their use count during signal invocation, since
33 // they don't actually control the lifetime of the
34 // signals2::trackable object they are associated with.
35 class trackable_pointee
40 trackable(): _tracked_ptr(static_cast<detail::trackable_pointee*>(0)) {}
41 trackable(const trackable &): _tracked_ptr(static_cast<detail::trackable_pointee*>(0)) {}
42 trackable& operator=(const trackable &)
48 friend class detail::tracked_objects_visitor;
49 weak_ptr<detail::trackable_pointee> get_weak_ptr() const
54 shared_ptr<detail::trackable_pointee> _tracked_ptr;
56 } // end namespace signals2
57 } // end namespace boost
59 #endif // BOOST_SIGNALS2_TRACKABLE_HPP