|
VoltMod
C++23 framework for CS2 server plugins
|
An engine hook that exists only while one of its events has handlers. More...
#include <LazyHook.hpp>
Public Member Functions | |
| LazyHook (std::string name, std::function< Result< Subscription >()> install) | |
| ~LazyHook () | |
| LazyHook (const LazyHook &)=delete | |
| LazyHook & | operator= (const LazyHook &)=delete |
| EventLifecycle | ForEvent () |
| bool | Installed () const noexcept |
| int | ListeningEvents () const noexcept |
An engine hook that exists only while one of its events has handlers.
The first event to gain a handler calls install and keeps the hook it returns; the last one to go quiet removes it. An install error is logged under name and refuses that subscription, so a later subscriber retries.
Adapters borrow this object, so declare it before the events they belong to. Destroying it with handlers still attached is an ownership error that can leave a hook in an unloading module; the destructor logs it.
Definition at line 29 of file LazyHook.hpp.
| VoltMod::LazyHook::LazyHook | ( | std::string | name, |
| std::function< Result< Subscription >()> | install | ||
| ) |
Definition at line 8 of file LazyHook.cpp.
| VoltMod::LazyHook::~LazyHook | ( | ) |
Definition at line 12 of file LazyHook.cpp.
References VoltMod::Log::Error().
| EventLifecycle VoltMod::LazyHook::ForEvent | ( | ) |
Definition at line 21 of file LazyHook.cpp.
References VoltMod::EventLifecycle::OnFirst.
|
inlinenoexcept |
Definition at line 40 of file LazyHook.hpp.
|
inlinenoexcept |
Number of adapted events with at least one handler. For diagnostics and tests only.
Definition at line 43 of file LazyHook.hpp.