Skip to content

Commit

Permalink
attempt
Browse files Browse the repository at this point in the history
  • Loading branch information
narmstro2020 committed Oct 11, 2024
1 parent fcfcb55 commit 1191215
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
10 changes: 10 additions & 0 deletions wpilibNewCommands/src/main/native/cpp/frc2/command/CommandPtr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,16 @@ CommandPtr CommandPtr::AsProxy() && {
return std::move(*this);
}

CommandPtr CommandPtr::Fork(CommandPtr&& other) && {
AssertValid();
std::vector<std::unique_ptr<Command>> vec;
vec.emplace_back(std::move(m_ptr));
vec.emplace_back(std::move(other).Unwrap());
std::span<std::unique_ptr<Command>> span(vec);
m_ptr = std::make_unique<ScheduleCommand>(std::move(span));
return std::move(*this);
}

class RunsWhenDisabledCommand : public WrapperCommand {
public:
RunsWhenDisabledCommand(std::unique_ptr<Command>&& command,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,21 @@ class CommandPtr final {
[[nodiscard]]
CommandPtr AsProxy() &&;

/**
* Decorates this command to run "forked" by wrapping it in a {@link ScheduleCommand}. Use this
* for "forking off" from command compositions when the user does not wish to extend the command's
* requirements to the entire command composition. Note that if run from a composition, the
* composition will not know about the status of the scheduled commands, and will treat this
* command as finishing instantly. Commands can be added to this and will be scheduled in order
* with this command scheduled first.
*
* @param other other commands to schedule along with this one. This command is scheduled first.
* @return the decorated command
* @see ScheduleCommand
*/
[[nodiscard]]
CommandPtr Fork(CommandPtr&& other) &&;

/**
* Decorates this command to run or stop when disabled.
*
Expand Down

0 comments on commit 1191215

Please sign in to comment.