[commands] Refactor lambda-based commands to inherit FunctionalCommand (#4451)

This commit is contained in:
Starlight220
2022-10-07 01:49:27 +03:00
committed by GitHub
parent b2276e47de
commit 5cf961edb9
9 changed files with 44 additions and 119 deletions

View File

@@ -9,8 +9,8 @@
#include <wpi/span.h>
#include "frc2/command/CommandBase.h"
#include "frc2/command/CommandHelper.h"
#include "frc2/command/FunctionalCommand.h"
namespace frc2 {
/**
@@ -22,7 +22,8 @@ namespace frc2 {
*
* This class is provided by the NewCommands VendorDep
*/
class StartEndCommand : public CommandHelper<CommandBase, StartEndCommand> {
class StartEndCommand
: public CommandHelper<FunctionalCommand, StartEndCommand> {
public:
/**
* Creates a new StartEndCommand. Will run the given runnables when the
@@ -48,14 +49,6 @@ class StartEndCommand : public CommandHelper<CommandBase, StartEndCommand> {
StartEndCommand(StartEndCommand&& other) = default;
StartEndCommand(const StartEndCommand& other);
void Initialize() override;
void End(bool interrupted) override;
protected:
std::function<void()> m_onInit;
std::function<void()> m_onEnd;
StartEndCommand(const StartEndCommand& other) = default;
};
} // namespace frc2