Răsfoiți Sursa

entity/*: renaming things to make them clear

Michele Caini 3 ani în urmă
părinte
comite
49c7b2f8f4

+ 4 - 4
src/entt/entity/handle.hpp

@@ -15,13 +15,13 @@ namespace entt {
  *
  * Tiny wrapper around a registry and an entity.
  *
- * @tparam Type Basic registry type.
+ * @tparam Registry Basic registry type.
  * @tparam Scope Types to which to restrict the scope of a handle.
  */
-template<typename Type, typename... Scope>
+template<typename Registry, typename... Scope>
 struct basic_handle {
     /*! @brief Type of registry accepted by the handle. */
-    using registry_type = Type;
+    using registry_type = Registry;
     /*! @brief Underlying entity identifier. */
     using entity_type = typename registry_type::entity_type;
     /*! @brief Underlying version type. */
@@ -52,7 +52,7 @@ struct basic_handle {
      */
     template<typename Other, typename... Args>
     operator basic_handle<Other, Args...>() const noexcept {
-        static_assert(std::is_same_v<Other, Type> || std::is_same_v<std::remove_const_t<Other>, Type>, "Invalid conversion between different handles");
+        static_assert(std::is_same_v<Other, Registry> || std::is_same_v<std::remove_const_t<Other>, Registry>, "Invalid conversion between different handles");
         static_assert((sizeof...(Scope) == 0 || ((sizeof...(Args) != 0 && sizeof...(Args) <= sizeof...(Scope)) && ... && (type_list_contains_v<type_list<Scope...>, Args>))), "Invalid conversion between different handles");
 
         return reg ? basic_handle<Other, Args...>{*reg, entt} : basic_handle<Other, Args...>{};

+ 16 - 16
src/entt/entity/helper.hpp

@@ -13,14 +13,14 @@ namespace entt {
 
 /**
  * @brief Converts a registry to a view.
- * @tparam Type Basic registry type.
+ * @tparam Registry Basic registry type.
  */
-template<typename Type>
+template<typename Registry>
 struct as_view {
     /*! @brief Type of registry to convert. */
-    using registry_type = Type;
+    using registry_type = Registry;
     /*! @brief Underlying entity identifier. */
-    using entity_type = std::remove_const_t<typename Type::entity_type>;
+    using entity_type = std::remove_const_t<typename registry_type::entity_type>;
 
     /**
      * @brief Constructs a converter for a given registry.
@@ -46,14 +46,14 @@ private:
 
 /**
  * @brief Converts a registry to a group.
- * @tparam Type Basic registry type.
+ * @tparam Registry Basic registry type.
  */
-template<typename Type>
+template<typename Registry>
 struct as_group {
     /*! @brief Type of registry to convert. */
-    using registry_type = Type;
+    using registry_type = Registry;
     /*! @brief Underlying entity identifier. */
-    using entity_type = std::remove_const_t<typename Type::entity_type>;
+    using entity_type = std::remove_const_t<typename registry_type::entity_type>;
 
     /**
      * @brief Constructs a converter for a given registry.
@@ -85,14 +85,14 @@ private:
 /**
  * @brief Helper to create a listener that directly invokes a member function.
  * @tparam Member Member function to invoke on a component of the given type.
- * @tparam Type Basic registry type.
+ * @tparam Registry Basic registry type.
  * @param reg A registry that contains the given entity and its components.
  * @param entt Entity from which to get the component.
  */
-template<auto Member, typename Type = registry>
-void invoke(Type &reg, const typename Type::entity_type entt) {
+template<auto Member, typename Registry = registry>
+void invoke(Registry &reg, const typename Registry::entity_type entt) {
     static_assert(std::is_member_function_pointer_v<decltype(Member)>, "Invalid pointer to non-static member function");
-    delegate<void(Type &, const typename Type::entity_type)> func;
+    delegate<void(Registry &, const typename Registry::entity_type)> func;
     func.template connect<Member>(reg.template get<member_class_t<decltype(Member)>>(entt));
     func(reg, entt);
 }
@@ -104,16 +104,16 @@ void invoke(Type &reg, const typename Type::entity_type entt) {
  * Currently, this function only works correctly with the default pool as it
  * makes assumptions about how the components are laid out.
  *
- * @tparam Type Basic registry type.
+ * @tparam Registry Basic registry type.
  * @tparam Component Type of component.
  * @param reg A registry that contains the given entity and its components.
  * @param instance A valid component instance.
  * @return The entity associated with the given component.
  */
-template<typename Type, typename Component>
-typename Type::entity_type to_entity(const Type &reg, const Component &instance) {
+template<typename Registry, typename Component>
+typename Registry::entity_type to_entity(const Registry &reg, const Component &instance) {
     const auto &storage = reg.template storage<Component>();
-    const typename Type::base_type &base = storage;
+    const typename Registry::base_type &base = storage;
     const auto *addr = std::addressof(instance);
 
     for(auto it = base.rbegin(), last = base.rend(); it < last; it += component_traits<Component>::page_size) {

+ 13 - 13
src/entt/entity/observer.hpp

@@ -155,9 +155,9 @@ inline constexpr basic_collector<> collector{};
  * from the registry before being destroyed to avoid crashes due to dangling
  * pointers.
  *
- * @tparam Type Basic registry type.
+ * @tparam Registry Basic registry type.
  */
-template<typename Type>
+template<typename Registry>
 class basic_observer {
     using payload_type = std::uint32_t;
 
@@ -167,7 +167,7 @@ class basic_observer {
     template<typename... Reject, typename... Require, typename AnyOf>
     struct matcher_handler<matcher<type_list<Reject...>, type_list<Require...>, AnyOf>> {
         template<std::size_t Index>
-        static void maybe_valid_if(basic_observer &obs, Type &reg, const typename Type::entity_type entt) {
+        static void maybe_valid_if(basic_observer &obs, Registry &reg, const typename Registry::entity_type entt) {
             if(reg.template all_of<Require...>(entt) && !reg.template any_of<Reject...>(entt)) {
                 if(!obs.storage.contains(entt)) {
                     obs.storage.emplace(entt);
@@ -178,21 +178,21 @@ class basic_observer {
         }
 
         template<std::size_t Index>
-        static void discard_if(basic_observer &obs, Type &, const typename Type::entity_type entt) {
+        static void discard_if(basic_observer &obs, Registry &, const typename Registry::entity_type entt) {
             if(obs.storage.contains(entt) && !(obs.storage.get(entt) &= (~(1 << Index)))) {
                 obs.storage.erase(entt);
             }
         }
 
         template<std::size_t Index>
-        static void connect(basic_observer &obs, Type &reg) {
+        static void connect(basic_observer &obs, Registry &reg) {
             (reg.template on_destroy<Require>().template connect<&discard_if<Index>>(obs), ...);
             (reg.template on_construct<Reject>().template connect<&discard_if<Index>>(obs), ...);
             reg.template on_update<AnyOf>().template connect<&maybe_valid_if<Index>>(obs);
             reg.template on_destroy<AnyOf>().template connect<&discard_if<Index>>(obs);
         }
 
-        static void disconnect(basic_observer &obs, Type &reg) {
+        static void disconnect(basic_observer &obs, Registry &reg) {
             (reg.template on_destroy<Require>().disconnect(obs), ...);
             (reg.template on_construct<Reject>().disconnect(obs), ...);
             reg.template on_update<AnyOf>().disconnect(obs);
@@ -203,7 +203,7 @@ class basic_observer {
     template<typename... Reject, typename... Require, typename... NoneOf, typename... AllOf>
     struct matcher_handler<matcher<type_list<Reject...>, type_list<Require...>, type_list<NoneOf...>, AllOf...>> {
         template<std::size_t Index, typename... Ignore>
-        static void maybe_valid_if(basic_observer &obs, Type &reg, const typename Type::entity_type entt) {
+        static void maybe_valid_if(basic_observer &obs, Registry &reg, const typename Registry::entity_type entt) {
             auto condition = [&reg, entt]() {
                 if constexpr(sizeof...(Ignore) == 0) {
                     return reg.template all_of<AllOf..., Require...>(entt) && !reg.template any_of<NoneOf..., Reject...>(entt);
@@ -222,14 +222,14 @@ class basic_observer {
         }
 
         template<std::size_t Index>
-        static void discard_if(basic_observer &obs, Type &, const typename Type::entity_type entt) {
+        static void discard_if(basic_observer &obs, Registry &, const typename Registry::entity_type entt) {
             if(obs.storage.contains(entt) && !(obs.storage.get(entt) &= (~(1 << Index)))) {
                 obs.storage.erase(entt);
             }
         }
 
         template<std::size_t Index>
-        static void connect(basic_observer &obs, Type &reg) {
+        static void connect(basic_observer &obs, Registry &reg) {
             (reg.template on_destroy<Require>().template connect<&discard_if<Index>>(obs), ...);
             (reg.template on_construct<Reject>().template connect<&discard_if<Index>>(obs), ...);
             (reg.template on_construct<AllOf>().template connect<&maybe_valid_if<Index>>(obs), ...);
@@ -238,7 +238,7 @@ class basic_observer {
             (reg.template on_construct<NoneOf>().template connect<&discard_if<Index>>(obs), ...);
         }
 
-        static void disconnect(basic_observer &obs, Type &reg) {
+        static void disconnect(basic_observer &obs, Registry &reg) {
             (reg.template on_destroy<Require>().disconnect(obs), ...);
             (reg.template on_construct<Reject>().disconnect(obs), ...);
             (reg.template on_construct<AllOf>().disconnect(obs), ...);
@@ -249,12 +249,12 @@ class basic_observer {
     };
 
     template<typename... Matcher>
-    static void disconnect(Type &reg, basic_observer &obs) {
+    static void disconnect(Registry &reg, basic_observer &obs) {
         (matcher_handler<Matcher>::disconnect(obs, reg), ...);
     }
 
     template<typename... Matcher, std::size_t... Index>
-    void connect(Type &reg, std::index_sequence<Index...>) {
+    void connect(Registry &reg, std::index_sequence<Index...>) {
         static_assert(sizeof...(Matcher) < std::numeric_limits<payload_type>::digits, "Too many matchers");
         (matcher_handler<Matcher>::template connect<Index>(*this, reg), ...);
         release.template connect<&basic_observer::disconnect<Matcher...>>(reg);
@@ -262,7 +262,7 @@ class basic_observer {
 
 public:
     /*! Basic registry type. */
-    using registry_type = Type;
+    using registry_type = Registry;
     /*! @brief Underlying entity identifier. */
     using entity_type = typename registry_type::entity_type;
     /*! @brief Unsigned integer type. */

+ 17 - 17
src/entt/entity/snapshot.hpp

@@ -26,11 +26,11 @@ namespace entt {
  * This type can be used in both cases if provided with a correctly configured
  * output archive.
  *
- * @tparam Type Basic registry type.
+ * @tparam Registry Basic registry type.
  */
-template<typename Type>
+template<typename Registry>
 class basic_snapshot {
-    using entity_traits = entt_traits<typename Type::entity_type>;
+    using entity_traits = entt_traits<typename Registry::entity_type>;
 
     template<typename Component, typename Archive, typename It>
     void get(Archive &archive, std::size_t sz, It first, It last) const {
@@ -61,9 +61,9 @@ class basic_snapshot {
 
 public:
     /*! Basic registry type. */
-    using registry_type = Type;
+    using registry_type = Registry;
     /*! @brief Underlying entity identifier. */
-    using entity_type = typename Type::entity_type;
+    using entity_type = typename registry_type::entity_type;
 
     /**
      * @brief Constructs an instance that is bound to a given registry.
@@ -157,11 +157,11 @@ private:
  * originally had.<br/>
  * An example of use is the implementation of a save/restore utility.
  *
- * @tparam Type Basic registry type.
+ * @tparam Registry Basic registry type.
  */
-template<typename Type>
+template<typename Registry>
 class basic_snapshot_loader {
-    using entity_traits = entt_traits<typename Type::entity_type>;
+    using entity_traits = entt_traits<typename Registry::entity_type>;
 
     template<typename Component, typename Archive>
     void assign(Archive &archive) const {
@@ -191,9 +191,9 @@ class basic_snapshot_loader {
 
 public:
     /*! Basic registry type. */
-    using registry_type = Type;
+    using registry_type = Registry;
     /*! @brief Underlying entity identifier. */
-    using entity_type = typename Type::entity_type;
+    using entity_type = typename registry_type::entity_type;
 
     /**
      * @brief Constructs an instance that is bound to a given registry.
@@ -294,13 +294,13 @@ private:
  * the requirement of transferring somehow parts of the representation side to
  * side.
  *
- * @tparam Type Basic registry type.
+ * @tparam Registry Basic registry type.
  */
-template<typename Type>
+template<typename Registry>
 class basic_continuous_loader {
-    using entity_traits = entt_traits<typename Type::entity_type>;
+    using entity_traits = entt_traits<typename Registry::entity_type>;
 
-    void destroy(typename Type::entity_type entt) {
+    void destroy(typename Registry::entity_type entt) {
         if(const auto it = remloc.find(entt); it == remloc.cend()) {
             const auto local = reg->create();
             remloc.emplace(entt, std::make_pair(local, true));
@@ -308,7 +308,7 @@ class basic_continuous_loader {
         }
     }
 
-    void restore(typename Type::entity_type entt) {
+    void restore(typename Registry::entity_type entt) {
         const auto it = remloc.find(entt);
 
         if(it == remloc.cend()) {
@@ -407,9 +407,9 @@ class basic_continuous_loader {
 
 public:
     /*! Basic registry type. */
-    using registry_type = Type;
+    using registry_type = Registry;
     /*! @brief Underlying entity identifier. */
-    using entity_type = typename Type::entity_type;
+    using entity_type = typename registry_type::entity_type;
 
     /**
      * @brief Constructs an instance that is bound to a given registry.