registry::clone supports type list now (close #165)
This commit is contained in:
2
TODO
2
TODO
@@ -26,4 +26,4 @@
|
||||
* hashed string: static (constexpr) member function to_value for direct hashing
|
||||
* entity: simplify get functions so as to generate less symbols for multiple components
|
||||
* events on replace, so that one can track updated components? indagate impact
|
||||
* add merge functionality for type list
|
||||
* allow to bind values to delegate on connect with free functions (sbo + check size on costruction to guarantee a zero allocation abstraction)
|
||||
|
||||
@@ -10,6 +10,30 @@ template<typename...>
|
||||
struct type_list {};
|
||||
|
||||
|
||||
/**
|
||||
* @brief Concatenates multiple type lists into one.
|
||||
* @tparam Type List of types.
|
||||
* @return The given type list.
|
||||
*/
|
||||
template<typename... Type>
|
||||
constexpr auto type_list_cat(type_list<Type...> = type_list<>{}) {
|
||||
return type_list<Type...>{};
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief Concatenates multiple type lists into one.
|
||||
* @tparam Type List of types.
|
||||
* @tparam Other List of types.
|
||||
* @tparam List Type list instances.
|
||||
* @return A type list that is the concatenation of the given type lists.
|
||||
*/
|
||||
template<typename... Type, typename... Other, typename... List>
|
||||
constexpr auto type_list_cat(type_list<Type...>, type_list<Other...>, List...) {
|
||||
return type_list_cat(type_list<Type..., Other...>{}, List{}...);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1161,7 +1161,7 @@ public:
|
||||
* @return A newly created persistent view.
|
||||
*/
|
||||
template<typename... Component, typename... Exclude>
|
||||
entt::persistent_view<Entity, Component...> persistent_view(type_list<Exclude...> = type_list<>{}) {
|
||||
entt::persistent_view<Entity, Component...> persistent_view(type_list<Exclude...> = {}) {
|
||||
static_assert(sizeof...(Component));
|
||||
using handler_type = handler_pool<type_list<Component...>, type_list<Exclude...>>;
|
||||
const auto htype = handler_family::type<Component...>;
|
||||
@@ -1196,7 +1196,7 @@ public:
|
||||
|
||||
/*! @copydoc persistent_view */
|
||||
template<typename... Component, typename... Exclude>
|
||||
inline entt::persistent_view<Entity, Component...> persistent_view(type_list<Exclude...> = type_list<>{}) const {
|
||||
inline entt::persistent_view<Entity, Component...> persistent_view(type_list<Exclude...> = {}) const {
|
||||
static_assert(std::conjunction_v<std::is_const<Component>...>);
|
||||
return const_cast<registry *>(this)->persistent_view<Component...>(type_list<Exclude...>{});
|
||||
}
|
||||
@@ -1294,7 +1294,7 @@ public:
|
||||
* @param reg A valid reference to a source registry.
|
||||
*/
|
||||
template<typename... Component>
|
||||
void clone(const registry ®) {
|
||||
void clone(const registry ®, type_list<Component...> = {}) {
|
||||
*this = {};
|
||||
|
||||
(assure<Component>(), ...);
|
||||
|
||||
@@ -63,6 +63,7 @@ SETUP_AND_ADD_TEST(family entt/core/family.cpp)
|
||||
SETUP_AND_ADD_TEST(hashed_string entt/core/hashed_string.cpp)
|
||||
SETUP_AND_ADD_TEST(ident entt/core/ident.cpp)
|
||||
SETUP_AND_ADD_TEST(monostate entt/core/monostate.cpp)
|
||||
SETUP_AND_ADD_TEST(type_traits entt/core/type_traits.cpp)
|
||||
SETUP_AND_ADD_TEST(utility entt/core/utility.cpp)
|
||||
|
||||
# Test entity
|
||||
|
||||
22
test/entt/core/type_traits.cpp
Normal file
22
test/entt/core/type_traits.cpp
Normal file
@@ -0,0 +1,22 @@
|
||||
#include <type_traits>
|
||||
#include <gtest/gtest.h>
|
||||
#include <entt/core/type_traits.hpp>
|
||||
|
||||
TEST(TypeTraits, TypeList) {
|
||||
static_assert(std::is_same_v<
|
||||
decltype(entt::type_list_cat()),
|
||||
entt::type_list<>
|
||||
>);
|
||||
|
||||
static_assert(std::is_same_v<
|
||||
decltype(entt::type_list_cat(entt::type_list<int>{})),
|
||||
entt::type_list<int>
|
||||
>);
|
||||
|
||||
static_assert(std::is_same_v<
|
||||
decltype(entt::type_list_cat(entt::type_list<int, char>{}, entt::type_list<>{}, entt::type_list<double, void>{})),
|
||||
entt::type_list<int, char, double, void>
|
||||
>);
|
||||
|
||||
SUCCEED();
|
||||
}
|
||||
@@ -127,13 +127,11 @@ class duktape_registry {
|
||||
|
||||
struct func_map {
|
||||
using func_type = duk_ret_t(*)(duk_context *, entt::registry<> &);
|
||||
using test_type = bool(entt::registry<>:: *)(entt::registry<>::entity_type) const;
|
||||
|
||||
func_type set;
|
||||
func_type unset;
|
||||
func_type has;
|
||||
func_type get;
|
||||
test_type test;
|
||||
};
|
||||
|
||||
template<typename... Comp>
|
||||
@@ -142,8 +140,7 @@ class duktape_registry {
|
||||
&::set<Comp>,
|
||||
&::unset<Comp>,
|
||||
&::has<Comp>,
|
||||
&::get<Comp>,
|
||||
&entt::registry<>::has<Comp>
|
||||
&::get<Comp>
|
||||
}), ...);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user