2020-12-26 14:12:05 -08:00
|
|
|
// Copyright (c) FIRST and other WPILib contributors.
|
|
|
|
|
// Open Source Software; you can modify and/or share it under the terms of
|
|
|
|
|
// the WPILib BSD license file in the root directory of this project.
|
2019-08-25 23:55:59 -04:00
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
2022-10-15 16:33:14 -07:00
|
|
|
#include <span>
|
|
|
|
|
|
2023-08-29 16:16:15 -04:00
|
|
|
#include <wpi/SmallSet.h>
|
2019-08-25 23:55:59 -04:00
|
|
|
|
2023-07-14 01:12:01 -04:00
|
|
|
#include "frc2/command/Command.h"
|
2019-11-05 20:52:49 -08:00
|
|
|
#include "frc2/command/CommandHelper.h"
|
2019-08-25 23:55:59 -04:00
|
|
|
|
|
|
|
|
namespace frc2 {
|
|
|
|
|
/**
|
2022-12-07 07:13:31 +02:00
|
|
|
* Schedules the given commands when this command is initialized. Useful for
|
|
|
|
|
* forking off from CommandGroups. Note that if run from a composition, the
|
|
|
|
|
* composition will not know about the status of the scheduled commands, and
|
|
|
|
|
* will treat this command as finishing instantly.
|
2022-01-08 11:11:34 -08:00
|
|
|
*
|
|
|
|
|
* This class is provided by the NewCommands VendorDep
|
2019-08-25 23:55:59 -04:00
|
|
|
*/
|
2023-07-14 01:12:01 -04:00
|
|
|
class ScheduleCommand : public CommandHelper<Command, ScheduleCommand> {
|
2019-08-25 23:55:59 -04:00
|
|
|
public:
|
|
|
|
|
/**
|
|
|
|
|
* Creates a new ScheduleCommand that schedules the given commands when
|
|
|
|
|
* initialized.
|
|
|
|
|
*
|
|
|
|
|
* @param toSchedule the commands to schedule
|
|
|
|
|
*/
|
2022-10-15 16:33:14 -07:00
|
|
|
explicit ScheduleCommand(std::span<Command* const> toSchedule);
|
2021-06-06 19:51:14 -07:00
|
|
|
|
|
|
|
|
explicit ScheduleCommand(Command* toSchedule);
|
2019-08-25 23:55:59 -04:00
|
|
|
|
|
|
|
|
ScheduleCommand(ScheduleCommand&& other) = default;
|
|
|
|
|
|
|
|
|
|
ScheduleCommand(const ScheduleCommand& other) = default;
|
|
|
|
|
|
|
|
|
|
void Initialize() override;
|
|
|
|
|
|
|
|
|
|
bool IsFinished() override;
|
|
|
|
|
|
|
|
|
|
bool RunsWhenDisabled() const override;
|
|
|
|
|
|
|
|
|
|
private:
|
2023-08-29 16:16:15 -04:00
|
|
|
wpi::SmallSet<Command*, 4> m_toSchedule;
|
2019-08-25 23:55:59 -04:00
|
|
|
};
|
|
|
|
|
} // namespace frc2
|