diff options
author | Murray Cumming <murrayc@usa.net> | 2004-02-13 17:09:42 +0000 |
---|---|---|
committer | Murray Cumming <murrayc@src.gnome.org> | 2004-02-13 17:09:42 +0000 |
commit | 053c56f010d8ba16aab65455ac4b6a559f987230 (patch) | |
tree | bf2483f5616909631fb0f27a176fbbcf9a6b95b1 /sigc++/connection.cc | |
parent | 4b2efc0d6420a478498adcc6db7289753b8a606d (diff) | |
download | sigc++-053c56f010d8ba16aab65455ac4b6a559f987230.tar.gz |
Create and use a typedef for the destroy_notify callback functions, to
2004-02-13 Murray Cumming <murrayc@usa.net>
* sigc++/functors/slot_base.[h|cc], sigc++/trackable.[h|cc]: Create
and use a typedef for the destroy_notify callback functions, to avoid
confusion function pointer declaration syntax in the API.
2004-02-13 Murray Cumming <murrayc@murrayc.com>
* Moved implementation to .cc files:
* sigc++/functors/: Added slot_base.[h|cc] which contains non-template
code that was previsouly in the generated functors/slot.h and
non-generated slot.cc files. All non-inline implementation is now in
the .cc file.
* sigc++/functors/macros/slot.m4: Removed the code that has been moved
to slot_base.[h|cc].
* sigc++/: Added signal_base.[h|cc] which contains non-template code
that was previously in the generated signal.h and non-generated
signal.cc file. All non-inline implementation is now in the .cc file.
* sigc++/macros/signal.m4: Removed the code that ahs been moved to
signal.cc
* sigc++/connector.[h|cc]: method implementation moved to the .cc file.
Diffstat (limited to 'sigc++/connection.cc')
-rw-r--r-- | sigc++/connection.cc | 62 |
1 files changed, 62 insertions, 0 deletions
diff --git a/sigc++/connection.cc b/sigc++/connection.cc index 66f6852..643ee6c 100644 --- a/sigc++/connection.cc +++ b/sigc++/connection.cc @@ -23,6 +23,68 @@ using namespace std; namespace sigc { +connection::connection() +: slot_(0) +{} + +connection::connection(const connection& c) +: slot_(c.slot_) +{ + if (slot_) + slot_->add_destroy_notify_callback(this, ¬ify); +} + +connection::connection(slot_base& sl) +: slot_(&sl) +{ + slot_->add_destroy_notify_callback(this, ¬ify); +} + +connection& connection::operator=(const connection& c) +{ + set_slot(c.slot_); + return *this; +} + +connection::~connection() +{ + if (slot_) + slot_->remove_destroy_notify_callback(this); +} + +bool connection::empty() const +{ + return (!slot_ || slot_->empty()); +} + +bool connection::connected() const +{ + return !empty(); +} + +bool connection::block(bool should_block) +{ + if (slot_) + return slot_->block(should_block); +} + +bool connection::unblock() +{ + if (slot_) + return slot_->unblock(); +} + +void connection::disconnect() +{ + if (slot_) + slot_->disconnect(); // This notifies slot_'s parent. +} + +connection::operator bool() +{ + return !empty(); +} + void connection::set_slot(slot_base* sl) { if (slot_) |