summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog7
-rw-r--r--sigc++/signal_base.cc35
-rw-r--r--sigc++/signal_base.h35
3 files changed, 77 insertions, 0 deletions
diff --git a/ChangeLog b/ChangeLog
index f92b923..f2061ab 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2012-10-12 Kjell Ahlstedt <kjell.ahlstedt@bredband.net>
+
+ signal_base: Add blocked(), block(), unblock().
+
+ * sigc++/signal_base.[h|cc]: Add signal_impl::blocked(), block() and
+ signal_base::blocked(), block(), unblock(). Bug #153780.
+
2.2.11:
2012-09-20 Andris Pavenis <andris.pavenis@iki.fi>
diff --git a/sigc++/signal_base.cc b/sigc++/signal_base.cc
index e22017f..ed1308a 100644
--- a/sigc++/signal_base.cc
+++ b/sigc++/signal_base.cc
@@ -49,6 +49,24 @@ signal_impl::size_type signal_impl::size() const
return slots_.size();
}
+bool signal_impl::blocked() const
+{
+ for (const_iterator_type iter = slots_.begin(); iter != slots_.end(); ++iter)
+ {
+ if (!iter->blocked())
+ return false;
+ }
+ return true;
+}
+
+void signal_impl::block(bool should_block)
+{
+ for (iterator_type iter = slots_.begin(); iter != slots_.end(); ++iter)
+ {
+ iter->block(should_block);
+ }
+}
+
signal_impl::iterator_type signal_impl::connect(const slot_base& slot_)
{
return insert(slots_.end(), slot_);
@@ -117,6 +135,23 @@ signal_base::size_type signal_base::size() const
return (impl_ ? impl_->size() : 0);
}
+bool signal_base::blocked() const
+{
+ return (impl_ ? impl_->blocked() : true);
+}
+
+void signal_base::block(bool should_block)
+{
+ if (impl_)
+ impl_->block(should_block);
+}
+
+void signal_base::unblock()
+{
+ if (impl_)
+ impl_->block(false);
+}
+
signal_base::iterator_type signal_base::connect(const slot_base& slot_)
{
return impl()->connect(slot_);
diff --git a/sigc++/signal_base.h b/sigc++/signal_base.h
index d16ccfa..94b2096 100644
--- a/sigc++/signal_base.h
+++ b/sigc++/signal_base.h
@@ -97,6 +97,21 @@ struct SIGC_API signal_impl
*/
size_type size() const;
+ /** Returns whether all slots in the list are blocked.
+ * @return @p true if all slots are blocked or the list is empty.
+ */
+ bool blocked() const;
+
+ /** Sets the blocking state of all slots in the list.
+ * If @e should_block is @p true then the blocking state is set.
+ * Subsequent emissions of the signal don't invoke the functors
+ * contained in the slots until block() with @e should_block = @p false is called.
+ * sigc::slot_base::block() and sigc::slot_base::unblock() can change the
+ * blocking state of individual slots.
+ * @param should_block Indicates whether the blocking state should be set or unset.
+ */
+ void block(bool should_block = true);
+
/** Adds a slot at the bottom of the list of slots.
* @param slot_ The slot to add to the list of slots.
* @return An iterator pointing to the new slot in the list.
@@ -263,6 +278,26 @@ struct SIGC_API signal_base : public trackable
*/
size_type size() const;
+ /** Returns whether all slots in the list are blocked.
+ * @return @p true if all slots are blocked or the list is empty.
+ */
+ bool blocked() const;
+
+ /** Sets the blocking state of all slots in the list.
+ * If @e should_block is @p true then the blocking state is set.
+ * Subsequent emissions of the signal don't invoke the functors
+ * contained in the slots until unblock() or block() with
+ * @e should_block = @p false is called.
+ * sigc::slot_base::block() and sigc::slot_base::unblock() can change the
+ * blocking state of individual slots.
+ * @param should_block Indicates whether the blocking state should be set or unset.
+ */
+ void block(bool should_block = true);
+
+ /** Unsets the blocking state of all slots in the list..
+ */
+ void unblock();
+
protected:
typedef internal::signal_impl::iterator_type iterator_type;