[commands] C++ unique_ptr migration (#4319)

Add a CommandPtr with an internal unique_ptr to enable not needing to move the underlying classes, which is error-prone due to the potential for lambda captures.
This commit is contained in:
Starlight220
2022-10-06 01:19:28 +03:00
committed by GitHub
parent 3b81cf6c35
commit 60e29627c0
18 changed files with 644 additions and 133 deletions

View File

@@ -69,6 +69,15 @@ class Trigger : public frc::BooleanEvent {
*/
Trigger WhenActive(Command* command);
/**
* Binds a command to start when the trigger becomes active. Moves
* command ownership to the button scheduler.
*
* @param command The command to bind.
* @return The trigger, for chained calls.
*/
Trigger WhenActive(CommandPtr&& command);
/**
* Binds a command to start when the trigger becomes active. Transfers
* command ownership to the button scheduler, so the user does not have to
@@ -116,6 +125,16 @@ class Trigger : public frc::BooleanEvent {
*/
Trigger WhileActiveContinous(Command* command);
/**
* Binds a command to be started repeatedly while the trigger is active, and
* canceled when it becomes inactive. Moves command ownership to the button
* scheduler.
*
* @param command The command to bind.
* @return The trigger, for chained calls.
*/
Trigger WhileActiveContinous(CommandPtr&& command);
/**
* Binds a command to be started repeatedly while the trigger is active, and
* canceled when it becomes inactive. Transfers command ownership to the
@@ -164,6 +183,16 @@ class Trigger : public frc::BooleanEvent {
*/
Trigger WhileActiveOnce(Command* command);
/**
* Binds a command to be started when the trigger becomes active, and
* canceled when it becomes inactive. Moves command ownership to the button
* scheduler.
*
* @param command The command to bind.
* @return The trigger, for chained calls.
*/
Trigger WhileActiveOnce(CommandPtr&& command);
/**
* Binds a command to be started when the trigger becomes active, and
* canceled when it becomes inactive. Transfers command ownership to the
@@ -195,6 +224,15 @@ class Trigger : public frc::BooleanEvent {
*/
Trigger WhenInactive(Command* command);
/**
* Binds a command to start when the trigger becomes inactive. Moves
* command ownership to the button scheduler.
*
* @param command The command to bind.
* @return The trigger, for chained calls.
*/
Trigger WhenInactive(CommandPtr&& command);
/**
* Binds a command to start when the trigger becomes inactive. Transfers
* command ownership to the button scheduler, so the user does not have to
@@ -242,6 +280,16 @@ class Trigger : public frc::BooleanEvent {
*/
Trigger ToggleWhenActive(Command* command);
/**
* Binds a command to start when the trigger becomes active, and be canceled
* when it again becomes active. Moves command ownership to the button
* scheduler.
*
* @param command The command to bind.
* @return The trigger, for chained calls.
*/
Trigger ToggleWhenActive(CommandPtr&& command);
/**
* Binds a command to start when the trigger becomes active, and be canceled
* when it again becomes active. Transfers command ownership to the button