Safe function pointer wrapper. More...
#include <base-callback.hpp>
Public Types | |
using | Callable = std::function< void(TArgs...)> |
The type of the callable the Callback points to. More... | |
Public Member Functions | |
BaseCallback ()=default | |
Default constructor. More... | |
BaseCallback (const BaseCallback &)=default | |
BaseCallback & | operator= (const BaseCallback &)=default |
BaseCallback (BaseCallback &&)=default | |
BaseCallback & | operator= (BaseCallback &&)=default |
virtual | ~BaseCallback ()=default |
void | operator() (TArgs... args) const |
Invoke the underlying callable. More... | |
Protected Member Functions | |
void | set_callable (Callable &&callable) |
Set the callable. More... | |
Private Attributes | |
Callable | m_callable |
Safe function pointer wrapper.
A Callback can be used to store pointers to callable such as free functions, lambdas, or member methods.
This class serves as a base for custom Callback implementations that may need to take into account details such as event loops or scheduling, depending on the target of the Callback.
TArgs | Callable arguments. |
using kouta::base::callback::BaseCallback< TArgs >::Callable = std::function<void(TArgs...)> |
The type of the callable the Callback points to.
|
default |
Default constructor.
Callbacks may be default-constructed, allowing for "optional callbacks" that may or may not be specified at runtime. Do note that calling a callback that has not been initialized will throw an exception (which is intended behaviour).
|
default |
|
default |
|
virtualdefault |
|
inline |
Invoke the underlying callable.
[in] | args | Arguments to provide to the invokation. |
|
default |
|
default |
|
inlineprotected |
Set the callable.
This method exists to allow inheriting from the Callback to add custom constructors that may, for instance, interface with event loops by posting events
[in] | callable | Callable to use internally. |
|
private |