1 // Boost.Signals library
3 // Copyright (C) 2001 Doug Gregor (gregod@cs.rpi.edu)
5 // Permission to copy, use, sell and distribute this software is granted
6 // provided this copyright notice appears in all copies.
7 // Permission to modify the code and to distribute modified code is granted
8 // provided this copyright notice appears in all copies, and a notice
9 // that the code was modified is included with the copyright notice.
11 // This software is provided "as is" without express or implied warranty,
12 // and with no claim as to its suitability for any purpose.
14 // For more information, see http://www.boost.org
16 #include <boost/signals/trackable.hpp>
20 namespace BOOST_SIGNALS_NAMESPACE {
21 void trackable::signal_disconnected(void* obj, void* data)
23 trackable* self = reinterpret_cast<trackable*>(obj);
24 connection_iterator* signal =
25 reinterpret_cast<connection_iterator*>(data);
27 // If we're dying, don't bother erasing the connection from the list;
28 // it'll be gone anyway
30 self->connected_signals.erase(*signal);
33 // This iterator pointer won't ever be used again
38 trackable::signal_connected(connection c,
39 BOOST_SIGNALS_NAMESPACE::detail::bound_object& binding) const
41 // Insert the connection
42 connection_iterator pos =
43 connected_signals.insert(connected_signals.end(), c);
45 // Make this copy of the object disconnect when destroyed
46 pos->set_controlling();
48 binding.obj = const_cast<void*>(reinterpret_cast<const void*>(this));
49 binding.data = reinterpret_cast<void*>(new connection_iterator(pos));
50 binding.disconnect = &signal_disconnected;
53 trackable::~trackable()
57 } // end namespace BOOST_SIGNALS_NAMESPACE
61 // Explicit instantiations to keep in the library
62 template class std::list<boost::BOOST_SIGNALS_NAMESPACE::connection>;