SPARK
0.1.0
A general purpose game engine written in C++.
|
A signal is a class used to emit events. More...
#include <Signal.h>
Public Member Functions | |
Signal (const Signal &signal)=delete | |
Signal (Signal &&signal) noexcept | |
Signal & | operator= (const Signal &signal)=delete |
Signal & | operator= (Signal &&signal) noexcept |
std::size_t | connect (Slot< Args... > *slot) |
Connects a slot to the signal. | |
std::size_t | connect (Slot< Args... > &slot) |
Connects a slot to the signal. | |
std::size_t | connect (Slot< Args... > &&slot) |
Connects a slot to the signal. | |
std::size_t | connect (const std::function< void(Args...)> &callback) |
Connects a callback to the signal. This will create an internal slot. Avoids the need to create an slot in place. | |
std::size_t | connect (std::function< void(Args...)> &&callback) |
Connects a callback to the signal. This will create an internal slot. Avoids the need to create an slot in place. | |
void | disconnect (std::size_t key) |
Disconnects a slot from the signal. | |
void | disconnect (Slot< Args... > *slot) |
Disconnects a slot from the signal. | |
void | disconnect (Slot< Args... > &slot) |
Disconnects a slot from the signal. | |
void | clear () |
Disconnects all connected slots from the signal. | |
bool | isConnected (std::size_t key) const |
Finds if a slot is connected to the signal. | |
std::vector< std::size_t > | connectedKeys () const |
Gets all the keys of the connected slots. | |
std::vector< const Slot< Args... > * > | connectedSlots () const |
Gets all the connected slots. | |
template<typename... FnArgs> | |
void | emit (FnArgs &&... args) const |
Emits the signal to all connected slots. | |
void | operator() (Args &&... args) const |
Emits the signal to all connected slots. Same as emit. | |
A signal is a class used to emit events.
Args | The types of the arguments emitted in the event. |
std::size_t spark::patterns::Signal< Args >::connect | ( | const std::function< void(Args...)> & | callback | ) |
Connects a callback to the signal. This will create an internal slot. Avoids the need to create an slot in place.
callback | A callback to connect. |
std::size_t spark::patterns::Signal< Args >::connect | ( | Slot< Args... > && | slot | ) |
Connects a slot to the signal.
slot | The slot to connect. |
std::size_t spark::patterns::Signal< Args >::connect | ( | Slot< Args... > & | slot | ) |
Connects a slot to the signal.
slot | A reference to the slot to connect. |
std::size_t spark::patterns::Signal< Args >::connect | ( | Slot< Args... > * | slot | ) |
Connects a slot to the signal.
slot | The address of the slot to connect. |
std::size_t spark::patterns::Signal< Args >::connect | ( | std::function< void(Args...)> && | callback | ) |
Connects a callback to the signal. This will create an internal slot. Avoids the need to create an slot in place.
callback | A callback to connect. |
|
nodiscard |
Gets all the keys of the connected slots.
|
nodiscard |
Gets all the connected slots.
void spark::patterns::Signal< Args >::disconnect | ( | Slot< Args... > & | slot | ) |
Disconnects a slot from the signal.
slot | A reference to the slot to disconnect. |
void spark::patterns::Signal< Args >::disconnect | ( | Slot< Args... > * | slot | ) |
Disconnects a slot from the signal.
slot | The address of the slot to disconnect. |
void spark::patterns::Signal< Args >::disconnect | ( | std::size_t | key | ) |
Disconnects a slot from the signal.
key | The key of the slot to disconnect. |
void spark::patterns::Signal< Args >::emit | ( | FnArgs &&... | args | ) | const |
Emits the signal to all connected slots.
FnArgs | The types of the arguments to emit. Must be convertible to the signal arguments. |
args | The arguments for the slots. |
|
nodiscard |
Finds if a slot is connected to the signal.
key | The key of the slot to find. |
void spark::patterns::Signal< Args >::operator() | ( | Args &&... | args | ) | const |
Emits the signal to all connected slots. Same as emit.
args | The arguments for the slots. |