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

misc: Add strict typing to attachment manager #152

Merged
merged 3 commits into from
Mar 2, 2025

Conversation

PlasmaPower
Copy link
Contributor

Feel free to reject this PR if the new abstraction is too complicated or otherwise not your preference, but it fixes a couple of potential pitfalls and simplifies the external API:

  • You no longer have to manage the eAttachmentType and figure out which enum values correspond to which types. This also makes it easier to add new attachment types in the future, and provides flexibility to use this in other non-DRM contexts or with external attachment types.
  • You no longer have to cast returned attachments to the right type, as the attachment manager now does the cast for you. This also avoids the potential pitfall of casting to the wrong attachment type.
  • Previously, we called removeByType before add because it was possible to have multiple attachments of the same type by accident, but attachments are now stored in a map instead of a vector to guarantee uniqueness.

@PlasmaPower PlasmaPower force-pushed the typed-attachment-manager branch from d005ce7 to f5eadc2 Compare March 2, 2025 03:27
Copy link
Member

@vaxerski vaxerski left a comment

Choose a reason for hiding this comment

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

generally fine, depends on RTTI but we already do in many places

Copy link
Member

@vaxerski vaxerski left a comment

Choose a reason for hiding this comment

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

thanks!

@vaxerski vaxerski merged commit 7b5db3d into hyprwm:main Mar 2, 2025
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants