13class ModManagerRegistry {
17 std::unique_ptr<Impl> impl;
20 ~ModManagerRegistry();
22 Expected<> loadMod(
Manifest manifest)
noexcept;
24 Expected<> unloadMod(std::string_view name)
noexcept;
26 Expected<> enableMod(std::string_view name)
const noexcept;
28 Expected<> disableMod(std::string_view name)
const noexcept;
30 Expected<> onModLoad(std::string_view name)
const noexcept;
32 Expected<> onModUnload(std::string_view name)
const noexcept;
34 Expected<> onModEnable(std::string_view name)
const noexcept;
36 Expected<> onModDisable(std::string_view name)
const noexcept;
39 using CallbackId = uint64;
41 enum class ModCallbackType {
49 LLNDAPI
static ModManagerRegistry& getInstance();
51 LLNDAPI
bool addManager(std::shared_ptr<ModManager>
const& manager);
53 LLNDAPI
bool eraseManager(std::string_view type);
55 LLNDAPI
bool hasManager(std::string_view type)
const;
57 LLNDAPI std::shared_ptr<ModManager> getManager(std::string_view type)
const;
59 LLNDAPI std::shared_ptr<ModManager> getManagerForMod(std::string_view name)
const;
65 LLNDAPI
bool hasMod(std::string_view name)
const;
67 LLNDAPI std::string getModType(std::string_view name)
const;
69 LLNDAPI std::shared_ptr<Mod> getMod(std::string_view name)
const;
71 LLAPI CallbackId executeOnMod(
73 std::function<
void(std::string_view name)>&& fn,
74 std::weak_ptr<Mod> mod = NativeMod::current()
77 CallbackId executeOnModLoad(
78 std::function<
void(std::string_view name)>&& fn,
79 std::weak_ptr<Mod> mod = NativeMod::current()
81 return executeOnMod(ModCallbackType::Load, std::move(fn), std::move(mod));
84 CallbackId executeOnModUnload(
85 std::function<
void(std::string_view name)>&& fn,
86 std::weak_ptr<Mod> mod = NativeMod::current()
88 return executeOnMod(ModCallbackType::Unload, std::move(fn), std::move(mod));
91 CallbackId executeOnModEnable(
92 std::function<
void(std::string_view name)>&& fn,
93 std::weak_ptr<Mod> mod = NativeMod::current()
95 return executeOnMod(ModCallbackType::Enable, std::move(fn), std::move(mod));
98 CallbackId executeOnModDisable(
99 std::function<
void(std::string_view name)>&& fn,
100 std::weak_ptr<Mod> mod = NativeMod::current()
102 return executeOnMod(ModCallbackType::Disable, std::move(fn), std::move(mod));
105 LLAPI
bool eraseOnModCallback(CallbackId
id)
noexcept;
106 LLAPI
size_t eraseOnModCallback(std::weak_ptr<Mod> mod, ModCallbackType type = ModCallbackType::All)
noexcept;