WPILibC++  unspecified
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Pages
SmartDashboard.h
1 /*----------------------------------------------------------------------------*/
2 /* Copyright (c) FIRST 2011-2016. 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 <map>
11 #include <memory>
12 #include <string>
13 #include <vector>
14 
15 #include "SensorBase.h"
16 #include "SmartDashboard/NamedSendable.h"
17 #include "SmartDashboard/Sendable.h"
18 #include "tables/ITable.h"
19 
20 namespace frc {
21 
22 class SmartDashboard : public SensorBase {
23  public:
24  static void init();
25 
26  static bool ContainsKey(llvm::StringRef key);
27 
28  static std::vector<std::string> GetKeys(int types = 0);
29 
30  static void SetPersistent(llvm::StringRef key);
31  static void ClearPersistent(llvm::StringRef key);
32  static bool IsPersistent(llvm::StringRef key);
33 
34  static void SetFlags(llvm::StringRef key, unsigned int flags);
35  static void ClearFlags(llvm::StringRef key, unsigned int flags);
36  static unsigned int GetFlags(llvm::StringRef key);
37 
38  static void Delete(llvm::StringRef key);
39 
40  static void PutData(llvm::StringRef key, Sendable* data);
41  static void PutData(NamedSendable* value);
42  static Sendable* GetData(llvm::StringRef keyName);
43 
44  static bool PutBoolean(llvm::StringRef keyName, bool value);
45  static bool SetDefaultBoolean(llvm::StringRef key, bool defaultValue);
46  static bool GetBoolean(llvm::StringRef keyName, bool defaultValue);
47 
48  static bool PutNumber(llvm::StringRef keyName, double value);
49  static bool SetDefaultNumber(llvm::StringRef key, double defaultValue);
50  static double GetNumber(llvm::StringRef keyName, double defaultValue);
51 
52  static bool PutString(llvm::StringRef keyName, llvm::StringRef value);
53  static bool SetDefaultString(llvm::StringRef key,
54  llvm::StringRef defaultValue);
55  static std::string GetString(llvm::StringRef keyName,
56  llvm::StringRef defaultValue);
57 
58  static bool PutBooleanArray(llvm::StringRef key, llvm::ArrayRef<int> value);
59  static bool SetDefaultBooleanArray(llvm::StringRef key,
60  llvm::ArrayRef<int> defaultValue);
61  static std::vector<int> GetBooleanArray(llvm::StringRef key,
62  llvm::ArrayRef<int> defaultValue);
63 
64  static bool PutNumberArray(llvm::StringRef key, llvm::ArrayRef<double> value);
65  static bool SetDefaultNumberArray(llvm::StringRef key,
66  llvm::ArrayRef<double> defaultValue);
67  static std::vector<double> GetNumberArray(
68  llvm::StringRef key, llvm::ArrayRef<double> defaultValue);
69 
70  static bool PutStringArray(llvm::StringRef key,
71  llvm::ArrayRef<std::string> value);
72  static bool SetDefaultStringArray(llvm::StringRef key,
73  llvm::ArrayRef<std::string> defaultValue);
74  static std::vector<std::string> GetStringArray(
75  llvm::StringRef key, llvm::ArrayRef<std::string> defaultValue);
76 
77  static bool PutRaw(llvm::StringRef key, llvm::StringRef value);
78  static bool SetDefaultRaw(llvm::StringRef key, llvm::StringRef defaultValue);
79  static std::string GetRaw(llvm::StringRef key, llvm::StringRef defaultValue);
80 
81  static bool PutValue(llvm::StringRef keyName,
82  std::shared_ptr<nt::Value> value);
83  static bool SetDefaultValue(llvm::StringRef key,
84  std::shared_ptr<nt::Value> defaultValue);
85  static std::shared_ptr<nt::Value> GetValue(llvm::StringRef keyName);
86 
87  private:
88  virtual ~SmartDashboard() = default;
89 
91  static std::shared_ptr<ITable> m_table;
92 
97  static std::map<std::shared_ptr<ITable>, Sendable*> m_tablesToData;
98 };
99 
100 } // namespace frc
static bool PutBooleanArray(llvm::StringRef key, llvm::ArrayRef< int > value)
Put a boolean array in the table.
Definition: SmartDashboard.cpp:324
static Sendable * GetData(llvm::StringRef keyName)
Returns the value at the specified key.
Definition: SmartDashboard.cpp:155
static bool PutString(llvm::StringRef keyName, llvm::StringRef value)
Maps the specified key to the specified value in this table.
Definition: SmartDashboard.cpp:286
static bool SetDefaultString(llvm::StringRef key, llvm::StringRef defaultValue)
Gets the current value in the table, setting it if it does not exist.
Definition: SmartDashboard.cpp:296
static std::vector< std::string > GetStringArray(llvm::StringRef key, llvm::ArrayRef< std::string > defaultValue)
Returns the string array the key maps to.
Definition: SmartDashboard.cpp:431
Base class for all sensors.
Definition: SensorBase.h:22
static double GetNumber(llvm::StringRef keyName, double defaultValue)
Returns the value at the specified key.
Definition: SmartDashboard.cpp:272
static bool SetDefaultBoolean(llvm::StringRef key, bool defaultValue)
Gets the current value in the table, setting it if it does not exist.
Definition: SmartDashboard.cpp:223
static unsigned int GetFlags(llvm::StringRef key)
Returns the flags for the specified key.
Definition: SmartDashboard.cpp:101
static std::vector< std::string > GetKeys(int types=0)
Definition: SmartDashboard.cpp:40
static bool PutStringArray(llvm::StringRef key, llvm::ArrayRef< std::string > value)
Put a string array in the table.
Definition: SmartDashboard.cpp:404
static std::vector< int > GetBooleanArray(llvm::StringRef key, llvm::ArrayRef< int > defaultValue)
Returns the boolean array the key maps to.
Definition: SmartDashboard.cpp:355
static std::string GetString(llvm::StringRef keyName, llvm::StringRef defaultValue)
Returns the value at the specified key.
Definition: SmartDashboard.cpp:309
static void SetFlags(llvm::StringRef key, unsigned int flags)
Sets flags on the specified key in this table.
Definition: SmartDashboard.cpp:80
static bool SetDefaultRaw(llvm::StringRef key, llvm::StringRef defaultValue)
Gets the current value in the table, setting it if it does not exist.
Definition: SmartDashboard.cpp:452
static void PutData(llvm::StringRef key, Sendable *data)
Maps the specified key to the specified value in this table.
Definition: SmartDashboard.cpp:121
static bool IsPersistent(llvm::StringRef key)
Returns whether the value is persistent through program restarts.
Definition: SmartDashboard.cpp:69
static bool PutBoolean(llvm::StringRef keyName, bool value)
Maps the specified key to the specified value in this table.
Definition: SmartDashboard.cpp:213
static std::vector< double > GetNumberArray(llvm::StringRef key, llvm::ArrayRef< double > defaultValue)
Returns the number array the key maps to.
Definition: SmartDashboard.cpp:393
static void SetPersistent(llvm::StringRef key)
Makes a key's value persistent through program restarts.
Definition: SmartDashboard.cpp:49
static bool ContainsKey(llvm::StringRef key)
Determines whether the given key is in this table.
Definition: SmartDashboard.cpp:32
static bool PutRaw(llvm::StringRef key, llvm::StringRef value)
Put a raw value (byte array) in the table.
Definition: SmartDashboard.cpp:442
static void ClearFlags(llvm::StringRef key, unsigned int flags)
Clears flags on the specified key in this table.
Definition: SmartDashboard.cpp:91
static bool SetDefaultBooleanArray(llvm::StringRef key, llvm::ArrayRef< int > defaultValue)
Gets the current value in the table, setting it if it does not exist.
Definition: SmartDashboard.cpp:335
static void Delete(llvm::StringRef key)
Deletes the specified key in this table.
Definition: SmartDashboard.cpp:110
static bool SetDefaultValue(llvm::StringRef key, std::shared_ptr< nt::Value > defaultValue)
Gets the current value in the table, setting it if it does not exist.
Definition: SmartDashboard.cpp:187
static bool PutNumber(llvm::StringRef keyName, double value)
Maps the specified key to the specified value in this table.
Definition: SmartDashboard.cpp:249
static bool GetBoolean(llvm::StringRef keyName, bool defaultValue)
Returns the value at the specified key.
Definition: SmartDashboard.cpp:235
static std::string GetRaw(llvm::StringRef key, llvm::StringRef defaultValue)
Returns the raw value (byte array) the key maps to.
Definition: SmartDashboard.cpp:468
Definition: SmartDashboard.h:22
static bool PutValue(llvm::StringRef keyName, std::shared_ptr< nt::Value > value)
Maps the specified key to the specified complex value (such as an array) in this table.
Definition: SmartDashboard.cpp:176
static bool SetDefaultNumber(llvm::StringRef key, double defaultValue)
Gets the current value in the table, setting it if it does not exist.
Definition: SmartDashboard.cpp:259
Definition: Sendable.h:17
static std::shared_ptr< nt::Value > GetValue(llvm::StringRef keyName)
Retrieves the complex value (such as an array) in this table into the complex data object...
Definition: SmartDashboard.cpp:199
static bool SetDefaultNumberArray(llvm::StringRef key, llvm::ArrayRef< double > defaultValue)
Gets the current value in the table, setting it if it does not exist.
Definition: SmartDashboard.cpp:377
static void ClearPersistent(llvm::StringRef key)
Stop making a key's value persistent through program restarts.
Definition: SmartDashboard.cpp:59
static bool PutNumberArray(llvm::StringRef key, llvm::ArrayRef< double > value)
Put a number array in the table.
Definition: SmartDashboard.cpp:366
The interface for sendable objects that gives the sendable a default name in the Smart Dashboard...
Definition: NamedSendable.h:21
static bool SetDefaultStringArray(llvm::StringRef key, llvm::ArrayRef< std::string > defaultValue)
Gets the current value in the table, setting it if it does not exist.
Definition: SmartDashboard.cpp:415