Chris@16: // Boost.Signals2 library Chris@16: Chris@16: // Copyright Frank Mori Hess 2007,2009. Chris@16: // Copyright Timmo Stange 2007. Chris@16: // Copyright Douglas Gregor 2001-2004. Use, modification and Chris@16: // distribution is subject to the Boost Software License, Version Chris@16: // 1.0. (See accompanying file LICENSE_1_0.txt or copy at Chris@16: // http://www.boost.org/LICENSE_1_0.txt) Chris@16: Chris@16: // Compatibility class to ease porting from the original Chris@16: // Boost.Signals library. However, Chris@16: // boost::signals2::trackable is NOT thread-safe. Chris@16: Chris@16: // For more information, see http://www.boost.org Chris@16: Chris@16: #ifndef BOOST_SIGNALS2_TRACKABLE_HPP Chris@16: #define BOOST_SIGNALS2_TRACKABLE_HPP Chris@16: Chris@16: #include Chris@16: #include Chris@101: #include Chris@16: Chris@16: namespace boost { Chris@16: namespace signals2 { Chris@16: namespace detail Chris@16: { Chris@16: class tracked_objects_visitor; Chris@101: Chris@101: // trackable_pointee is used to identify the tracked shared_ptr Chris@101: // originating from the signals2::trackable class. These tracked Chris@101: // shared_ptr are special in that we shouldn't bother to Chris@101: // increment their use count during signal invocation, since Chris@101: // they don't actually control the lifetime of the Chris@101: // signals2::trackable object they are associated with. Chris@101: class trackable_pointee Chris@101: {}; Chris@16: } Chris@16: class trackable { Chris@16: protected: Chris@101: trackable(): _tracked_ptr(static_cast(0)) {} Chris@101: trackable(const trackable &): _tracked_ptr(static_cast(0)) {} Chris@16: trackable& operator=(const trackable &) Chris@16: { Chris@16: return *this; Chris@16: } Chris@16: ~trackable() {} Chris@16: private: Chris@16: friend class detail::tracked_objects_visitor; Chris@101: weak_ptr get_weak_ptr() const Chris@16: { Chris@16: return _tracked_ptr; Chris@16: } Chris@16: Chris@101: shared_ptr _tracked_ptr; Chris@16: }; Chris@16: } // end namespace signals2 Chris@16: } // end namespace boost Chris@16: Chris@16: #endif // BOOST_SIGNALS2_TRACKABLE_HPP