[commands] Remove EndlessCommand (#4483)

This commit is contained in:
Starlight220
2022-10-21 03:24:54 +03:00
committed by GitHub
parent 16cdc741cf
commit dc037f8d41
16 changed files with 44 additions and 289 deletions

View File

@@ -29,7 +29,11 @@ namespace frc2 {
*
* This class is provided by the NewCommands VendorDep
*
* @deprecated replace with EndlessCommand
* @deprecated PerpetualCommand violates the assumption that execute() doesn't
get called after isFinished() returns true -- an assumption that should be
valid. This was unsafe/undefined behavior from the start, and RepeatCommand
provides an easy way to achieve similar end results with slightly different (and
safe) semantics.
*/
class PerpetualCommand : public CommandHelper<CommandBase, PerpetualCommand> {
public:
@@ -40,10 +44,16 @@ class PerpetualCommand : public CommandHelper<CommandBase, PerpetualCommand> {
*
* @param command the command to run perpetually
*/
WPI_DEPRECATED("Replace with EndlessCommand")
WPI_DEPRECATED(
"PerpetualCommand violates the assumption that execute() doesn't get "
"called after isFinished() returns true -- an assumption that should be "
"valid."
"This was unsafe/undefined behavior from the start, and RepeatCommand "
"provides an easy way to achieve similar end results with slightly "
"different (and safe) semantics.")
explicit PerpetualCommand(std::unique_ptr<Command>&& command);
WPI_IGNORE_DEPRECATED
/**
* Creates a new PerpetualCommand. Will run another command in perpetuity,
* ignoring that command's end conditions, unless this command itself is
@@ -53,7 +63,13 @@ class PerpetualCommand : public CommandHelper<CommandBase, PerpetualCommand> {
*/
template <class T, typename = std::enable_if_t<std::is_base_of_v<
Command, std::remove_reference_t<T>>>>
WPI_DEPRECATED("Replace with EndlessCommand")
WPI_DEPRECATED(
"PerpetualCommand violates the assumption that execute() doesn't get "
"called after isFinished() returns true -- an assumption that should be "
"valid."
"This was unsafe/undefined behavior from the start, and RepeatCommand "
"provides an easy way to achieve similar end results with slightly "
"different (and safe) semantics.")
explicit PerpetualCommand(T&& command)
: PerpetualCommand(std::make_unique<std::remove_reference_t<T>>(
std::forward<T>(command))) {}