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.

References VoltMod::ReadFile().

Referenced by VoltMod::CallbackRegistry< T >::AddOwned(), and VoltMod::Event< Args >::operator+=().

◆ AddOwned()

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

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

Definition at line 36 of file CallbackRegistry.hpp.

References VoltMod::CallbackRegistry< T >::Add(), VoltMod::ReadFile(), and VoltMod::CallbackRegistry< T >::Remove().

◆ Clear()

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

Definition at line 64 of file CallbackRegistry.hpp.

References VoltMod::ReadFile().

◆ 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 VoltMod::CallbackRegistry< T >::DispatchIf(), VoltMod::ReadFile(), and VoltMod::T.

Referenced by VoltMod::Event< Args >::Raise().

◆ 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.

References VoltMod::ReadFile().

Referenced by VoltMod::CallbackRegistry< T >::Dispatch(), and VoltMod::Scheduler::OnGameFrame().

◆ Empty()

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

◆ Find()

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

Null once removed.

Definition at line 83 of file CallbackRegistry.hpp.

References VoltMod::ReadFile().

Referenced by VoltMod::Scheduler::OnGameFrame().

◆ 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.

References VoltMod::ReadFile().

Referenced by VoltMod::CallbackRegistry< T >::AddOwned(), VoltMod::Scheduler::OnGameFrame(), and VoltMod::Event< Args >::operator+=().

◆ Size()

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

Definition at line 80 of file CallbackRegistry.hpp.

Referenced by VoltMod::Event< Args >::Count().


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