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

[cmd] Add missing C++ decorators #6599

Merged
merged 2 commits into from
May 24, 2024

Conversation

KangarooKoala
Copy link
Contributor

Notes:

  • CommandPtr didn't already have AndThen, DeadlineFor, AlongWith, and RaceWith decorators that take multiple commands, so I didn't add equivalents of those to Command. (I did add the single command argument versions, though) This unfortunately affected the DeadlineFor test, so if people want me to add those as well in this PR then I'm fine with doing that. (Or if they want to do it themselves in a separate PR, that's cool too)
  • Defines consistent execution order of Until, OnlyWhile, DeadlineFor, AlongWith, RaceWith, where the textual order of arguments matches the order of processing. (The decorated command is processed first (execute() run and isFinished() checked, optionally running end()), then the arguments to the decorator)

@KangarooKoala KangarooKoala requested a review from a team as a code owner May 8, 2024 03:12
Copy link
Member

@Starlight220 Starlight220 left a comment

Choose a reason for hiding this comment

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

This PR does a lot -- maybe split to one that adds the missing decorators in C++ and another that preserves and tests execution order?

Copy link
Member

@Starlight220 Starlight220 left a comment

Choose a reason for hiding this comment

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

Looks good overall


Command command = new WaitCommand(10).until(condition::get);
Command command = new RunCommand(() -> {}).until(finish::get);
Copy link
Member

Choose a reason for hiding this comment

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

All these instances of RunCommand(() -> {}) can be replaced with Commands.idle().

Not important enough to block this PR, though.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I opened #6652 since there's a bunch of other spots in command tests that should also be updated. If this PR gets merged before the issue gets resolved, I'll update the list on the issue, and if the issue gets resolved first, then I'll update this PR.

@Starlight220 Starlight220 changed the title [cmd] Improve Java and C++ decorator consistency [cmd] Add missing C++ decorators May 24, 2024
@PeterJohnson PeterJohnson merged commit 5c5e5af into wpilibsuite:main May 24, 2024
25 checks passed
@KangarooKoala KangarooKoala deleted the consistent-decorator branch May 24, 2024 21:07
chauser pushed a commit to chauser/allwpilib that referenced this pull request May 30, 2024
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.

3 participants