From df5ba465d55a4241a96dfad711df16b677974b36 Mon Sep 17 00:00:00 2001 From: Tyler Veness Date: Tue, 27 Oct 2020 19:25:28 -0700 Subject: [PATCH] [wpilib] Add SmartDashboard::PutData() reference overload --- .../cpp/smartdashboard/SmartDashboard.cpp | 8 ++++++ .../frc/smartdashboard/SmartDashboard.h | 28 +++++++++++++++++++ 2 files changed, 36 insertions(+) diff --git a/wpilibc/src/main/native/cpp/smartdashboard/SmartDashboard.cpp b/wpilibc/src/main/native/cpp/smartdashboard/SmartDashboard.cpp index 8248a94dc8c..86f04b8fc6f 100644 --- a/wpilibc/src/main/native/cpp/smartdashboard/SmartDashboard.cpp +++ b/wpilibc/src/main/native/cpp/smartdashboard/SmartDashboard.cpp @@ -119,6 +119,14 @@ void SmartDashboard::PutData(wpi::Sendable* value) { } } +void SmartDashboard::PutData(std::string_view key, wpi::Sendable& data) { + PutData(key, &data); +} + +void SmartDashboard::PutData(wpi::Sendable& value) { + PutData(&value); +} + wpi::Sendable* SmartDashboard::GetData(std::string_view key) { auto& inst = GetInstance(); std::scoped_lock lock(inst.tablesToDataMutex); diff --git a/wpilibc/src/main/native/include/frc/smartdashboard/SmartDashboard.h b/wpilibc/src/main/native/include/frc/smartdashboard/SmartDashboard.h index 04435f0252c..eb66b95d295 100644 --- a/wpilibc/src/main/native/include/frc/smartdashboard/SmartDashboard.h +++ b/wpilibc/src/main/native/include/frc/smartdashboard/SmartDashboard.h @@ -101,6 +101,34 @@ class SmartDashboard { */ static void PutData(wpi::Sendable* value); + /** + * Maps the specified key to the specified value in this table. + * + * The value can be retrieved by calling the get method with a key that is + * equal to the original key. + * + * In order for the value to appear in the dashboard, it must be registered + * with SendableRegistry. WPILib components do this automatically. + * + * @param key the key + * @param data the value + */ + static void PutData(std::string_view key, wpi::Sendable& data); + + /** + * Maps the specified key (where the key is the name of the Sendable) + * to the specified value in this table. + * + * The value can be retrieved by calling the get method with a key that is + * equal to the original key. + * + * In order for the value to appear in the dashboard, it must be registered + * with SendableRegistry. WPILib components do this automatically. + * + * @param value the value + */ + static void PutData(wpi::Sendable& value); + /** * Returns the value at the specified key. *