libsigc++  3.6.0
Public Types | Public Member Functions | Public Attributes | List of all members
sigc::slot_base Class Reference

Base type for slots. More...

#include <sigc++/functors/slot_base.h>

Inheritance diagram for sigc::slot_base:
Inheritance graph
[legend]

Public Types

using func_destroy_notify = notifiable::func_destroy_notify
 

Public Member Functions

 slot_base () noexcept
 Constructs an empty slot. More...
 
 slot_base (const slot_base & src)
 Constructs a slot, copying an existing one. More...
 
 slot_base (rep_type * rep) noexcept
 Constructs a slot from an existing slot_rep object. More...
 
 slot_base (slot_base && src)
 Constructs a slot, moving an existing one. More...
 
 ~slot_base ()
 
void add_destroy_notify_callback (notifiable *data, notifiable::func_destroy_notify func) const
 Add a callback that is executed (notified) when the slot is destroyed. More...
 
bool block (bool should_block=true) noexcept
 Sets the blocking state. More...
 
bool blocked () const noexcept
 Returns whether the slot is blocked. More...
 
void disconnect ()
 Disconnects the slot. More...
 
bool empty () const noexcept
 Returns whether the slot is invalid. More...
 
 operator bool () const noexcept
 Tests whether a slot is null, because the default constructor was used. More...
 
slot_baseoperator= (const slot_base & src)
 Overrides this slot, making a copy from another slot. More...
 
slot_baseoperator= (slot_base && src)
 Overrides this slot, making a move from another slot. More...
 
void remove_destroy_notify_callback (notifiable *data) const
 Remove a callback previously installed with add_destroy_notify_callback(). More...
 
void set_parent (notifiable * parent, notifiable::func_destroy_notify cleanup) const noexcept
 Sets the parent of this slot. More...
 
bool unblock () noexcept
 Unsets the blocking state. More...
 

Public Attributes

bool blocked_
 Indicates whether the slot is blocked. More...
 
rep_type * rep_
 Typed slot_rep object that contains a functor. More...
 

Detailed Description

Base type for slots.

slot_base integrates most of the interface of the derived sigc::slot template. Slots can be connected to signals, be disconnected at some later point (disconnect()) and temporarily be blocked (block(), unblock()). The validity of a slot can be tested with empty().

The internal representation of a sigc::internal::slot_rep derived type is built from slot_base's derivations. set_parent() is used to register a notification callback that is executed when the slot gets invalid. add_destroy_notify_callback() is used by connection objects to add a notification callback that is executed on destruction.

Member Typedef Documentation

◆ func_destroy_notify

Constructor & Destructor Documentation

◆ slot_base() [1/4]

sigc::slot_base::slot_base ( )
noexcept

Constructs an empty slot.

◆ slot_base() [2/4]

sigc::slot_base::slot_base ( rep_type *  rep)
explicitnoexcept

Constructs a slot from an existing slot_rep object.

Parameters
repThe slot_rep object this slot should contain.

◆ slot_base() [3/4]

sigc::slot_base::slot_base ( const slot_base src)

Constructs a slot, copying an existing one.

Parameters
srcThe existing slot to copy.

◆ slot_base() [4/4]

sigc::slot_base::slot_base ( slot_base &&  src)

Constructs a slot, moving an existing one.

If src is connected to a parent (e.g. a signal), it is copied, not moved.

Parameters
srcThe existing slot to move or copy.

◆ ~slot_base()

sigc::slot_base::~slot_base ( )

Member Function Documentation

◆ add_destroy_notify_callback()

void sigc::slot_base::add_destroy_notify_callback ( notifiable data,
notifiable::func_destroy_notify  func 
) const

Add a callback that is executed (notified) when the slot is destroyed.

This function is used internally by connection objects.

Parameters
dataPassed into func upon notification.
funcCallback executed upon destruction of the object.

◆ block()

bool sigc::slot_base::block ( bool  should_block = true)
noexcept

Sets the blocking state.

If should_block is true then the blocking state is set. Subsequent calls to slot::operator()() don't invoke the functor contained by this slot until unblock() or block() with should_block = false is called.

Parameters
should_blockIndicates whether the blocking state should be set or unset.
Returns
true if the slot was in blocking state before.

◆ blocked()

bool sigc::slot_base::blocked ( ) const
inlinenoexcept

Returns whether the slot is blocked.

Returns
true if the slot is blocked.

◆ disconnect()

void sigc::slot_base::disconnect ( )

Disconnects the slot.

Invalidates the slot and notifies the parent.

◆ empty()

bool sigc::slot_base::empty ( ) const
inlinenoexcept

Returns whether the slot is invalid.

Returns
true if the slot is invalid (empty).

◆ operator bool()

sigc::slot_base::operator bool ( ) const
explicitnoexcept

Tests whether a slot is null, because the default constructor was used.

Test a slot for null like so:

if(slot)
do_something()

◆ operator=() [1/2]

slot_base& sigc::slot_base::operator= ( const slot_base src)

Overrides this slot, making a copy from another slot.

Parameters
srcThe slot from which to make a copy.
Returns
this.

◆ operator=() [2/2]

slot_base& sigc::slot_base::operator= ( slot_base &&  src)

Overrides this slot, making a move from another slot.

If src is connected to a parent (e.g. a signal), it is copied, not moved.

Parameters
srcThe slot from which to move or copy.
Returns
this.

◆ remove_destroy_notify_callback()

void sigc::slot_base::remove_destroy_notify_callback ( notifiable data) const

Remove a callback previously installed with add_destroy_notify_callback().

The callback is not executed.

Parameters
dataParameter passed into previous call to add_destroy_notify_callback().

◆ set_parent()

void sigc::slot_base::set_parent ( notifiable parent,
notifiable::func_destroy_notify  cleanup 
) const
noexcept

Sets the parent of this slot.

This function is used by signals to register a notification callback. This notification callback is executed when the slot becomes invalid because of some referred object dying.

Parameters
parentThe new parent.
cleanupThe notification callback.

◆ unblock()

bool sigc::slot_base::unblock ( )
noexcept

Unsets the blocking state.

Returns
true if the slot was in blocking state before.

Member Data Documentation

◆ blocked_

bool sigc::slot_base::blocked_

Indicates whether the slot is blocked.

◆ rep_

rep_type* sigc::slot_base::rep_
mutable

Typed slot_rep object that contains a functor.