WPILibC++  2019.3.1
 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/ErrorBase.h"
22 #include "frc/WPIErrors.h"
23 #include "frc/shuffleboard/BuiltInLayouts.h"
24 #include "frc/shuffleboard/LayoutType.h"
25 #include "frc/shuffleboard/ShuffleboardComponentBase.h"
26 #include "frc/shuffleboard/ShuffleboardValue.h"
27 
28 namespace cs {
29 class VideoSource;
30 } // namespace cs
31 
32 namespace frc {
33 
34 class ComplexWidget;
35 class Sendable;
36 class ShuffleboardLayout;
37 class SimpleWidget;
38 
43  public ErrorBase {
44  public:
45  explicit ShuffleboardContainer(const wpi::Twine& title);
46 
48 
49  virtual ~ShuffleboardContainer() = default;
50 
54  const std::vector<std::unique_ptr<ShuffleboardComponentBase>>& GetComponents()
55  const;
56 
66 
76  const LayoutType& type);
77 
92  const wpi::Twine& type);
93 
109  ShuffleboardLayout& GetLayout(const wpi::Twine& title);
110 
120  ComplexWidget& Add(const wpi::Twine& title, Sendable& sendable);
121 
131  ComplexWidget& Add(const wpi::Twine& title, const cs::VideoSource& video);
132 
142  ComplexWidget& Add(Sendable& sendable);
143 
152  ComplexWidget& Add(const cs::VideoSource& video);
153 
164  SimpleWidget& Add(const wpi::Twine& title,
165  std::shared_ptr<nt::Value> defaultValue);
166 
177  SimpleWidget& Add(const wpi::Twine& title, bool defaultValue);
178 
189  SimpleWidget& Add(const wpi::Twine& title, double defaultValue);
190 
201  SimpleWidget& Add(const wpi::Twine& title, int defaultValue);
202 
213  SimpleWidget& Add(const wpi::Twine& title, const wpi::Twine& defaultValue);
214 
225  SimpleWidget& Add(const wpi::Twine& title, const char* defaultValue);
226 
237  SimpleWidget& Add(const wpi::Twine& title, wpi::ArrayRef<bool> defaultValue);
238 
249  SimpleWidget& Add(const wpi::Twine& title,
250  wpi::ArrayRef<double> defaultValue);
251 
262  SimpleWidget& Add(const wpi::Twine& title,
263  wpi::ArrayRef<std::string> defaultValue);
264 
277  SimpleWidget& AddPersistent(const wpi::Twine& title,
278  std::shared_ptr<nt::Value> defaultValue);
279 
292  SimpleWidget& AddPersistent(const wpi::Twine& title, bool defaultValue);
293 
306  SimpleWidget& AddPersistent(const wpi::Twine& title, double defaultValue);
307 
320  SimpleWidget& AddPersistent(const wpi::Twine& title, int defaultValue);
321 
334  SimpleWidget& AddPersistent(const wpi::Twine& title,
335  const wpi::Twine& defaultValue);
336 
349  SimpleWidget& AddPersistent(const wpi::Twine& title,
350  wpi::ArrayRef<bool> defaultValue);
351 
364  SimpleWidget& AddPersistent(const wpi::Twine& title,
365  wpi::ArrayRef<double> defaultValue);
366 
379  SimpleWidget& AddPersistent(const wpi::Twine& title,
380  wpi::ArrayRef<std::string> defaultValue);
381 
382  void EnableIfActuator() override;
383 
384  void DisableIfActuator() override;
385 
386  protected:
387  bool m_isLayout = false;
388 
389  private:
390  wpi::SmallSet<std::string, 32> m_usedTitles;
391  std::vector<std::unique_ptr<ShuffleboardComponentBase>> m_components;
393 
399  void CheckTitle(const wpi::Twine& title);
400 
401  friend class SimpleWidget;
402 };
403 
404 } // namespace frc
405 
406 // Make use of references returned by member functions usable
407 #include "frc/shuffleboard/ComplexWidget.h"
408 #include "frc/shuffleboard/ShuffleboardLayout.h"
409 #include "frc/shuffleboard/SimpleWidget.h"
WPILib FRC namespace.
Definition: SPIAccelerometerSim.h:18
CameraServer (cscore) namespace.
Definition: cscore_oo.inl:11
A source for video that provides a sequence of frames.
Definition: cscore_oo.h:97
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
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.
BuiltInLayouts
The types of layouts bundled with Shuffleboard.
Definition: BuiltInLayouts.h:22
Represents the type of a layout in Shuffleboard.
Definition: LayoutType.h:21
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
Base class for most objects.
Definition: ErrorBase.h:74
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:42
ShuffleboardLayout & GetLayout(const wpi::Twine &title, BuiltInLayouts type)
Gets the layout with the given type and title, creating it if it does not already exist at the time t...