mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-19 00:41:43 +00:00
[commands] Add onlyWhile and onlyIf (#5291)
This commit is contained in:
@@ -41,6 +41,10 @@ CommandPtr Command::Until(std::function<bool()> condition) && {
|
||||
return std::move(*this).ToPtr().Until(std::move(condition));
|
||||
}
|
||||
|
||||
CommandPtr Command::OnlyWhile(std::function<bool()> condition) && {
|
||||
return std::move(*this).ToPtr().OnlyWhile(std::move(condition));
|
||||
}
|
||||
|
||||
CommandPtr Command::IgnoringDisable(bool doesRunWhenDisabled) && {
|
||||
return std::move(*this).ToPtr().IgnoringDisable(doesRunWhenDisabled);
|
||||
}
|
||||
@@ -96,6 +100,10 @@ CommandPtr Command::Unless(std::function<bool()> condition) && {
|
||||
return std::move(*this).ToPtr().Unless(std::move(condition));
|
||||
}
|
||||
|
||||
CommandPtr Command::OnlyIf(std::function<bool()> condition) && {
|
||||
return std::move(*this).ToPtr().OnlyIf(std::move(condition));
|
||||
}
|
||||
|
||||
CommandPtr Command::FinallyDo(std::function<void(bool)> end) && {
|
||||
return std::move(*this).ToPtr().FinallyDo(std::move(end));
|
||||
}
|
||||
|
||||
@@ -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