Anklang 0.3.0-460-gc4ef46ba
ASE — Anklang Sound Engine (C++)

« « « Anklang Documentation
Loading...
Searching...
No Matches
Classes | Public Types | Public Member Functions | List of all members
Ase::CallbackList< A > Class Template Reference

Reentrant callback list with configurable arguments. More...

#include "callback.hh"

Inheritance diagram for Ase::CallbackList< A >:
[legend]

Public Types

using Callback = std::function< void(const A &...)>
 

Public Member Functions

 ASE_DEFINE_MAKE_SHARED (CallbackList)
 
bool empty () const
 Check if the callback list is empty, i.e. invocation will not call any callbacks.
 
bool del (size_t id)
 Delete a previously added callback via its id, returns if any was found.
 
size_t add (const Callback &f)
 Add a callback, returns an id that can be used for deletion.
 
std::function< void()> add_delcb (const Callback &f)
 Add a callback and return a deleter that removes the callback when invoked.
 
void call (const std::function< void(const Callback &, const A &...)> &wrapper, const A &...args)
 Call all callbacks in the order they were added via wrapper function.
 
void operator() (const A &...args)
 Call all callbacks in the order they were added.
 
- Public Member Functions inherited from std::enable_shared_from_this< CallbackList< A... > >
enable_shared_from_this (T... args)
 
operator= (T... args)
 
shared_from_this (T... args)
 
weak_from_this (T... args)
 
~enable_shared_from_this (T... args)
 

Detailed Description

template<class... A>
class Ase::CallbackList< A >

Reentrant callback list with configurable arguments.

Definition at line 13 of file callback.hh.

Member Typedef Documentation

◆ Callback

template<class... A>
using Ase::CallbackList< A >::Callback = std::function<void(const A&...)>

Definition at line 17 of file callback.hh.

Member Function Documentation

◆ add()

template<class... A>
size_t Ase::CallbackList< A >::add ( const Callback f)

Add a callback, returns an id that can be used for deletion.

Definition at line 23 of file callback.hh.

◆ add_delcb()

template<class... A>
std::function< void()> Ase::CallbackList< A >::add_delcb ( const Callback f)

Add a callback and return a deleter that removes the callback when invoked.

Definition at line 26 of file callback.hh.

References ASE_ASSERT_RETURN, and std::enable_shared_from_this< CallbackList< A... > >::shared_from_this().

◆ call()

template<class... A>
void Ase::CallbackList< A >::call ( const std::function< void(const Callback &, const A &...)> &  wrapper,
const A &...  args 
)

Call all callbacks in the order they were added via wrapper function.

Definition at line 36 of file callback.hh.

References ASE_ASSERT_RETURN, std::vector::begin(), std::vector::end(), std::vector::erase(), std::vector::push_back(), std::remove_if(), and std::vector::size().

Referenced by Ase::CallbackList< A >::operator()().

◆ del()

template<class... A>
bool Ase::CallbackList< A >::del ( size_t  id)

Delete a previously added callback via its id, returns if any was found.

Definition at line 21 of file callback.hh.

◆ empty()

template<class... A>
bool Ase::CallbackList< A >::empty ( ) const

Check if the callback list is empty, i.e. invocation will not call any callbacks.

Definition at line 19 of file callback.hh.

References std::vector::empty().

◆ operator()()

template<class... A>
void Ase::CallbackList< A >::operator() ( const A &...  args)

Call all callbacks in the order they were added.

Definition at line 51 of file callback.hh.

References Ase::CallbackList< A >::call().


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