Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added ignoreDisable() and respectDisable() instance methods #7300

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -451,6 +451,24 @@ public boolean runsWhenDisabled() {
};
}

/**
* Decorates this command to run when disabled.
*
* @return the decorated command
*/
public WrapperCommand ignoreDisable() {
return this.ignoringDisable(true);
}

/**
* Decorates this command to stop when disabled.
*
* @return the decorated command
*/
public WrapperCommand respectDisable() {
return this.ignoringDisable(false);
}

/**
* Decorates this command to have a different {@link InterruptionBehavior interruption behavior}.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,14 @@ CommandPtr Command::IgnoringDisable(bool doesRunWhenDisabled) && {
return std::move(*this).ToPtr().IgnoringDisable(doesRunWhenDisabled);
}

CommandPtr Command::IgnoreDisable() && {
return std::move(*this).ToPtr().IgnoringDisable(true);
}

CommandPtr Command::RespectDisable() && {
return std::move(*this).ToPtr().IgnoringDisable(false);
}

CommandPtr Command::WithInterruptBehavior(
InterruptionBehavior interruptBehavior) && {
return std::move(*this).ToPtr().WithInterruptBehavior(interruptBehavior);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,14 @@ CommandPtr CommandPtr::IgnoringDisable(bool doesRunWhenDisabled) && {
return std::move(*this);
}

CommandPtr CommandPtr::IgnoreDisable() && {
return std::move(*this).IgnoringDisable(true);
}

CommandPtr CommandPtr::RespectDisable() && {
return std::move(*this).IgnoringDisable(false);
}

using InterruptionBehavior = Command::InterruptionBehavior;
class InterruptBehaviorCommand : public WrapperCommand {
public:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -352,6 +352,22 @@ class Command : public wpi::Sendable, public wpi::SendableHelper<Command> {
[[nodiscard]]
CommandPtr IgnoringDisable(bool doesRunWhenDisabled) &&;

/**
* Decorates this command to run when disabled.
*
* @return the decorated command
*/
[[nodiscard]]
CommandPtr IgnoreDisable() &&;

/**
* Decorates this command to stop when disabled.
*
* @return the decorated command
*/
[[nodiscard]]
CommandPtr RespectDisable() &&;

/**
* Decorates this command to have a different interrupt behavior.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,22 @@ class CommandPtr final {
[[nodiscard]]
CommandPtr IgnoringDisable(bool doesRunWhenDisabled) &&;

/**
* Decorates this command to run when disabled.
*
* @return the decorated command
*/
[[nodiscard]]
CommandPtr IgnoreDisable() &&;

/**
* Decorates this command to stop when disabled.
*
* @return the decorated command
*/
[[nodiscard]]
CommandPtr RespectDisable() &&;

/**
* Decorates this command to have a different interrupt behavior.
*
Expand Down