Kanzi 4.1.0
kanzi::Delegate< F > Class Template Reference

Multicast delegate — holds zero or more callbacks with the same signature and invokes them all. More...

#include <kanzi/core/util/delegate.hpp>

Public Types

using Callback
 

Public Member Functions

bool empty () const
 Returns true if no callbacks are subscribed.
 
template<typename... Args>
void invoke (Args &&... args) const
 Invokes all subscribed callbacks with the given arguments.
 
DelegateHandle subscribe (Callback callback)
 Subscribes a callback. Returns a handle that can be passed to unsubscribe().
 
void unsubscribe (DelegateHandle handle)
 Removes the callback registered with the given handle. No-op if the handle is not found.
 

Detailed Description

template<typename F>
class kanzi::Delegate< F >

Multicast delegate — holds zero or more callbacks with the same signature and invokes them all.

subscribe() returns a DelegateHandle used to unsubscribe a specific callback later.

Since
Kanzi 4.1.0
Attention
This feature is experimental and is likely to change in future releases.

Member Typedef Documentation

◆ Callback

template<typename F >
using kanzi::Delegate< F >::Callback

Member Function Documentation

◆ subscribe()

template<typename F >
DelegateHandle kanzi::Delegate< F >::subscribe ( Callback callback)
inline

Subscribes a callback. Returns a handle that can be passed to unsubscribe().

◆ unsubscribe()

template<typename F >
void kanzi::Delegate< F >::unsubscribe ( DelegateHandle handle)
inline

Removes the callback registered with the given handle. No-op if the handle is not found.

◆ invoke()

template<typename F >
template<typename... Args>
void kanzi::Delegate< F >::invoke ( Args &&... args) const
inline

Invokes all subscribed callbacks with the given arguments.

◆ empty()

template<typename F >
bool kanzi::Delegate< F >::empty ( ) const
inline

Returns true if no callbacks are subscribed.


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