1
0

mixin.hpp 957 B

123456789101112131415161718192021222324252627282930313233343536
  1. #ifndef ENTT_COMMON_MIXIN_HPP
  2. #define ENTT_COMMON_MIXIN_HPP
  3. #include <entt/core/any.hpp>
  4. #include <entt/entity/fwd.hpp>
  5. namespace test {
  6. struct assure_loop {};
  7. template<typename Type>
  8. class assure_loop_mixin: public Type {
  9. using underlying_type = Type;
  10. using registry_type = entt::basic_registry<typename underlying_type::entity_type, typename underlying_type::base_type::allocator_type>;
  11. public:
  12. using allocator_type = typename underlying_type::allocator_type;
  13. using entity_type = typename underlying_type::entity_type;
  14. using Type::Type;
  15. void bind(entt::any value) noexcept override {
  16. if(auto *owner = entt::any_cast<registry_type>(&value); owner) {
  17. owner->template storage<int>();
  18. }
  19. }
  20. };
  21. } // namespace test
  22. template<typename Entity>
  23. struct entt::storage_type<test::assure_loop, Entity> {
  24. using type = test::assure_loop_mixin<entt::basic_storage<test::assure_loop, Entity>>;
  25. };
  26. #endif