WPILibC++  2019.1.1-beta-2-14-gdf347e3
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Modules Pages
SendableBase.h
1 /*----------------------------------------------------------------------------*/
2 /* Copyright (c) 2017-2018 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 <memory>
11 #include <string>
12 
13 #include <wpi/mutex.h>
14 
15 #include "frc/smartdashboard/Sendable.h"
16 
17 namespace frc {
18 
19 class SendableBase : public Sendable {
20  public:
26  explicit SendableBase(bool addLiveWindow = true);
27 
28  ~SendableBase() override;
29 
31  SendableBase& operator=(SendableBase&& rhs);
32 
33  using Sendable::SetName;
34 
35  std::string GetName() const final;
36  void SetName(const wpi::Twine& name) final;
37  std::string GetSubsystem() const final;
38  void SetSubsystem(const wpi::Twine& subsystem) final;
39 
40  protected:
46  void AddChild(std::shared_ptr<Sendable> child);
47 
53  void AddChild(void* child);
54 
62  void SetName(const wpi::Twine& moduleType, int channel);
63 
73  void SetName(const wpi::Twine& moduleType, int moduleNumber, int channel);
74 
75  private:
76  mutable wpi::mutex m_mutex;
77  std::string m_name;
78  std::string m_subsystem = "Ungrouped";
79 };
80 
81 } // namespace frc
WPILib FRC namespace.
Definition: SPIAccelerometerSim.h:18
SendableBase(bool addLiveWindow=true)
Creates an instance of the sensor base.
std::string GetName() const final
Gets the name of this Sendable object.
virtual void SetName(const wpi::Twine &name)=0
Sets the name of this Sendable object.
void SetSubsystem(const wpi::Twine &subsystem) final
Sets the subsystem name of this Sendable object.
void AddChild(std::shared_ptr< Sendable > child)
Add a child component.
Definition: SendableBase.h:19
void SetName(const wpi::Twine &name) final
Sets the name of this Sendable object.
Definition: Sendable.h:18
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
Definition: Twine.h:79
std::string GetSubsystem() const final
Gets the subsystem name of this Sendable object.