Browse Source

entity: deprecate handle::remove_all and registry::remove_all

Michele Caini 4 years ago
parent
commit
e5d4f1bb58

+ 1 - 0
src/entt/entity/handle.hpp

@@ -224,6 +224,7 @@ struct basic_handle {
      * @brief Removes all the components from a handle and makes it orphaned.
      * @brief Removes all the components from a handle and makes it orphaned.
      * @sa basic_registry::remove_all
      * @sa basic_registry::remove_all
      */
      */
+    [[deprecated("No longer supported")]]
     void remove_all() const {
     void remove_all() const {
         static_assert(sizeof...(Type) == 0, "Invalid operation");
         static_assert(sizeof...(Type) == 0, "Invalid operation");
         reg->remove_all(entt);
         reg->remove_all(entt);

+ 1 - 0
src/entt/entity/registry.hpp

@@ -748,6 +748,7 @@ public:
      *
      *
      * @param entity A valid entity identifier.
      * @param entity A valid entity identifier.
      */
      */
+    [[deprecated("Use ::destroy(entity)/::create(entity) instead")]]
     void remove_all(const entity_type entity) {
     void remove_all(const entity_type entity) {
         ENTT_ASSERT(valid(entity), "Invalid entity");
         ENTT_ASSERT(valid(entity), "Invalid entity");
 
 

+ 0 - 14
test/entt/entity/handle.cpp

@@ -186,20 +186,6 @@ TEST(BasicHandle, Component) {
     ASSERT_EQ(nullptr, std::get<1>(handle.try_get<int, char, double>()));
     ASSERT_EQ(nullptr, std::get<1>(handle.try_get<int, char, double>()));
 }
 }
 
 
-TEST(BasicHandle, RemoveAll) {
-    entt::registry registry;
-    const auto entity = registry.create();
-    entt::handle handle{registry, entity};
-
-    ASSERT_EQ(3, handle.emplace<int>(3));
-    ASSERT_EQ('c', handle.emplace_or_replace<char>('c'));
-    ASSERT_TRUE((handle.all_of<int, char>()));
-
-    handle.remove_all();
-
-    ASSERT_FALSE((handle.any_of<int, char>()));
-}
-
 TEST(BasicHandle, FromEntity) {
 TEST(BasicHandle, FromEntity) {
     entt::registry registry;
     entt::registry registry;
     const auto entity = registry.create();
     const auto entity = registry.create();

+ 11 - 5
test/entt/entity/registry.cpp

@@ -593,18 +593,24 @@ TEST(Registry, Each) {
 TEST(Registry, Orphans) {
 TEST(Registry, Orphans) {
     entt::registry registry;
     entt::registry registry;
     entt::registry::size_type tot{};
     entt::registry::size_type tot{};
+    entt::entity entities[3u]{};
 
 
-    registry.emplace<int>(registry.create());
-    registry.create();
-    registry.emplace<int>(registry.create());
+    registry.create(std::begin(entities), std::end(entities));
+    registry.emplace<int>(entities[0u]);
+    registry.emplace<int>(entities[2u]);
 
 
     registry.orphans([&](auto) { ++tot; });
     registry.orphans([&](auto) { ++tot; });
+
     ASSERT_EQ(tot, 1u);
     ASSERT_EQ(tot, 1u);
-    tot = {};
 
 
-    registry.each([&](auto entity) { registry.remove_all(entity); });
+    registry.erase<int>(entities[0u]);
+    registry.erase<int>(entities[2u]);
+
+    tot = {};
     registry.orphans([&](auto) { ++tot; });
     registry.orphans([&](auto) { ++tot; });
+
     ASSERT_EQ(tot, 3u);
     ASSERT_EQ(tot, 3u);
+
     registry.clear();
     registry.clear();
     tot = {};
     tot = {};