trackable.hpp 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. // Boost.Signals2 library
  2. // Copyright Frank Mori Hess 2007,2009.
  3. // Copyright Timmo Stange 2007.
  4. // Copyright Douglas Gregor 2001-2004. Use, modification and
  5. // distribution is subject to the Boost Software License, Version
  6. // 1.0. (See accompanying file LICENSE_1_0.txt or copy at
  7. // http://www.boost.org/LICENSE_1_0.txt)
  8. // Compatibility class to ease porting from the original
  9. // Boost.Signals library. However,
  10. // boost::signals2::trackable is NOT thread-safe.
  11. // For more information, see http://www.boost.org
  12. #ifndef BOOST_SIGNALS2_TRACKABLE_HPP
  13. #define BOOST_SIGNALS2_TRACKABLE_HPP
  14. #include <boost/assert.hpp>
  15. #include <boost/shared_ptr.hpp>
  16. namespace boost {
  17. namespace signals2 {
  18. namespace detail
  19. {
  20. class tracked_objects_visitor;
  21. }
  22. class trackable {
  23. protected:
  24. trackable(): _tracked_ptr(static_cast<int*>(0)) {}
  25. trackable(const trackable &): _tracked_ptr(static_cast<int*>(0)) {}
  26. trackable& operator=(const trackable &)
  27. {
  28. return *this;
  29. }
  30. ~trackable() {}
  31. private:
  32. friend class detail::tracked_objects_visitor;
  33. const shared_ptr<void>& get_shared_ptr() const
  34. {
  35. return _tracked_ptr;
  36. }
  37. shared_ptr<void> _tracked_ptr;
  38. };
  39. } // end namespace signals2
  40. } // end namespace boost
  41. #endif // BOOST_SIGNALS2_TRACKABLE_HPP