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 Types | |
using | impl = std::list< T > |
impl How the callbackas are stored. A list is used since iterators to other callbacks must not be invalidated upon removal. | |
using | iterator = typename impl::iterator |
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. More... | |
void | remove_callback (iterator it) |
remove_callback Removes a callback identified by an iterator. More... | |
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 More... | |
bool | callbacks_empty () const |
callbacks_empty More... | |
template<typename... Args> | |
void | send (Args &&... args) |
send Trigger all callbacks More... | |
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 More... | |
virtual void | on_removing_last_callback () |
on_removing_last_callback More... | |
|
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.