lxgui
|
Generic class for observing and triggering events. More...
#include <utils_signal.hpp>
Public Types | |
using | function_type = std::function< T > |
Type of the callable function stored in a slot. Can use any function/delegate type here, as long as it has a matching call operator. The function type does not need to be owning; in this case, the slot must be manually disconnected whenever the pointed function is destroyed. More... | |
using | slot_list_view = utils::view::adaptor< slot_list, slot_dereferencer, non_disconnected_filter > |
Type of the view returned by slots(). More... | |
Public Member Functions | |
signal () | |
Default constructor (no slot). More... | |
~signal () | |
Destructor. More... | |
signal (const signal &)=delete | |
signal (signal &&)=default | |
signal & | operator= (const signal &)=delete |
signal & | operator= (signal &&)=default |
void | disconnect_all () noexcept |
Disconnects all slots. More... | |
bool | empty () const noexcept |
Check if this signal contains any slot. More... | |
slot_list_view | slots () const noexcept |
Return a constant view onto the connected slots. More... | |
connection | connect (function_type function) |
Connect a new slot to this signal. More... | |
template<typename... Args> | |
void | operator() (Args &&... args) |
Trigger the signal. More... | |
Generic class for observing and triggering events.
The implementation guarantees that the following is safe:
Other notable behaviors:
Example:
Definition at line 142 of file utils_signal.hpp.
using lxgui::utils::signal< T >::function_type = std::function<T> |
Type of the callable function stored in a slot. Can use any function/delegate type here, as long as it has a matching call operator. The function type does not need to be owning; in this case, the slot must be manually disconnected whenever the pointed function is destroyed.
Definition at line 151 of file utils_signal.hpp.
using lxgui::utils::signal< T >::slot_list_view = utils::view::adaptor<slot_list, slot_dereferencer, non_disconnected_filter> |
Type of the view returned by slots().
Definition at line 218 of file utils_signal.hpp.
|
inline |
Default constructor (no slot).
Definition at line 222 of file utils_signal.hpp.
|
inline |
Destructor.
Definition at line 225 of file utils_signal.hpp.
|
delete |
|
default |
|
inline |
Connect a new slot to this signal.
function | The function to store in the slot. |
Definition at line 283 of file utils_signal.hpp.
|
inlinenoexcept |
Disconnects all slots.
Definition at line 238 of file utils_signal.hpp.
|
inlinenoexcept |
Check if this signal contains any slot.
Definition at line 258 of file utils_signal.hpp.
|
inline |
Trigger the signal.
args | Arguments to forward to all the connected slots. |
Definition at line 293 of file utils_signal.hpp.
|
delete |
|
default |
|
inlinenoexcept |
Return a constant view onto the connected slots.
Definition at line 269 of file utils_signal.hpp.