Skip to content

KDBindings::ConnectionHandle

A ConnectionHandle represents the connection of a Signal to a slot (i.e. a function that is called when the Signal is emitted). More...

#include <signal.h>

Public Functions

Name
ConnectionHandle() =default
ConnectionHandle(ConnectionHandle && ) =default
ConnectionHandle(const ConnectionHandle & ) =default
template <typename... Args>
bool
belongsTo(const Signal< Args... > & signal) const
bool block(bool blocked)
void disconnect()
bool isActive() const
bool isBlocked() const
ConnectionHandle & operator=(ConnectionHandle && ) =default
ConnectionHandle & operator=(const ConnectionHandle & ) =default

Friends

Name
class Signal

Detailed Description

1
class KDBindings::ConnectionHandle;

A ConnectionHandle represents the connection of a Signal to a slot (i.e. a function that is called when the Signal is emitted).

It is returned from a Signal when a connection is created and used to manage the connection by disconnecting, (un)blocking it and checking its state.

Public Functions Documentation

function ConnectionHandle

1
ConnectionHandle() =default

A ConnectionHandle can be default constructed. In this case the ConnectionHandle will not reference any active connection (i.e. isActive() will return false), and not belong to any Signal.

function ConnectionHandle

1
2
3
ConnectionHandle(
    ConnectionHandle && 
) =default

A ConnectionHandle can be moved.

function ConnectionHandle

1
2
3
ConnectionHandle(
    const ConnectionHandle & 
) =default

A ConnectionHandle can be copied.

function belongsTo

1
2
3
4
template <typename... Args>
inline bool belongsTo(
    const Signal< Args... > & signal
) const

Return: true if this ConnectionHandle refers to a connection within the given Signal

Check whether this ConnectionHandle belongs to the given Signal.

function block

1
2
3
inline bool block(
    bool blocked
)

Parameters:

  • blocked The new blocked state of the connection.

Exceptions:

  • std::out_of_range Throws if the connection is not active (i.e. isActive() returns false).

Return: whether the connection was previously blocked.

Sets the block state of the connection. If a connection is blocked, emitting the Signal will no longer call this connections slot, until the connection is unblocked.

Behaves the same as calling Signal::blockConnection with this ConnectionHandle as argument.

To temporarily block a connection, consider using an instance of ConnectionBlocker, which offers a RAII-style implementation that makes sure the connection is always returned to its original state.

function disconnect

1
inline void disconnect()

Disconnect the slot.

When this function is called, the function that was passed to Signal::connect to create this ConnectionHandle will no longer be called when the Signal is emitted.

If the ConnectionHandle is not active or the connection has already been disconnected, nothing happens.

After this call, the ConnectionHandle will be inactive (i.e. isActive() returns false) and will no longer belong to any Signal (i.e. belongsTo returns false).

function isActive

1
inline bool isActive() const

Return: true if the ConnectionHandle refers to an active Signal and the connection was not disconnected previously, false otherwise.

Check whether the connection of this ConnectionHandle is active.

function isBlocked

1
inline bool isBlocked() const

Return: whether the connection is currently blocked.

Checks whether the connection is currently blocked.

To change the blocked state of a connection, call ConnectionHandle::block.

function operator=

1
2
3
ConnectionHandle & operator=(
    ConnectionHandle && 
) =default

function operator=

1
2
3
ConnectionHandle & operator=(
    const ConnectionHandle & 
) =default

Friends

friend Signal

1
friend class Signal;

Updated on 2022-04-12 at 00:03:54 +0000

Back to top