Kouta
A small application framework based on Boost
kouta::base::callback::CallbackList< TArgs > Class Template Reference

Callback list. More...

#include <callback-list.hpp>

Inheritance diagram for kouta::base::callback::CallbackList< TArgs >:
Collaboration diagram for kouta::base::callback::CallbackList< TArgs >:

Public Member Functions

 CallbackList (const CallbackList &)=default
 
CallbackListoperator= (const CallbackList &)=default
 
 CallbackList (CallbackList &&)=default
 
CallbackListoperator= (CallbackList &&)=default
 
 ~CallbackList () override=default
 
 CallbackList (std::initializer_list< BaseCallback< TArgs... >> callbacks)
 Callback constructor from a set of callbacks. More...
 
- Public Member Functions inherited from kouta::base::callback::BaseCallback< TArgs... >
 BaseCallback ()=default
 Default constructor. More...
 
 BaseCallback (const BaseCallback &)=default
 
 BaseCallback (BaseCallback &&)=default
 
BaseCallbackoperator= (const BaseCallback &)=default
 
BaseCallbackoperator= (BaseCallback &&)=default
 
virtual ~BaseCallback ()=default
 
void operator() (TArgs... args) const
 Invoke the underlying callable. More...
 

Private Member Functions

void invoke_callbacks (TArgs... args)
 Invoke all stored callbacks in order. More...
 

Private Attributes

std::vector< BaseCallback< TArgs... > > m_callbacks
 

Additional Inherited Members

- Public Types inherited from kouta::base::callback::BaseCallback< TArgs... >
using Callable = std::function< void(TArgs...)>
 The type of the callable the Callback points to. More...
 
- Protected Member Functions inherited from kouta::base::callback::BaseCallback< TArgs... >
void set_callable (Callable &&callable)
 Set the callable. More...
 

Detailed Description

template<class... TArgs>
class kouta::base::callback::CallbackList< TArgs >

Callback list.

The Callback list exposes the same API as a regular Callback, but is initialized by providing a set of any kind of Callback. When the callback list is called, it will in turn invoke every Callback contained within.

The lifetime of the contained Callbacks and the objects they may point to must be guaranteed to surpass that of the Callback list itself.

Template Parameters
TArgsCallable arguments.

Constructor & Destructor Documentation

◆ CallbackList() [1/3]

template<class... TArgs>
kouta::base::callback::CallbackList< TArgs >::CallbackList ( const CallbackList< TArgs > &  )
default

◆ CallbackList() [2/3]

template<class... TArgs>
kouta::base::callback::CallbackList< TArgs >::CallbackList ( CallbackList< TArgs > &&  )
default

◆ ~CallbackList()

template<class... TArgs>
kouta::base::callback::CallbackList< TArgs >::~CallbackList ( )
overridedefault

◆ CallbackList() [3/3]

template<class... TArgs>
kouta::base::callback::CallbackList< TArgs >::CallbackList ( std::initializer_list< BaseCallback< TArgs... >>  callbacks)
inline

Callback constructor from a set of callbacks.

This constructor initializes the internal callable to point to an internal function that calls all the stored Callbacks (in order).

Parameters
[in]callbacksSet of Callbacks to store.

Member Function Documentation

◆ invoke_callbacks()

template<class... TArgs>
void kouta::base::callback::CallbackList< TArgs >::invoke_callbacks ( TArgs...  args)
inlineprivate

Invoke all stored callbacks in order.

◆ operator=() [1/2]

template<class... TArgs>
CallbackList& kouta::base::callback::CallbackList< TArgs >::operator= ( CallbackList< TArgs > &&  )
default

◆ operator=() [2/2]

template<class... TArgs>
CallbackList& kouta::base::callback::CallbackList< TArgs >::operator= ( const CallbackList< TArgs > &  )
default

Member Data Documentation

◆ m_callbacks

template<class... TArgs>
std::vector<BaseCallback<TArgs...> > kouta::base::callback::CallbackList< TArgs >::m_callbacks
private

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