template<typename ... Args> asge::signals::Signal
This class represents a simple Thread-safe Signal.
#include <Signal.hpp>In the signals and slot design pattern a signal is represented by a function ( the actual emitted signal ) and a number of connections connecting the signal with a number of slots ( callback functions ) which must have the same signature of the signaling function. Valid connections are created using the Signal::Connect method. When emitting the signal, before calling all the releated slot functions, it checks for invalid connections and in case they exists it disconnects them from itself, in some sense performing automatic-disconnection.
Differently from the more generic Observer or Event Dispatching design pattern, the Signal and Slot pattern heavily relies on type safety, given that the signal and all connected slots must have the same function signature. This is obtained via its template parameter arguments.
Args | The type of input parameters of the signal |
Public Types
using conn_type = Connection< Args... >using slot_type = std::function< void(Args...)>Private Types
Friends
Private Attributes
Static Private Attributes
Public Member Functions
Signal()Connect a slot to the current signal.
The connection is managed either using a lifetime token or manually.
inCallback | The callback to run when emitting the signal |
inLfToken | The lifetime token to handle disconnection |
void Emit(Args... inArgs)std::size_t GetNofConnections() const