1 #ifndef ENTT_SIGNAL_DISPATCHER_HPP 2 #define ENTT_SIGNAL_DISPATCHER_HPP 9 #include "../core/family.hpp" 29 template<
template<
typename...>
class Sig>
33 template<
typename Class,
typename Event>
34 using instance_type =
typename Sig<void(const Event &)>::template instance_type<Class>;
36 struct BaseSignalWrapper {
37 virtual ~BaseSignalWrapper() =
default;
38 virtual void publish(std::size_t) = 0;
41 template<
typename Event>
42 struct SignalWrapper final: BaseSignalWrapper {
43 void publish(std::size_t current)
override {
44 for(
const auto &event: events[current]) {
45 signal.publish(event);
48 events[current].clear();
51 template<
typename Class,
void(Class::*Member)(const Event &)>
52 inline void connect(instance_type<Class, Event> instance) noexcept {
53 signal.template connect<Class, Member>(std::move(instance));
56 template<
typename Class,
void(Class::*Member)(const Event &)>
57 inline void disconnect(instance_type<Class, Event> instance) noexcept {
58 signal.template disconnect<Class, Member>(std::move(instance));
61 template<
typename... Args>
62 inline void trigger(Args&&... args) {
63 signal.publish({ std::forward<Args>(args)... });
66 template<
typename... Args>
67 inline void enqueue(std::size_t current, Args&&... args) {
68 events[current].push_back({ std::forward<Args>(args)... });
72 Sig<void(const Event &)> signal{};
73 std::vector<Event> events[2];
76 inline static std::size_t buffer(
bool mode) {
80 template<
typename Event>
81 SignalWrapper<Event> & wrapper() {
82 const auto type = event_family::type<Event>();
84 if(!(type < wrappers.size())) {
85 wrappers.resize(type + 1);
89 wrappers[type] = std::make_unique<SignalWrapper<Event>>();
92 return static_cast<SignalWrapper<Event> &
>(*wrappers[type]);
98 : wrappers{}, mode{
false}
117 template<
typename Event,
typename Class,
void(Class::*Member)(const Event &) = &Class::receive>
118 void connect(instance_type<Class, Event> instance) noexcept {
119 wrapper<Event>().
template connect<Class, Member>(std::move(instance));
138 template<
typename Event,
typename Class,
void(Class::*Member)(const Event &) = &Class::receive>
139 void disconnect(instance_type<Class, Event> instance) noexcept {
140 wrapper<Event>().
template disconnect<Class, Member>(std::move(instance));
153 template<
typename Event,
typename... Args>
155 wrapper<Event>().
trigger(std::forward<Args>(args)...);
168 template<
typename Event,
typename... Args>
170 wrapper<Event>().
enqueue(buffer(mode), std::forward<Args>(args)...);
181 const auto buf = buffer(mode);
184 for(
auto pos = wrappers.size(); pos > decltype(pos){0}; --pos) {
185 auto &wrapper = wrappers[pos-1];
188 wrapper->publish(buf);
194 std::vector<std::unique_ptr<BaseSignalWrapper>> wrappers;
224 #endif // ENTT_SIGNAL_DISPATCHER_HPP Dispatcher() noexcept
Default constructor.
void update()
Delivers all the pending events.
void trigger(Args &&... args)
Triggers an immediate event of the given type.
diff --git a/emitter_8hpp_source.html b/emitter_8hpp_source.html
index 4650df002..e10836d6e 100644
--- a/emitter_8hpp_source.html
+++ b/emitter_8hpp_source.html
@@ -22,7 +22,7 @@
|
entt
- 2.4.0
+ 2.4.1
|
diff --git a/entt_8hpp_source.html b/entt_8hpp_source.html
index b12d17af7..3eff5585d 100644
--- a/entt_8hpp_source.html
+++ b/entt_8hpp_source.html
@@ -22,7 +22,7 @@
|
entt
- 2.4.0
+ 2.4.1
|
diff --git a/family_8hpp_source.html b/family_8hpp_source.html
index 59807b28a..500c32662 100644
--- a/family_8hpp_source.html
+++ b/family_8hpp_source.html
@@ -22,7 +22,7 @@
|
entt
- 2.4.0
+ 2.4.1
|
diff --git a/files.html b/files.html
index 3b08351da..bb7b43c92 100644
--- a/files.html
+++ b/files.html
@@ -22,7 +22,7 @@
|
entt
- 2.4.0
+ 2.4.1
|
diff --git a/functions.html b/functions.html
index c23c2cdb0..db66582d1 100644
--- a/functions.html
+++ b/functions.html
@@ -22,7 +22,7 @@
|
entt
- 2.4.0
+ 2.4.1
|
diff --git a/functions_0x7e.html b/functions_0x7e.html
index dc966bb47..aa8453875 100644
--- a/functions_0x7e.html
+++ b/functions_0x7e.html
@@ -22,7 +22,7 @@
|
entt
- 2.4.0
+ 2.4.1
|
diff --git a/functions_b.html b/functions_b.html
index 7b3f69386..08d0d02fa 100644
--- a/functions_b.html
+++ b/functions_b.html
@@ -22,7 +22,7 @@
|
entt
- 2.4.0
+ 2.4.1
|
diff --git a/functions_c.html b/functions_c.html
index fd78f341b..57ed3f4d3 100644
--- a/functions_c.html
+++ b/functions_c.html
@@ -22,7 +22,7 @@
|
entt
- 2.4.0
+ 2.4.1
|
diff --git a/functions_d.html b/functions_d.html
index 6ad43e3b6..902de17f8 100644
--- a/functions_d.html
+++ b/functions_d.html
@@ -22,7 +22,7 @@
|
entt
- 2.4.0
+ 2.4.1
|
diff --git a/functions_e.html b/functions_e.html
index 9249ac8c0..1bb0f09f0 100644
--- a/functions_e.html
+++ b/functions_e.html
@@ -22,7 +22,7 @@
|
entt
- 2.4.0
+ 2.4.1
|
diff --git a/functions_f.html b/functions_f.html
index a8196963c..67377b6a7 100644
--- a/functions_f.html
+++ b/functions_f.html
@@ -22,7 +22,7 @@
|
entt
- 2.4.0
+ 2.4.1
|
diff --git a/functions_func.html b/functions_func.html
index 18e277a8b..21bd79f81 100644
--- a/functions_func.html
+++ b/functions_func.html
@@ -22,7 +22,7 @@
|
entt
- 2.4.0
+ 2.4.1
|
diff --git a/functions_func_0x7e.html b/functions_func_0x7e.html
index 567b04174..831519fe6 100644
--- a/functions_func_0x7e.html
+++ b/functions_func_0x7e.html
@@ -22,7 +22,7 @@
|
entt
- 2.4.0
+ 2.4.1
|
diff --git a/functions_func_b.html b/functions_func_b.html
index ae500d6d5..1f87c3b32 100644
--- a/functions_func_b.html
+++ b/functions_func_b.html
@@ -22,7 +22,7 @@
|
entt
- 2.4.0
+ 2.4.1
|
diff --git a/functions_func_c.html b/functions_func_c.html
index da6a0ae68..1b95c8eea 100644
--- a/functions_func_c.html
+++ b/functions_func_c.html
@@ -22,7 +22,7 @@
|
entt
- 2.4.0
+ 2.4.1
|
diff --git a/functions_func_d.html b/functions_func_d.html
index 0586b40f8..4fdcaec1a 100644
--- a/functions_func_d.html
+++ b/functions_func_d.html
@@ -22,7 +22,7 @@
|
entt
- 2.4.0
+ 2.4.1
|
diff --git a/functions_func_e.html b/functions_func_e.html
index 6fb7c0aa1..88f41e554 100644
--- a/functions_func_e.html
+++ b/functions_func_e.html
@@ -22,7 +22,7 @@
|
entt
- 2.4.0
+ 2.4.1
|
diff --git a/functions_func_f.html b/functions_func_f.html
index 3c964e49b..83a36988a 100644
--- a/functions_func_f.html
+++ b/functions_func_f.html
@@ -22,7 +22,7 @@
|
entt
- 2.4.0
+ 2.4.1
|
diff --git a/functions_func_g.html b/functions_func_g.html
index d7bf3bb43..d1c22adad 100644
--- a/functions_func_g.html
+++ b/functions_func_g.html
@@ -22,7 +22,7 @@
|
entt
- 2.4.0
+ 2.4.1
|
diff --git a/functions_func_h.html b/functions_func_h.html
index c83236a6a..fcfc1ce2a 100644
--- a/functions_func_h.html
+++ b/functions_func_h.html
@@ -22,7 +22,7 @@
|
entt
- 2.4.0
+ 2.4.1
|
diff --git a/functions_func_l.html b/functions_func_l.html
index 76ba78071..476dbeb0c 100644
--- a/functions_func_l.html
+++ b/functions_func_l.html
@@ -22,7 +22,7 @@
|
entt
- 2.4.0
+ 2.4.1
|
diff --git a/functions_func_o.html b/functions_func_o.html
index 2fcb10505..e82f4883c 100644
--- a/functions_func_o.html
+++ b/functions_func_o.html
@@ -22,7 +22,7 @@
|
entt
- 2.4.0
+ 2.4.1
|
diff --git a/functions_func_p.html b/functions_func_p.html
index 823d66ae0..e64d0d74e 100644
--- a/functions_func_p.html
+++ b/functions_func_p.html
@@ -22,7 +22,7 @@
|
entt
- 2.4.0
+ 2.4.1
|
diff --git a/functions_func_r.html b/functions_func_r.html
index 415f1aed2..7f138223f 100644
--- a/functions_func_r.html
+++ b/functions_func_r.html
@@ -22,7 +22,7 @@
|
entt
- 2.4.0
+ 2.4.1
|
diff --git a/functions_func_s.html b/functions_func_s.html
index c49967406..da864a6db 100644
--- a/functions_func_s.html
+++ b/functions_func_s.html
@@ -22,7 +22,7 @@
|
entt
- 2.4.0
+ 2.4.1
|
diff --git a/functions_func_t.html b/functions_func_t.html
index 8625b076c..e75f8361b 100644
--- a/functions_func_t.html
+++ b/functions_func_t.html
@@ -22,7 +22,7 @@
|
entt
- 2.4.0
+ 2.4.1
|
diff --git a/functions_func_u.html b/functions_func_u.html
index d0c6c87d8..705dc4744 100644
--- a/functions_func_u.html
+++ b/functions_func_u.html
@@ -22,7 +22,7 @@
|
entt
- 2.4.0
+ 2.4.1
|
diff --git a/functions_func_v.html b/functions_func_v.html
index da8b27b97..c20d244c3 100644
--- a/functions_func_v.html
+++ b/functions_func_v.html
@@ -22,7 +22,7 @@
|
entt
- 2.4.0
+ 2.4.1
|
diff --git a/functions_g.html b/functions_g.html
index 92c88e3b8..735736c54 100644
--- a/functions_g.html
+++ b/functions_g.html
@@ -22,7 +22,7 @@
|
entt
- 2.4.0
+ 2.4.1
|
diff --git a/functions_h.html b/functions_h.html
index 617492a0e..931364124 100644
--- a/functions_h.html
+++ b/functions_h.html
@@ -22,7 +22,7 @@
|
entt
- 2.4.0
+ 2.4.1
|
diff --git a/functions_i.html b/functions_i.html
index 47f127e85..655718c41 100644
--- a/functions_i.html
+++ b/functions_i.html
@@ -22,7 +22,7 @@
|
entt
- 2.4.0
+ 2.4.1
|
diff --git a/functions_l.html b/functions_l.html
index a7dc54732..6df07eb7d 100644
--- a/functions_l.html
+++ b/functions_l.html
@@ -22,7 +22,7 @@
|
entt
- 2.4.0
+ 2.4.1
|
diff --git a/functions_o.html b/functions_o.html
index e99fbf544..93e8dc9a5 100644
--- a/functions_o.html
+++ b/functions_o.html
@@ -22,7 +22,7 @@
|
entt
- 2.4.0
+ 2.4.1
|
diff --git a/functions_p.html b/functions_p.html
index 53db95072..98875150a 100644
--- a/functions_p.html
+++ b/functions_p.html
@@ -22,7 +22,7 @@
|
entt
- 2.4.0
+ 2.4.1
|
diff --git a/functions_r.html b/functions_r.html
index 5b61411c9..aa4e6a4a4 100644
--- a/functions_r.html
+++ b/functions_r.html
@@ -22,7 +22,7 @@
|
entt
- 2.4.0
+ 2.4.1
|
diff --git a/functions_rela.html b/functions_rela.html
index f7714722a..e2d457651 100644
--- a/functions_rela.html
+++ b/functions_rela.html
@@ -22,7 +22,7 @@
|
entt
- 2.4.0
+ 2.4.1
|
diff --git a/functions_s.html b/functions_s.html
index 369a48b1d..928da9221 100644
--- a/functions_s.html
+++ b/functions_s.html
@@ -22,7 +22,7 @@
|
entt
- 2.4.0
+ 2.4.1
|
diff --git a/functions_t.html b/functions_t.html
index 5b08f7b99..a9a974b30 100644
--- a/functions_t.html
+++ b/functions_t.html
@@ -22,7 +22,7 @@
|
entt
- 2.4.0
+ 2.4.1
|
diff --git a/functions_type.html b/functions_type.html
index 21b53d03b..87a3b230f 100644
--- a/functions_type.html
+++ b/functions_type.html
@@ -22,7 +22,7 @@
|
entt
- 2.4.0
+ 2.4.1
|
diff --git a/functions_u.html b/functions_u.html
index f5de8b004..81cff3a48 100644
--- a/functions_u.html
+++ b/functions_u.html
@@ -22,7 +22,7 @@
|
entt
- 2.4.0
+ 2.4.1
|
diff --git a/functions_v.html b/functions_v.html
index a253072b1..fa2edfbd1 100644
--- a/functions_v.html
+++ b/functions_v.html
@@ -22,7 +22,7 @@
|
entt
- 2.4.0
+ 2.4.1
|
diff --git a/functions_vars.html b/functions_vars.html
index 95b6bb923..e71ea9e60 100644
--- a/functions_vars.html
+++ b/functions_vars.html
@@ -22,7 +22,7 @@
|
entt
- 2.4.0
+ 2.4.1
|
diff --git a/graph_legend.html b/graph_legend.html
index 7f9f7a7ab..194a8dcb4 100644
--- a/graph_legend.html
+++ b/graph_legend.html
@@ -22,7 +22,7 @@
|
entt
- 2.4.0
+ 2.4.1
|
diff --git a/handle_8hpp_source.html b/handle_8hpp_source.html
index 8f4be63b1..9af70b9bb 100644
--- a/handle_8hpp_source.html
+++ b/handle_8hpp_source.html
@@ -22,7 +22,7 @@
|
entt
- 2.4.0
+ 2.4.1
|
diff --git a/hashed__string_8hpp_source.html b/hashed__string_8hpp_source.html
index 9b73484ee..e891c7596 100644
--- a/hashed__string_8hpp_source.html
+++ b/hashed__string_8hpp_source.html
@@ -22,7 +22,7 @@
|
entt
- 2.4.0
+ 2.4.1
|
diff --git a/hierarchy.html b/hierarchy.html
index 2eb2d7c5f..a015e11fc 100644
--- a/hierarchy.html
+++ b/hierarchy.html
@@ -22,7 +22,7 @@
|
entt
- 2.4.0
+ 2.4.1
|
diff --git a/ident_8hpp_source.html b/ident_8hpp_source.html
index e7c88b2b0..bf0f7d0b2 100644
--- a/ident_8hpp_source.html
+++ b/ident_8hpp_source.html
@@ -22,7 +22,7 @@
|
entt
- 2.4.0
+ 2.4.1
|
diff --git a/index.html b/index.html
index c7eec65fd..cfec9941f 100644
--- a/index.html
+++ b/index.html
@@ -22,7 +22,7 @@
|
entt
- 2.4.0
+ 2.4.1
|
diff --git a/inherits.html b/inherits.html
index f42eb3b5f..62178bec6 100644
--- a/inherits.html
+++ b/inherits.html
@@ -22,7 +22,7 @@
|
entt
- 2.4.0
+ 2.4.1
|
diff --git a/loader_8hpp_source.html b/loader_8hpp_source.html
index 3a580bcb1..7cd3e660d 100644
--- a/loader_8hpp_source.html
+++ b/loader_8hpp_source.html
@@ -22,7 +22,7 @@
|
entt
- 2.4.0
+ 2.4.1
|
diff --git a/locator_8hpp_source.html b/locator_8hpp_source.html
index 6da7c07a4..9bbfbace7 100644
--- a/locator_8hpp_source.html
+++ b/locator_8hpp_source.html
@@ -22,7 +22,7 @@
|
entt
- 2.4.0
+ 2.4.1
|
diff --git a/namespaceentt.html b/namespaceentt.html
index 40de22ef3..c45d365cc 100644
--- a/namespaceentt.html
+++ b/namespaceentt.html
@@ -22,7 +22,7 @@
|
entt
- 2.4.0
+ 2.4.1
|
@@ -313,7 +313,7 @@ template<typename... Event>
Managed dispatcher.