EnTT: entt::sigh< Ret(Args...), Allocator > Class Template Reference

EnTT 3.16.0

Loading...
Searching...
No Matches
Public Types | Public Member Functions | Friends | List of all members
entt::sigh< Ret(Args...), Allocator > Class Template Reference

Unmanaged signal handler. More...

`#include <sigh.hpp>`

## Public Types
using | allocator_type = Allocator
| Allocator type.
using | size_type = std::size_t
| Unsigned integer type.
using | sink_type = sink<sigh<Ret(Args...), Allocator>>
| Sink type.

## Public Member Functions
| sigh () noexcept(noexcept(allocator_type{}))
| Default constructor.
| sigh (const allocator_type &allocator) noexcept
| Constructs a signal handler with a given allocator.
| sigh (const sigh &other)
| Copy constructor.
| sigh (const sigh &other, const allocator_type &allocator)
| Allocator-extended copy constructor.
| sigh (sigh &&other) noexcept
| Move constructor.
| sigh (sigh &&other, const allocator_type &allocator)
| Allocator-extended move constructor.
| ~sigh ()=default
| Default destructor.
sigh & | operator= (const sigh &other)
| Copy assignment operator.
sigh & | operator= (sigh &&other) noexcept
| Move assignment operator.
void | swap (sigh &other) noexcept
| 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.

## Friends
class | sink< sigh< Ret(Args...), Allocator > >

## Detailed Description

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.

## Member Typedef Documentation

## ◆ allocator_type

template<typename Ret, typename... Args, typename Allocator>

using entt::sigh< Ret(Args...), Allocator >::allocator_type = Allocator

Allocator type.

Definition at line 63 of file sigh.hpp.

## ◆ sink_type

template<typename Ret, typename... Args, typename Allocator>

using entt::sigh< Ret(Args...), Allocator >::sink_type = sink<sigh<Ret(Args...), Allocator>>

Sink type.

Definition at line 67 of file sigh.hpp.

## ◆ size_type

template<typename Ret, typename... Args, typename Allocator>

using entt::sigh< Ret(Args...), Allocator >::size_type = std::size_t

Unsigned integer type.

Definition at line 65 of file sigh.hpp.

## Constructor & Destructor Documentation

## ◆ sigh() [1/6]

template<typename Ret, typename... Args, typename Allocator>

entt::sigh< Ret(Args...), Allocator >::sigh | ( |  | ) |
| inlinenoexcept

Default constructor.

Definition at line 70 of file sigh.hpp.

## ◆ sigh() [2/6]

template<typename Ret, typename... Args, typename Allocator>

entt::sigh< Ret(Args...), Allocator >::sigh | ( | const allocator_type & | allocator | ) |
| inlineexplicitnoexcept

Constructs a signal handler with a given allocator.

Parameters

  allocator | The allocator to use.

Definition at line 77 of file sigh.hpp.

## ◆ sigh() [3/6]

template<typename Ret, typename... Args, typename Allocator>

entt::sigh< Ret(Args...), Allocator >::sigh | ( | const sigh< Ret(Args...), Allocator > & | other | ) |
| inline

Copy constructor.

Parameters

  other | The instance to copy from.

Definition at line 84 of file sigh.hpp.

## ◆ sigh() [4/6]

template<typename Ret, typename... Args, typename Allocator>

entt::sigh< Ret(Args...), Allocator >::sigh | ( | const sigh< Ret(Args...), Allocator > & | other,
|  | const allocator_type & | allocator )
| inline

Allocator-extended copy constructor.

Parameters

  other | The instance to copy from.
  allocator | The allocator to use.

Definition at line 92 of file sigh.hpp.

## ◆ sigh() [5/6]

template<typename Ret, typename... Args, typename Allocator>

entt::sigh< Ret(Args...), Allocator >::sigh | ( | sigh< Ret(Args...), Allocator > && | other | ) |
| inlinenoexcept

Move constructor.

Parameters

  other | The instance to move from.

Definition at line 99 of file sigh.hpp.

## ◆ sigh() [6/6]

template<typename Ret, typename... Args, typename Allocator>

entt::sigh< Ret(Args...), Allocator >::sigh | ( | sigh< Ret(Args...), Allocator > && | other,
|  | const allocator_type & | allocator )
| inline

Allocator-extended move constructor.

Parameters

  other | The instance to move from.
  allocator | The allocator to use.

Definition at line 107 of file sigh.hpp.

## Member Function Documentation

## ◆ collect()

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 194 of file sigh.hpp.

## ◆ empty()

template<typename Ret, typename... Args, typename Allocator>

bool entt::sigh< Ret(Args...), Allocator >::empty | ( |  | ) | const
| inlinenodiscardnoexcept

Returns false if at least a listener is connected to the signal.

Returns
  True if the signal has no listeners connected, false otherwise.

Definition at line 162 of file sigh.hpp.

## ◆ get_allocator()

template<typename Ret, typename... Args, typename Allocator>

allocator_type entt::sigh< Ret(Args...), Allocator >::get_allocator | ( |  | ) | const
| inlinenodiscardconstexprnoexcept

Returns the associated allocator.

Returns
  The associated allocator.

Definition at line 146 of file sigh.hpp.

## ◆ operator=() [1/2]

template<typename Ret, typename... Args, typename Allocator>

sigh & entt::sigh< Ret(Args...), Allocator >::operator= | ( | const sigh< Ret(Args...), Allocator > & | other | ) |
| inline

Copy assignment operator.

Parameters

  other | The instance to copy from.

Returns
  This signal handler.

Definition at line 118 of file sigh.hpp.

## ◆ operator=() [2/2]

template<typename Ret, typename... Args, typename Allocator>

sigh & entt::sigh< Ret(Args...), Allocator >::operator= | ( | sigh< Ret(Args...), Allocator > && | other | ) |
| inlinenoexcept

Move assignment operator.

Parameters

  other | The instance to move from.

Returns
  This signal handler.

Definition at line 128 of file sigh.hpp.

## ◆ publish()

template<typename Ret, typename... Args, typename Allocator>

void entt::sigh< Ret(Args...), Allocator >::publish | ( | Args... | args | ) | const
| inline

Triggers a signal.

All the listeners are notified. Order isn't guaranteed.

Parameters

  args | Arguments to use to invoke listeners.

Definition at line 173 of file sigh.hpp.

## ◆ size()

template<typename Ret, typename... Args, typename Allocator>

size_type entt::sigh< Ret(Args...), Allocator >::size | ( |  | ) | const
| inlinenodiscardnoexcept

Number of listeners connected to the signal.

Returns
  Number of listeners currently connected.

Definition at line 154 of file sigh.hpp.

## ◆ swap()

template<typename Ret, typename... Args, typename Allocator>

void entt::sigh< Ret(Args...), Allocator >::swap | ( | sigh< Ret(Args...), Allocator > & | other | ) |
| inlinenoexcept

Exchanges the contents with those of a given signal handler.

Parameters

  other | Signal handler to exchange the content with.

Definition at line 137 of file sigh.hpp.

## Friends And Related Symbol Documentation

## ◆ sink< sigh< Ret(Args...), Allocator > >

template<typename Ret, typename... Args, typename Allocator>

friend class sink< sigh< Ret(Args...), Allocator > >
| friend

Definition at line 571 of file sigh.hpp.

The documentation for this class was generated from the following file:

- src/entt/signal/sigh.hpp