Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

templated sigh mixin with registry type #1079

Closed

Conversation

actondev
Copy link

closes #1078

This a proposed approach for the linked issue

@skypjack skypjack self-requested a review October 18, 2023 13:27
@skypjack skypjack self-assigned this Oct 18, 2023
@skypjack skypjack added the feature request feature request not yet accepted label Oct 18, 2023
Copy link
Owner

@skypjack skypjack left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please, change the base branch to wip. That's where development happens and where all PRs are merged. Thanks.

using underlying_type = Type;
template<typename Storage, typename Registry>
class sigh_mixin final: public Storage {
using underlying_type = Storage;
using basic_registry_type = basic_registry<typename underlying_type::entity_type, typename underlying_type::base_type::allocator_type>;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you want to update this member type and use it all over as it happened before already.
All other changes seem unnecessary once you updated this one. Am I wrong?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's needed in one place, in bind. The issue being that the any value passed there is of type basic_registry, not of the inherited one. And actually this part is the one that I'm not so certain about the approach, cause of the reinterpret_cast needed there

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Regarding my comment above, added a static_assert that the template parameter Registry is indeed inheriting from basic_registry

template<typename Entity = entity, typename = std::allocator<Entity>>
class basic_registry;

template<typename Storage, typename Registry = basic_registry<typename Storage::entity_type, typename Storage::base_type::allocator_type>>
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure about this one in the long term but let it be, we can still change it later on. 👍

test/entt/entity/observer.cpp Outdated Show resolved Hide resolved
test/entt/entity/sigh_mixin.cpp Outdated Show resolved Hide resolved
test/entt/entity/observer.cpp Outdated Show resolved Hide resolved
test/entt/entity/sigh_mixin.cpp Outdated Show resolved Hide resolved
};


TEST(Observer, CustomInheritedRegistry) {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To be honest, this test seems unnecessary to me. The one for the sigh_mixin is enough to test it. I don't see what this one brings to the table.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It tests that the observer setup, through setting up the required signals, via the sigh_mixin storage, is working correctly. Can remove it though if you still think it's redundant

This enables inheriting basic_registry and getting the inherited
registry type (instead of basic_registry) in the signal handlers
callback as the first argument
@actondev actondev force-pushed the feat/templated-sigh_mixin-registry-type branch from a0885db to 154bdfd Compare October 18, 2023 15:14
@actondev actondev changed the base branch from master to wip October 18, 2023 17:29
@skypjack
Copy link
Owner

Sorry for the inconvenience but you'll have to wait a few days. I got a flu and I'm not exactly in the mood to work on PRs. 🙂

@actondev
Copy link
Author

Sorry for the inconvenience but you'll have to wait a few days. I got a flu and I'm not exactly in the mood to work on PRs. 🙂

No inconvenience at all, take some rest & get better! 🍵

@skypjack skypjack added the solved available upstream or in a branch label Nov 23, 2023
@skypjack skypjack closed this in e3475c0 Dec 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature request feature request not yet accepted solved available upstream or in a branch
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Signals for inherited registry
2 participants