WPILibC++ 2023.4.3
ProxyScheduleCommand.h
Go to the documentation of this file.
1// Copyright (c) FIRST and other WPILib contributors.
2// Open Source Software; you can modify and/or share it under the terms of
3// the WPILib BSD license file in the root directory of this project.
4
5#pragma once
6
7#include <memory>
8#include <span>
9
10#include <wpi/SmallVector.h>
11#include <wpi/deprecated.h>
12
16
17namespace frc2 {
18/**
19 * Schedules the given commands when this command is initialized, and ends when
20 * all the commands are no longer scheduled. Useful for forking off from
21 * CommandGroups. If this command is interrupted, it will cancel all of the
22 * commands.
23 *
24 * This class is provided by the NewCommands VendorDep
25 */
27 : public CommandHelper<CommandBase, ProxyScheduleCommand> {
28 public:
29 /**
30 * Creates a new ProxyScheduleCommand that schedules the given commands when
31 * initialized, and ends when they are all no longer scheduled.
32 *
33 * @param toSchedule the commands to schedule
34 * @deprecated Replace with {@link ProxyCommand},
35 * composing multiple of them in a {@link ParallelRaceGroup} if needed.
36 */
37 WPI_DEPRECATED("Replace with ProxyCommand")
38 explicit ProxyScheduleCommand(std::span<Command* const> toSchedule);
39
40 explicit ProxyScheduleCommand(Command* toSchedule);
41
43
44 void Initialize() override;
45
46 void End(bool interrupted) override;
47
48 void Execute() override;
49
50 bool IsFinished() override;
51
52 private:
53 wpi::SmallVector<Command*, 4> m_toSchedule;
54 std::unique_ptr<Command> m_owning;
55 bool m_finished{false};
56};
57} // namespace frc2
CRTP implementation to allow polymorphic decorator functions in Command.
Definition: CommandHelper.h:26
A state machine representing a complete action to be performed by the robot.
Definition: Command.h:47
Schedules the given commands when this command is initialized, and ends when all the commands are no ...
Definition: ProxyScheduleCommand.h:27
bool IsFinished() override
Whether the command has finished.
void Execute() override
The main body of a command.
void Initialize() override
The initial subroutine of a command.
void End(bool interrupted) override
The action to take when the command ends.
Definition: InstantCommand.h:14
Definition: StdDeque.h:50
/file This file defines the SmallVector class.
Definition: AprilTagFieldLayout.h:18
class LLVM_GSL_OWNER SmallVector
Forward declaration of SmallVector so that calculateSmallVectorDefaultInlinedElements can reference s...
Definition: SmallVector.h:1112