VoltMod
C++23 framework for CS2 server plugins
Loading...
Searching...
No Matches
VoltMod::CallbackRegistry< T > Class Template Reference

#include <CallbackRegistry.hpp>

Public Member Functions

uint64_t Add (T item)
Subscription AddOwned (T item)
bool Remove (uint64_t id)
void Clear ()
bool Empty () const
size_t Size () const
T * Find (uint64_t id)
void DispatchIf (std::predicate< const T & > auto &&pred, std::invocable< T & > auto &&fn)
void Dispatch (std::invocable< T & > auto &&fn)

Detailed Description

template<class T>
class VoltMod::CallbackRegistry< T >

Definition at line 23 of file CallbackRegistry.hpp.

Member Function Documentation

◆ Add()

template<class T>
uint64_t VoltMod::CallbackRegistry< T >::Add ( T item)
inline

Store item and return its handle.

Definition at line 27 of file CallbackRegistry.hpp.

Referenced by AddOwned().

◆ AddOwned()

template<class T>
Subscription VoltMod::CallbackRegistry< T >::AddOwned ( T item)
inlinenodiscard

Add, returning a Subscription that removes the item when dropped.

Definition at line 36 of file CallbackRegistry.hpp.

References Add(), and Remove().

◆ Clear()

template<class T>
void VoltMod::CallbackRegistry< T >::Clear ( )
inline

Definition at line 64 of file CallbackRegistry.hpp.

◆ Dispatch()

template<class T>
void VoltMod::CallbackRegistry< T >::Dispatch ( std::invocable< T & > auto && fn)
inline

DispatchIf over every stored item.

Definition at line 112 of file CallbackRegistry.hpp.

References DispatchIf(), and VoltMod::T.

◆ DispatchIf()

template<class T>
void VoltMod::CallbackRegistry< T >::DispatchIf ( std::predicate< const T & > auto && pred,
std::invocable< T & > auto && fn )
inline

Invoke fn on every item pred accepts. A callback may add or remove items, its own included, or dispatch again; items it adds first run on the next dispatch.

Definition at line 91 of file CallbackRegistry.hpp.

Referenced by Dispatch().

◆ Empty()

template<class T>
bool VoltMod::CallbackRegistry< T >::Empty ( ) const
inline

Definition at line 78 of file CallbackRegistry.hpp.

◆ Find()

template<class T>
T * VoltMod::CallbackRegistry< T >::Find ( uint64_t id)
inline

Null once removed.

Definition at line 83 of file CallbackRegistry.hpp.

◆ Remove()

template<class T>
bool VoltMod::CallbackRegistry< T >::Remove ( uint64_t id)
inline

Whether id was stored; an unknown id is ignored.

Definition at line 43 of file CallbackRegistry.hpp.

Referenced by AddOwned().

◆ Size()

template<class T>
size_t VoltMod::CallbackRegistry< T >::Size ( ) const
inline

Definition at line 80 of file CallbackRegistry.hpp.


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