Merge branch 'main' into 2027

This commit is contained in:
Peter Johnson
2024-12-14 10:45:32 -08:00
43 changed files with 768 additions and 1278 deletions

View File

@@ -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));
}

View File

@@ -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;

View File

@@ -309,6 +309,16 @@ class Command : public wpi::Sendable, public wpi::SendableHelper<Command> {
[[nodiscard]]
CommandPtr OnlyIf(std::function<bool()> condition) &&;
/**
* Creates a new command that runs this command and the deadline in parallel,
* finishing (and interrupting this command) when the deadline finishes.
*
* @param deadline the deadline of the command group
* @return the decorated command
* @see DeadlineFor
*/
CommandPtr WithDeadline(CommandPtr&& deadline) &&;
/**
* Decorates this command with a set of commands to run parallel to it, ending
* when the calling command ends and interrupting all the others. Often more
@@ -318,9 +328,11 @@ class Command : public wpi::Sendable, public wpi::SendableHelper<Command> {
* @param parallel the commands to run in parallel. Note the parallel commands
* will be interupted when the deadline command ends
* @return the decorated command
* @see WithDeadline
*/
[[nodiscard]]
CommandPtr DeadlineFor(CommandPtr&& parallel) &&;
/**
* Decorates this command with a set of commands to run parallel to it, ending
* when the last command ends. Often more convenient/less-verbose than

View File

@@ -182,6 +182,16 @@ class CommandPtr final {
[[nodiscard]]
CommandPtr OnlyIf(std::function<bool()> condition) &&;
/**
* Creates a new command that runs this command and the deadline in parallel,
* finishing (and interrupting this command) when the deadline finishes.
*
* @param deadline the deadline of the command group
* @return the decorated command
* @see DeadlineFor
*/
CommandPtr WithDeadline(CommandPtr&& deadline) &&;
/**
* Decorates this command with a set of commands to run parallel to it, ending
* when the calling command ends and interrupting all the others. Often more