diff --git a/src/entt/entity/fwd.hpp b/src/entt/entity/fwd.hpp index 2ea4ea535..14a2f20a8 100644 --- a/src/entt/entity/fwd.hpp +++ b/src/entt/entity/fwd.hpp @@ -108,7 +108,7 @@ using registry = basic_registry; using observer = basic_observer; /*! @brief Alias declaration for the most common use case. */ -using organizer = basic_organizer; +using organizer = basic_organizer; /*! @brief Alias declaration for the most common use case. */ using handle = basic_handle; diff --git a/src/entt/entity/organizer.hpp b/src/entt/entity/organizer.hpp index 069914495..cef17e385 100644 --- a/src/entt/entity/organizer.hpp +++ b/src/entt/entity/organizer.hpp @@ -44,15 +44,15 @@ struct unpack_type { type_list<>>; }; -template -struct unpack_type, type_list> { +template +struct unpack_type, type_list> { using ro = type_list<>; using rw = type_list<>; }; -template -struct unpack_type, type_list> - : unpack_type, type_list> {}; +template +struct unpack_type, type_list> + : unpack_type, type_list> {}; template struct unpack_type, exclude_t>, type_list> { @@ -102,12 +102,12 @@ resource_traits...>, type_list> * goal of the tool. Instead, they are returned to the user in the form of a * graph that allows for safe execution. * - * @tparam Entity A valid entity type (see entt_traits for more details). + * @tparam Registry Basic registry type. */ -template +template class basic_organizer final { - using callback_type = void(const void *, basic_registry &); - using prepare_type = void(basic_registry &); + using callback_type = void(const void *, Registry &); + using prepare_type = void(Registry &); using dependency_type = std::size_t(const bool, const type_info **, const std::size_t); struct vertex_data final { @@ -122,8 +122,8 @@ class basic_organizer final { }; template - [[nodiscard]] static decltype(auto) extract(basic_registry ®) { - if constexpr(std::is_same_v>) { + [[nodiscard]] static decltype(auto) extract(Registry ®) { + if constexpr(std::is_same_v) { return reg; } else if constexpr(internal::is_view_v) { return as_view{reg}; @@ -133,7 +133,7 @@ class basic_organizer final { } template - [[nodiscard]] static auto to_args(basic_registry ®, type_list) { + [[nodiscard]] static auto to_args(Registry ®, type_list) { return std::tuple(reg))...>(extract(reg)...); } @@ -151,7 +151,7 @@ class basic_organizer final { template void track_dependencies(std::size_t index, const bool requires_registry, type_list, type_list) { - dependencies[type_hash>::value()].emplace_back(index, requires_registry || (sizeof...(RO) + sizeof...(RW) == 0u)); + dependencies[type_hash::value()].emplace_back(index, requires_registry || (sizeof...(RO) + sizeof...(RW) == 0u)); (dependencies[type_hash::value()].emplace_back(index, false), ...); (dependencies[type_hash::value()].emplace_back(index, true), ...); } @@ -227,8 +227,10 @@ class basic_organizer final { } public: + /*! Basic registry type. */ + using registry_type = Registry; /*! @brief Underlying entity identifier. */ - using entity_type = Entity; + using entity_type = typename registry_type::entity_type; /*! @brief Unsigned integer type. */ using size_type = std::size_t; /*! @brief Raw task function type. */ @@ -338,7 +340,7 @@ public: * are properly instantiated before using them. * @param reg A valid registry. */ - void prepare(basic_registry ®) const { + void prepare(registry_type ®) const { node.prepare ? node.prepare(reg) : void(); } @@ -357,9 +359,9 @@ public: template void emplace(const char *name = nullptr) { using resource_type = decltype(internal::free_function_to_resource_traits(Candidate)); - constexpr auto requires_registry = type_list_contains_v>; + constexpr auto requires_registry = type_list_contains_v; - callback_type *callback = +[](const void *, basic_registry ®) { + callback_type *callback = +[](const void *, registry_type ®) { std::apply(Candidate, to_args(reg, typename resource_type::args{})); }; @@ -370,7 +372,7 @@ public: nullptr, callback, +[](const bool rw, const type_info **buffer, const std::size_t length) { return rw ? fill_dependencies(typename resource_type::rw{}, buffer, length) : fill_dependencies(typename resource_type::ro{}, buffer, length); }, - +[](basic_registry ®) { void(to_args(reg, typename resource_type::args{})); }, + +[](registry_type ®) { void(to_args(reg, typename resource_type::args{})); }, &type_id>()}; track_dependencies(vertices.size(), requires_registry, typename resource_type::ro{}, typename resource_type::rw{}); @@ -389,9 +391,9 @@ public: template void emplace(Type &value_or_instance, const char *name = nullptr) { using resource_type = decltype(internal::constrained_function_to_resource_traits(Candidate)); - constexpr auto requires_registry = type_list_contains_v>; + constexpr auto requires_registry = type_list_contains_v; - callback_type *callback = +[](const void *payload, basic_registry ®) { + callback_type *callback = +[](const void *payload, registry_type ®) { Type *curr = static_cast(const_cast *>(payload)); std::apply(Candidate, std::tuple_cat(std::forward_as_tuple(*curr), to_args(reg, typename resource_type::args{}))); }; @@ -403,7 +405,7 @@ public: &value_or_instance, callback, +[](const bool rw, const type_info **buffer, const std::size_t length) { return rw ? fill_dependencies(typename resource_type::rw{}, buffer, length) : fill_dependencies(typename resource_type::ro{}, buffer, length); }, - +[](basic_registry ®) { void(to_args(reg, typename resource_type::args{})); }, + +[](registry_type ®) { void(to_args(reg, typename resource_type::args{})); }, &type_id>()}; track_dependencies(vertices.size(), requires_registry, typename resource_type::ro{}, typename resource_type::rw{});