[commands] Disambiguate ProxyCommand and DeferredCommand (#6324)

This commit is contained in:
DeltaDizzy
2024-04-28 00:41:04 -05:00
committed by GitHub
parent 39d33bfca6
commit 1e4a647918
8 changed files with 69 additions and 33 deletions

View File

@@ -13,9 +13,15 @@
namespace frc2 {
/**
* Schedules the given command when this command is initialized, and ends when
* it ends. Useful for forking off from CommandGroups. If this command is
* interrupted, it will cancel the command.
* Schedules a given command when this command is initialized and ends when it
* ends, but does not directly run it. Use this for including a command in a
* composition without adding its requirements, <strong>but only if you know
* what you are doing. If you are unsure, see <a
* href="https://docs.wpilib.org/en/stable/docs/software/commandbased/command-compositions.html#scheduling-other-commands">the
* WPILib docs</a> for a complete explanation of proxy semantics.</strong> Do
* not proxy a command from a subsystem already required by the composition, or
* else the composition will cancel itself when the proxy is reached. If this
* command is interrupted, it will cancel the command.
*
* <p>This class is provided by the NewCommands VendorDep
*/
@@ -23,19 +29,27 @@ class ProxyCommand : public CommandHelper<Command, ProxyCommand> {
public:
/**
* Creates a new ProxyCommand that schedules the supplied command when
* initialized, and ends when it is no longer scheduled. Useful for lazily
* creating commands at runtime.
* initialized, and ends when it is no longer scheduled. Use this for lazily
* creating <strong>proxied</strong> commands at runtime. Proxying should only
* be done to escape from composition requirement semantics, so if only
* initialization time command construction is needed, use {@link
* DeferredCommand} instead.
*
* @param supplier the command supplier
* @see DeferredCommand
*/
explicit ProxyCommand(wpi::unique_function<Command*()> supplier);
/**
* Creates a new ProxyCommand that schedules the supplied command when
* initialized, and ends when it is no longer scheduled. Useful for lazily
* creating commands at runtime.
* initialized, and ends when it is no longer scheduled. Use this for lazily
* creating <strong>proxied</strong> commands at runtime. Proxying should only
* be done to escape from composition requirement semantics, so if only
* initialization time command construction is needed, use {@link
* DeferredCommand} instead.
*
* @param supplier the command supplier
* @see DeferredCommand
*/
explicit ProxyCommand(wpi::unique_function<CommandPtr()> supplier);