2002-05-26 13:02:17 +00:00
|
|
|
// Boost.Signals library
|
2004-02-05 09:14:22 +00:00
|
|
|
|
2004-11-20 09:08:45 +00:00
|
|
|
// Copyright Douglas Gregor 2001-2004. Use, modification and
|
2004-02-05 09:14:22 +00:00
|
|
|
// distribution is subject to the Boost Software License, Version
|
|
|
|
// 1.0. (See accompanying file LICENSE_1_0.txt or copy at
|
|
|
|
// http://www.boost.org/LICENSE_1_0.txt)
|
|
|
|
|
2002-05-26 13:02:17 +00:00
|
|
|
// For more information, see http://www.boost.org
|
|
|
|
|
2004-02-05 09:14:22 +00:00
|
|
|
#define BOOST_SIGNALS_SOURCE
|
2002-08-20 21:50:08 +00:00
|
|
|
|
2002-05-26 13:02:17 +00:00
|
|
|
#include <boost/signals/trackable.hpp>
|
|
|
|
#include <algorithm>
|
|
|
|
|
|
|
|
namespace boost {
|
2002-06-18 15:39:27 +00:00
|
|
|
namespace BOOST_SIGNALS_NAMESPACE {
|
2002-05-26 13:02:17 +00:00
|
|
|
void trackable::signal_disconnected(void* obj, void* data)
|
|
|
|
{
|
|
|
|
trackable* self = reinterpret_cast<trackable*>(obj);
|
2004-02-05 09:14:22 +00:00
|
|
|
connection_iterator* signal =
|
2002-05-26 13:02:17 +00:00
|
|
|
reinterpret_cast<connection_iterator*>(data);
|
|
|
|
|
|
|
|
// If we're dying, don't bother erasing the connection from the list;
|
|
|
|
// it'll be gone anyway
|
|
|
|
if (!self->dying) {
|
|
|
|
self->connected_signals.erase(*signal);
|
|
|
|
}
|
|
|
|
|
|
|
|
// This iterator pointer won't ever be used again
|
|
|
|
delete signal;
|
|
|
|
}
|
|
|
|
|
2004-02-05 09:14:22 +00:00
|
|
|
void
|
|
|
|
trackable::signal_connected(connection c,
|
2002-06-18 15:39:27 +00:00
|
|
|
BOOST_SIGNALS_NAMESPACE::detail::bound_object& binding) const
|
2002-05-26 13:02:17 +00:00
|
|
|
{
|
|
|
|
// Insert the connection
|
2004-02-05 09:14:22 +00:00
|
|
|
connection_iterator pos =
|
2002-05-26 13:02:17 +00:00
|
|
|
connected_signals.insert(connected_signals.end(), c);
|
|
|
|
|
|
|
|
// Make this copy of the object disconnect when destroyed
|
|
|
|
pos->set_controlling();
|
|
|
|
|
|
|
|
binding.obj = const_cast<void*>(reinterpret_cast<const void*>(this));
|
|
|
|
binding.data = reinterpret_cast<void*>(new connection_iterator(pos));
|
|
|
|
binding.disconnect = &signal_disconnected;
|
|
|
|
}
|
|
|
|
|
|
|
|
trackable::~trackable()
|
|
|
|
{
|
|
|
|
dying = true;
|
|
|
|
}
|
2002-06-18 15:39:27 +00:00
|
|
|
} // end namespace BOOST_SIGNALS_NAMESPACE
|
2002-05-26 13:02:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#ifndef BOOST_MSVC
|
|
|
|
// Explicit instantiations to keep in the library
|
2002-06-18 15:39:27 +00:00
|
|
|
template class std::list<boost::BOOST_SIGNALS_NAMESPACE::connection>;
|
2002-05-26 13:02:17 +00:00
|
|
|
#endif
|