HikoGUI
A low latency retained GUI
Loading...
Searching...
No Matches
Public Types | Public Member Functions
tt::notifier< Result(Args...)> Class Template Reference

#include <ttauri/notifier.hpp>

Public Types

using callback_type = std::function<Result(Args const &...)>
 
using callback_ptr_type = std::shared_ptr<callback_type>
 

Public Member Functions

void subscribe_ptr (callback_ptr_type const &callback_ptr) noexcept
 Add a callback to the notifier.
 
template<typename Callback >
callback_ptr_type subscribe (Callback &&callback) noexcept
 Add a callback to the notifier.
 
void unsubscribe (callback_ptr_type const &callback_ptr) noexcept
 Remove a callback from the notifier.
 
void operator() (Args const &...args) const noexcept
 Call the subscribed callbacks with the given arguments.
 

Detailed Description

template<typename Result, typename... Args>
class tt::notifier< Result(Args...)>

A notifier which can be used to call a set of registered callbacks.

This class is thread-safe; however you must not use this object from within the callback.

Template Parameters
ResultThe result of calling the callback.
ArgsThe argument types of the callback function.

Member Function Documentation

◆ operator()()

template<typename Result , typename... Args>
void tt::notifier< Result(Args...)>::operator() ( Args const &... args) const
inlinenoexcept

Call the subscribed callbacks with the given arguments.

Parameters
argsThe arguments to pass with the invocation of the callback

◆ subscribe()

template<typename Result , typename... Args>
template<typename Callback >
callback_ptr_type tt::notifier< Result(Args...)>::subscribe ( Callback && callback)
inlinenoexcept

Add a callback to the notifier.

Ownership of the callback belongs with the caller of subscribe(). The notifier will hold a weak_ptr to the callback so that when the callback is destroyed it will no longer be called.

Parameters
callbackThe callback-function to register.
Returns
A shared_ptr to a function object holding the callback.

◆ subscribe_ptr()

template<typename Result , typename... Args>
void tt::notifier< Result(Args...)>::subscribe_ptr ( callback_ptr_type const & callback_ptr)
inlinenoexcept

Add a callback to the notifier.

Ownership of the callback belongs with the caller of subscribe(). The notifier will hold a weak_ptr to the callback so that when the callback is destroyed it will no longer be called.

Parameters
callback_ptrA shared_ptr to a callback function.

◆ unsubscribe()

template<typename Result , typename... Args>
void tt::notifier< Result(Args...)>::unsubscribe ( callback_ptr_type const & callback_ptr)
inlinenoexcept

Remove a callback from the notifier.

Parameters
callback_ptrA share_ptr to the callback function to unsubscribe.

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