WPILibC++  2020.3.2
RunCommand.h
1 /*----------------------------------------------------------------------------*/
2 /* Copyright (c) 2019-2020 FIRST. All Rights Reserved. */
3 /* Open Source Software - may be modified and shared by FRC teams. The code */
4 /* must be accompanied by the FIRST BSD license file in the root directory of */
5 /* the project. */
6 /*----------------------------------------------------------------------------*/
7 
8 #pragma once
9 
10 #include <functional>
11 #include <initializer_list>
12 
13 #include <wpi/ArrayRef.h>
14 
15 #include "frc2/command/CommandBase.h"
16 #include "frc2/command/CommandHelper.h"
17 
18 namespace frc2 {
25 class RunCommand : public CommandHelper<CommandBase, RunCommand> {
26  public:
34  RunCommand(std::function<void()> toRun,
35  std::initializer_list<Subsystem*> requirements);
36 
44  RunCommand(std::function<void()> toRun,
45  wpi::ArrayRef<Subsystem*> requirements = {});
46 
47  RunCommand(RunCommand&& other) = default;
48 
49  RunCommand(const RunCommand& other) = default;
50 
51  void Execute();
52 
53  protected:
54  std::function<void()> m_toRun;
55 };
56 } // namespace frc2
frc2::RunCommand::Execute
void Execute()
The main body of a command.
wpi::ArrayRef
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
Definition: ArrayRef.h:42
frc2::RunCommand::RunCommand
RunCommand(std::function< void()> toRun, std::initializer_list< Subsystem * > requirements)
Creates a new RunCommand.
frc2::CommandHelper
CRTP implementation to allow polymorphic decorator functions in Command.
Definition: CommandHelper.h:26
frc2::RunCommand
A command that runs a Runnable continuously.
Definition: RunCommand.h:25