WPILibC++  2020.3.2-60-g3011ebe
CommandBase.h
1 /*----------------------------------------------------------------------------*/
2 /* Copyright (c) 2019-2020 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 <initializer_list>
11 #include <string>
12 
13 #include <frc/smartdashboard/Sendable.h>
14 #include <frc/smartdashboard/SendableHelper.h>
15 #include <wpi/ArrayRef.h>
16 #include <wpi/SmallSet.h>
17 #include <wpi/Twine.h>
18 
19 #include "frc2/command/Command.h"
20 
21 namespace frc2 {
25 class CommandBase : public Command,
26  public frc::Sendable,
27  public frc::SendableHelper<CommandBase> {
28  public:
34  void AddRequirements(std::initializer_list<Subsystem*> requirements);
35 
41  void AddRequirements(wpi::ArrayRef<Subsystem*> requirements);
42 
44 
46 
52  void SetName(const wpi::Twine& name);
53 
59  std::string GetName() const override;
60 
66  std::string GetSubsystem() const;
67 
73  void SetSubsystem(const wpi::Twine& subsystem);
74 
75  void InitSendable(frc::SendableBuilder& builder) override;
76 
77  protected:
78  CommandBase();
79  wpi::SmallSet<Subsystem*, 4> m_requirements;
80 };
81 } // namespace frc2
frc2::CommandBase::GetSubsystem
std::string GetSubsystem() const
Gets the subsystem name of this Command.
wpi::ArrayRef
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
Definition: ArrayRef.h:42
frc2::CommandBase::GetRequirements
wpi::SmallSet< Subsystem *, 4 > GetRequirements() const override
Specifies the set of subsystems used by this command.
frc2::Command
A state machine representing a complete action to be performed by the robot.
Definition: Command.h:52
wpi::SmallSet
SmallSet - This maintains a set of unique values, optimizing for the case when the set is small (less...
Definition: SmallSet.h:135
frc2::CommandBase::SetSubsystem
void SetSubsystem(const wpi::Twine &subsystem)
Sets the subsystem name of this Command.
frc2::CommandBase::InitSendable
void InitSendable(frc::SendableBuilder &builder) override
Initializes this Sendable object.
frc2::CommandBase::AddRequirements
void AddRequirements(std::initializer_list< Subsystem * > requirements)
Adds the specified requirements to the command.
frc::Sendable
Interface for Sendable objects.
Definition: Sendable.h:17
frc2::CommandBase
A Sendable base class for Commands.
Definition: CommandBase.h:25
frc2::CommandBase::GetName
std::string GetName() const override
Gets the name of this Command.
wpi::Twine
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
Definition: Twine.h:85
frc::SendableHelper
A helper class for use with objects that add themselves to SendableRegistry.
Definition: SendableHelper.h:28
frc::SendableBuilder
Definition: SendableBuilder.h:23
frc2::CommandBase::SetName
void SetName(const wpi::Twine &name)
Sets the name of this Command.