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

support multiple event factories #618

Merged
merged 2 commits into from
Jan 7, 2025
Merged

Conversation

barbibulle
Copy link
Collaborator

While there's no way to ensure the uniqueness of HCI vendor event codes across vendors, it is still possible to have vendor event factories that don't overlap (by design), such as the generic set of Android vendor HCI events which multiple vendors do implement (and in that case the vendors ensure that they don't re-use the same event codes for other events).
This change allows having multiple vendor factories, which will be invoked in registration order when an HCI vendor event is encountered, instead of a single factory. It is up to the caller to ensure that they do not register factories with overlapping IDs.

@barbibulle barbibulle requested a review from zxzxwu January 6, 2025 13:45
if cls.vendor_factory:
if event := cls.vendor_factory(parameters):
for vendor_factory in cls.vendor_factories:
if event := vendor_factory(parameters):
return event

# No factory, or the factory could not create an instance,
Copy link
Collaborator

Choose a reason for hiding this comment

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

Should here return HCI_Vendor_Event instead of HCI_Event?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes. Done. I've also added a test for it.

@barbibulle barbibulle merged commit 509df4c into main Jan 7, 2025
57 checks 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