mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-07-05 03:21:42 +00:00
[commands] Add proxy factory to Commands (#5603)
This commit is contained in:
@@ -11,6 +11,7 @@
|
||||
#include "frc2/command/ParallelDeadlineGroup.h"
|
||||
#include "frc2/command/ParallelRaceGroup.h"
|
||||
#include "frc2/command/PrintCommand.h"
|
||||
#include "frc2/command/ProxyCommand.h"
|
||||
#include "frc2/command/RunCommand.h"
|
||||
#include "frc2/command/SequentialCommandGroup.h"
|
||||
#include "frc2/command/WaitCommand.h"
|
||||
@@ -58,6 +59,14 @@ CommandPtr cmd::Print(std::string_view msg) {
|
||||
return PrintCommand(msg).ToPtr();
|
||||
}
|
||||
|
||||
CommandPtr cmd::DeferredProxy(wpi::unique_function<Command*()> supplier) {
|
||||
return ProxyCommand(std::move(supplier)).ToPtr();
|
||||
}
|
||||
|
||||
CommandPtr cmd::DeferredProxy(wpi::unique_function<CommandPtr()> supplier) {
|
||||
return ProxyCommand(std::move(supplier)).ToPtr();
|
||||
}
|
||||
|
||||
CommandPtr cmd::Wait(units::second_t duration) {
|
||||
return WaitCommand(duration).ToPtr();
|
||||
}
|
||||
|
||||
@@ -142,6 +142,26 @@ CommandPtr Select(std::function<Key()> selector,
|
||||
return SelectCommand(std::move(selector), std::move(vec)).ToPtr();
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a command that schedules the command returned from the supplier
|
||||
* when initialized, and ends when it is no longer scheduled. The supplier is
|
||||
* called when the command is initialized.
|
||||
*
|
||||
* @param supplier the command supplier
|
||||
*/
|
||||
[[nodiscard]]
|
||||
CommandPtr DeferredProxy(wpi::unique_function<Command*()> supplier);
|
||||
|
||||
/**
|
||||
* Constructs a command that schedules the command returned from the supplier
|
||||
* when initialized, and ends when it is no longer scheduled. The supplier is
|
||||
* called when the command is initialized.
|
||||
*
|
||||
* @param supplier the command supplier
|
||||
*/
|
||||
[[nodiscard]]
|
||||
CommandPtr DeferredProxy(wpi::unique_function<CommandPtr()> supplier);
|
||||
|
||||
// Command Groups
|
||||
|
||||
namespace impl {
|
||||
|
||||
Reference in New Issue
Block a user