mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-20 00:51:42 +00:00
Add requirements param to more Command APIs (#2059)
Assorted improvements to the ergonomics of declaring requirements in the new command framework. C++ requirements list parameters have been defaulted to an empty list, some missing C++ requirements list parameters have been added, and both C++ and Java have been given requirements list params in various InstantCommand wrapper methods (#2049), whose value is forwarded to the command.
This commit is contained in:
@@ -48,19 +48,21 @@ ParallelRaceGroup Command::WithInterrupt(std::function<bool()> condition) && {
|
||||
return ParallelRaceGroup(std::move(temp));
|
||||
}
|
||||
|
||||
SequentialCommandGroup Command::BeforeStarting(std::function<void()> toRun) && {
|
||||
SequentialCommandGroup Command::BeforeStarting(std::function<void()> toRun,
|
||||
std::initializer_list<Subsystem*> requirements) && {
|
||||
std::vector<std::unique_ptr<Command>> temp;
|
||||
temp.emplace_back(std::make_unique<InstantCommand>(
|
||||
std::move(toRun), std::initializer_list<Subsystem*>{}));
|
||||
std::move(toRun), requirements));
|
||||
temp.emplace_back(std::move(*this).TransferOwnership());
|
||||
return SequentialCommandGroup(std::move(temp));
|
||||
}
|
||||
|
||||
SequentialCommandGroup Command::AndThen(std::function<void()> toRun) && {
|
||||
SequentialCommandGroup Command::AndThen(std::function<void()> toRun,
|
||||
std::initializer_list<Subsystem*> requirements) && {
|
||||
std::vector<std::unique_ptr<Command>> temp;
|
||||
temp.emplace_back(std::move(*this).TransferOwnership());
|
||||
temp.emplace_back(std::make_unique<InstantCommand>(
|
||||
std::move(toRun), std::initializer_list<Subsystem*>{}));
|
||||
std::move(toRun), requirements));
|
||||
return SequentialCommandGroup(std::move(temp));
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user