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>
|
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
|
|
|
|
2019-11-05 20:52:49 -08:00
|
|
|
#include <frc/smartdashboard/Sendable.h>
|
|
|
|
|
#include <frc/smartdashboard/SendableHelper.h>
|
2019-08-25 23:55:59 -04:00
|
|
|
#include <wpi/SmallSet.h>
|
2021-06-06 19:51:14 -07:00
|
|
|
#include <wpi/span.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.
|
|
|
|
|
*/
|
2019-09-14 15:22:54 -05:00
|
|
|
class CommandBase : public Command,
|
|
|
|
|
public frc::Sendable,
|
|
|
|
|
public frc::SendableHelper<CommandBase> {
|
2019-08-25 23:55:59 -04:00
|
|
|
public:
|
|
|
|
|
/**
|
|
|
|
|
* Adds the specified requirements to the command.
|
|
|
|
|
*
|
|
|
|
|
* @param requirements the requirements to add
|
|
|
|
|
*/
|
|
|
|
|
void AddRequirements(std::initializer_list<Subsystem*> requirements);
|
|
|
|
|
|
2020-01-01 20:09:17 -08:00
|
|
|
/**
|
|
|
|
|
* Adds the specified requirements to the command.
|
|
|
|
|
*
|
|
|
|
|
* @param requirements the requirements to add
|
|
|
|
|
*/
|
2021-06-06 19:51:14 -07:00
|
|
|
void AddRequirements(wpi::span<Subsystem* const> requirements);
|
2020-01-01 20:09:17 -08:00
|
|
|
|
2019-08-25 23:55:59 -04:00
|
|
|
void AddRequirements(wpi::SmallSet<Subsystem*, 4> requirements);
|
|
|
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
|
void InitSendable(frc::SendableBuilder& builder) override;
|
|
|
|
|
|
|
|
|
|
protected:
|
|
|
|
|
CommandBase();
|
|
|
|
|
wpi::SmallSet<Subsystem*, 4> m_requirements;
|
|
|
|
|
};
|
|
|
|
|
} // namespace frc2
|