Skip to content
LeviMC
English
AutoLightDark
LeviLamina
Loading...
Searching...
No Matches
Emitter.h
1#pragma once
2
3#include <concepts>
4#include <type_traits>
5
6#include "ll/api/base/Meta.h"
7#include "ll/api/event/EmitterBase.h"
8#include "ll/api/event/EventBus.h"
9
10namespace ll::event {
11namespace detail {
12template <auto F, std::derived_from<Event>... Ts>
13inline bool emitterRegistration = [] {
14 auto& ins = EventBus::getInstance();
15 (ins.setEventEmitter<Ts>(F), ...);
16 return true;
17}();
18} // namespace detail
19
20template <auto F, std::derived_from<Event>... Ts>
21class Emitter : public EmitterBase, private meta::StaticRegistrationAnchor<detail::emitterRegistration<F, Ts...>> {
22 static_assert((std::is_final_v<Ts> && ...), "Only final classes can be emitted");
23
24protected:
25 Emitter() = default;
26 ~Emitter() override = default;
27};
28} // namespace ll::event