From 4f0baa80d791885d975dfe8a5f710b6b78bc68b0 Mon Sep 17 00:00:00 2001 From: Michele Caini Date: Wed, 14 Oct 2020 19:45:54 +0200 Subject: [PATCH] *: object_type -> value_type (breaking changes) --- src/entt/entity/group.hpp | 12 ++++++------ src/entt/entity/pool.hpp | 10 +++++----- src/entt/entity/storage.hpp | 36 ++++++++++++++++++------------------ src/entt/entity/view.hpp | 4 ++-- 4 files changed, 31 insertions(+), 31 deletions(-) diff --git a/src/entt/entity/group.hpp b/src/entt/entity/group.hpp index 5b78f76f9..2f1b34787 100644 --- a/src/entt/entity/group.hpp +++ b/src/entt/entity/group.hpp @@ -134,7 +134,7 @@ class basic_group, get_t> { [[nodiscard]] iterator begin() const ENTT_NOEXCEPT { return proxy_iterator{handler->begin(), std::tuple_cat([](auto *cpool) { - if constexpr(is_eto_eligible_v::object_type>) { + if constexpr(is_eto_eligible_v::value_type>) { return std::make_tuple(); } else { return std::make_tuple(cpool); @@ -144,7 +144,7 @@ class basic_group, get_t> { [[nodiscard]] iterator end() const ENTT_NOEXCEPT { return proxy_iterator{handler->end(), std::tuple_cat([](auto *cpool) { - if constexpr(is_eto_eligible_v::object_type>) { + if constexpr(is_eto_eligible_v::value_type>) { return std::make_tuple(); } else { return std::make_tuple(cpool); @@ -683,14 +683,14 @@ class basic_group, get_t, Owned...> { return proxy_iterator{ std::get<0>(pools)->basic_sparse_set::end() - *length, std::tuple_cat([length = *length](auto *cpool) { - if constexpr(is_eto_eligible_v::object_type>) { + if constexpr(is_eto_eligible_v::value_type>) { return std::make_tuple(); } else { return std::make_tuple(cpool->end() - length); } }(std::get *>(pools))...), std::tuple_cat([](auto *cpool) { - if constexpr(is_eto_eligible_v::object_type>) { + if constexpr(is_eto_eligible_v::value_type>) { return std::make_tuple(); } else { return std::make_tuple(cpool); @@ -703,14 +703,14 @@ class basic_group, get_t, Owned...> { return proxy_iterator{ std::get<0>(pools)->basic_sparse_set::end(), std::tuple_cat([](auto *cpool) { - if constexpr(is_eto_eligible_v::object_type>) { + if constexpr(is_eto_eligible_v::value_type>) { return std::make_tuple(); } else { return std::make_tuple(cpool->end()); } }(std::get *>(pools))...), std::tuple_cat([](auto *cpool) { - if constexpr(is_eto_eligible_v::object_type>) { + if constexpr(is_eto_eligible_v::value_type>) { return std::make_tuple(); } else { return std::make_tuple(cpool); diff --git a/src/entt/entity/pool.hpp b/src/entt/entity/pool.hpp index 5c2221695..3b8150db9 100644 --- a/src/entt/entity/pool.hpp +++ b/src/entt/entity/pool.hpp @@ -25,7 +25,7 @@ struct default_pool final: basic_storage { static_assert(std::is_same_v>, "Invalid object type"); /*! @brief Type of the objects associated with the entities. */ - using object_type = Type; + using value_type = Type; /*! @brief Underlying entity identifier. */ using entity_type = Entity; @@ -118,7 +118,7 @@ struct default_pool final: basic_storage { basic_storage::emplace(entity, std::forward(args)...); construction.publish(owner, entity); - if constexpr(!is_eto_eligible_v) { + if constexpr(!is_eto_eligible_v) { return this->get(entity); } } @@ -139,7 +139,7 @@ struct default_pool final: basic_storage { */ template void insert(basic_registry &owner, It first, It last, Args &&... args) { - basic_storage::insert(first, last, std::forward(args)...); + basic_storage::insert(first, last, std::forward(args)...); if(!construction.empty()) { for(; first != last; ++first) { @@ -162,7 +162,7 @@ struct default_pool final: basic_storage { */ void erase(basic_registry &owner, const entity_type entity) { destruction.publish(owner, entity); - basic_storage::erase(entity); + basic_storage::erase(entity); } /** @@ -214,7 +214,7 @@ struct default_pool final: basic_storage { */ template decltype(auto) patch(basic_registry &owner, const entity_type entity, [[maybe_unused]] Func &&... func) { - if constexpr(is_eto_eligible_v) { + if constexpr(is_eto_eligible_v) { update.publish(owner, entity); } else { (std::forward(func)(this->get(entity)), ...); diff --git a/src/entt/entity/storage.hpp b/src/entt/entity/storage.hpp index 898f8ee25..2fa2c2697 100644 --- a/src/entt/entity/storage.hpp +++ b/src/entt/entity/storage.hpp @@ -158,7 +158,7 @@ class basic_storage: public basic_sparse_set { public: /*! @brief Type of the objects associated with the entities. */ - using object_type = Type; + using value_type = Type; /*! @brief Underlying entity identifier. */ using entity_type = Entity; /*! @brief Unsigned integer type. */ @@ -203,13 +203,13 @@ public: * * @return A pointer to the array of objects. */ - [[nodiscard]] const object_type * raw() const ENTT_NOEXCEPT { + [[nodiscard]] const value_type * raw() const ENTT_NOEXCEPT { return instances.data(); } /*! @copydoc raw */ - [[nodiscard]] object_type * raw() ENTT_NOEXCEPT { - return const_cast(std::as_const(*this).raw()); + [[nodiscard]] value_type * raw() ENTT_NOEXCEPT { + return const_cast(std::as_const(*this).raw()); } /** @@ -319,13 +319,13 @@ public: * @param entt A valid entity identifier. * @return The object associated with the entity. */ - [[nodiscard]] const object_type & get(const entity_type entt) const { + [[nodiscard]] const value_type & get(const entity_type entt) const { return instances[underlying_type::index(entt)]; } /*! @copydoc get */ - [[nodiscard]] object_type & get(const entity_type entt) { - return const_cast(std::as_const(*this).get(entt)); + [[nodiscard]] value_type & get(const entity_type entt) { + return const_cast(std::as_const(*this).get(entt)); } /** @@ -333,13 +333,13 @@ public: * @param entt A valid entity identifier. * @return The object associated with the entity, if any. */ - [[nodiscard]] const object_type * try_get(const entity_type entt) const { + [[nodiscard]] const value_type * try_get(const entity_type entt) const { return underlying_type::contains(entt) ? (instances.data() + underlying_type::index(entt)) : nullptr; } /*! @copydoc try_get */ - [[nodiscard]] object_type * try_get(const entity_type entt) { - return const_cast(std::as_const(*this).try_get(entt)); + [[nodiscard]] value_type * try_get(const entity_type entt) { + return const_cast(std::as_const(*this).try_get(entt)); } /** @@ -361,8 +361,8 @@ public: * @return A reference to the newly created object. */ template - object_type & emplace(const entity_type entt, Args &&... args) { - if constexpr(std::is_aggregate_v) { + value_type & emplace(const entity_type entt, Args &&... args) { + if constexpr(std::is_aggregate_v) { instances.push_back(Type{std::forward(args)...}); } else { instances.emplace_back(std::forward(args)...); @@ -389,7 +389,7 @@ public: * @param value An instance of the object to construct. */ template - void insert(It first, It last, const object_type &value = {}) { + void insert(It first, It last, const value_type &value = {}) { instances.insert(instances.end(), std::distance(first, last), value); // entities go after components in case constructors throw underlying_type::insert(first, last); @@ -502,7 +502,7 @@ public: std::swap(instances[underlying_type::index(lhs)], instances[underlying_type::index(rhs)]); }; - if constexpr(std::is_invocable_v) { + if constexpr(std::is_invocable_v) { underlying_type::arrange(from, to, std::move(apply), [this, compare = std::move(compare)](const auto lhs, const auto rhs) { return compare(std::as_const(instances[underlying_type::index(lhs)]), std::as_const(instances[underlying_type::index(rhs)])); }, std::move(algo), std::forward(args)...); @@ -518,7 +518,7 @@ public: } private: - std::vector instances; + std::vector instances; }; @@ -529,7 +529,7 @@ class basic_storage>>: pu public: /*! @brief Type of the objects associated with the entities. */ - using object_type = Type; + using value_type = Type; /*! @brief Underlying entity identifier. */ using entity_type = Entity; /*! @brief Unsigned integer type. */ @@ -550,7 +550,7 @@ public: */ template void emplace(const entity_type entt, Args &&... args) { - [[maybe_unused]] object_type instance{std::forward(args)...}; + [[maybe_unused]] value_type instance{std::forward(args)...}; underlying_type::emplace(entt); } @@ -568,7 +568,7 @@ public: * @param last An iterator past the last element of the range of entities. */ template - void insert(It first, It last, const object_type & = {}) { + void insert(It first, It last, const value_type & = {}) { underlying_type::insert(first, last); } }; diff --git a/src/entt/entity/view.hpp b/src/entt/entity/view.hpp index 8d0658f14..20a7f8ad3 100644 --- a/src/entt/entity/view.hpp +++ b/src/entt/entity/view.hpp @@ -213,7 +213,7 @@ class basic_view, Component...> { [[nodiscard]] iterator begin() const ENTT_NOEXCEPT { return proxy_iterator{first, std::tuple_cat([](auto *cpool) { - if constexpr(is_eto_eligible_v::object_type>) { + if constexpr(is_eto_eligible_v::value_type>) { return std::make_tuple(); } else { return std::make_tuple(cpool); @@ -223,7 +223,7 @@ class basic_view, Component...> { [[nodiscard]] iterator end() const ENTT_NOEXCEPT { return proxy_iterator{last, std::tuple_cat([](auto *cpool) { - if constexpr(is_eto_eligible_v::object_type>) { + if constexpr(is_eto_eligible_v::value_type>) { return std::make_tuple(); } else { return std::make_tuple(cpool);