WPILibC++  2020.3.2
ShuffleboardValue.h
1 /*----------------------------------------------------------------------------*/
2 /* Copyright (c) 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 <networktables/NetworkTable.h>
14 #include <wpi/SmallVector.h>
15 #include <wpi/StringRef.h>
16 
17 namespace frc {
18 
20  public:
21  explicit ShuffleboardValue(const wpi::Twine& title) {
23  m_title = title.toStringRef(storage);
24  }
25 
26  virtual ~ShuffleboardValue() = default;
27 
31  wpi::StringRef GetTitle() const { return m_title; }
32 
46  virtual void BuildInto(std::shared_ptr<nt::NetworkTable> parentTable,
47  std::shared_ptr<nt::NetworkTable> metaTable) = 0;
48 
56  virtual void EnableIfActuator() {}
57 
65  virtual void DisableIfActuator() {}
66 
67  private:
68  std::string m_title;
69 };
70 
71 } // namespace frc
wpi::Twine::toStringRef
StringRef toStringRef(SmallVectorImpl< char > &Out) const
This returns the twine as a single StringRef if it can be represented as such.
Definition: Twine.h:450
frc::ShuffleboardValue
Definition: ShuffleboardValue.h:19
frc::ShuffleboardValue::BuildInto
virtual void BuildInto(std::shared_ptr< nt::NetworkTable > parentTable, std::shared_ptr< nt::NetworkTable > metaTable)=0
Builds the entries for this value.
wpi::StringRef
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:49
frc
A class that enforces constraints on the differential drive kinematics.
Definition: SPIAccelerometerSim.h:16
wpi::SmallVector
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
Definition: SmallVector.h:856
frc::ShuffleboardValue::EnableIfActuator
virtual void EnableIfActuator()
Enables user control of this widget in the Shuffleboard application.
Definition: ShuffleboardValue.h:56
wpi::Twine
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
Definition: Twine.h:85
frc::ShuffleboardValue::GetTitle
wpi::StringRef GetTitle() const
Gets the title of this Shuffleboard value.
Definition: ShuffleboardValue.h:31
frc::ShuffleboardValue::DisableIfActuator
virtual void DisableIfActuator()
Disables user control of this widget in the Shuffleboard application.
Definition: ShuffleboardValue.h:65