WPILibC++  2019.1.1-beta-4-28-g80f87ff
 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/LayoutType.h"
24 #include "frc/shuffleboard/ShuffleboardComponentBase.h"
25 #include "frc/shuffleboard/ShuffleboardValue.h"
26 
27 namespace cs {
28 class VideoSource;
29 } // namespace cs
30 
31 namespace frc {
32 
33 class ComplexWidget;
34 class Sendable;
35 class ShuffleboardLayout;
36 class SimpleWidget;
37 
42  public ErrorBase {
43  public:
44  explicit ShuffleboardContainer(const wpi::Twine& title);
45 
47 
48  virtual ~ShuffleboardContainer() = default;
49 
53  const std::vector<std::unique_ptr<ShuffleboardComponentBase>>& GetComponents()
54  const;
55 
65  const LayoutType& type);
66 
81  const wpi::Twine& type);
82 
99 
109  ComplexWidget& Add(const wpi::Twine& title, Sendable& sendable);
110 
120  ComplexWidget& Add(const wpi::Twine& title, const cs::VideoSource& video);
121 
131  ComplexWidget& Add(Sendable& sendable);
132 
141  ComplexWidget& Add(const cs::VideoSource& video);
142 
153  SimpleWidget& Add(const wpi::Twine& title,
154  std::shared_ptr<nt::Value> defaultValue);
155 
166  SimpleWidget& Add(const wpi::Twine& title, bool defaultValue);
167 
178  SimpleWidget& Add(const wpi::Twine& title, double defaultValue);
179 
190  SimpleWidget& Add(const wpi::Twine& title, int defaultValue);
191 
202  SimpleWidget& Add(const wpi::Twine& title, const wpi::Twine& defaultValue);
203 
214  SimpleWidget& Add(const wpi::Twine& title, const char* defaultValue);
215 
226  SimpleWidget& Add(const wpi::Twine& title, wpi::ArrayRef<bool> defaultValue);
227 
238  SimpleWidget& Add(const wpi::Twine& title,
239  wpi::ArrayRef<double> defaultValue);
240 
251  SimpleWidget& Add(const wpi::Twine& title,
252  wpi::ArrayRef<std::string> defaultValue);
253 
266  SimpleWidget& AddPersistent(const wpi::Twine& title,
267  std::shared_ptr<nt::Value> defaultValue);
268 
281  SimpleWidget& AddPersistent(const wpi::Twine& title, bool defaultValue);
282 
295  SimpleWidget& AddPersistent(const wpi::Twine& title, double defaultValue);
296 
309  SimpleWidget& AddPersistent(const wpi::Twine& title, int defaultValue);
310 
323  SimpleWidget& AddPersistent(const wpi::Twine& title,
324  const wpi::Twine& defaultValue);
325 
338  SimpleWidget& AddPersistent(const wpi::Twine& title,
339  wpi::ArrayRef<bool> defaultValue);
340 
353  SimpleWidget& AddPersistent(const wpi::Twine& title,
354  wpi::ArrayRef<double> defaultValue);
355 
368  SimpleWidget& AddPersistent(const wpi::Twine& title,
369  wpi::ArrayRef<std::string> defaultValue);
370 
371  void EnableIfActuator() override;
372 
373  void DisableIfActuator() override;
374 
375  protected:
376  bool m_isLayout = false;
377 
378  private:
379  wpi::SmallSet<std::string, 32> m_usedTitles;
380  std::vector<std::unique_ptr<ShuffleboardComponentBase>> m_components;
382 
388  void CheckTitle(const wpi::Twine& title);
389 
390  friend class SimpleWidget;
391 };
392 
393 } // namespace frc
394 
395 // Make use of references returned by member functions usable
396 #include "frc/shuffleboard/ComplexWidget.h"
397 #include "frc/shuffleboard/ShuffleboardLayout.h"
398 #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.
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
ShuffleboardLayout & GetLayout(const wpi::Twine &title, const LayoutType &type)
Gets the layout with the given type and title, creating it if it does not already exist at the time t...
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:41