WPILibC++  2019.4.1-3-g655763a
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Modules Pages
ShuffleboardWidget.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 <wpi/Twine.h>
11 
12 #include "frc/shuffleboard/BuiltInWidgets.h"
13 #include "frc/shuffleboard/ShuffleboardComponent.h"
14 #include "frc/shuffleboard/WidgetType.h"
15 
16 namespace frc {
17 
18 class ShuffleboardContainer;
19 
20 namespace detail {
21 const char* GetStringForWidgetType(BuiltInWidgets type);
22 } // namespace detail
23 
31 template <typename Derived>
32 class ShuffleboardWidget : public ShuffleboardComponent<Derived> {
33  public:
35  : ShuffleboardValue(title),
36  ShuffleboardComponent<Derived>(parent, title) {}
37 
46  Derived& WithWidget(BuiltInWidgets widgetType) {
47  return WithWidget(detail::GetStringForWidgetType(widgetType));
48  }
49 
57  Derived& WithWidget(const WidgetType& widgetType) {
58  return WithWidget(widgetType.GetWidgetName());
59  }
60 
72  Derived& WithWidget(const wpi::Twine& widgetType) {
73  this->SetType(widgetType);
74  return *static_cast<Derived*>(this);
75  }
76 };
77 
78 } // namespace frc
WPILib FRC namespace.
Definition: SPIAccelerometerSim.h:18
Derived & WithWidget(const WidgetType &widgetType)
Sets the type of widget used to display the data.
Definition: ShuffleboardWidget.h:57
A generic component in Shuffleboard.
Definition: ShuffleboardComponent.h:30
BuiltInWidgets
The types of the widgets bundled with Shuffleboard.
Definition: BuiltInWidgets.h:28
Derived & WithWidget(const wpi::Twine &widgetType)
Sets the type of widget used to display the data.
Definition: ShuffleboardWidget.h:72
wpi::StringRef GetWidgetName() const
Gets the string type of the widget as defined by that widget in Shuffleboard.
Definition: ShuffleboardValue.h:19
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
Definition: Twine.h:79
Common interface for objects that can contain shuffleboard components.
Definition: ShuffleboardContainer.h:42
Represents the type of a widget in Shuffleboard.
Definition: WidgetType.h:21
Derived & WithWidget(BuiltInWidgets widgetType)
Sets the type of widget used to display the data.
Definition: ShuffleboardWidget.h:46
Abstract superclass for widgets.
Definition: ShuffleboardWidget.h:32