1 // Boost.Signals library
3 // Copyright Douglas Gregor 2001-2004. Use, modification and
4 // distribution is subject to the Boost Software License, Version
5 // 1.0. (See accompanying file LICENSE_1_0.txt or copy at
6 // http://www.boost.org/LICENSE_1_0.txt)
8 // For more information, see http://www.boost.org
10 #define BOOST_SIGNALS_SOURCE
12 #include <boost/signals/trackable.hpp>
16 namespace BOOST_SIGNALS_NAMESPACE {
17 void trackable::signal_disconnected(void* obj, void* data)
19 trackable* self = reinterpret_cast<trackable*>(obj);
20 connection_iterator* signal =
21 reinterpret_cast<connection_iterator*>(data);
23 // If we're dying, don't bother erasing the connection from the list;
24 // it'll be gone anyway
26 self->connected_signals.erase(*signal);
29 // This iterator pointer won't ever be used again
34 trackable::signal_connected(connection c,
35 BOOST_SIGNALS_NAMESPACE::detail::bound_object& binding) const
37 // Insert the connection
38 connection_iterator pos =
39 connected_signals.insert(connected_signals.end(), c);
41 // Make this copy of the object disconnect when destroyed
42 pos->set_controlling();
44 binding.obj = const_cast<void*>(reinterpret_cast<const void*>(this));
45 binding.data = reinterpret_cast<void*>(new connection_iterator(pos));
46 binding.disconnect = &signal_disconnected;
49 trackable::~trackable()
53 } // end namespace BOOST_SIGNALS_NAMESPACE
57 // Explicit instantiations to keep in the library
58 template class std::list<boost::BOOST_SIGNALS_NAMESPACE::connection>;