LibrePCB Developers Documentation
|
The Slot class is used to receive signals from non-QObject derived classes. More...
#include <signalslot.h>
Public Member Functions | |
Slot ()=delete | |
Slot (const Slot &other)=delete | |
Slot (const std::function< void(const Tsender &, Args...)> &callback) noexcept | |
Constructor. More... | |
template<typename T > | |
Slot (T &obj, void(T::*func)(const Tsender &, Args...)) noexcept | |
Constructor. More... | |
~Slot () noexcept | |
Destructor. More... | |
int | getSignalCount () const noexcept |
Get the count of registered signals. More... | |
void | detachAll () noexcept |
Detach from all signals. More... | |
Slot & | operator= (Slot const &other)=delete |
Private Attributes | |
QSet< const Signal< Tsender, Args... > * > | mSignals |
All signals this slot is attached to. More... | |
std::function< void(const Tsender &, Args...)> | mCallback |
The registered callback function. More... | |
Friends | |
class | Signal< Tsender, Args... > |
The Slot class is used to receive signals from non-QObject derived classes.
Instances of this class allow to connect librepcb::Signal objects to callback functions. Instead of connecting signals directly to callbacks, this indirection allows to automatically disconnect connections if either the sender or the receiver object is destroyed. This avoids potential segfaults due to dereferencing dangling pointers.
A slot can be connected to multiple signals if they have the same signature.
Tsender | Type of the sender object |
Args | Arguments passed from librepcb::Signal::notify() to the callbacks |
|
delete |
|
inlineexplicitnoexcept |
Constructor.
callback | The callback to be called if the signal is emitted |
|
inlineexplicitnoexcept |
Constructor.
obj | The object to be called if the signal is emitted |
func | The member function to be called if the signal is emitted |
|
inlinenoexcept |
Destructor.
Automatically disconnects from all signals.
|
inlinenoexcept |
Get the count of registered signals.
|
inlinenoexcept |
Detach from all signals.
|
friend |
|
private |
All signals this slot is attached to.
|
private |
The registered callback function.