blob: 51e51d1ae5d14c1db702be2760e1f2327f2e8a7b [file] [log] [blame]
Brian Silverman26e4e522015-12-17 01:56:40 -05001/*----------------------------------------------------------------------------*/
Brian Silverman1a675112016-02-20 20:42:49 -05002/* Copyright (c) FIRST 2011-2016. All Rights Reserved. */
Brian Silverman26e4e522015-12-17 01:56:40 -05003/* Open Source Software - may be modified and shared by FRC teams. The code */
Brian Silverman1a675112016-02-20 20:42:49 -05004/* must be accompanied by the FIRST BSD license file in the root directory of */
5/* the project. */
Brian Silverman26e4e522015-12-17 01:56:40 -05006/*----------------------------------------------------------------------------*/
7
8#ifndef __SMART_DASHBOARD_H__
9#define __SMART_DASHBOARD_H__
10
11#include "SensorBase.h"
12#include <map>
13#include <string>
14#include "SmartDashboard/Sendable.h"
15#include "SmartDashboard/NamedSendable.h"
16#include "tables/ITable.h"
17
18class SmartDashboard : public SensorBase {
19 public:
20 static void init();
21
22 static void PutData(llvm::StringRef key, Sendable *data);
23 static void PutData(NamedSendable *value);
24 static Sendable *GetData(llvm::StringRef keyName);
25
26 static void PutBoolean(llvm::StringRef keyName, bool value);
27 static bool GetBoolean(llvm::StringRef keyName, bool defaultValue);
28
29 static void PutNumber(llvm::StringRef keyName, double value);
30 static double GetNumber(llvm::StringRef keyName, double defaultValue);
31
32 static void PutString(llvm::StringRef keyName, llvm::StringRef value);
33 static std::string GetString(llvm::StringRef keyName,
34 llvm::StringRef defaultValue);
35
36 static void PutValue(llvm::StringRef keyName,
37 std::shared_ptr<nt::Value> value);
38 static std::shared_ptr<nt::Value> GetValue(llvm::StringRef keyName);
39
40 private:
41 virtual ~SmartDashboard() = default;
42
43 /** The {@link NetworkTable} used by {@link SmartDashboard} */
44 static std::shared_ptr<ITable> m_table;
45
46 /**
47 * A map linking tables in the SmartDashboard to the {@link
48 * SmartDashboardData} objects
49 * they came from.
50 */
51 static std::map<std::shared_ptr<ITable> , Sendable *> m_tablesToData;
52};
53
54#endif