registry: clean up

This commit is contained in:
Michele Caini
2021-04-22 08:53:16 +02:00
parent 64eb8a2d0d
commit b030df55ee
2 changed files with 19 additions and 24 deletions

34
TODO
View File

@@ -7,23 +7,23 @@
* custom pools example (multi instance, tables, enable/disable, and so on...)
WIP:
* HP: see msvc only issue at https://godbolt.org/z/8KW9PhG4c
* HP: scheduler, use any (or poly?) instead of unique_ptr
* HP: any and the like: remove constructor that accepts reference wrapper, allow only in-place T& and entt::make_any<T>(...)
* HP: resource, forward the id to the loader from the cache and if constexpr the call to load, update doc and describe customization points
* HP: make it possible to create views of the type `view<T, T>`, add get by index and such, allow to register custom pools by name with the registry
* HP: add user data to type_info
* HP: make pools available (registry/view/group), review operator| for views
* HP: any_vector for context variables
* HP: make const registry::view thread safe, switch to a view<T...>{registry} model (long term goal)
* HP: weak reference wrapper example with custom storage
* HP: paginate pools
* HP: headless (sparse set only) view
* HP: write documentation for custom storages and views!!
* HP: registry: use a poly object for pools, no more pool_data type.
* HP: make runtime views use opaque storage and therefore return also elements.
* HP: add exclude-only views to combine with packs
* HP: entity-aware observer, add observer functions aside observer class
* registry: deprecate remove_if_exists/remove_all, add remove/erase similar to sparse set that also remove all in case of no components
* scheduler, use any (or poly?) instead of unique_ptr
* any and the like: remove constructor that accepts reference wrapper, allow only in-place T& and entt::make_any<T>(...)
* resource, forward the id to the loader from the cache and if constexpr the call to load, update doc and describe customization points
* make it possible to create views of the type `view<T, T>`, add get by index and such, allow to register custom pools by name with the registry
* add user data to type_info
* make pools available (registry/view/group), review operator| for views
* any_vector for context variables
* make const registry::view thread safe, switch to a view<T...>{registry} model (long term goal)
* weak reference wrapper example with custom storage
* paginate pools
* headless (sparse set only) view
* write documentation for custom storages and views!!
* registry: use a poly object for pools, no more pool_data type.
* make runtime views use opaque storage and therefore return also elements.
* add exclude-only views to combine with packs
* entity-aware observer, add observer functions aside observer class
* deprecate non-owning groups in favor of owning views and view packs, introduce lazy owning views
* pagination doesn't work nicely across boundaries probably, give it a look. RO operations are fine, adding components maybe not.
* snapshot: support for range-based archives

View File

@@ -713,10 +713,7 @@ public:
template<typename... Component>
size_type remove_if_exists(const entity_type entity) {
ENTT_ASSERT(valid(entity), "Invalid entity");
return ([this, entity](auto *cpool) {
return cpool->contains(entity) ? (cpool->erase(entity, this), true) : false;
}(assure<Component>()) + ... + size_type{});
return (assure<Component>()->remove(entity, this) + ... + size_type{});
}
/**
@@ -737,9 +734,7 @@ public:
ENTT_ASSERT(valid(entity), "Invalid entity");
for(auto pos = pools.size(); pos; --pos) {
if(auto &pdata = pools[pos-1]; pdata.pool && pdata.pool->contains(entity)) {
pdata.pool->erase(entity, this);
}
pools[pos-1].pool && pools[pos-1].pool->remove(entity, this);
}
}