WPILibC++  2020.3.2-60-g3011ebe
ProxyScheduleCommand.h
1 /*----------------------------------------------------------------------------*/
2 /* Copyright (c) 2019 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 <wpi/ArrayRef.h>
11 #include <wpi/SmallVector.h>
12 
13 #include "frc2/command/CommandBase.h"
14 #include "frc2/command/CommandHelper.h"
15 #include "frc2/command/SetUtilities.h"
16 
17 namespace frc2 {
25  : public CommandHelper<CommandBase, ProxyScheduleCommand> {
26  public:
33  explicit ProxyScheduleCommand(wpi::ArrayRef<Command*> toSchedule);
34 
35  ProxyScheduleCommand(ProxyScheduleCommand&& other) = default;
36 
37  ProxyScheduleCommand(const ProxyScheduleCommand& other) = default;
38 
39  void Initialize() override;
40 
41  void End(bool interrupted) override;
42 
43  void Execute() override;
44 
45  bool IsFinished() override;
46 
47  private:
48  wpi::SmallVector<Command*, 4> m_toSchedule;
49  bool m_finished{false};
50 };
51 } // namespace frc2
wpi::ArrayRef
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
Definition: ArrayRef.h:42
frc2::ProxyScheduleCommand::Execute
void Execute() override
The main body of a command.
frc2::ProxyScheduleCommand::ProxyScheduleCommand
ProxyScheduleCommand(wpi::ArrayRef< Command * > toSchedule)
Creates a new ProxyScheduleCommand that schedules the given commands when initialized,...
frc2::ProxyScheduleCommand::Initialize
void Initialize() override
The initial subroutine of a command.
frc2::ProxyScheduleCommand::End
void End(bool interrupted) override
The action to take when the command ends.
frc2::ProxyScheduleCommand
Schedules the given commands when this command is initialized, and ends when all the commands are no ...
Definition: ProxyScheduleCommand.h:24
frc2::CommandHelper
CRTP implementation to allow polymorphic decorator functions in Command.
Definition: CommandHelper.h:26
wpi::SmallVector
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
Definition: SmallVector.h:856
frc2::ProxyScheduleCommand::IsFinished
bool IsFinished() override
Whether the command has finished.