|
| sigh () noexcept(std::is_nothrow_default_constructible_v< allocator_type > &&std::is_nothrow_constructible_v< container_type, const allocator_type & >) |
| Default constructor.
|
|
| sigh (const allocator_type &allocator) noexcept(std::is_nothrow_constructible_v< container_type, const allocator_type & >) |
| Constructs a signal handler with a given allocator.
|
|
| sigh (const sigh &other) noexcept(std::is_nothrow_copy_constructible_v< container_type >) |
| Copy constructor.
|
|
| sigh (const sigh &other, const allocator_type &allocator) noexcept(std::is_nothrow_constructible_v< container_type, const container_type &, const allocator_type & >) |
| Allocator-extended copy constructor.
|
|
| sigh (sigh &&other) noexcept(std::is_nothrow_move_constructible_v< container_type >) |
| Move constructor.
|
|
| sigh (sigh &&other, const allocator_type &allocator) noexcept(std::is_nothrow_constructible_v< container_type, container_type &&, const allocator_type & >) |
| Allocator-extended move constructor.
|
|
sigh & | operator= (const sigh &other) noexcept(std::is_nothrow_copy_assignable_v< container_type >) |
| Copy assignment operator.
|
|
sigh & | operator= (sigh &&other) noexcept(std::is_nothrow_move_assignable_v< container_type >) |
| Move assignment operator.
|
|
void | swap (sigh &other) noexcept(std::is_nothrow_swappable_v< container_type >) |
| Exchanges the contents with those of a given signal handler.
|
|
constexpr allocator_type | get_allocator () const noexcept |
| Returns the associated allocator.
|
|
size_type | size () const noexcept |
| Number of listeners connected to the signal.
|
|
bool | empty () const noexcept |
| Returns false if at least a listener is connected to the signal.
|
|
void | publish (Args... args) const |
| Triggers a signal.
|
|
template<typename Func > |
void | collect (Func func, Args... args) const |
| Collects return values from the listeners.
|
|
template<typename Ret, typename... Args, typename Allocator>
class entt::sigh< Ret(Args...), Allocator >
Unmanaged signal handler.
It works directly with references to classes and pointers to member functions as well as pointers to free functions. Users of this class are in charge of disconnecting instances before deleting them.
This class serves mainly two purposes:
- Creating signals to use later to notify a bunch of listeners.
- Collecting results from a set of functions like in a voting system.
- Template Parameters
-
Ret | Return type of a function type. |
Args | Types of arguments of a function type. |
Allocator | Type of allocator used to manage memory and elements. |
Definition at line 54 of file sigh.hpp.
template<typename Ret , typename... Args, typename Allocator >
template<typename Func >
void entt::sigh< Ret(Args...), Allocator >::collect |
( |
Func |
func, |
|
|
Args... |
args |
|
) |
| const |
|
inline |
Collects return values from the listeners.
The collector must expose a call operator with the following properties:
- The return type is either
void
or such that it's convertible to bool
. In the second case, a true value will stop the iteration.
- The list of parameters is empty if
Ret
is void
, otherwise it contains a single element such that Ret
is convertible to it.
- Template Parameters
-
Func | Type of collector to use, if any. |
- Parameters
-
func | A valid function object. |
args | Arguments to use to invoke listeners. |
Definition at line 191 of file sigh.hpp.