EnTT 3.13.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(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.
 
sighoperator= (const sigh &other) noexcept(std::is_nothrow_copy_assignable_v< container_type >)
 Copy assignment operator.
 
sighoperator= (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.
 

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:

Template Parameters
RetReturn type of a function type.
ArgsTypes of arguments of a function type.
AllocatorType 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
allocatorThe 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)
inlinenoexcept

Copy constructor.

Parameters
otherThe 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 
)
inlinenoexcept

Allocator-extended copy constructor.

Parameters
otherThe instance to copy from.
allocatorThe 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
otherThe 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 
)
inlinenoexcept

Allocator-extended move constructor.

Parameters
otherThe instance to move from.
allocatorThe 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
FuncType of collector to use, if any.
Parameters
funcA valid function object.
argsArguments to use to invoke listeners.

Definition at line 191 of file sigh.hpp.

◆ empty()

template<typename Ret , typename... Args, typename Allocator >
bool entt::sigh< Ret(Args...), Allocator >::empty ( ) const
inlinenoexcept

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

◆ get_allocator()

template<typename Ret , typename... Args, typename Allocator >
constexpr allocator_type entt::sigh< Ret(Args...), Allocator >::get_allocator ( ) const
inlineconstexprnoexcept

Returns the associated allocator.

Returns
The associated allocator.

Definition at line 143 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)
inlinenoexcept

Copy assignment operator.

Parameters
otherThe instance to copy from.
Returns
This signal handler.

Definition at line 115 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
otherThe instance to move from.
Returns
This signal handler.

Definition at line 125 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
argsArguments to use to invoke listeners.

Definition at line 170 of file sigh.hpp.

◆ size()

template<typename Ret , typename... Args, typename Allocator >
size_type entt::sigh< Ret(Args...), Allocator >::size ( ) const
inlinenoexcept

Number of listeners connected to the signal.

Returns
Number of listeners currently connected.

Definition at line 151 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
otherSignal handler to exchange the content with.

Definition at line 134 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 465 of file sigh.hpp.


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