|
VoltMod
C++23 framework for CS2 server plugins
|
Typed view of the host's table of interfaces plugins publish to each other. More...
#include <ServiceExchange.hpp>
Public Member Functions | |
| ServiceExchange (IPluginServices &services) | |
| template<class T> | |
| Subscription | Publish (T *impl) |
| template<class T> | |
| Subscription | Publish (T *impl, std::string_view key) |
| template<class T> | |
| T * | Get () const |
| template<class T> | |
| T * | Get (std::string_view key) const |
Typed view of the host's table of interfaces plugins publish to each other.
An interface is a pure-virtual struct with a versioned InterfaceName ("bans.IBanService/2"). Bump the version whenever the vtable or a parameter's meaning changes, so a stale consumer gets nullptr instead of a mismatched vtable. Each plugin has its own allocator: never transfer ownership through an interface, and let no exception escape one.
Definition at line 19 of file ServiceExchange.hpp.
|
inlineexplicit |
services is the host's table; it outlives the exchange.
Definition at line 23 of file ServiceExchange.hpp.
|
inline |
What any plugin published for T, or nullptr. Ask where you use it and do not keep it: the publisher can unload between callbacks, never inside one.
Definition at line 44 of file ServiceExchange.hpp.
References VoltMod::T.
|
inline |
What a plugin published for T under key, or nullptr.
Definition at line 51 of file ServiceExchange.hpp.
References VoltMod::T.
|
inlinenodiscard |
Offer impl while the returned Subscription lives. Name T explicitly, Publish<IBanService>(&_bans), so the stored pointer is the interface subobject the consumer casts back to. Keep the Subscription below impl, so the entry goes first.
Definition at line 29 of file ServiceExchange.hpp.
|
inlinenodiscard |
Offer impl as one of several T, told apart by key: Publish<IMenuSection>(this, "admin").
Definition at line 36 of file ServiceExchange.hpp.