WPILibC++ 2027.0.0-alpha-4
Loading...
Searching...
No Matches
SubsystemBase.hpp
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 <string>
8#include <string_view>
9
13
14namespace wpi::cmd {
15/**
16 * A base for subsystems that handles registration in the constructor, and
17 * provides a more intuitive method for setting the default command.
18 *
19 * This class is provided by the NewCommands VendorDep
20 */
21class SubsystemBase : public Subsystem,
23 public wpi::util::SendableHelper<SubsystemBase> {
24 public:
26
27 /**
28 * Gets the name of this Subsystem.
29 *
30 * @return Name
31 */
32 std::string GetName() const override;
33
34 /**
35 * Sets the name of this Subsystem.
36 *
37 * @param name name
38 */
39 void SetName(std::string_view name);
40
41 /**
42 * Gets the subsystem name of this Subsystem.
43 *
44 * @return Subsystem name
45 */
46 std::string GetSubsystem() const;
47
48 /**
49 * Sets the subsystem name of this Subsystem.
50 *
51 * @param name subsystem name
52 */
53 void SetSubsystem(std::string_view name);
54
55 /**
56 * Associate a Sendable with this Subsystem.
57 * Also update the child's name.
58 *
59 * @param name name to give child
60 * @param child sendable
61 */
62 void AddChild(std::string name, wpi::util::Sendable* child);
63
64 protected:
65 /**
66 * Constructor. Telemetry/log name defaults to the classname.
67 */
69 /**
70 * Constructor.
71 *
72 * @param name Name of the subsystem for telemetry and logging.
73 */
74 explicit SubsystemBase(std::string_view name);
75};
76} // namespace wpi::cmd
@ name
Definition base.h:690
SubsystemBase()
Constructor.
void AddChild(std::string name, wpi::util::Sendable *child)
Associate a Sendable with this Subsystem.
void SetSubsystem(std::string_view name)
Sets the subsystem name of this Subsystem.
std::string GetSubsystem() const
Gets the subsystem name of this Subsystem.
void SetName(std::string_view name)
Sets the name of this Subsystem.
void InitSendable(wpi::util::SendableBuilder &builder) override
Initializes this Sendable object.
SubsystemBase(std::string_view name)
Constructor.
std::string GetName() const override
Gets the name of this Subsystem.
A robot subsystem.
Definition Subsystem.hpp:42
Helper class for building Sendable dashboard representations.
Definition SendableBuilder.hpp:21
A helper class for use with objects that add themselves to SendableRegistry.
Definition SendableHelper.hpp:21
Interface for Sendable objects.
Definition Sendable.hpp:16
Definition CommandNiDsStadiaController.hpp:15