OSSIA
Open Scenario System for Interactive Application
|
The callback_container class. More...
The callback_container class.
Contains callbacks. Classes that have network callbacks may want to derive from this and implement on_first_callback_added, on_removing_last_callback.
This allows to cleanly stop listening when there are no callbacks.
Public Member Functions | |
callback_container (const callback_container &other) | |
callback_container (callback_container &&other) noexcept | |
callback_container & | operator= (const callback_container &other) |
callback_container & | operator= (callback_container &&other) noexcept |
iterator | add_callback (T &&callback) |
add_callback Add a new callback. | |
void | remove_callback (iterator it) |
remove_callback Removes a callback identified by an iterator. | |
void | replace_callback (iterator it, T &&cb) |
Replaces an existing callback with another function. | |
void | replace_callbacks (impl &&cbs) |
disabled_callback | disable_callback (iterator it) |
std::size_t | callback_count () const |
callback_count | |
bool | callbacks_empty () const |
callbacks_empty | |
template<typename... Args> | |
void | send (Args &&... args) |
send Trigger all callbacks | |
void | callbacks_clear () |
clear Clears callbacks. | |
impl m_callbacks | TS_GUARDED_BY (m_mutx) |
Public Attributes | |
mutex | m_mutx |
Protected Member Functions | |
virtual void | on_first_callback_added () |
on_first_callback_added | |
virtual void | on_removing_last_callback () |
on_removing_last_callback | |
|
inline |
add_callback Add a new callback.
callback | must be a std::function or similar. |
|
inline |
remove_callback Removes a callback identified by an iterator.
it | Iterator to remove. |
|
inline |
callback_count
|
inline |
callbacks_empty
|
inline |
send Trigger all callbacks
args | Arguments to send to the callbacks. |
|
inlineprotectedvirtual |
on_first_callback_added
These functions can be reimplemented by subclasses wishing to perform special actions. For instance, when the last callback is removed, stop listening somewhere...
Reimplemented in ossia::net::generic_parameter.
|
inlineprotectedvirtual |
on_removing_last_callback
Reimplemented in ossia::net::generic_parameter.