Clementine
Public Member Functions | List of all members
entt::sink< Ret(Args...)> Class Template Reference

Sink class. More...

#include <entt.hpp>

Public Member Functions

 sink (sigh< Ret(Args...)> &ref) ENTT_NOEXCEPT
 Constructs a sink that is allowed to modify a given signal. More...
 
bool empty () const ENTT_NOEXCEPT
 Returns false if at least a listener is connected to the sink. More...
 
template<auto Function>
sink before ()
 Returns a sink that connects before a given free function or an unbound member. More...
 
template<auto Candidate, typename Type >
sink before (Type &&value_or_instance)
 Returns a sink that connects before a free function with payload or a bound member. More...
 
template<typename Type >
sink before (Type &value_or_instance)
 Returns a sink that connects before a given instance or specific payload. More...
 
template<typename Type >
sink before (Type *value_or_instance)
 Returns a sink that connects before a given instance or specific payload. More...
 
sink before ()
 Returns a sink that connects before anything else. More...
 
template<auto Candidate>
connection connect ()
 Connects a free function or an unbound member to a signal. More...
 
template<auto Candidate, typename Type >
connection connect (Type &&value_or_instance)
 Connects a free function with payload or a bound member to a signal. More...
 
template<auto Candidate>
void disconnect ()
 Disconnects a free function or an unbound member from a signal. More...
 
template<auto Candidate, typename Type >
void disconnect (Type &&value_or_instance)
 Disconnects a free function with payload or a bound member from a signal. More...
 
template<typename Type >
void disconnect (Type &value_or_instance)
 Disconnects free functions with payload or bound members from a signal. More...
 
template<typename Type >
void disconnect (Type *value_or_instance)
 Disconnects free functions with payload or bound members from a signal. More...
 
void disconnect ()
 Disconnects all the listeners from a signal.
 

Detailed Description

template<typename Ret, typename... Args>
class entt::sink< Ret(Args...)>

Sink class.

A sink is used to connect listeners to signals and to disconnect them.
The function type for a listener is the one of the signal to which it belongs.

The clear separation between a signal and a sink permits to store the former as private data member without exposing the publish functionality to the users of the class.

Warning
Lifetime of a sink must not overcome that of the signal to which it refers. In any other case, attempting to use a sink results in undefined behavior.
Template Parameters
RetReturn type of a function type.
ArgsTypes of arguments of a function type.

Constructor & Destructor Documentation

◆ sink()

template<typename Ret , typename... Args>
entt::sink< Ret(Args...)>::sink ( sigh< Ret(Args...)> &  ref)
inline

Constructs a sink that is allowed to modify a given signal.

Parameters
refA valid reference to a signal object.

Member Function Documentation

◆ before() [1/5]

template<typename Ret , typename... Args>
template<auto Function>
sink entt::sink< Ret(Args...)>::before ( )
inline

Returns a sink that connects before a given free function or an unbound member.

Template Parameters
FunctionA valid free function pointer.
Returns
A properly initialized sink object.

◆ before() [2/5]

template<typename Ret , typename... Args>
template<auto Candidate, typename Type >
sink entt::sink< Ret(Args...)>::before ( Type &&  value_or_instance)
inline

Returns a sink that connects before a free function with payload or a bound member.

Template Parameters
CandidateMember or free function to look for.
TypeType of class or type of payload.
Parameters
value_or_instanceA valid object that fits the purpose.
Returns
A properly initialized sink object.

◆ before() [3/5]

template<typename Ret , typename... Args>
template<typename Type >
sink entt::sink< Ret(Args...)>::before ( Type &  value_or_instance)
inline

Returns a sink that connects before a given instance or specific payload.

Template Parameters
TypeType of class or type of payload.
Parameters
value_or_instanceA valid object that fits the purpose.
Returns
A properly initialized sink object.

◆ before() [4/5]

template<typename Ret , typename... Args>
template<typename Type >
sink entt::sink< Ret(Args...)>::before ( Type *  value_or_instance)
inline

Returns a sink that connects before a given instance or specific payload.

Template Parameters
TypeType of class or type of payload.
Parameters
value_or_instanceA valid pointer that fits the purpose.
Returns
A properly initialized sink object.

◆ before() [5/5]

template<typename Ret , typename... Args>
sink entt::sink< Ret(Args...)>::before ( )
inline

Returns a sink that connects before anything else.

Returns
A properly initialized sink object.

◆ connect() [1/2]

template<typename Ret , typename... Args>
template<auto Candidate>
connection entt::sink< Ret(Args...)>::connect ( )
inline

Connects a free function or an unbound member to a signal.

The signal handler performs checks to avoid multiple connections for the same function.

Template Parameters
CandidateFunction or member to connect to the signal.
Returns
A properly initialized connection object.

◆ connect() [2/2]

template<typename Ret , typename... Args>
template<auto Candidate, typename Type >
connection entt::sink< Ret(Args...)>::connect ( Type &&  value_or_instance)
inline

Connects a free function with payload or a bound member to a signal.

The signal isn't responsible for the connected object or the payload. Users must always guarantee that the lifetime of the instance overcomes the one of the signal. On the other side, the signal handler performs checks to avoid multiple connections for the same function.
When used to connect a free function with payload, its signature must be such that the instance is the first argument before the ones used to define the signal itself.

Template Parameters
CandidateFunction or member to connect to the signal.
TypeType of class or type of payload.
Parameters
value_or_instanceA valid object that fits the purpose.
Returns
A properly initialized connection object.

◆ disconnect() [1/4]

template<typename Ret , typename... Args>
template<auto Candidate>
void entt::sink< Ret(Args...)>::disconnect ( )
inline

Disconnects a free function or an unbound member from a signal.

Template Parameters
CandidateFunction or member to disconnect from the signal.

◆ disconnect() [2/4]

template<typename Ret , typename... Args>
template<auto Candidate, typename Type >
void entt::sink< Ret(Args...)>::disconnect ( Type &&  value_or_instance)
inline

Disconnects a free function with payload or a bound member from a signal.

Template Parameters
CandidateFunction or member to disconnect from the signal.
TypeType of class or type of payload.
Parameters
value_or_instanceA valid object that fits the purpose.

◆ disconnect() [3/4]

template<typename Ret , typename... Args>
template<typename Type >
void entt::sink< Ret(Args...)>::disconnect ( Type &  value_or_instance)
inline

Disconnects free functions with payload or bound members from a signal.

Template Parameters
TypeType of class or type of payload.
Parameters
value_or_instanceA valid object that fits the purpose.

◆ disconnect() [4/4]

template<typename Ret , typename... Args>
template<typename Type >
void entt::sink< Ret(Args...)>::disconnect ( Type *  value_or_instance)
inline

Disconnects free functions with payload or bound members from a signal.

Template Parameters
TypeType of class or type of payload.
Parameters
value_or_instanceA valid object that fits the purpose.

◆ empty()

template<typename Ret , typename... Args>
bool entt::sink< Ret(Args...)>::empty ( ) const
inline

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

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

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