42 template <IsService T>
43 event::ListenerPtr subscribeService(std::function<
void(std::shared_ptr<T>
const&)>
const& fn) {
44 if (
auto service = getService<T>(); service) {
50 if (event.service()->getServiceId() == T::ServiceId) {
51 if constexpr (std::is_same_v<
52 std::remove_cvref_t<
decltype((event))>,
53 event::server::ServiceUnregisterEvent>) {
56 fn(std::static_pointer_cast<T>(event.service()));
61 event::EventBus::getInstance().addListener(listener);
65 template <IsService T>
66 Expected<std::shared_ptr<T>> getService() {
67 auto res = getService(getServiceId<T>);
69 return forwardError(res.error());
71 return std::static_pointer_cast<T>(*res);
74 LLNDAPI Expected<std::shared_ptr<Service>> getService(
ServiceIdView const&
id);
76 LLNDAPI std::optional<QueryServiceResult> queryService(std::string_view name);
78 LLAPI
bool registerService(
79 std::shared_ptr<Service>
const& service,
80 std::shared_ptr<mod::Mod>
const& mod = mod::NativeMod::current()
85 LLAPI
void unregisterService(
mod::Mod const& mod);
94 std::unique_ptr<Impl> impl;