]> git.lyx.org Git - lyx.git/blob - boost/libs/signals/src/connection.cpp
3f7020a054b3dc9ad0a645f9c0996621b5be3ca0
[lyx.git] / boost / libs / signals / src / connection.cpp
1 // Boost.Signals library
2 //
3 // Copyright (C) 2001 Doug Gregor (gregod@cs.rpi.edu)
4 //
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.
10 //
11 // This software is provided "as is" without express or implied warranty,
12 // and with no claim as to its suitability for any purpose.
13  
14 // For more information, see http://www.boost.org
15
16 #include <boost/signals/connection.hpp>
17 #include <cassert>
18
19 namespace boost {
20   namespace BOOST_SIGNALS_NAMESPACE {
21     void connection::disconnect() const
22     {
23       if (this->connected()) {
24         // Make sure we have a reference to the basic_connection object,
25         // because 'this' may disappear
26         shared_ptr<detail::basic_connection> local_con = con;
27
28         void (*signal_disconnect)(void*, void*) = local_con->signal_disconnect;
29
30         // Note that this connection no longer exists
31         // Order is important here: we could get into an infinite loop if this
32         // isn't cleared before we try the disconnect.
33         local_con->signal_disconnect = 0;
34
35         // Disconnect signal
36         signal_disconnect(local_con->signal, local_con->signal_data);
37       
38         // Disconnect all bound objects
39         typedef std::list<BOOST_SIGNALS_NAMESPACE::detail::bound_object>::iterator iterator;
40         for (iterator i = local_con->bound_objects.begin(); 
41              i != local_con->bound_objects.end(); ++i) {
42           assert(i->disconnect != 0);
43           i->disconnect(i->obj, i->data);
44         }
45       }
46     }
47   } // end namespace boost 
48 } // end namespace boost
49
50 #ifndef BOOST_MSVC
51 // Explicit instantiations to keep everything in the library
52 template class std::list<boost::BOOST_SIGNALS_NAMESPACE::detail::bound_object>;
53 #endif