WPILibC++  2019.1.1-beta-2-44-g608d824
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Modules Pages
ShuffleboardContainer.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 #include <vector>
13 
14 #include <networktables/NetworkTableEntry.h>
15 #include <networktables/NetworkTableValue.h>
16 #include <wpi/ArrayRef.h>
17 #include <wpi/SmallSet.h>
18 #include <wpi/StringMap.h>
19 #include <wpi/Twine.h>
20 
21 #include "frc/shuffleboard/ShuffleboardComponentBase.h"
22 #include "frc/shuffleboard/ShuffleboardValue.h"
23 
24 namespace frc {
25 
26 class ComplexWidget;
27 class Sendable;
28 class ShuffleboardLayout;
29 class SimpleWidget;
30 
34 class ShuffleboardContainer : public virtual ShuffleboardValue {
35  public:
36  explicit ShuffleboardContainer(const wpi::Twine& title);
37 
39 
40  virtual ~ShuffleboardContainer() = default;
41 
45  const std::vector<std::unique_ptr<ShuffleboardComponentBase>>& GetComponents()
46  const;
47 
57  const wpi::Twine& title);
58 
68  ComplexWidget& Add(const wpi::Twine& title, Sendable& sendable);
69 
79  ComplexWidget& Add(Sendable& sendable);
80 
91  SimpleWidget& Add(const wpi::Twine& title,
92  std::shared_ptr<nt::Value> defaultValue);
93 
104  SimpleWidget& Add(const wpi::Twine& title, bool defaultValue);
105 
116  SimpleWidget& Add(const wpi::Twine& title, double defaultValue);
117 
128  SimpleWidget& Add(const wpi::Twine& title, int defaultValue);
129 
140  SimpleWidget& Add(const wpi::Twine& title, const wpi::Twine& defaultValue);
141 
152  SimpleWidget& Add(const wpi::Twine& title, const char* defaultValue);
153 
164  SimpleWidget& Add(const wpi::Twine& title, wpi::ArrayRef<bool> defaultValue);
165 
176  SimpleWidget& Add(const wpi::Twine& title,
177  wpi::ArrayRef<double> defaultValue);
178 
189  SimpleWidget& Add(const wpi::Twine& title,
190  wpi::ArrayRef<std::string> defaultValue);
191 
204  SimpleWidget& AddPersistent(const wpi::Twine& title,
205  std::shared_ptr<nt::Value> defaultValue);
206 
219  SimpleWidget& AddPersistent(const wpi::Twine& title, bool defaultValue);
220 
233  SimpleWidget& AddPersistent(const wpi::Twine& title, double defaultValue);
234 
247  SimpleWidget& AddPersistent(const wpi::Twine& title, int defaultValue);
248 
261  SimpleWidget& AddPersistent(const wpi::Twine& title,
262  const wpi::Twine& defaultValue);
263 
276  SimpleWidget& AddPersistent(const wpi::Twine& title,
277  wpi::ArrayRef<bool> defaultValue);
278 
291  SimpleWidget& AddPersistent(const wpi::Twine& title,
292  wpi::ArrayRef<double> defaultValue);
293 
306  SimpleWidget& AddPersistent(const wpi::Twine& title,
307  wpi::ArrayRef<std::string> defaultValue);
308 
309  void EnableIfActuator() override;
310 
311  void DisableIfActuator() override;
312 
313  protected:
314  bool m_isLayout = false;
315 
316  private:
317  wpi::SmallSet<std::string, 32> m_usedTitles;
318  std::vector<std::unique_ptr<ShuffleboardComponentBase>> m_components;
320 
326  void CheckTitle(const wpi::Twine& title);
327 
328  friend class SimpleWidget;
329 };
330 
331 } // namespace frc
332 
333 // Make use of references returned by member functions usable
334 #include "frc/shuffleboard/ComplexWidget.h"
335 #include "frc/shuffleboard/ShuffleboardLayout.h"
336 #include "frc/shuffleboard/SimpleWidget.h"
WPILib FRC namespace.
Definition: SPIAccelerometerSim.h:18
void EnableIfActuator() override
Enables user control of this widget in the Shuffleboard application.
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory)...
Definition: ArrayRef.h:41
A layout in a Shuffleboard tab.
Definition: ShuffleboardLayout.h:25
ShuffleboardLayout & GetLayout(const wpi::Twine &type, const wpi::Twine &title)
Gets the layout with the given type and title, creating it if it does not already exist at the time t...
const std::vector< std::unique_ptr< ShuffleboardComponentBase > > & GetComponents() const
Gets the components that are direct children of this container.
void DisableIfActuator() override
Disables user control of this widget in the Shuffleboard application.
A Shuffleboard widget that handles a single data point such as a number or string.
Definition: SimpleWidget.h:26
SimpleWidget & AddPersistent(const wpi::Twine &title, std::shared_ptr< nt::Value > defaultValue)
Adds a widget to this container to display a simple piece of data.
A Shuffleboard widget that handles a Sendable object such as a speed controller or sensor...
Definition: ComplexWidget.h:28
Definition: ShuffleboardValue.h:19
ComplexWidget & Add(const wpi::Twine &title, Sendable &sendable)
Adds a widget to this container to display the given sendable.
StringMap - This is an unconventional map that is specialized for handling keys that are "strings"...
Definition: StringMap.h:205
Definition: Sendable.h:18
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:34