mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-20 00:51:42 +00:00
[commands] Add withDeadline modifier (#7299)
Co-authored-by: Ryan Blue <ryanzblue@gmail.com>
This commit is contained in:
@@ -121,6 +121,10 @@ CommandPtr Command::OnlyIf(std::function<bool()> condition) && {
|
||||
return std::move(*this).ToPtr().OnlyIf(std::move(condition));
|
||||
}
|
||||
|
||||
CommandPtr Command::WithDeadline(CommandPtr&& deadline) && {
|
||||
return std::move(*this).ToPtr().WithDeadline(std::move(deadline));
|
||||
}
|
||||
|
||||
CommandPtr Command::DeadlineFor(CommandPtr&& parallel) && {
|
||||
return std::move(*this).ToPtr().DeadlineFor(std::move(parallel));
|
||||
}
|
||||
|
||||
@@ -168,6 +168,15 @@ CommandPtr CommandPtr::OnlyIf(std::function<bool()> condition) && {
|
||||
return std::move(*this).Unless(std::not_fn(std::move(condition)));
|
||||
}
|
||||
|
||||
CommandPtr CommandPtr::WithDeadline(CommandPtr&& deadline) && {
|
||||
AssertValid();
|
||||
std::vector<std::unique_ptr<Command>> vec;
|
||||
vec.emplace_back(std::move(m_ptr));
|
||||
m_ptr = std::make_unique<ParallelDeadlineGroup>(std::move(deadline).Unwrap(),
|
||||
std::move(vec));
|
||||
return std::move(*this);
|
||||
}
|
||||
|
||||
CommandPtr CommandPtr::DeadlineWith(CommandPtr&& parallel) && {
|
||||
AssertValid();
|
||||
std::vector<std::unique_ptr<Command>> vec;
|
||||
|
||||
Reference in New Issue
Block a user