WPILibC++  2019.1.1-beta-4-27-ga2368a6
 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 frc {
28 
29 class ComplexWidget;
30 class Sendable;
31 class ShuffleboardLayout;
32 class SimpleWidget;
33 
38  public ErrorBase {
39  public:
40  explicit ShuffleboardContainer(const wpi::Twine& title);
41 
43 
44  virtual ~ShuffleboardContainer() = default;
45 
49  const std::vector<std::unique_ptr<ShuffleboardComponentBase>>& GetComponents()
50  const;
51 
61  const LayoutType& type);
62 
77  const wpi::Twine& type);
78 
95 
105  ComplexWidget& Add(const wpi::Twine& title, Sendable& sendable);
106 
116  ComplexWidget& Add(Sendable& sendable);
117 
128  SimpleWidget& Add(const wpi::Twine& title,
129  std::shared_ptr<nt::Value> defaultValue);
130 
141  SimpleWidget& Add(const wpi::Twine& title, bool defaultValue);
142 
153  SimpleWidget& Add(const wpi::Twine& title, double defaultValue);
154 
165  SimpleWidget& Add(const wpi::Twine& title, int defaultValue);
166 
177  SimpleWidget& Add(const wpi::Twine& title, const wpi::Twine& defaultValue);
178 
189  SimpleWidget& Add(const wpi::Twine& title, const char* defaultValue);
190 
201  SimpleWidget& Add(const wpi::Twine& title, wpi::ArrayRef<bool> defaultValue);
202 
213  SimpleWidget& Add(const wpi::Twine& title,
214  wpi::ArrayRef<double> defaultValue);
215 
226  SimpleWidget& Add(const wpi::Twine& title,
227  wpi::ArrayRef<std::string> defaultValue);
228 
241  SimpleWidget& AddPersistent(const wpi::Twine& title,
242  std::shared_ptr<nt::Value> defaultValue);
243 
256  SimpleWidget& AddPersistent(const wpi::Twine& title, bool defaultValue);
257 
270  SimpleWidget& AddPersistent(const wpi::Twine& title, double defaultValue);
271 
284  SimpleWidget& AddPersistent(const wpi::Twine& title, int defaultValue);
285 
298  SimpleWidget& AddPersistent(const wpi::Twine& title,
299  const wpi::Twine& defaultValue);
300 
313  SimpleWidget& AddPersistent(const wpi::Twine& title,
314  wpi::ArrayRef<bool> defaultValue);
315 
328  SimpleWidget& AddPersistent(const wpi::Twine& title,
329  wpi::ArrayRef<double> defaultValue);
330 
343  SimpleWidget& AddPersistent(const wpi::Twine& title,
344  wpi::ArrayRef<std::string> defaultValue);
345 
346  void EnableIfActuator() override;
347 
348  void DisableIfActuator() override;
349 
350  protected:
351  bool m_isLayout = false;
352 
353  private:
354  wpi::SmallSet<std::string, 32> m_usedTitles;
355  std::vector<std::unique_ptr<ShuffleboardComponentBase>> m_components;
357 
363  void CheckTitle(const wpi::Twine& title);
364 
365  friend class SimpleWidget;
366 };
367 
368 } // namespace frc
369 
370 // Make use of references returned by member functions usable
371 #include "frc/shuffleboard/ComplexWidget.h"
372 #include "frc/shuffleboard/ShuffleboardLayout.h"
373 #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
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:37