From e5d4f1bb589043f625731b8ba321ff5d0c499049 Mon Sep 17 00:00:00 2001 From: Michele Caini Date: Thu, 6 May 2021 14:52:33 +0200 Subject: [PATCH] entity: deprecate handle::remove_all and registry::remove_all --- src/entt/entity/handle.hpp | 1 + src/entt/entity/registry.hpp | 1 + test/entt/entity/handle.cpp | 14 -------------- test/entt/entity/registry.cpp | 16 +++++++++++----- 4 files changed, 13 insertions(+), 19 deletions(-) diff --git a/src/entt/entity/handle.hpp b/src/entt/entity/handle.hpp index 568948de1..036e06733 100644 --- a/src/entt/entity/handle.hpp +++ b/src/entt/entity/handle.hpp @@ -224,6 +224,7 @@ struct basic_handle { * @brief Removes all the components from a handle and makes it orphaned. * @sa basic_registry::remove_all */ + [[deprecated("No longer supported")]] void remove_all() const { static_assert(sizeof...(Type) == 0, "Invalid operation"); reg->remove_all(entt); diff --git a/src/entt/entity/registry.hpp b/src/entt/entity/registry.hpp index 59ac728ff..c757c2378 100644 --- a/src/entt/entity/registry.hpp +++ b/src/entt/entity/registry.hpp @@ -748,6 +748,7 @@ public: * * @param entity A valid entity identifier. */ + [[deprecated("Use ::destroy(entity)/::create(entity) instead")]] void remove_all(const entity_type entity) { ENTT_ASSERT(valid(entity), "Invalid entity"); diff --git a/test/entt/entity/handle.cpp b/test/entt/entity/handle.cpp index 25f6da6bb..3b5093bbd 100644 --- a/test/entt/entity/handle.cpp +++ b/test/entt/entity/handle.cpp @@ -186,20 +186,6 @@ TEST(BasicHandle, Component) { ASSERT_EQ(nullptr, std::get<1>(handle.try_get())); } -TEST(BasicHandle, RemoveAll) { - entt::registry registry; - const auto entity = registry.create(); - entt::handle handle{registry, entity}; - - ASSERT_EQ(3, handle.emplace(3)); - ASSERT_EQ('c', handle.emplace_or_replace('c')); - ASSERT_TRUE((handle.all_of())); - - handle.remove_all(); - - ASSERT_FALSE((handle.any_of())); -} - TEST(BasicHandle, FromEntity) { entt::registry registry; const auto entity = registry.create(); diff --git a/test/entt/entity/registry.cpp b/test/entt/entity/registry.cpp index c8d790522..06e02acdd 100644 --- a/test/entt/entity/registry.cpp +++ b/test/entt/entity/registry.cpp @@ -593,18 +593,24 @@ TEST(Registry, Each) { TEST(Registry, Orphans) { entt::registry registry; entt::registry::size_type tot{}; + entt::entity entities[3u]{}; - registry.emplace(registry.create()); - registry.create(); - registry.emplace(registry.create()); + registry.create(std::begin(entities), std::end(entities)); + registry.emplace(entities[0u]); + registry.emplace(entities[2u]); registry.orphans([&](auto) { ++tot; }); + ASSERT_EQ(tot, 1u); - tot = {}; - registry.each([&](auto entity) { registry.remove_all(entity); }); + registry.erase(entities[0u]); + registry.erase(entities[2u]); + + tot = {}; registry.orphans([&](auto) { ++tot; }); + ASSERT_EQ(tot, 3u); + registry.clear(); tot = {};