WPILibC++  2018.4.1-20180928043320-1211-g175c6c1
 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, wpi::ArrayRef<bool> defaultValue);
153 
164  SimpleWidget& Add(const wpi::Twine& title,
165  wpi::ArrayRef<double> defaultValue);
166 
177  SimpleWidget& Add(const wpi::Twine& title,
178  wpi::ArrayRef<std::string> defaultValue);
179 
192  SimpleWidget& AddPersistent(const wpi::Twine& title,
193  std::shared_ptr<nt::Value> defaultValue);
194 
207  SimpleWidget& AddPersistent(const wpi::Twine& title, bool defaultValue);
208 
221  SimpleWidget& AddPersistent(const wpi::Twine& title, double defaultValue);
222 
235  SimpleWidget& AddPersistent(const wpi::Twine& title, int defaultValue);
236 
249  SimpleWidget& AddPersistent(const wpi::Twine& title,
250  const wpi::Twine& defaultValue);
251 
264  SimpleWidget& AddPersistent(const wpi::Twine& title,
265  wpi::ArrayRef<bool> defaultValue);
266 
279  SimpleWidget& AddPersistent(const wpi::Twine& title,
280  wpi::ArrayRef<double> defaultValue);
281 
294  SimpleWidget& AddPersistent(const wpi::Twine& title,
295  wpi::ArrayRef<std::string> defaultValue);
296 
297  void EnableIfActuator() override;
298 
299  void DisableIfActuator() override;
300 
301  protected:
302  bool m_isLayout = false;
303 
304  private:
305  wpi::SmallSet<std::string, 32> m_usedTitles;
306  std::vector<std::unique_ptr<ShuffleboardComponentBase>> m_components;
308 
314  void CheckTitle(const wpi::Twine& title);
315 
316  friend class SimpleWidget;
317 };
318 
319 } // namespace frc
320 
321 // Make use of references returned by member functions usable
322 #include "frc/shuffleboard/ComplexWidget.h"
323 #include "frc/shuffleboard/ShuffleboardLayout.h"
324 #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