WPILibC++  2019.1.1-2-g444b899
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Modules Pages
SmartDashboard.h
1 /*----------------------------------------------------------------------------*/
2 /* Copyright (c) 2011-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/NetworkTableValue.h>
15 
16 #include "frc/ErrorBase.h"
17 #include "frc/smartdashboard/SendableBase.h"
18 
19 namespace frc {
20 
21 class Sendable;
22 
23 class SmartDashboard : public ErrorBase, public SendableBase {
24  public:
25  static void init();
26 
33  static bool ContainsKey(wpi::StringRef key);
34 
39  static std::vector<std::string> GetKeys(int types = 0);
40 
46  static void SetPersistent(wpi::StringRef key);
47 
54  static void ClearPersistent(wpi::StringRef key);
55 
62  static bool IsPersistent(wpi::StringRef key);
63 
71  static void SetFlags(wpi::StringRef key, unsigned int flags);
72 
80  static void ClearFlags(wpi::StringRef key, unsigned int flags);
81 
88  static unsigned int GetFlags(wpi::StringRef key);
89 
95  static void Delete(wpi::StringRef key);
96 
106  static void PutData(wpi::StringRef key, Sendable* data);
107 
117  static void PutData(Sendable* value);
118 
125  static Sendable* GetData(wpi::StringRef keyName);
126 
137  static bool PutBoolean(wpi::StringRef keyName, bool value);
138 
145  static bool SetDefaultBoolean(wpi::StringRef key, bool defaultValue);
146 
155  static bool GetBoolean(wpi::StringRef keyName, bool defaultValue);
156 
167  static bool PutNumber(wpi::StringRef keyName, double value);
168 
176  static bool SetDefaultNumber(wpi::StringRef key, double defaultValue);
177 
186  static double GetNumber(wpi::StringRef keyName, double defaultValue);
187 
198  static bool PutString(wpi::StringRef keyName, wpi::StringRef value);
199 
207  static bool SetDefaultString(wpi::StringRef key, wpi::StringRef defaultValue);
208 
217  static std::string GetString(wpi::StringRef keyName,
218  wpi::StringRef defaultValue);
219 
231  static bool PutBooleanArray(wpi::StringRef key, wpi::ArrayRef<int> value);
232 
240  static bool SetDefaultBooleanArray(wpi::StringRef key,
241  wpi::ArrayRef<int> defaultValue);
242 
261  static std::vector<int> GetBooleanArray(wpi::StringRef key,
262  wpi::ArrayRef<int> defaultValue);
263 
271  static bool PutNumberArray(wpi::StringRef key, wpi::ArrayRef<double> value);
272 
280  static bool SetDefaultNumberArray(wpi::StringRef key,
281  wpi::ArrayRef<double> defaultValue);
282 
297  static std::vector<double> GetNumberArray(wpi::StringRef key,
298  wpi::ArrayRef<double> defaultValue);
299 
307  static bool PutStringArray(wpi::StringRef key,
309 
317  static bool SetDefaultStringArray(wpi::StringRef key,
318  wpi::ArrayRef<std::string> defaultValue);
319 
334  static std::vector<std::string> GetStringArray(
335  wpi::StringRef key, wpi::ArrayRef<std::string> defaultValue);
336 
344  static bool PutRaw(wpi::StringRef key, wpi::StringRef value);
345 
353  static bool SetDefaultRaw(wpi::StringRef key, wpi::StringRef defaultValue);
354 
369  static std::string GetRaw(wpi::StringRef key, wpi::StringRef defaultValue);
370 
382  static bool PutValue(wpi::StringRef keyName,
383  std::shared_ptr<nt::Value> value);
384 
392  static bool SetDefaultValue(wpi::StringRef key,
393  std::shared_ptr<nt::Value> defaultValue);
394 
402  static std::shared_ptr<nt::Value> GetValue(wpi::StringRef keyName);
403 
407  static void UpdateValues();
408 
409  private:
410  virtual ~SmartDashboard() = default;
411 };
412 
413 } // namespace frc
static bool IsPersistent(wpi::StringRef key)
Returns whether the value is persistent through program restarts.
static bool PutStringArray(wpi::StringRef key, wpi::ArrayRef< std::string > value)
Put a string array in the table.
WPILib FRC namespace.
Definition: SPIAccelerometerSim.h:18
static void SetFlags(wpi::StringRef key, unsigned int flags)
Sets flags on the specified key in this table.
static bool SetDefaultBooleanArray(wpi::StringRef key, wpi::ArrayRef< int > defaultValue)
Gets the current value in the table, setting it if it does not exist.
static void ClearPersistent(wpi::StringRef key)
Stop making a key's value persistent through program restarts.
static bool SetDefaultRaw(wpi::StringRef key, wpi::StringRef defaultValue)
Gets the current value in the table, setting it if it does not exist.
static bool PutBoolean(wpi::StringRef keyName, bool value)
Maps the specified key to the specified value in this table.
static std::vector< std::string > GetStringArray(wpi::StringRef key, wpi::ArrayRef< std::string > defaultValue)
Returns the string array the key maps to.
static bool SetDefaultBoolean(wpi::StringRef key, bool defaultValue)
Gets the current value in the table, setting it if it does not exist.
static void UpdateValues()
Puts all sendable data to the dashboard.
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory)...
Definition: ArrayRef.h:41
static std::vector< std::string > GetKeys(int types=0)
static bool PutValue(wpi::StringRef keyName, std::shared_ptr< nt::Value > value)
Maps the specified key to the specified complex value (such as an array) in this table.
static void Delete(wpi::StringRef key)
Deletes the specified key in this table.
static bool SetDefaultStringArray(wpi::StringRef key, wpi::ArrayRef< std::string > defaultValue)
Gets the current value in the table, setting it if it does not exist.
static bool GetBoolean(wpi::StringRef keyName, bool defaultValue)
Returns the value at the specified key.
static std::vector< int > GetBooleanArray(wpi::StringRef key, wpi::ArrayRef< int > defaultValue)
Returns the boolean array the key maps to.
static std::string GetRaw(wpi::StringRef key, wpi::StringRef defaultValue)
Returns the raw value (byte array) the key maps to.
static bool SetDefaultNumberArray(wpi::StringRef key, wpi::ArrayRef< double > defaultValue)
Gets the current value in the table, setting it if it does not exist.
static void ClearFlags(wpi::StringRef key, unsigned int flags)
Clears flags on the specified key in this table.
static bool PutString(wpi::StringRef keyName, wpi::StringRef value)
Maps the specified key to the specified value in this table.
static bool PutBooleanArray(wpi::StringRef key, wpi::ArrayRef< int > value)
Put a boolean array in the table.
static bool SetDefaultString(wpi::StringRef key, wpi::StringRef defaultValue)
Gets the current value in the table, setting it if it does not exist.
static Sendable * GetData(wpi::StringRef keyName)
Returns the value at the specified key.
Base class for most objects.
Definition: ErrorBase.h:74
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:49
Definition: SendableBase.h:19
Definition: SmartDashboard.h:23
static unsigned int GetFlags(wpi::StringRef key)
Returns the flags for the specified key.
static bool ContainsKey(wpi::StringRef key)
Determines whether the given key is in this table.
static std::string GetString(wpi::StringRef keyName, wpi::StringRef defaultValue)
Returns the value at the specified key.
static double GetNumber(wpi::StringRef keyName, double defaultValue)
Returns the value at the specified key.
static bool PutRaw(wpi::StringRef key, wpi::StringRef value)
Put a raw value (byte array) in the table.
static void SetPersistent(wpi::StringRef key)
Makes a key's value persistent through program restarts.
Definition: Sendable.h:18
static std::shared_ptr< nt::Value > GetValue(wpi::StringRef keyName)
Retrieves the complex value (such as an array) in this table into the complex data object...
static bool SetDefaultNumber(wpi::StringRef key, double defaultValue)
Gets the current value in the table, setting it if it does not exist.
static bool PutNumber(wpi::StringRef keyName, double value)
Maps the specified key to the specified value in this table.
static void PutData(wpi::StringRef key, Sendable *data)
Maps the specified key to the specified value in this table.
static bool SetDefaultValue(wpi::StringRef key, std::shared_ptr< nt::Value > defaultValue)
Gets the current value in the table, setting it if it does not exist.
static std::vector< double > GetNumberArray(wpi::StringRef key, wpi::ArrayRef< double > defaultValue)
Returns the number array the key maps to.
static bool PutNumberArray(wpi::StringRef key, wpi::ArrayRef< double > value)
Put a number array in the table.