Sink is a helper class used to bind listeners to signals. The separation between signal and sink makes it possible to store signals as private data members without exposing their invoke functionality to the users of the class. It also allows for less header files contention because any binding can (and should) happen in source files.
More...
#include <signal.h>
|
| | sink (signal< Ret(Args...)> &ref) noexcept |
| | Constructs a sink that is allowed to modify a given signal.
|
| |
| void | move_from (sink &other) |
| | Moves signals from another sink to this one. Result is stored in this object. The sink we merge from is cleared.
|
| |
| template<auto FuncToBind> |
| void | bind () |
| | Binds a free function or an unbound member to a signal. The signal handler performs checks to avoid multiple connections for the same function.
|
| |
| template<auto FuncToBind, typename Type > |
| void | bind (Type &value_or_instance) |
| | Binds a free function with context or a bound member to a signal. When used to bind a free function with context, its signature must be such that the instance is the first argument before the ones used to define the signal itself.
|
| |
| void | bind (func_type *func, const void *data=nullptr) |
| | Binds an user defined function with optional context to a signal. The context is returned as the first argument to the target function in all cases.
|
| |
| template<auto FuncToUnbind> |
| void | unbind () |
| | Unbinds a free function or an unbound member from a signal.
|
| |
| template<auto FuncToUnbind, typename Type > |
| void | unbind (Type &value_or_instance) |
| | Unbinds a free function with context or a bound member from a signal.
|
| |
| template<typename Type > |
| void | unbind (Type *value_or_instance) |
| | Unbinds a free function with context or bound members from a signal.
|
| |
| template<typename Type > |
| void | unbind (Type &value_or_instance) |
| | Unbinds a free function with context or bound members from a signal.
|
| |
|
void | reset () |
| | Unbinds all listeners from a signal.
|
| |
template<typename Ret, typename... Args>
class gaia::util::sink< Ret(Args...)>
Sink is a helper class used to bind listeners to signals. The separation between signal and sink makes it possible to store signals as private data members without exposing their invoke functionality to the users of the class. It also allows for less header files contention because any binding can (and should) happen in source files.
- Warning
- Lifetime of any sink must not be longer than that of the signal to which it refers.
- Template Parameters
-
| Ret | Return type of a function type. |
| Args | Types of arguments of a function type. |
◆ sink()
template<typename Ret , typename... Args>
Constructs a sink that is allowed to modify a given signal.
- Parameters
-
| ref | A valid reference to a signal object. |
◆ bind() [1/3]
template<typename Ret , typename... Args>
template<auto FuncToBind>
Binds 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
-
| FuncToBind | Function or member to bind to the signal. |
◆ bind() [2/3]
template<typename Ret , typename... Args>
| void gaia::util::sink< Ret(Args...)>::bind |
( |
func_type * |
func, |
|
|
const void * |
data = nullptr |
|
) |
| |
|
inline |
Binds an user defined function with optional context to a signal. The context is returned as the first argument to the target function in all cases.
- Parameters
-
| func | Function to bind to the signal. |
| data | User defined arbitrary ctx. |
◆ bind() [3/3]
template<typename Ret , typename... Args>
template<auto FuncToBind, typename Type >
Binds a free function with context or a bound member to a signal. When used to bind a free function with context, its signature must be such that the instance is the first argument before the ones used to define the signal itself.
- Template Parameters
-
| FuncToBind | Function or member to bind to the signal. |
| Type | Type of class or type of context. |
- Parameters
-
| value_or_instance | A valid object that fits the purpose. |
◆ move_from()
template<typename Ret , typename... Args>
Moves signals from another sink to this one. Result is stored in this object. The sink we merge from is cleared.
- Parameters
-
| other | Sink to move signals from |
◆ unbind() [1/4]
template<typename Ret , typename... Args>
template<auto FuncToUnbind>
Unbinds a free function or an unbound member from a signal.
- Template Parameters
-
| FuncToUnbind* | Function* or member to unbind from the signal. |
◆ unbind() [2/4]
template<typename Ret , typename... Args>
template<auto FuncToUnbind, typename Type >
Unbinds a free function with context or a bound member from a signal.
- Template Parameters
-
| FuncToUnbind | Function or member to unbind from the signal. |
| Type | Type of class or type of context. |
- Parameters
-
| value_or_instance | A valid object that fits the purpose. |
◆ unbind() [3/4]
template<typename Ret , typename... Args>
template<typename Type >
Unbinds a free function with context or bound members from a signal.
- Template Parameters
-
| Type | Type of class or type of context. |
- Parameters
-
| value_or_instance | A valid object that fits the purpose. |
◆ unbind() [4/4]
template<typename Ret , typename... Args>
template<typename Type >
Unbinds a free function with context or bound members from a signal.
- Template Parameters
-
| Type | Type of class or type of context. |
- Parameters
-
| value_or_instance | A valid object that fits the purpose. |
The documentation for this class was generated from the following file:
- /home/runner/work/gaia-ecs/gaia-ecs/include/gaia/util/signal.h