Reorganize states and enter actions with enum-map#48
Merged
Conversation
- Rename states to better reflect a sense of being rather than an action - Use enum-map instead of HashMap for complete mapping of enter actions - Make enter actions actual methods instead of associated functions - Take mutable references for eventual component usage
samderanova
reviewed
May 13, 2024
Contributor
samderanova
left a comment
There was a problem hiding this comment.
Thanks for working to make the code simpler. A few questions:
61c5dc8 to
9950142
Compare
- Use corresponding verbs of the new state names on the control panel action buttons and for the socket event name
9950142 to
a0e2864
Compare
samderanova
approved these changes
May 13, 2024
SM-dot
approved these changes
May 13, 2024
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Following from #39 and as part of #21, we can rename some of the states to identify what the pod is doing/has done rather than naming them after the action message. We can also simplify the correspondence for enter actions by using enum-map rather than
HashMap. WithEnumMap, all enum values must have an associated map value which eliminates the need for checking if the key exists. Additionally,EnumMapstores the mapping as an array which should be more performant than hashing.The enter actions were previously just associated functions, but they'll need to manipulate pod components (e.g. the signal light, brakes, and others), so they were changed to actual methods which mutably borrow. The enter actions cannot be tested yet as the actual state transition logic from #39 needs to be fixed while completing #21.
Changes
HashMapfor complete mapping of enter actions