VoltMod
C++23 framework for CS2 server plugins
Loading...
Searching...
No Matches
PublishedInterfaces.hpp
Go to the documentation of this file.
1#pragma once
2
4#include <string>
5#include <string_view>
6#include <vector>
7
8namespace VoltMod
9{
10
11/** Interfaces plugins publish to each other. Only the publishing owner can refresh or withdraw a name. */
13{
14public:
15 using OwnerId = const void*;
16
17 /** Add or refresh @p name. A peer's live pointer is never swapped out from under it. */
18 void Publish(OwnerId owner, std::string_view name, void* implementation);
19 void Unpublish(OwnerId owner, std::string_view name);
20 void* Find(std::string_view name) const;
21
22 /** Withdraw everything @p owner published and report the names it was still holding. */
23 std::vector<std::string> RemoveAll(OwnerId owner);
24
25private:
26 struct Service
27 {
28 std::string Name;
29 void* Implementation = nullptr;
30 OwnerId Owner = nullptr;
31 };
32
33 std::vector<Service> _services;
34};
35
36} // namespace VoltMod
void Publish(OwnerId owner, std::string_view name, void *implementation)
void * Find(std::string_view name) const
std::vector< std::string > RemoveAll(OwnerId owner)
void Unpublish(OwnerId owner, std::string_view name)
constexpr std::string_view Name(E value) noexcept
Definition EnumNames.hpp:33
static std::string ReadFile(const std::filesystem::path &path)
Definition Loader.cpp:56