WPILibC++  unspecified
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 <support/mutex.h>
14 
15 #include "Sendable.h"
16 
17 namespace frc {
18 
19 class SendableBase : public Sendable {
20  public:
21  explicit SendableBase(bool addLiveWindow = true);
22  ~SendableBase() override;
23 
24  using Sendable::SetName;
25 
26  std::string GetName() const final;
27  void SetName(const llvm::Twine& name) final;
28  std::string GetSubsystem() const final;
29  void SetSubsystem(const llvm::Twine& subsystem) final;
30 
31  protected:
32  void AddChild(std::shared_ptr<Sendable> child);
33  void AddChild(void* child);
34 
35  void SetName(const llvm::Twine& moduleType, int channel);
36  void SetName(const llvm::Twine& moduleType, int moduleNumber, int channel);
37 
38  private:
39  mutable wpi::mutex m_mutex;
40  std::string m_name;
41  std::string m_subsystem = "Ungrouped";
42 };
43 
44 } // namespace frc
virtual void SetName(const llvm::Twine &name)=0
Sets the name of this Sendable object.
Definition: RobotController.cpp:14
~SendableBase() override
Free the resources used by this object.
Definition: SendableBase.cpp:26
SendableBase(bool addLiveWindow=true)
Creates an instance of the sensor base.
Definition: SendableBase.cpp:19
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
Definition: Twine.h:79
void SetName(const llvm::Twine &name) final
Sets the name of this Sendable object.
Definition: SendableBase.cpp:33
std::string GetSubsystem() const final
Gets the subsystem name of this Sendable object.
Definition: SendableBase.cpp:38
Definition: SendableBase.h:19
void AddChild(std::shared_ptr< Sendable > child)
Add a child component.
Definition: SendableBase.cpp:53
Definition: Sendable.h:18
void SetSubsystem(const llvm::Twine &subsystem) final
Sets the subsystem name of this Sendable object.
Definition: SendableBase.cpp:43
std::string GetName() const final
Gets the name of this Sendable object.
Definition: SendableBase.cpp:28