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
|
|
|
|
|
|
2019-11-05 20:52:49 -08:00
|
|
|
#include <initializer_list>
|
2022-10-15 16:33:14 -07:00
|
|
|
#include <span>
|
2019-08-25 23:55:59 -04:00
|
|
|
#include <string>
|
2021-05-26 17:44:18 -07:00
|
|
|
#include <string_view>
|
2019-08-25 23:55:59 -04:00
|
|
|
|
|
|
|
|
#include <wpi/SmallSet.h>
|
2021-06-13 16:38:05 -07:00
|
|
|
#include <wpi/sendable/Sendable.h>
|
|
|
|
|
#include <wpi/sendable/SendableHelper.h>
|
2019-08-25 23:55:59 -04:00
|
|
|
|
2019-11-05 20:52:49 -08:00
|
|
|
#include "frc2/command/Command.h"
|
2019-08-25 23:55:59 -04:00
|
|
|
|
|
|
|
|
namespace frc2 {
|
|
|
|
|
/**
|
|
|
|
|
* A Sendable base class for Commands.
|
2022-01-08 11:11:34 -08:00
|
|
|
*
|
|
|
|
|
* This class is provided by the NewCommands VendorDep
|
2019-08-25 23:55:59 -04:00
|
|
|
*/
|
2019-09-14 15:22:54 -05:00
|
|
|
class CommandBase : public Command,
|
2021-06-13 16:38:05 -07:00
|
|
|
public wpi::Sendable,
|
|
|
|
|
public wpi::SendableHelper<CommandBase> {
|
2019-08-25 23:55:59 -04:00
|
|
|
public:
|
|
|
|
|
/**
|
2021-10-25 08:57:22 -07:00
|
|
|
* Adds the specified Subsystem requirements to the command.
|
2019-08-25 23:55:59 -04:00
|
|
|
*
|
2021-10-25 08:57:22 -07:00
|
|
|
* @param requirements the Subsystem requirements to add
|
2019-08-25 23:55:59 -04:00
|
|
|
*/
|
|
|
|
|
void AddRequirements(std::initializer_list<Subsystem*> requirements);
|
|
|
|
|
|
2020-01-01 20:09:17 -08:00
|
|
|
/**
|
2021-10-25 08:57:22 -07:00
|
|
|
* Adds the specified Subsystem requirements to the command.
|
2020-01-01 20:09:17 -08:00
|
|
|
*
|
2021-10-25 08:57:22 -07:00
|
|
|
* @param requirements the Subsystem requirements to add
|
2020-01-01 20:09:17 -08:00
|
|
|
*/
|
2022-10-15 16:33:14 -07:00
|
|
|
void AddRequirements(std::span<Subsystem* const> requirements);
|
2020-01-01 20:09:17 -08:00
|
|
|
|
2021-10-25 08:57:22 -07:00
|
|
|
/**
|
|
|
|
|
* Adds the specified Subsystem requirements to the command.
|
|
|
|
|
*
|
|
|
|
|
* @param requirements the Subsystem requirements to add
|
|
|
|
|
*/
|
2019-08-25 23:55:59 -04:00
|
|
|
void AddRequirements(wpi::SmallSet<Subsystem*, 4> requirements);
|
|
|
|
|
|
2021-10-25 08:57:22 -07:00
|
|
|
/**
|
|
|
|
|
* Adds the specified Subsystem requirement to the command.
|
|
|
|
|
*
|
|
|
|
|
* @param requirement the Subsystem requirement to add
|
|
|
|
|
*/
|
|
|
|
|
void AddRequirements(Subsystem* requirement);
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Gets the Subsystem requirements of the command.
|
|
|
|
|
*
|
|
|
|
|
* @return the Command's Subsystem requirements
|
|
|
|
|
*/
|
2019-08-25 23:55:59 -04:00
|
|
|
wpi::SmallSet<Subsystem*, 4> GetRequirements() const override;
|
|
|
|
|
|
2019-09-14 15:22:54 -05:00
|
|
|
/**
|
|
|
|
|
* Sets the name of this Command.
|
|
|
|
|
*
|
|
|
|
|
* @param name name
|
|
|
|
|
*/
|
2021-05-26 17:44:18 -07:00
|
|
|
void SetName(std::string_view name);
|
2019-08-25 23:55:59 -04:00
|
|
|
|
2019-09-14 15:22:54 -05:00
|
|
|
/**
|
|
|
|
|
* Gets the name of this Command.
|
|
|
|
|
*
|
|
|
|
|
* @return Name
|
|
|
|
|
*/
|
2019-08-25 23:55:59 -04:00
|
|
|
std::string GetName() const override;
|
|
|
|
|
|
2019-09-14 15:22:54 -05:00
|
|
|
/**
|
|
|
|
|
* Gets the subsystem name of this Command.
|
|
|
|
|
*
|
|
|
|
|
* @return Subsystem name
|
|
|
|
|
*/
|
|
|
|
|
std::string GetSubsystem() const;
|
2019-08-25 23:55:59 -04:00
|
|
|
|
2019-09-14 15:22:54 -05:00
|
|
|
/**
|
|
|
|
|
* Sets the subsystem name of this Command.
|
|
|
|
|
*
|
|
|
|
|
* @param subsystem subsystem name
|
|
|
|
|
*/
|
2021-05-26 17:44:18 -07:00
|
|
|
void SetSubsystem(std::string_view subsystem);
|
2019-08-25 23:55:59 -04:00
|
|
|
|
2021-06-13 16:38:05 -07:00
|
|
|
void InitSendable(wpi::SendableBuilder& builder) override;
|
2019-08-25 23:55:59 -04:00
|
|
|
|
|
|
|
|
protected:
|
|
|
|
|
CommandBase();
|
|
|
|
|
wpi::SmallSet<Subsystem*, 4> m_requirements;
|
|
|
|
|
};
|
|
|
|
|
} // namespace frc2
|