Corrade::Interconnect namespace

Signal/slot connections.

This library allows you to interconnect objects. See Signals and slots for more information.

This library is built if CORRADE_WITH_INTERCONNECT is enabled when building Corrade. To use this library with CMake, request the Interconnect component of the Corrade package and link to the Corrade::Interconnect target:

find_package(Corrade REQUIRED Interconnect)

# ...
target_link_libraries(your-app PRIVATE Corrade::Interconnect)

See also Downloading and building Corrade and Using Corrade with CMake for more information.

Classes

class Connection
Connection.
class Emitter
Emitter object.
class Receiver
Receiver object.
template<std::size_t states, std::size_t inputs, class State, class Input>
class StateMachine
State machine.
template<class State, class Input>
class StateTransition
Transition between states.

Functions

template<class EmitterObject, class Emitter, class Functor, class ... Args>
auto connect(EmitterObject& emitter, Interconnect::Emitter::Signal(Emitter::*)(Args...) signal, Functor&& slot) -> Connection
Connect signal to function slot.
template<class EmitterObject, class Emitter, class Receiver, class ReceiverObject, class ... Args>
auto connect(EmitterObject& emitter, Interconnect::Emitter::Signal(Emitter::*)(Args...) signal, ReceiverObject& receiver, void(Receiver::*)(Args...) slot) -> Connection
Connect signal to member function slot.
auto disconnect(Emitter& emitter, const Connection& connection) -> bool
Disconnect a signal/slot connection.

Function documentation

template<class EmitterObject, class Emitter, class Functor, class ... Args>
Connection Corrade::Interconnect::connect(EmitterObject& emitter, Interconnect::Emitter::Signal(Emitter::*)(Args...) signal, Functor&& slot)

Connect signal to function slot.

Parameters
emitter Emitter
signal Signal
slot Slot

Connects given signal to compatible slot. emitter must be subclass of Emitter, signal must be implemented signal and slot can be either a non-member function, a lambda or any other function object. The argument count and types must be exactly the same.

See Emitter class documentation for more information about connections.

template<class EmitterObject, class Emitter, class Receiver, class ReceiverObject, class ... Args>
Connection Corrade::Interconnect::connect(EmitterObject& emitter, Interconnect::Emitter::Signal(Emitter::*)(Args...) signal, ReceiverObject& receiver, void(Receiver::*)(Args...) slot)

Connect signal to member function slot.

Parameters
emitter Emitter
signal Signal
receiver Receiver
slot Slot

Connects given signal to compatible slot in receiver object. emitter must be subclass of Emitter, signal must be implemented signal, receiver must be subclass of Receiver and slot must be non-constant member function with void as return type. The argument count and types must be exactly the same.

See Emitter class documentation for more information about connections.

bool Corrade::Interconnect::disconnect(Emitter& emitter, const Connection& connection)

Disconnect a signal/slot connection.

Parameters
emitter Emitter
connection Connection handle returned by connect()

It's the user responsibility to ensure that connection corresponds to given emitter instance. See Emitter class documentation for more information about connections.