Brian Silverman | 26e4e52 | 2015-12-17 01:56:40 -0500 | [diff] [blame^] | 1 | /*----------------------------------------------------------------------------*/ |
| 2 | /* Copyright (c) FIRST 2011. All Rights Reserved. |
| 3 | */ |
| 4 | /* Open Source Software - may be modified and shared by FRC teams. The code */ |
| 5 | /* must be accompanied by the FIRST BSD license file in $(WIND_BASE)/WPILib. */ |
| 6 | /*----------------------------------------------------------------------------*/ |
| 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 | |
| 18 | class 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 |