dispatcher/emitter: constrained assure

This commit is contained in:
Michele Caini
2019-12-14 16:44:24 +01:00
parent 449b03f6bd
commit 8451301a5a
3 changed files with 6 additions and 2 deletions

4
TODO
View File

@@ -25,9 +25,11 @@
* Mission: get rid of named types
- make it possible to use custom generators (eg for plugins)
* dispatcher, emitter, registry
* registry
* meta: use type_id, remove import, everything should work transparently
* type_id_enabled and fallback on old-fashioned families otherwise
* add discard pool functionality (+ test)
- use type_id also for groups, get rid of extent and subfunctions, is it possible?
- reintroduce old-fashion family and add a new family-like thing with generators
- families should be defined as out-of-class to guarantee the same identifiers for the same types
- update doc: family, dispatcher, emitter, registry, meta, across boundaries

View File

@@ -81,6 +81,7 @@ class dispatcher {
template<typename Event>
pool_handler<Event> & assure() {
static_assert(std::is_same_v<Event, std::decay_t<Event>>);
static std::size_t index{pools.size()};
if(!(index < pools.size()) || pools[index]->id() != type_id_v<Event>) {
@@ -192,7 +193,7 @@ public:
cpool->clear();
});
} else {
(assure<std::decay_t<Event>>().clear(), ...);
(assure<Event>().clear(), ...);
}
}

View File

@@ -120,6 +120,7 @@ class emitter {
template<typename Event>
const pool_handler<Event> & assure() const {
static_assert(std::is_same_v<Event, std::decay_t<Event>>);
static std::size_t index{pools.size()};
if(!(index < pools.size()) || pools[index]->id() != type_id_v<Event>) {