mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-21 01:01:43 +00:00
[commands] Add onlyWhile and onlyIf (#5291)
This commit is contained in:
@@ -151,6 +151,11 @@ CommandPtr CommandPtr::Until(std::function<bool()> condition) && {
|
||||
return std::move(*this);
|
||||
}
|
||||
|
||||
CommandPtr CommandPtr::OnlyWhile(std::function<bool()> condition) && {
|
||||
AssertValid();
|
||||
return std::move(*this).Until(std::not_fn(std::move(condition)));
|
||||
}
|
||||
|
||||
CommandPtr CommandPtr::Unless(std::function<bool()> condition) && {
|
||||
AssertValid();
|
||||
m_ptr = std::make_unique<ConditionalCommand>(
|
||||
@@ -159,6 +164,11 @@ CommandPtr CommandPtr::Unless(std::function<bool()> condition) && {
|
||||
return std::move(*this);
|
||||
}
|
||||
|
||||
CommandPtr CommandPtr::OnlyIf(std::function<bool()> condition) && {
|
||||
AssertValid();
|
||||
return std::move(*this).Unless(std::not_fn(std::move(condition)));
|
||||
}
|
||||
|
||||
CommandPtr CommandPtr::DeadlineWith(CommandPtr&& parallel) && {
|
||||
AssertValid();
|
||||
std::vector<std::unique_ptr<Command>> vec;
|
||||
|
||||
Reference in New Issue
Block a user