mixin: sigh_storage_mixin -> sigh_mixin

This commit is contained in:
Michele Caini
2022-12-13 10:53:07 +01:00
parent fe3edf2c83
commit 1d4d99d090
5 changed files with 42 additions and 42 deletions

View File

@@ -21,7 +21,7 @@ template<typename Type, typename = entity, typename = std::allocator<Type>, type
class basic_storage;
template<typename Type>
class sigh_storage_mixin;
class sigh_mixin;
/**
* @brief Provides a common way to define storage types.
@@ -32,7 +32,7 @@ class sigh_storage_mixin;
template<typename Type, typename Entity = entity, typename Allocator = std::allocator<std::remove_const_t<Type>>, typename = void>
struct storage_type {
/*! @brief Type-to-storage conversion result. */
using type = sigh_storage_mixin<basic_storage<Type, Entity, Allocator>>;
using type = sigh_mixin<basic_storage<Type, Entity, Allocator>>;
};
/*! @copydoc storage_type */

View File

@@ -23,7 +23,7 @@ namespace entt {
* @tparam Type The type of the underlying storage.
*/
template<typename Type>
class sigh_storage_mixin final: public Type {
class sigh_mixin final: public Type {
using basic_registry_type = basic_registry<typename Type::entity_type, typename Type::base_type::allocator_type>;
using sigh_type = sigh<void(basic_registry_type &, const typename Type::entity_type), typename Type::allocator_type>;
using basic_iterator = typename Type::basic_iterator;
@@ -55,14 +55,14 @@ public:
using registry_type = basic_registry_type;
/*! @brief Default constructor. */
sigh_storage_mixin()
: sigh_storage_mixin{allocator_type{}} {}
sigh_mixin()
: sigh_mixin{allocator_type{}} {}
/**
* @brief Constructs an empty storage with a given allocator.
* @param allocator The allocator to use.
*/
explicit sigh_storage_mixin(const allocator_type &allocator)
explicit sigh_mixin(const allocator_type &allocator)
: Type{allocator},
owner{},
construction{allocator},
@@ -73,7 +73,7 @@ public:
* @brief Move constructor.
* @param other The instance to move from.
*/
sigh_storage_mixin(sigh_storage_mixin &&other) noexcept
sigh_mixin(sigh_mixin &&other) noexcept
: Type{std::move(other)},
owner{other.owner},
construction{std::move(other.construction)},
@@ -85,7 +85,7 @@ public:
* @param other The instance to move from.
* @param allocator The allocator to use.
*/
sigh_storage_mixin(sigh_storage_mixin &&other, const allocator_type &allocator) noexcept
sigh_mixin(sigh_mixin &&other, const allocator_type &allocator) noexcept
: Type{std::move(other), allocator},
owner{other.owner},
construction{std::move(other.construction), allocator},
@@ -97,7 +97,7 @@ public:
* @param other The instance to move from.
* @return This storage.
*/
sigh_storage_mixin &operator=(sigh_storage_mixin &&other) noexcept {
sigh_mixin &operator=(sigh_mixin &&other) noexcept {
Type::operator=(std::move(other));
owner = other.owner;
construction = std::move(other.construction);
@@ -110,7 +110,7 @@ public:
* @brief Exchanges the contents with those of a given storage.
* @param other Storage to exchange the content with.
*/
void swap(sigh_storage_mixin &other) {
void swap(sigh_mixin &other) {
using std::swap;
Type::swap(other);
swap(owner, other.owner);

View File

@@ -1962,10 +1962,10 @@ TEST(Storage, UsesAllocatorConstruction) {
TEST(Storage, StorageType) {
// just a bunch of static asserts to avoid regressions
static_assert(std::is_same_v<entt::storage_type_t<const double, entt::entity>, const entt::sigh_storage_mixin<entt::basic_storage<double, entt::entity>>>);
static_assert(std::is_same_v<entt::storage_type_t<char, entt::entity>, entt::sigh_storage_mixin<entt::basic_storage<char, entt::entity>>>);
static_assert(std::is_same_v<entt::storage_type_t<const bool>, const entt::sigh_storage_mixin<entt::storage<bool>>>);
static_assert(std::is_same_v<entt::storage_type_t<int>, entt::sigh_storage_mixin<entt::storage<int>>>);
static_assert(std::is_same_v<entt::storage_type_t<const double, entt::entity>, const entt::sigh_mixin<entt::basic_storage<double, entt::entity>>>);
static_assert(std::is_same_v<entt::storage_type_t<char, entt::entity>, entt::sigh_mixin<entt::basic_storage<char, entt::entity>>>);
static_assert(std::is_same_v<entt::storage_type_t<const bool>, const entt::sigh_mixin<entt::storage<bool>>>);
static_assert(std::is_same_v<entt::storage_type_t<int>, entt::sigh_mixin<entt::storage<int>>>);
}
#endif

View File

@@ -30,9 +30,9 @@ void listener(counter &counter, Registry &, typename Registry::entity_type) {
++counter.value;
}
TEST(SighStorageMixin, GenericType) {
TEST(SighMixin, GenericType) {
entt::entity entities[2u]{entt::entity{3}, entt::entity{42}};
entt::sigh_storage_mixin<entt::storage<int>> pool;
entt::sigh_mixin<entt::storage<int>> pool;
entt::sparse_set &base = pool;
entt::registry registry;
@@ -95,9 +95,9 @@ TEST(SighStorageMixin, GenericType) {
ASSERT_TRUE(pool.empty());
}
TEST(SighStorageMixin, StableType) {
TEST(SighMixin, StableType) {
entt::entity entities[2u]{entt::entity{3}, entt::entity{42}};
entt::sigh_storage_mixin<entt::storage<stable_type>> pool;
entt::sigh_mixin<entt::storage<stable_type>> pool;
entt::sparse_set &base = pool;
entt::registry registry;
@@ -160,9 +160,9 @@ TEST(SighStorageMixin, StableType) {
ASSERT_FALSE(pool.empty());
}
TEST(SighStorageMixin, EmptyType) {
TEST(SighMixin, EmptyType) {
entt::entity entities[2u]{entt::entity{3}, entt::entity{42}};
entt::sigh_storage_mixin<entt::storage<empty_type>> pool;
entt::sigh_mixin<entt::storage<empty_type>> pool;
entt::sparse_set &base = pool;
entt::registry registry;
@@ -225,9 +225,9 @@ TEST(SighStorageMixin, EmptyType) {
ASSERT_TRUE(pool.empty());
}
TEST(SighStorageMixin, NonDefaultConstructibleType) {
TEST(SighMixin, NonDefaultConstructibleType) {
entt::entity entities[2u]{entt::entity{3}, entt::entity{42}};
entt::sigh_storage_mixin<entt::storage<non_default_constructible>> pool;
entt::sigh_mixin<entt::storage<non_default_constructible>> pool;
entt::sparse_set &base = pool;
entt::registry registry;
@@ -281,8 +281,8 @@ TEST(SighStorageMixin, NonDefaultConstructibleType) {
ASSERT_TRUE(pool.empty());
}
TEST(SighStorageMixin, VoidType) {
entt::sigh_storage_mixin<entt::storage<void>> pool;
TEST(SighMixin, VoidType) {
entt::sigh_mixin<entt::storage<void>> pool;
entt::registry registry;
counter on_construct{};
@@ -297,7 +297,7 @@ TEST(SighStorageMixin, VoidType) {
ASSERT_EQ(pool.type(), entt::type_id<void>());
ASSERT_TRUE(pool.contains(entt::entity{99}));
entt::sigh_storage_mixin<entt::storage<void>> other{std::move(pool)};
entt::sigh_mixin<entt::storage<void>> other{std::move(pool)};
ASSERT_FALSE(pool.contains(entt::entity{99}));
ASSERT_TRUE(other.contains(entt::entity{99}));
@@ -313,8 +313,8 @@ TEST(SighStorageMixin, VoidType) {
ASSERT_EQ(on_destroy.value, 1);
}
TEST(SighStorageMixin, Move) {
entt::sigh_storage_mixin<entt::storage<int>> pool;
TEST(SighMixin, Move) {
entt::sigh_mixin<entt::storage<int>> pool;
entt::registry registry;
counter on_construct{};
@@ -330,7 +330,7 @@ TEST(SighStorageMixin, Move) {
ASSERT_TRUE(std::is_move_assignable_v<decltype(pool)>);
ASSERT_EQ(pool.type(), entt::type_id<int>());
entt::sigh_storage_mixin<entt::storage<int>> other{std::move(pool)};
entt::sigh_mixin<entt::storage<int>> other{std::move(pool)};
ASSERT_TRUE(pool.empty());
ASSERT_FALSE(other.empty());
@@ -347,7 +347,7 @@ TEST(SighStorageMixin, Move) {
ASSERT_EQ(pool.get(entt::entity{3}), 3);
ASSERT_EQ(other.at(0u), static_cast<entt::entity>(entt::null));
other = entt::sigh_storage_mixin<entt::storage<int>>{};
other = entt::sigh_mixin<entt::storage<int>>{};
other.bind(entt::forward_as_any(registry));
other.emplace(entt::entity{42}, 42);
@@ -365,9 +365,9 @@ TEST(SighStorageMixin, Move) {
ASSERT_EQ(on_destroy.value, 1);
}
TEST(SighStorageMixin, Swap) {
entt::sigh_storage_mixin<entt::storage<int>> pool;
entt::sigh_storage_mixin<entt::storage<int>> other;
TEST(SighMixin, Swap) {
entt::sigh_mixin<entt::storage<int>> pool;
entt::sigh_mixin<entt::storage<int>> other;
entt::registry registry;
counter on_construct{};
@@ -411,7 +411,7 @@ TEST(SighStorageMixin, Swap) {
ASSERT_EQ(on_destroy.value, 3);
}
TEST(SighStorageMixin, CustomAllocator) {
TEST(SighMixin, CustomAllocator) {
auto test = [](auto pool, auto alloc) {
using registry_type = typename decltype(pool)::registry_type;
registry_type registry;
@@ -466,12 +466,12 @@ TEST(SighStorageMixin, CustomAllocator) {
test::throwing_allocator<entt::entity> allocator{};
test(entt::sigh_storage_mixin<entt::basic_storage<int, entt::entity, test::throwing_allocator<int>>>{allocator}, allocator);
test(entt::sigh_storage_mixin<entt::basic_storage<std::true_type, entt::entity, test::throwing_allocator<std::true_type>>>{allocator}, allocator);
test(entt::sigh_storage_mixin<entt::basic_storage<stable_type, entt::entity, test::throwing_allocator<stable_type>>>{allocator}, allocator);
test(entt::sigh_mixin<entt::basic_storage<int, entt::entity, test::throwing_allocator<int>>>{allocator}, allocator);
test(entt::sigh_mixin<entt::basic_storage<std::true_type, entt::entity, test::throwing_allocator<std::true_type>>>{allocator}, allocator);
test(entt::sigh_mixin<entt::basic_storage<stable_type, entt::entity, test::throwing_allocator<stable_type>>>{allocator}, allocator);
}
TEST(SighStorageMixin, ThrowingAllocator) {
TEST(SighMixin, ThrowingAllocator) {
auto test = [](auto pool) {
using pool_allocator_type = typename decltype(pool)::allocator_type;
using value_type = typename decltype(pool)::value_type;
@@ -543,12 +543,12 @@ TEST(SighStorageMixin, ThrowingAllocator) {
ASSERT_EQ(on_destroy.value, 1);
};
test(entt::sigh_storage_mixin<entt::basic_storage<int, entt::entity, test::throwing_allocator<int>>>{});
test(entt::sigh_storage_mixin<entt::basic_storage<stable_type, entt::entity, test::throwing_allocator<stable_type>>>{});
test(entt::sigh_mixin<entt::basic_storage<int, entt::entity, test::throwing_allocator<int>>>{});
test(entt::sigh_mixin<entt::basic_storage<stable_type, entt::entity, test::throwing_allocator<stable_type>>>{});
}
TEST(SighStorageMixin, ThrowingComponent) {
entt::sigh_storage_mixin<entt::storage<test::throwing_type>> pool;
TEST(SighMixin, ThrowingComponent) {
entt::sigh_mixin<entt::storage<test::throwing_type>> pool;
using registry_type = typename decltype(pool)::registry_type;
registry_type registry;

View File

@@ -13,7 +13,7 @@ struct entt::storage_type<Type, Entity> {
template<typename Entity>
struct entt::storage_type<char, Entity> {
// ... unless it's char, because yes.
using type = sigh_storage_mixin<basic_storage<char, Entity>>;
using type = sigh_mixin<basic_storage<char, Entity>>;
};
template<typename, typename, typename = void>