VoltMod
C++23 framework for CS2 server plugins
Loading...
Searching...
No Matches
VoltMod::Subscriptions Class Reference

Holds the subscriptions an object makes and releases them together, newest first. More...

#include <Subscriptions.hpp>

Public Member Functions

 Subscriptions ()=default
 
 ~Subscriptions ()
 
 Subscriptions (Subscriptions &&) noexcept=default
 
Subscriptions & operator= (Subscriptions &&other) noexcept
 
 Subscriptions (const Subscriptions &)=delete
 
Subscriptions & operator= (const Subscriptions &)=delete
 
void Add (Subscription subscription)
 
void Clear ()
 
bool Empty () const noexcept
 

Detailed Description

Holds the subscriptions an object makes and releases them together, newest first.

_subs.Add(runtime.Slots.Changed += [this](int slot) { Forget(slot); });
_subs.Add(runtime.GameEvents.On<PlayerSpawn>([this](const PlayerSpawn& e) { Spawn(e.Slot); }));
static std::string ReadFile(const std::filesystem::path &path)
Definition Loader.cpp:56

Declare it after whatever its handlers touch, the same as a single Subscription. A handler that has to be dropped on its own still wants its own Subscription member.

Definition at line 21 of file Subscriptions.hpp.

Constructor & Destructor Documentation

◆ Subscriptions() [1/3]

VoltMod::Subscriptions::Subscriptions ( )
default

◆ ~Subscriptions()

VoltMod::Subscriptions::~Subscriptions ( )
inline

Definition at line 25 of file Subscriptions.hpp.

References Clear().

◆ Subscriptions() [2/3]

VoltMod::Subscriptions::Subscriptions ( Subscriptions &&  )
defaultnoexcept

◆ Subscriptions() [3/3]

VoltMod::Subscriptions::Subscriptions ( const Subscriptions &  )
delete

Member Function Documentation

◆ Add()

void VoltMod::Subscriptions::Add ( Subscription  subscription)
inline

Keep subscription for as long as this lives.

Definition at line 43 of file Subscriptions.hpp.

References VoltMod::ReadFile().

Referenced by VoltMod::EngineHooks::EngineHooks(), and VoltMod::PanoramaMenu::PanoramaMenu().

◆ Clear()

void VoltMod::Subscriptions::Clear ( )
inline

Release everything now, newest first.

Definition at line 46 of file Subscriptions.hpp.

Referenced by operator=(), and ~Subscriptions().

◆ Empty()

bool VoltMod::Subscriptions::Empty ( ) const
inlinenoexcept

True while this holds nothing - also how a caller asks "have I subscribed yet?" for a registration deferred to first use.

Definition at line 56 of file Subscriptions.hpp.

◆ operator=() [1/2]

Subscriptions & VoltMod::Subscriptions::operator= ( const Subscriptions &  )
delete

◆ operator=() [2/2]

Subscriptions & VoltMod::Subscriptions::operator= ( Subscriptions &&  other)
inlinenoexcept

Releases what this held before taking other's.

Definition at line 29 of file Subscriptions.hpp.

References Clear(), and VoltMod::ReadFile().


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