2 * Copyright 2002, The libsigc++ Development Team
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 #include <sigc++/connection.h>
24 connection::connection() noexcept
28 connection::connection(const connection& c)
31 //Let the connection forget about the signal handler when the handler object dies:
33 slot_->add_destroy_notify_callback(this, ¬ify);
36 connection::connection(slot_base& sl)
39 //Let the connection forget about the signal handler when the handler object dies:
40 slot_->add_destroy_notify_callback(this, ¬ify);
43 connection& connection::operator=(const connection& c)
49 connection::~connection()
52 slot_->remove_destroy_notify_callback(this);
55 bool connection::empty() const noexcept
57 return (!slot_ || slot_->empty());
60 bool connection::connected() const noexcept
65 bool connection::blocked() const noexcept
67 return (slot_ ? slot_->blocked() : false);
70 bool connection::block(bool should_block) noexcept
72 return (slot_ ? slot_->block(should_block) : false);
75 bool connection::unblock() noexcept
77 return (slot_ ? slot_->unblock() : false);
80 void connection::disconnect()
83 slot_->disconnect(); // This notifies slot_'s parent.
86 connection::operator bool() noexcept
91 void connection::set_slot(slot_base* sl)
94 slot_->remove_destroy_notify_callback(this);
99 slot_->add_destroy_notify_callback(this, ¬ify);
102 void* connection::notify(void* data)
104 auto self = reinterpret_cast<connection*>(data);
105 self->slot_ = nullptr;
109 } /* namespace sigc */