@@ -689,3 +689,43 @@ TEST(SighMixin, ThrowingComponent) {
689
689
ASSERT_EQ (on_construct.value , 2 );
690
690
ASSERT_EQ (on_destroy.value , 3 );
691
691
}
692
+
693
+ enum class CustomEntity : std::uint32_t
694
+ {
695
+ };
696
+
697
+
698
+ // This could be used to add custom methods to the registry or, in case of non-public inheritance,
699
+ // to restrict the access to the registry.
700
+ class CustomRegistry : public entt ::basic_registry<CustomEntity> {
701
+ };
702
+
703
+ template <typename Component>
704
+ struct entt ::storage_type<Component, CustomEntity>
705
+ {
706
+ using type = entt::sigh_mixin<entt::basic_storage<Component, CustomEntity>, CustomRegistry>;
707
+ };
708
+
709
+ void custom_registry_listener (counter &counter, CustomRegistry &, CustomEntity) {
710
+ ++counter.value ;
711
+ }
712
+
713
+ TEST (SighMixin, CustomRegistry) {
714
+ CustomRegistry registry;
715
+
716
+ counter on_construct_int{};
717
+ counter on_construct_float{};
718
+
719
+ registry.on_construct <int >().connect <&custom_registry_listener>(on_construct_int);
720
+ registry.on_construct <float >().connect <&custom_registry_listener>(on_construct_float);
721
+
722
+ const auto e1 = registry.create ();
723
+ const auto e2 = registry.create ();
724
+
725
+ registry.emplace <int >(e1 , 1 );
726
+ registry.emplace <int >(e2 , 2 );
727
+ registry.emplace <float >(e1 , 1 .1f );
728
+
729
+ ASSERT_EQ (on_construct_int.value , 2 );
730
+ ASSERT_EQ (on_construct_float.value , 1 );
731
+ }
0 commit comments