From d7d663a38b7bfe62d5203f7486fff2935d066133 Mon Sep 17 00:00:00 2001 From: Sam Carlberg Date: Sun, 10 Feb 2019 21:41:54 -0500 Subject: [PATCH 01/18] Fix C++ ShuffleboardComponent template type Fix `WithWidget(WidgetType&)`not being properly capitalized Add tests for ShuffleboardWidget --- .../frc/shuffleboard/ShuffleboardWidget.h | 6 +- .../shuffleboard/ShuffleboardWidgetTest.cpp | 67 +++++++++++++++++++ 2 files changed, 70 insertions(+), 3 deletions(-) create mode 100644 wpilibc/src/test/native/cpp/shuffleboard/ShuffleboardWidgetTest.cpp diff --git a/wpilibc/src/main/native/include/frc/shuffleboard/ShuffleboardWidget.h b/wpilibc/src/main/native/include/frc/shuffleboard/ShuffleboardWidget.h index 2e67160d3fc..d857bb8b1ea 100644 --- a/wpilibc/src/main/native/include/frc/shuffleboard/ShuffleboardWidget.h +++ b/wpilibc/src/main/native/include/frc/shuffleboard/ShuffleboardWidget.h @@ -25,11 +25,11 @@ class ShuffleboardContainer; */ template class ShuffleboardWidget - : public ShuffleboardComponent> { + : public ShuffleboardComponent { public: ShuffleboardWidget(ShuffleboardContainer& parent, const wpi::Twine& title) : ShuffleboardValue(title), - ShuffleboardComponent>(parent, title) {} + ShuffleboardComponent(parent, title) {} /** * Sets the type of widget used to display the data. If not set, the default @@ -39,7 +39,7 @@ class ShuffleboardWidget * @return this widget object * @see BuiltInWidgets */ - Derived& withWidget(const WidgetType& widgetType) { + Derived& WithWidget(const WidgetType& widgetType) { return WithWidget(widgetType.GetWidgetName()); } diff --git a/wpilibc/src/test/native/cpp/shuffleboard/ShuffleboardWidgetTest.cpp b/wpilibc/src/test/native/cpp/shuffleboard/ShuffleboardWidgetTest.cpp new file mode 100644 index 00000000000..c3f357c25ec --- /dev/null +++ b/wpilibc/src/test/native/cpp/shuffleboard/ShuffleboardWidgetTest.cpp @@ -0,0 +1,67 @@ +/*----------------------------------------------------------------------------*/ +/* Copyright (c) 2019 FIRST. All Rights Reserved. */ +/* Open Source Software - may be modified and shared by FRC teams. The code */ +/* must be accompanied by the FIRST BSD license file in the root directory of */ +/* the project. */ +/*----------------------------------------------------------------------------*/ + +#include +#include +#include + +#include +#include + +#include "frc/commands/InstantCommand.h" +#include "frc/shuffleboard/ShuffleboardInstance.h" +#include "frc/shuffleboard/ShuffleboardTab.h" +#include "frc/shuffleboard/ShuffleboardWidget.h" +#include "frc/shuffleboard/BuiltInWidgets.h" +#include "frc/smartdashboard/Sendable.h" +#include "gtest/gtest.h" + +using namespace frc; + +class ShuffleboardWidgetTest : public testing::Test { + void SetUp() override { + m_ntInstance = nt::NetworkTableInstance::Create(); + m_instance = std::make_unique(m_ntInstance); + m_tab = &(m_instance->GetTab("Tab")); + } + + protected: + nt::NetworkTableInstance m_ntInstance; + ShuffleboardTab* m_tab; + std::unique_ptr m_instance; +}; + +TEST_F(ShuffleboardWidgetTest, UseBuiltInWidget) { + auto entry = m_tab->Add("Name", "") + .WithWidget(BuiltInWidgets::kTextView) + .GetEntry(); + EXPECT_EQ("/Shuffleboard/Tab/Name", entry.GetName()) + << "The widget entry has the wrong name"; +} + +TEST_F(ShuffleboardWidgetTest, WithProperties) { + wpi::StringMap> properties { + std::make_pair("min", nt::Value::MakeDouble(0)), + std::make_pair("max", nt::Value::MakeDouble(1)) + }; + auto entry = m_tab->Add("WithProperties", "") + .WithProperties(properties) + .GetEntry(); + + // Update the instance to generation the metadata entries for the widget properties + m_instance->Update(); + + auto propertiesTable = + m_ntInstance.GetTable("/Shuffleboard/.metadata/Tab/WithProperties/Properties"); + + EXPECT_EQ("/Shuffleboard/Tab/WithProperties", entry.GetName()) + << "The widget entry has the wrong name"; + EXPECT_FLOAT_EQ(0, propertiesTable->GetEntry("min").GetDouble(-1)) + << "The 'min' property should be 0"; + EXPECT_FLOAT_EQ(1, propertiesTable->GetEntry("max").GetDouble(-1)) + << "The 'max' property should be 1"; +} From 073910762687da5bedfb4c5b5e60e1271b1617d5 Mon Sep 17 00:00:00 2001 From: Sam Carlberg Date: Sun, 10 Feb 2019 21:49:13 -0500 Subject: [PATCH 02/18] Formatting --- .../shuffleboard/ShuffleboardWidgetTest.cpp | 32 +++++++++---------- 1 file changed, 15 insertions(+), 17 deletions(-) diff --git a/wpilibc/src/test/native/cpp/shuffleboard/ShuffleboardWidgetTest.cpp b/wpilibc/src/test/native/cpp/shuffleboard/ShuffleboardWidgetTest.cpp index c3f357c25ec..0b41ede9186 100644 --- a/wpilibc/src/test/native/cpp/shuffleboard/ShuffleboardWidgetTest.cpp +++ b/wpilibc/src/test/native/cpp/shuffleboard/ShuffleboardWidgetTest.cpp @@ -13,10 +13,10 @@ #include #include "frc/commands/InstantCommand.h" +#include "frc/shuffleboard/BuiltInWidgets.h" #include "frc/shuffleboard/ShuffleboardInstance.h" #include "frc/shuffleboard/ShuffleboardTab.h" #include "frc/shuffleboard/ShuffleboardWidget.h" -#include "frc/shuffleboard/BuiltInWidgets.h" #include "frc/smartdashboard/Sendable.h" #include "gtest/gtest.h" @@ -36,32 +36,30 @@ class ShuffleboardWidgetTest : public testing::Test { }; TEST_F(ShuffleboardWidgetTest, UseBuiltInWidget) { - auto entry = m_tab->Add("Name", "") - .WithWidget(BuiltInWidgets::kTextView) - .GetEntry(); + auto entry = + m_tab->Add("Name", "").WithWidget(BuiltInWidgets::kTextView).GetEntry(); EXPECT_EQ("/Shuffleboard/Tab/Name", entry.GetName()) - << "The widget entry has the wrong name"; + << "The widget entry has the wrong name"; } TEST_F(ShuffleboardWidgetTest, WithProperties) { wpi::StringMap> properties { - std::make_pair("min", nt::Value::MakeDouble(0)), - std::make_pair("max", nt::Value::MakeDouble(1)) - }; - auto entry = m_tab->Add("WithProperties", "") - .WithProperties(properties) - .GetEntry(); + std::make_pair("min", nt::Value::MakeDouble(0)), + std::make_pair("max", nt::Value::MakeDouble(1))}; + auto entry = + m_tab->Add("WithProperties", "").WithProperties(properties).GetEntry(); - // Update the instance to generation the metadata entries for the widget properties + // Update the instance to generate + // the metadata entries for the widget properties m_instance->Update(); - auto propertiesTable = - m_ntInstance.GetTable("/Shuffleboard/.metadata/Tab/WithProperties/Properties"); + auto propertiesTable = m_ntInstance.GetTable( + "/Shuffleboard/.metadata/Tab/WithProperties/Properties"); EXPECT_EQ("/Shuffleboard/Tab/WithProperties", entry.GetName()) - << "The widget entry has the wrong name"; + << "The widget entry has the wrong name"; EXPECT_FLOAT_EQ(0, propertiesTable->GetEntry("min").GetDouble(-1)) - << "The 'min' property should be 0"; + << "The 'min' property should be 0"; EXPECT_FLOAT_EQ(1, propertiesTable->GetEntry("max").GetDouble(-1)) - << "The 'max' property should be 1"; + << "The 'max' property should be 1"; } From d2f32459d852cd7ed466b070724fb4e19197397d Mon Sep 17 00:00:00 2001 From: Sam Carlberg Date: Sun, 10 Feb 2019 21:59:35 -0500 Subject: [PATCH 03/18] Copyright year 2018 wpiformat not updated for 2019 yet --- .../test/native/cpp/shuffleboard/ShuffleboardWidgetTest.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/wpilibc/src/test/native/cpp/shuffleboard/ShuffleboardWidgetTest.cpp b/wpilibc/src/test/native/cpp/shuffleboard/ShuffleboardWidgetTest.cpp index 0b41ede9186..3dd9dbf790c 100644 --- a/wpilibc/src/test/native/cpp/shuffleboard/ShuffleboardWidgetTest.cpp +++ b/wpilibc/src/test/native/cpp/shuffleboard/ShuffleboardWidgetTest.cpp @@ -1,5 +1,5 @@ /*----------------------------------------------------------------------------*/ -/* Copyright (c) 2019 FIRST. All Rights Reserved. */ +/* Copyright (c) 2018 FIRST. All Rights Reserved. */ /* Open Source Software - may be modified and shared by FRC teams. The code */ /* must be accompanied by the FIRST BSD license file in the root directory of */ /* the project. */ @@ -43,7 +43,7 @@ TEST_F(ShuffleboardWidgetTest, UseBuiltInWidget) { } TEST_F(ShuffleboardWidgetTest, WithProperties) { - wpi::StringMap> properties { + wpi::StringMap> properties{ std::make_pair("min", nt::Value::MakeDouble(0)), std::make_pair("max", nt::Value::MakeDouble(1))}; auto entry = From 7834dafcdca71851528d381e83627eebf3dac131 Mon Sep 17 00:00:00 2001 From: Sam Carlberg Date: Sun, 10 Feb 2019 22:03:56 -0500 Subject: [PATCH 04/18] Format ShuffleboardWidget class declaration --- .../main/native/include/frc/shuffleboard/ShuffleboardWidget.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/wpilibc/src/main/native/include/frc/shuffleboard/ShuffleboardWidget.h b/wpilibc/src/main/native/include/frc/shuffleboard/ShuffleboardWidget.h index d857bb8b1ea..9f9e0ef3b93 100644 --- a/wpilibc/src/main/native/include/frc/shuffleboard/ShuffleboardWidget.h +++ b/wpilibc/src/main/native/include/frc/shuffleboard/ShuffleboardWidget.h @@ -24,8 +24,7 @@ class ShuffleboardContainer; * @tparam Derived the self type */ template -class ShuffleboardWidget - : public ShuffleboardComponent { +class ShuffleboardWidget : public ShuffleboardComponent { public: ShuffleboardWidget(ShuffleboardContainer& parent, const wpi::Twine& title) : ShuffleboardValue(title), From 3111001e7703f6ad444c617ae73d3644801e7002 Mon Sep 17 00:00:00 2001 From: Sam Carlberg Date: Mon, 11 Feb 2019 15:24:01 -0500 Subject: [PATCH 05/18] Store component names with std::string --- wpilibc/src/main/native/include/frc/shuffleboard/LayoutType.h | 2 +- wpilibc/src/main/native/include/frc/shuffleboard/WidgetType.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/wpilibc/src/main/native/include/frc/shuffleboard/LayoutType.h b/wpilibc/src/main/native/include/frc/shuffleboard/LayoutType.h index 22fe3617047..6d5bdb16549 100644 --- a/wpilibc/src/main/native/include/frc/shuffleboard/LayoutType.h +++ b/wpilibc/src/main/native/include/frc/shuffleboard/LayoutType.h @@ -30,7 +30,7 @@ class LayoutType { wpi::StringRef GetLayoutName() const; private: - wpi::StringRef m_layoutName; + std::string m_layoutName; }; } // namespace frc diff --git a/wpilibc/src/main/native/include/frc/shuffleboard/WidgetType.h b/wpilibc/src/main/native/include/frc/shuffleboard/WidgetType.h index f96e9b60e4e..063edbde274 100644 --- a/wpilibc/src/main/native/include/frc/shuffleboard/WidgetType.h +++ b/wpilibc/src/main/native/include/frc/shuffleboard/WidgetType.h @@ -30,7 +30,7 @@ class WidgetType { wpi::StringRef GetWidgetName() const; private: - wpi::StringRef m_widgetName; + std::string m_widgetName; }; } // namespace frc From f964f960b13c053cdf9ae7f2e810d050790658ce Mon Sep 17 00:00:00 2001 From: Thad House Date: Mon, 11 Feb 2019 12:27:08 -0800 Subject: [PATCH 06/18] Fix data members across dll boundaries --- shared/config.gradle | 2 +- wpilibc/src/main/native/cpp/Watchdog.cpp | 8 +---- .../cpp/shuffleboard/BuiltInWidgets.cpp | 2 ++ .../include/frc/shuffleboard/BuiltInWidgets.h | 29 +++++++++++++++++++ 4 files changed, 33 insertions(+), 8 deletions(-) diff --git a/shared/config.gradle b/shared/config.gradle index 02c2b687990..bde11bfb6fe 100644 --- a/shared/config.gradle +++ b/shared/config.gradle @@ -1,7 +1,7 @@ import edu.wpi.first.nativeutils.* import org.gradle.internal.os.OperatingSystem -def windowsCompilerArgs = ['/EHsc', '/DNOMINMAX', '/Zi', '/FS', '/Zc:inline', '/MP4'] +def windowsCompilerArgs = ['/EHsc', '/DNOMINMAX', '/Zi', '/FS', '/Zc:inline', '/MP4', '/std:c++17'] def windowsCCompilerArgs = ['/Zi', '/FS', '/Zc:inline'] def windowsReleaseCompilerArgs = ['/O2', '/MD'] def windowsDebugCompilerArgs = ['/Od', '/MDd'] diff --git a/wpilibc/src/main/native/cpp/Watchdog.cpp b/wpilibc/src/main/native/cpp/Watchdog.cpp index 043abac0035..7dce1c7205d 100644 --- a/wpilibc/src/main/native/cpp/Watchdog.cpp +++ b/wpilibc/src/main/native/cpp/Watchdog.cpp @@ -17,14 +17,8 @@ constexpr std::chrono::milliseconds Watchdog::kMinPrintPeriod; class Watchdog::Thread : public wpi::SafeThread { public: - template - struct DerefGreater : public std::binary_function { - constexpr bool operator()(const T& lhs, const T& rhs) const { - return *lhs > *rhs; - } - }; - wpi::PriorityQueue, DerefGreater> + wpi::PriorityQueue> m_watchdogs; private: diff --git a/wpilibc/src/main/native/cpp/shuffleboard/BuiltInWidgets.cpp b/wpilibc/src/main/native/cpp/shuffleboard/BuiltInWidgets.cpp index df6a1f3334c..e3dc3ee81ed 100644 --- a/wpilibc/src/main/native/cpp/shuffleboard/BuiltInWidgets.cpp +++ b/wpilibc/src/main/native/cpp/shuffleboard/BuiltInWidgets.cpp @@ -9,6 +9,7 @@ using namespace frc; +#ifndef _WIN32 const WidgetType BuiltInWidgets::kTextView{"Text View"}; const WidgetType BuiltInWidgets::kNumberSlider{"Number Slider"}; const WidgetType BuiltInWidgets::kNumberBar{"Number Bar"}; @@ -33,3 +34,4 @@ const WidgetType BuiltInWidgets::kRelay{"Relay"}; const WidgetType BuiltInWidgets::kDifferentialDrive{"Differential Drivebase"}; const WidgetType BuiltInWidgets::kMecanumDrive{"Mecanum Drivebase"}; const WidgetType BuiltInWidgets::kCameraStream{"Camera Stream"}; +#endif diff --git a/wpilibc/src/main/native/include/frc/shuffleboard/BuiltInWidgets.h b/wpilibc/src/main/native/include/frc/shuffleboard/BuiltInWidgets.h index 1fd720fbda3..cba0e060aa0 100644 --- a/wpilibc/src/main/native/include/frc/shuffleboard/BuiltInWidgets.h +++ b/wpilibc/src/main/native/include/frc/shuffleboard/BuiltInWidgets.h @@ -384,4 +384,33 @@ class BuiltInWidgets { static const WidgetType kCameraStream; }; +#ifdef _WIN32 +inline const WidgetType BuiltInWidgets::kTextView{"Text View"}; +inline const WidgetType BuiltInWidgets::kNumberSlider{"Number Slider"}; +inline const WidgetType BuiltInWidgets::kNumberBar{"Number Bar"}; +inline const WidgetType BuiltInWidgets::kDial{"Simple Dial"}; +inline const WidgetType BuiltInWidgets::kGraph{"Graph"}; +inline const WidgetType BuiltInWidgets::kBooleanBox{"Boolean Box"}; +inline const WidgetType BuiltInWidgets::kToggleButton{"Toggle Button"}; +inline const WidgetType BuiltInWidgets::kToggleSwitch{"Toggle Switch"}; +inline const WidgetType BuiltInWidgets::kVoltageView{"Voltage View"}; +inline const WidgetType BuiltInWidgets::kPowerDistributionPanel{"PDP"}; +inline const WidgetType BuiltInWidgets::kComboBoxChooser{"ComboBox Chooser"}; +inline const WidgetType BuiltInWidgets::kSplitButtonChooser{"Split Button Chooser"}; +inline const WidgetType BuiltInWidgets::kEncoder{"Encoder"}; +inline const WidgetType BuiltInWidgets::kSpeedController{"Speed Controller"}; +inline const WidgetType BuiltInWidgets::kCommand{"Command"}; +inline const WidgetType BuiltInWidgets::kPIDCommand{"PID Command"}; +inline const WidgetType BuiltInWidgets::kPIDController{"PID Controller"}; +inline const WidgetType BuiltInWidgets::kAccelerometer{"Accelerometer"}; +inline const WidgetType BuiltInWidgets::k3AxisAccelerometer{"3-Axis Accelerometer"}; +inline const WidgetType BuiltInWidgets::kGyro{"Gyro"}; +inline const WidgetType BuiltInWidgets::kRelay{"Relay"}; +inline const WidgetType BuiltInWidgets::kDifferentialDrive{"Differential Drivebase"}; +inline const WidgetType BuiltInWidgets::kMecanumDrive{"Mecanum Drivebase"}; +inline const WidgetType BuiltInWidgets::kCameraStream{"Camera Stream"}; +#endif + + } // namespace frc + From f47f4afc41bce85c992d1446121ee83b2a6c617f Mon Sep 17 00:00:00 2001 From: Thad House Date: Mon, 11 Feb 2019 12:34:34 -0800 Subject: [PATCH 07/18] Fix layout constants and formatting --- wpilibc/src/main/native/cpp/shuffleboard/BuiltInLayouts.cpp | 2 ++ .../main/native/include/frc/shuffleboard/BuiltInLayouts.h | 5 +++++ .../src/main/native/include/frc/shuffleboard/LayoutType.h | 2 ++ .../src/main/native/include/frc/shuffleboard/WidgetType.h | 2 ++ 4 files changed, 11 insertions(+) diff --git a/wpilibc/src/main/native/cpp/shuffleboard/BuiltInLayouts.cpp b/wpilibc/src/main/native/cpp/shuffleboard/BuiltInLayouts.cpp index 5d09310318a..206eefd70d9 100644 --- a/wpilibc/src/main/native/cpp/shuffleboard/BuiltInLayouts.cpp +++ b/wpilibc/src/main/native/cpp/shuffleboard/BuiltInLayouts.cpp @@ -9,5 +9,7 @@ using namespace frc; +#ifndef _WIN32 const LayoutType BuiltInLayouts::kList{"List Layout"}; const LayoutType BuiltInLayouts::kGrid{"Grid Layout"}; +#endif diff --git a/wpilibc/src/main/native/include/frc/shuffleboard/BuiltInLayouts.h b/wpilibc/src/main/native/include/frc/shuffleboard/BuiltInLayouts.h index 6a61b870ba5..7e20f2e2c19 100644 --- a/wpilibc/src/main/native/include/frc/shuffleboard/BuiltInLayouts.h +++ b/wpilibc/src/main/native/include/frc/shuffleboard/BuiltInLayouts.h @@ -50,4 +50,9 @@ class BuiltInLayouts { static const LayoutType kGrid; }; +#ifdef _WIN32 +inline const LayoutType BuiltInLayouts::kList{"List Layout"}; +inline const LayoutType BuiltInLayouts::kGrid{"Grid Layout"}; +#endif + } // namespace frc diff --git a/wpilibc/src/main/native/include/frc/shuffleboard/LayoutType.h b/wpilibc/src/main/native/include/frc/shuffleboard/LayoutType.h index 6d5bdb16549..742103c4890 100644 --- a/wpilibc/src/main/native/include/frc/shuffleboard/LayoutType.h +++ b/wpilibc/src/main/native/include/frc/shuffleboard/LayoutType.h @@ -7,6 +7,8 @@ #pragma once +#include + #include namespace frc { diff --git a/wpilibc/src/main/native/include/frc/shuffleboard/WidgetType.h b/wpilibc/src/main/native/include/frc/shuffleboard/WidgetType.h index 063edbde274..cdf6221d9af 100644 --- a/wpilibc/src/main/native/include/frc/shuffleboard/WidgetType.h +++ b/wpilibc/src/main/native/include/frc/shuffleboard/WidgetType.h @@ -7,6 +7,8 @@ #pragma once +#include + #include namespace frc { From 3e7e2ee6db3190199f0392e248e9a916e60de758 Mon Sep 17 00:00:00 2001 From: Thad House Date: Mon, 11 Feb 2019 12:40:24 -0800 Subject: [PATCH 08/18] Fix Formatting --- wpilibc/src/main/native/cpp/Watchdog.cpp | 4 +--- .../native/include/frc/shuffleboard/BuiltInWidgets.h | 9 ++++++--- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/wpilibc/src/main/native/cpp/Watchdog.cpp b/wpilibc/src/main/native/cpp/Watchdog.cpp index 7dce1c7205d..7d6b07f0954 100644 --- a/wpilibc/src/main/native/cpp/Watchdog.cpp +++ b/wpilibc/src/main/native/cpp/Watchdog.cpp @@ -17,9 +17,7 @@ constexpr std::chrono::milliseconds Watchdog::kMinPrintPeriod; class Watchdog::Thread : public wpi::SafeThread { public: - - wpi::PriorityQueue> - m_watchdogs; + wpi::PriorityQueue> m_watchdogs; private: void Main() override; diff --git a/wpilibc/src/main/native/include/frc/shuffleboard/BuiltInWidgets.h b/wpilibc/src/main/native/include/frc/shuffleboard/BuiltInWidgets.h index cba0e060aa0..93f8d8914fd 100644 --- a/wpilibc/src/main/native/include/frc/shuffleboard/BuiltInWidgets.h +++ b/wpilibc/src/main/native/include/frc/shuffleboard/BuiltInWidgets.h @@ -396,17 +396,20 @@ inline const WidgetType BuiltInWidgets::kToggleSwitch{"Toggle Switch"}; inline const WidgetType BuiltInWidgets::kVoltageView{"Voltage View"}; inline const WidgetType BuiltInWidgets::kPowerDistributionPanel{"PDP"}; inline const WidgetType BuiltInWidgets::kComboBoxChooser{"ComboBox Chooser"}; -inline const WidgetType BuiltInWidgets::kSplitButtonChooser{"Split Button Chooser"}; +inline const WidgetType BuiltInWidgets::kSplitButtonChooser{ + "Split Button Chooser"}; inline const WidgetType BuiltInWidgets::kEncoder{"Encoder"}; inline const WidgetType BuiltInWidgets::kSpeedController{"Speed Controller"}; inline const WidgetType BuiltInWidgets::kCommand{"Command"}; inline const WidgetType BuiltInWidgets::kPIDCommand{"PID Command"}; inline const WidgetType BuiltInWidgets::kPIDController{"PID Controller"}; inline const WidgetType BuiltInWidgets::kAccelerometer{"Accelerometer"}; -inline const WidgetType BuiltInWidgets::k3AxisAccelerometer{"3-Axis Accelerometer"}; +inline const WidgetType BuiltInWidgets::k3AxisAccelerometer{ + "3-Axis Accelerometer"}; inline const WidgetType BuiltInWidgets::kGyro{"Gyro"}; inline const WidgetType BuiltInWidgets::kRelay{"Relay"}; -inline const WidgetType BuiltInWidgets::kDifferentialDrive{"Differential Drivebase"}; +inline const WidgetType BuiltInWidgets::kDifferentialDrive{ + "Differential Drivebase"}; inline const WidgetType BuiltInWidgets::kMecanumDrive{"Mecanum Drivebase"}; inline const WidgetType BuiltInWidgets::kCameraStream{"Camera Stream"}; #endif From a77e72303281710129047eb9b034857b231d0af7 Mon Sep 17 00:00:00 2001 From: Thad House Date: Mon, 11 Feb 2019 13:19:42 -0800 Subject: [PATCH 09/18] Add Comparator back in Just wanted to remove the inheritance --- wpilibc/src/main/native/cpp/Watchdog.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/wpilibc/src/main/native/cpp/Watchdog.cpp b/wpilibc/src/main/native/cpp/Watchdog.cpp index 7d6b07f0954..3eaf459bbdf 100644 --- a/wpilibc/src/main/native/cpp/Watchdog.cpp +++ b/wpilibc/src/main/native/cpp/Watchdog.cpp @@ -17,7 +17,15 @@ constexpr std::chrono::milliseconds Watchdog::kMinPrintPeriod; class Watchdog::Thread : public wpi::SafeThread { public: - wpi::PriorityQueue> m_watchdogs; + template + struct DerefGreater { + constexpr bool operator()(const T& lhs, const T& rhs) const { + return *lhs > *rhs; + } + }; + + wpi::PriorityQueue, DerefGreater> + m_watchdogs; private: void Main() override; From 93086a112074292a7c21e576da1bf0e6a7234498 Mon Sep 17 00:00:00 2001 From: Thad House Date: Mon, 11 Feb 2019 13:24:25 -0800 Subject: [PATCH 10/18] more formatting --- wpilibc/src/main/native/cpp/Watchdog.cpp | 2 +- .../src/main/native/include/frc/shuffleboard/BuiltInWidgets.h | 4 +--- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/wpilibc/src/main/native/cpp/Watchdog.cpp b/wpilibc/src/main/native/cpp/Watchdog.cpp index 3eaf459bbdf..f7c1778b0ef 100644 --- a/wpilibc/src/main/native/cpp/Watchdog.cpp +++ b/wpilibc/src/main/native/cpp/Watchdog.cpp @@ -24,7 +24,7 @@ class Watchdog::Thread : public wpi::SafeThread { } }; - wpi::PriorityQueue, DerefGreater> + wpi::PriorityQueue, DerefGreater> m_watchdogs; private: diff --git a/wpilibc/src/main/native/include/frc/shuffleboard/BuiltInWidgets.h b/wpilibc/src/main/native/include/frc/shuffleboard/BuiltInWidgets.h index 93f8d8914fd..5d2a3f3da80 100644 --- a/wpilibc/src/main/native/include/frc/shuffleboard/BuiltInWidgets.h +++ b/wpilibc/src/main/native/include/frc/shuffleboard/BuiltInWidgets.h @@ -409,11 +409,9 @@ inline const WidgetType BuiltInWidgets::k3AxisAccelerometer{ inline const WidgetType BuiltInWidgets::kGyro{"Gyro"}; inline const WidgetType BuiltInWidgets::kRelay{"Relay"}; inline const WidgetType BuiltInWidgets::kDifferentialDrive{ - "Differential Drivebase"}; + "Differential Drivebase"}; inline const WidgetType BuiltInWidgets::kMecanumDrive{"Mecanum Drivebase"}; inline const WidgetType BuiltInWidgets::kCameraStream{"Camera Stream"}; #endif - } // namespace frc - From c046ef723b3c05145e81c36535f7facd8bf72208 Mon Sep 17 00:00:00 2001 From: Thad House Date: Mon, 11 Feb 2019 13:58:26 -0800 Subject: [PATCH 11/18] Shim gtest for missing c++17 print on windows --- ntcore/src/test/native/cpp/StorageTest.cpp | 8 ++++++++ ntcore/src/test/native/cpp/WireDecoderTest.cpp | 8 ++++++++ ntcore/src/test/native/cpp/WireEncoderTest.cpp | 8 ++++++++ 3 files changed, 24 insertions(+) diff --git a/ntcore/src/test/native/cpp/StorageTest.cpp b/ntcore/src/test/native/cpp/StorageTest.cpp index 47c1096a9b9..d23d0d81f66 100644 --- a/ntcore/src/test/native/cpp/StorageTest.cpp +++ b/ntcore/src/test/native/cpp/StorageTest.cpp @@ -10,6 +10,14 @@ #include #include +// TODO https://github.com/google/googletest/pull/1620 +// Merge above PR into gtest to remove this shim +#ifdef _WIN32 +namespace std { +inline void PrintTo(std::nullptr_t, ::std::ostream* os) { *os << "(nullptr)"; } +} // namespace std +#endif + #include "MessageMatcher.h" #include "MockNetworkConnection.h" #include "Storage.h" diff --git a/ntcore/src/test/native/cpp/WireDecoderTest.cpp b/ntcore/src/test/native/cpp/WireDecoderTest.cpp index a13fa7a275e..2078b5ccfe1 100644 --- a/ntcore/src/test/native/cpp/WireDecoderTest.cpp +++ b/ntcore/src/test/native/cpp/WireDecoderTest.cpp @@ -13,6 +13,14 @@ #include +// TODO https://github.com/google/googletest/pull/1620 +// Merge above PR into gtest to remove this shim +#ifdef _WIN32 +namespace std { +inline void PrintTo(std::nullptr_t, ::std::ostream* os) { *os << "(nullptr)"; } +} // namespace std +#endif + #include "TestPrinters.h" #include "WireDecoder.h" #include "gtest/gtest.h" diff --git a/ntcore/src/test/native/cpp/WireEncoderTest.cpp b/ntcore/src/test/native/cpp/WireEncoderTest.cpp index 664344fae9b..303b97ef5a7 100644 --- a/ntcore/src/test/native/cpp/WireEncoderTest.cpp +++ b/ntcore/src/test/native/cpp/WireEncoderTest.cpp @@ -11,6 +11,14 @@ #include +// TODO https://github.com/google/googletest/pull/1620 +// Merge above PR into gtest to remove this shim +#ifdef _WIN32 +namespace std { +inline void PrintTo(std::nullptr_t, ::std::ostream* os) { *os << "(nullptr)"; } +} // namespace std +#endif + #include "TestPrinters.h" #include "WireEncoder.h" #include "gtest/gtest.h" From 2bd143efb6faad8bd46bad189005ecceb87032ed Mon Sep 17 00:00:00 2001 From: Thad House Date: Tue, 12 Feb 2019 14:12:24 -0800 Subject: [PATCH 12/18] Use constexpr for creating BuiltInWidgets and Layouts --- ntcore/src/test/native/cpp/StorageTest.cpp | 8 -- .../src/test/native/cpp/WireDecoderTest.cpp | 8 -- .../src/test/native/cpp/WireEncoderTest.cpp | 8 -- shared/config.gradle | 2 +- .../cpp/shuffleboard/BuiltInLayouts.cpp | 15 ---- .../cpp/shuffleboard/BuiltInWidgets.cpp | 37 --------- .../include/frc/shuffleboard/BuiltInLayouts.h | 9 +-- .../include/frc/shuffleboard/BuiltInWidgets.h | 78 ++++++------------- .../include/frc/shuffleboard/LayoutType.h | 5 +- .../include/frc/shuffleboard/WidgetType.h | 5 +- 10 files changed, 33 insertions(+), 142 deletions(-) delete mode 100644 wpilibc/src/main/native/cpp/shuffleboard/BuiltInLayouts.cpp delete mode 100644 wpilibc/src/main/native/cpp/shuffleboard/BuiltInWidgets.cpp diff --git a/ntcore/src/test/native/cpp/StorageTest.cpp b/ntcore/src/test/native/cpp/StorageTest.cpp index d23d0d81f66..47c1096a9b9 100644 --- a/ntcore/src/test/native/cpp/StorageTest.cpp +++ b/ntcore/src/test/native/cpp/StorageTest.cpp @@ -10,14 +10,6 @@ #include #include -// TODO https://github.com/google/googletest/pull/1620 -// Merge above PR into gtest to remove this shim -#ifdef _WIN32 -namespace std { -inline void PrintTo(std::nullptr_t, ::std::ostream* os) { *os << "(nullptr)"; } -} // namespace std -#endif - #include "MessageMatcher.h" #include "MockNetworkConnection.h" #include "Storage.h" diff --git a/ntcore/src/test/native/cpp/WireDecoderTest.cpp b/ntcore/src/test/native/cpp/WireDecoderTest.cpp index 2078b5ccfe1..a13fa7a275e 100644 --- a/ntcore/src/test/native/cpp/WireDecoderTest.cpp +++ b/ntcore/src/test/native/cpp/WireDecoderTest.cpp @@ -13,14 +13,6 @@ #include -// TODO https://github.com/google/googletest/pull/1620 -// Merge above PR into gtest to remove this shim -#ifdef _WIN32 -namespace std { -inline void PrintTo(std::nullptr_t, ::std::ostream* os) { *os << "(nullptr)"; } -} // namespace std -#endif - #include "TestPrinters.h" #include "WireDecoder.h" #include "gtest/gtest.h" diff --git a/ntcore/src/test/native/cpp/WireEncoderTest.cpp b/ntcore/src/test/native/cpp/WireEncoderTest.cpp index 303b97ef5a7..664344fae9b 100644 --- a/ntcore/src/test/native/cpp/WireEncoderTest.cpp +++ b/ntcore/src/test/native/cpp/WireEncoderTest.cpp @@ -11,14 +11,6 @@ #include -// TODO https://github.com/google/googletest/pull/1620 -// Merge above PR into gtest to remove this shim -#ifdef _WIN32 -namespace std { -inline void PrintTo(std::nullptr_t, ::std::ostream* os) { *os << "(nullptr)"; } -} // namespace std -#endif - #include "TestPrinters.h" #include "WireEncoder.h" #include "gtest/gtest.h" diff --git a/shared/config.gradle b/shared/config.gradle index bde11bfb6fe..02c2b687990 100644 --- a/shared/config.gradle +++ b/shared/config.gradle @@ -1,7 +1,7 @@ import edu.wpi.first.nativeutils.* import org.gradle.internal.os.OperatingSystem -def windowsCompilerArgs = ['/EHsc', '/DNOMINMAX', '/Zi', '/FS', '/Zc:inline', '/MP4', '/std:c++17'] +def windowsCompilerArgs = ['/EHsc', '/DNOMINMAX', '/Zi', '/FS', '/Zc:inline', '/MP4'] def windowsCCompilerArgs = ['/Zi', '/FS', '/Zc:inline'] def windowsReleaseCompilerArgs = ['/O2', '/MD'] def windowsDebugCompilerArgs = ['/Od', '/MDd'] diff --git a/wpilibc/src/main/native/cpp/shuffleboard/BuiltInLayouts.cpp b/wpilibc/src/main/native/cpp/shuffleboard/BuiltInLayouts.cpp deleted file mode 100644 index 206eefd70d9..00000000000 --- a/wpilibc/src/main/native/cpp/shuffleboard/BuiltInLayouts.cpp +++ /dev/null @@ -1,15 +0,0 @@ -/*----------------------------------------------------------------------------*/ -/* Copyright (c) 2018 FIRST. All Rights Reserved. */ -/* Open Source Software - may be modified and shared by FRC teams. The code */ -/* must be accompanied by the FIRST BSD license file in the root directory of */ -/* the project. */ -/*----------------------------------------------------------------------------*/ - -#include "frc/shuffleboard/BuiltInLayouts.h" - -using namespace frc; - -#ifndef _WIN32 -const LayoutType BuiltInLayouts::kList{"List Layout"}; -const LayoutType BuiltInLayouts::kGrid{"Grid Layout"}; -#endif diff --git a/wpilibc/src/main/native/cpp/shuffleboard/BuiltInWidgets.cpp b/wpilibc/src/main/native/cpp/shuffleboard/BuiltInWidgets.cpp deleted file mode 100644 index e3dc3ee81ed..00000000000 --- a/wpilibc/src/main/native/cpp/shuffleboard/BuiltInWidgets.cpp +++ /dev/null @@ -1,37 +0,0 @@ -/*----------------------------------------------------------------------------*/ -/* Copyright (c) 2018 FIRST. All Rights Reserved. */ -/* Open Source Software - may be modified and shared by FRC teams. The code */ -/* must be accompanied by the FIRST BSD license file in the root directory of */ -/* the project. */ -/*----------------------------------------------------------------------------*/ - -#include "frc/shuffleboard/BuiltInWidgets.h" - -using namespace frc; - -#ifndef _WIN32 -const WidgetType BuiltInWidgets::kTextView{"Text View"}; -const WidgetType BuiltInWidgets::kNumberSlider{"Number Slider"}; -const WidgetType BuiltInWidgets::kNumberBar{"Number Bar"}; -const WidgetType BuiltInWidgets::kDial{"Simple Dial"}; -const WidgetType BuiltInWidgets::kGraph{"Graph"}; -const WidgetType BuiltInWidgets::kBooleanBox{"Boolean Box"}; -const WidgetType BuiltInWidgets::kToggleButton{"Toggle Button"}; -const WidgetType BuiltInWidgets::kToggleSwitch{"Toggle Switch"}; -const WidgetType BuiltInWidgets::kVoltageView{"Voltage View"}; -const WidgetType BuiltInWidgets::kPowerDistributionPanel{"PDP"}; -const WidgetType BuiltInWidgets::kComboBoxChooser{"ComboBox Chooser"}; -const WidgetType BuiltInWidgets::kSplitButtonChooser{"Split Button Chooser"}; -const WidgetType BuiltInWidgets::kEncoder{"Encoder"}; -const WidgetType BuiltInWidgets::kSpeedController{"Speed Controller"}; -const WidgetType BuiltInWidgets::kCommand{"Command"}; -const WidgetType BuiltInWidgets::kPIDCommand{"PID Command"}; -const WidgetType BuiltInWidgets::kPIDController{"PID Controller"}; -const WidgetType BuiltInWidgets::kAccelerometer{"Accelerometer"}; -const WidgetType BuiltInWidgets::k3AxisAccelerometer{"3-Axis Accelerometer"}; -const WidgetType BuiltInWidgets::kGyro{"Gyro"}; -const WidgetType BuiltInWidgets::kRelay{"Relay"}; -const WidgetType BuiltInWidgets::kDifferentialDrive{"Differential Drivebase"}; -const WidgetType BuiltInWidgets::kMecanumDrive{"Mecanum Drivebase"}; -const WidgetType BuiltInWidgets::kCameraStream{"Camera Stream"}; -#endif diff --git a/wpilibc/src/main/native/include/frc/shuffleboard/BuiltInLayouts.h b/wpilibc/src/main/native/include/frc/shuffleboard/BuiltInLayouts.h index 7e20f2e2c19..2231993d116 100644 --- a/wpilibc/src/main/native/include/frc/shuffleboard/BuiltInLayouts.h +++ b/wpilibc/src/main/native/include/frc/shuffleboard/BuiltInLayouts.h @@ -30,7 +30,7 @@ class BuiltInLayouts { * {@code ["TOP", "LEFT", "BOTTOM", "RIGHT", "HIDDEN"} * */ - static const LayoutType kList; + static constexpr LayoutType kList{"List Layout"}; /** * Groups components in an n x m grid. Grid layouts default to @@ -47,12 +47,7 @@ class BuiltInLayouts { * * */ - static const LayoutType kGrid; + static constexpr LayoutType kGrid{"Grid Layout"}; }; -#ifdef _WIN32 -inline const LayoutType BuiltInLayouts::kList{"List Layout"}; -inline const LayoutType BuiltInLayouts::kGrid{"Grid Layout"}; -#endif - } // namespace frc diff --git a/wpilibc/src/main/native/include/frc/shuffleboard/BuiltInWidgets.h b/wpilibc/src/main/native/include/frc/shuffleboard/BuiltInWidgets.h index 5d2a3f3da80..8780405c8c4 100644 --- a/wpilibc/src/main/native/include/frc/shuffleboard/BuiltInWidgets.h +++ b/wpilibc/src/main/native/include/frc/shuffleboard/BuiltInWidgets.h @@ -37,7 +37,7 @@ class BuiltInWidgets { * *
This widget has no custom properties. */ - static const WidgetType kTextView; + static constexpr WidgetType kTextView{"Text View"}; /** * Displays a number with a controllable slider. *
Supported types: @@ -54,7 +54,7 @@ class BuiltInWidgets { * slider by with the arrow keys * */ - static const WidgetType kNumberSlider; + static constexpr WidgetType kNumberSlider{"Number Slider"}; /** * Displays a number with a view-only bar. *
Supported types: @@ -71,7 +71,7 @@ class BuiltInWidgets { * of the bar * */ - static const WidgetType kNumberBar; + static constexpr WidgetType kNumberBar{"Number Bar"}; /** * Displays a number with a view-only dial. Displayed values are rounded to * the nearest integer.
Supported types:
  • Number
  • @@ -86,7 +86,7 @@ class BuiltInWidgets { * value as text * */ - static const WidgetType kDial; + static constexpr WidgetType kDial{"Simple Dial"}; /** * Displays a number with a graph. NOTE: graphs can be taxing * on the computer running the dashboard. Keep the number of visible data @@ -103,7 +103,7 @@ class BuiltInWidgets { * How long, in seconds, should past data be visible for * */ - static const WidgetType kGraph; + static constexpr WidgetType kGraph{"Graph"}; /** * Displays a boolean value as a large colored box. *
    Supported types: @@ -121,7 +121,7 @@ class BuiltInWidgets { * Can be specified as a string or a number * */ - static const WidgetType kBooleanBox; + static constexpr WidgetType kBooleanBox{"Boolean Box"}; /** * Displays a boolean with a large interactive toggle button. *
    Supported types: @@ -130,7 +130,7 @@ class BuiltInWidgets { *
*
This widget has no custom properties. */ - static const WidgetType kToggleButton; + static constexpr WidgetType kToggleButton{"Toggle Button"}; /** * Displays a boolean with a fixed-size toggle switch. *
Supported types: @@ -139,7 +139,7 @@ class BuiltInWidgets { * *
This widget has no custom properties. */ - static const WidgetType kToggleSwitch; + static constexpr WidgetType kToggleSwitch{"Toggle Switch"}; /** * Displays an analog input or a raw number with a number bar. *
Supported types: @@ -162,7 +162,7 @@ class BuiltInWidgets { * bar * */ - static const WidgetType kVoltageView; + static constexpr WidgetType kVoltageView{"Voltage View"}; /** * Displays a {@link edu.wpi.first.wpilibj.PowerDistributionPanel * PowerDistributionPanel}.
Supported types:
  • {@link @@ -175,7 +175,7 @@ class BuiltInWidgets { * Whether or not to display the voltage and current draw * */ - static const WidgetType kPowerDistributionPanel; + static constexpr WidgetType kPowerDistributionPanel{"PDP"}; /** * Displays a {@link edu.wpi.first.wpilibj.smartdashboard.SendableChooser * SendableChooser} with a dropdown combo box with a list of options. @@ -185,7 +185,7 @@ class BuiltInWidgets { *
*
This widget has no custom properties. */ - static const WidgetType kComboBoxChooser; + static constexpr WidgetType kComboBoxChooser{"ComboBox Chooser"}; /** * Displays a {@link edu.wpi.first.wpilibj.smartdashboard.SendableChooser * SendableChooser} with a toggle button for each available option. @@ -195,7 +195,7 @@ class BuiltInWidgets { * *
This widget has no custom properties. */ - static const WidgetType kSplitButtonChooser; + static constexpr WidgetType kSplitButtonChooser{"Split Button Chooser"}; /** * Displays an {@link edu.wpi.first.wpilibj.Encoder} displaying its speed, * total travelled distance, and its distance per tick.
Supported types: @@ -204,7 +204,7 @@ class BuiltInWidgets { * *
This widget has no custom properties. */ - static const WidgetType kEncoder; + static constexpr WidgetType kEncoder{"Encoder"}; /** * Displays a {@link edu.wpi.first.wpilibj.SpeedController SpeedController}. * The speed controller will be controllable from the dashboard when test mode @@ -228,7 +228,7 @@ class BuiltInWidgets { * One of {@code ["HORIZONTAL", "VERTICAL"]} * */ - static const WidgetType kSpeedController; + static constexpr WidgetType kSpeedController{"Speed Controller"}; /** * Displays a command with a toggle button. Pressing the button will start the * command, and the button will automatically release when the command @@ -239,7 +239,7 @@ class BuiltInWidgets { * *
This widget has no custom properties. */ - static const WidgetType kCommand; + static constexpr WidgetType kCommand{"Command"}; /** * Displays a PID command with a checkbox and an editor for the PIDF * constants. Selecting the checkbox will start the command, and the checkbox @@ -249,7 +249,7 @@ class BuiltInWidgets { * *
This widget has no custom properties. */ - static const WidgetType kPIDCommand; + static constexpr WidgetType kPIDCommand{"PID Command"}; /** * Displays a PID controller with an editor for the PIDF constants and a * toggle switch for enabling and disabling the controller.
Supported @@ -257,7 +257,7 @@ class BuiltInWidgets { * *
This widget has no custom properties. */ - static const WidgetType kPIDController; + static constexpr WidgetType kPIDController{"PID Controller"}; /** * Displays an accelerometer with a number bar displaying the magnitude of the * acceleration and text displaying the exact value.
Supported types:
    @@ -278,7 +278,7 @@ class BuiltInWidgets { * Show or hide the tick marks on the number bars * */ - static const WidgetType kAccelerometer; + static constexpr WidgetType kAccelerometer{"Accelerometer"}; /** * Displays a 3-axis accelerometer with a number bar for each axis' * accleration.
    Supported types:
    • {@link @@ -298,7 +298,7 @@ class BuiltInWidgets { * Show or hide the tick marks on the number bars * */ - static const WidgetType k3AxisAccelerometer; + static constexpr WidgetType k3AxisAccelerometer{"3-Axis Accelerometer"}; /** * Displays a gyro with a dial from 0 to 360 degrees. *
      Supported types: @@ -317,7 +317,7 @@ class BuiltInWidgets { * Show tick mark ringBooleantrue * */ - static const WidgetType kGyro; + static constexpr WidgetType kGyro{"Gyro"}; /** * Displays a relay with toggle buttons for each supported mode (off, on, * forward, reverse).
      Supported types:
      • {@link @@ -325,7 +325,7 @@ class BuiltInWidgets { *
      *
      This widget has no custom properties. */ - static const WidgetType kRelay; + static constexpr WidgetType kRelay{"Relay"}; /** * Displays a differential drive with a widget that displays the speed of each * side of the drivebase and a vector for the direction and rotation of the @@ -344,7 +344,7 @@ class BuiltInWidgets { * Show velocity vectorsBooleantrue * */ - static const WidgetType kDifferentialDrive; + static constexpr WidgetType kDifferentialDrive{"Differential Drivebase"}; /** * Displays a mecanum drive with a widget that displays the speed of each * wheel, and vectors for the direction and rotation of the drivebase. The @@ -357,7 +357,7 @@ class BuiltInWidgets { * Show velocity vectorsBooleantrue * */ - static const WidgetType kMecanumDrive; + static constexpr WidgetType kMecanumDrive{"Mecanum Drivebase"}; /** * Displays a camera stream. *
      Supported types: @@ -381,37 +381,7 @@ class BuiltInWidgets { * * */ - static const WidgetType kCameraStream; + static constexpr WidgetType kCameraStream{"Camera Stream"}; }; -#ifdef _WIN32 -inline const WidgetType BuiltInWidgets::kTextView{"Text View"}; -inline const WidgetType BuiltInWidgets::kNumberSlider{"Number Slider"}; -inline const WidgetType BuiltInWidgets::kNumberBar{"Number Bar"}; -inline const WidgetType BuiltInWidgets::kDial{"Simple Dial"}; -inline const WidgetType BuiltInWidgets::kGraph{"Graph"}; -inline const WidgetType BuiltInWidgets::kBooleanBox{"Boolean Box"}; -inline const WidgetType BuiltInWidgets::kToggleButton{"Toggle Button"}; -inline const WidgetType BuiltInWidgets::kToggleSwitch{"Toggle Switch"}; -inline const WidgetType BuiltInWidgets::kVoltageView{"Voltage View"}; -inline const WidgetType BuiltInWidgets::kPowerDistributionPanel{"PDP"}; -inline const WidgetType BuiltInWidgets::kComboBoxChooser{"ComboBox Chooser"}; -inline const WidgetType BuiltInWidgets::kSplitButtonChooser{ - "Split Button Chooser"}; -inline const WidgetType BuiltInWidgets::kEncoder{"Encoder"}; -inline const WidgetType BuiltInWidgets::kSpeedController{"Speed Controller"}; -inline const WidgetType BuiltInWidgets::kCommand{"Command"}; -inline const WidgetType BuiltInWidgets::kPIDCommand{"PID Command"}; -inline const WidgetType BuiltInWidgets::kPIDController{"PID Controller"}; -inline const WidgetType BuiltInWidgets::kAccelerometer{"Accelerometer"}; -inline const WidgetType BuiltInWidgets::k3AxisAccelerometer{ - "3-Axis Accelerometer"}; -inline const WidgetType BuiltInWidgets::kGyro{"Gyro"}; -inline const WidgetType BuiltInWidgets::kRelay{"Relay"}; -inline const WidgetType BuiltInWidgets::kDifferentialDrive{ - "Differential Drivebase"}; -inline const WidgetType BuiltInWidgets::kMecanumDrive{"Mecanum Drivebase"}; -inline const WidgetType BuiltInWidgets::kCameraStream{"Camera Stream"}; -#endif - } // namespace frc diff --git a/wpilibc/src/main/native/include/frc/shuffleboard/LayoutType.h b/wpilibc/src/main/native/include/frc/shuffleboard/LayoutType.h index 742103c4890..802b5adca70 100644 --- a/wpilibc/src/main/native/include/frc/shuffleboard/LayoutType.h +++ b/wpilibc/src/main/native/include/frc/shuffleboard/LayoutType.h @@ -22,7 +22,8 @@ namespace frc { */ class LayoutType { public: - explicit LayoutType(const char* layoutName) : m_layoutName(layoutName) {} + explicit constexpr LayoutType(const char* layoutName) + : m_layoutName(layoutName) {} ~LayoutType() = default; /** @@ -32,7 +33,7 @@ class LayoutType { wpi::StringRef GetLayoutName() const; private: - std::string m_layoutName; + const char* m_layoutName; }; } // namespace frc diff --git a/wpilibc/src/main/native/include/frc/shuffleboard/WidgetType.h b/wpilibc/src/main/native/include/frc/shuffleboard/WidgetType.h index cdf6221d9af..b76ecf9be3c 100644 --- a/wpilibc/src/main/native/include/frc/shuffleboard/WidgetType.h +++ b/wpilibc/src/main/native/include/frc/shuffleboard/WidgetType.h @@ -22,7 +22,8 @@ namespace frc { */ class WidgetType { public: - explicit WidgetType(const char* widgetName) : m_widgetName(widgetName) {} + explicit constexpr WidgetType(const char* widgetName) + : m_widgetName(widgetName) {} ~WidgetType() = default; /** @@ -32,7 +33,7 @@ class WidgetType { wpi::StringRef GetWidgetName() const; private: - std::string m_widgetName; + const char* m_widgetName; }; } // namespace frc From 18df258982a09f5ef88d6dbffa6f6dee0831d2f8 Mon Sep 17 00:00:00 2001 From: Thad House Date: Tue, 12 Feb 2019 14:15:41 -0800 Subject: [PATCH 13/18] StringRef header change --- wpilibc/src/main/native/include/frc/shuffleboard/LayoutType.h | 4 +--- wpilibc/src/main/native/include/frc/shuffleboard/WidgetType.h | 4 +--- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/wpilibc/src/main/native/include/frc/shuffleboard/LayoutType.h b/wpilibc/src/main/native/include/frc/shuffleboard/LayoutType.h index 802b5adca70..50e448b2d55 100644 --- a/wpilibc/src/main/native/include/frc/shuffleboard/LayoutType.h +++ b/wpilibc/src/main/native/include/frc/shuffleboard/LayoutType.h @@ -7,9 +7,7 @@ #pragma once -#include - -#include +#include namespace frc { diff --git a/wpilibc/src/main/native/include/frc/shuffleboard/WidgetType.h b/wpilibc/src/main/native/include/frc/shuffleboard/WidgetType.h index b76ecf9be3c..057d594a18d 100644 --- a/wpilibc/src/main/native/include/frc/shuffleboard/WidgetType.h +++ b/wpilibc/src/main/native/include/frc/shuffleboard/WidgetType.h @@ -7,9 +7,7 @@ #pragma once -#include - -#include +#include namespace frc { From a40bed231e327474cbab2d90164193548ac627fc Mon Sep 17 00:00:00 2001 From: Thad House Date: Tue, 12 Feb 2019 14:47:21 -0800 Subject: [PATCH 14/18] Use namespace for layout types, not class members --- .../src/main/native/include/frc/shuffleboard/BuiltInLayouts.h | 3 +-- .../src/main/native/include/frc/shuffleboard/BuiltInWidgets.h | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/wpilibc/src/main/native/include/frc/shuffleboard/BuiltInLayouts.h b/wpilibc/src/main/native/include/frc/shuffleboard/BuiltInLayouts.h index 2231993d116..71d2afc4a11 100644 --- a/wpilibc/src/main/native/include/frc/shuffleboard/BuiltInLayouts.h +++ b/wpilibc/src/main/native/include/frc/shuffleboard/BuiltInLayouts.h @@ -19,8 +19,7 @@ namespace frc { * .GetLayout(BuiltinLayouts::kList, "My List"); * } */ -class BuiltInLayouts { - public: +namespace BuiltInLayouts { /** * Groups components in a vertical list. New widgets added to the layout will * be placed at the bottom of the list.
      Custom properties: diff --git a/wpilibc/src/main/native/include/frc/shuffleboard/BuiltInWidgets.h b/wpilibc/src/main/native/include/frc/shuffleboard/BuiltInWidgets.h index 8780405c8c4..44430ada898 100644 --- a/wpilibc/src/main/native/include/frc/shuffleboard/BuiltInWidgets.h +++ b/wpilibc/src/main/native/include/frc/shuffleboard/BuiltInWidgets.h @@ -25,8 +25,7 @@ namespace frc { *

      Each value in this enum goes into detail on what data types that widget * can support, as well as the custom properties that widget uses. */ -class BuiltInWidgets { - public: +namespace BuiltInWidgets { /** * Displays a value with a simple text field. *
      Supported types: From 170856547c5b3426cea57ec498ebc06e3d84ca3b Mon Sep 17 00:00:00 2001 From: Thad House Date: Tue, 12 Feb 2019 16:03:37 -0800 Subject: [PATCH 15/18] Extra semicolon --- .../src/main/native/include/frc/shuffleboard/BuiltInLayouts.h | 2 +- .../src/main/native/include/frc/shuffleboard/BuiltInWidgets.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/wpilibc/src/main/native/include/frc/shuffleboard/BuiltInLayouts.h b/wpilibc/src/main/native/include/frc/shuffleboard/BuiltInLayouts.h index 71d2afc4a11..2ac74b37789 100644 --- a/wpilibc/src/main/native/include/frc/shuffleboard/BuiltInLayouts.h +++ b/wpilibc/src/main/native/include/frc/shuffleboard/BuiltInLayouts.h @@ -47,6 +47,6 @@ namespace BuiltInLayouts { *

      */ static constexpr LayoutType kGrid{"Grid Layout"}; -}; +} } // namespace frc diff --git a/wpilibc/src/main/native/include/frc/shuffleboard/BuiltInWidgets.h b/wpilibc/src/main/native/include/frc/shuffleboard/BuiltInWidgets.h index 44430ada898..d95025b5da1 100644 --- a/wpilibc/src/main/native/include/frc/shuffleboard/BuiltInWidgets.h +++ b/wpilibc/src/main/native/include/frc/shuffleboard/BuiltInWidgets.h @@ -381,6 +381,6 @@ namespace BuiltInWidgets { * */ static constexpr WidgetType kCameraStream{"Camera Stream"}; -}; +} } // namespace frc From d9c1914400d9735e3136fa8debe415edbc2b3be1 Mon Sep 17 00:00:00 2001 From: Thad House Date: Tue, 12 Feb 2019 16:27:36 -0800 Subject: [PATCH 16/18] Use enum for built in types Overloads were added for the other cases --- .../shuffleboard/ShuffleboardContainer.cpp | 14 +++++ .../cpp/shuffleboard/ShuffleboardWidget.cpp | 41 +++++++++++++++ .../include/frc/shuffleboard/BuiltInLayouts.h | 8 +-- .../include/frc/shuffleboard/BuiltInWidgets.h | 52 +++++++++---------- .../frc/shuffleboard/ShuffleboardContainer.h | 12 +++++ .../frc/shuffleboard/ShuffleboardWidget.h | 16 ++++++ 6 files changed, 113 insertions(+), 30 deletions(-) create mode 100644 wpilibc/src/main/native/cpp/shuffleboard/ShuffleboardWidget.cpp diff --git a/wpilibc/src/main/native/cpp/shuffleboard/ShuffleboardContainer.cpp b/wpilibc/src/main/native/cpp/shuffleboard/ShuffleboardContainer.cpp index 4954cff4e98..41c02ae752b 100644 --- a/wpilibc/src/main/native/cpp/shuffleboard/ShuffleboardContainer.cpp +++ b/wpilibc/src/main/native/cpp/shuffleboard/ShuffleboardContainer.cpp @@ -18,6 +18,15 @@ using namespace frc; +static constexpr char* layoutStrings[] = { + "List Layout", + "Grid Layout" + }; + +static constexpr const char* GetStringFromBuiltInLayout(BuiltInLayouts layout) { + return layoutStrings[static_cast(layout)]; +} + ShuffleboardContainer::ShuffleboardContainer(const wpi::Twine& title) : ShuffleboardValue(title) {} @@ -26,6 +35,11 @@ ShuffleboardContainer::GetComponents() const { return m_components; } +ShuffleboardLayout& ShuffleboardContainer::GetLayout(const wpi::Twine& title, + BuiltInLayouts type) { + return GetLayout(title, GetStringFromBuiltInLayout(type)); +} + ShuffleboardLayout& ShuffleboardContainer::GetLayout(const wpi::Twine& title, const LayoutType& type) { return GetLayout(title, type.GetLayoutName()); diff --git a/wpilibc/src/main/native/cpp/shuffleboard/ShuffleboardWidget.cpp b/wpilibc/src/main/native/cpp/shuffleboard/ShuffleboardWidget.cpp new file mode 100644 index 00000000000..57096652b0c --- /dev/null +++ b/wpilibc/src/main/native/cpp/shuffleboard/ShuffleboardWidget.cpp @@ -0,0 +1,41 @@ +/*----------------------------------------------------------------------------*/ +/* Copyright (c) 2018 FIRST. All Rights Reserved. */ +/* Open Source Software - may be modified and shared by FRC teams. The code */ +/* must be accompanied by the FIRST BSD license file in the root directory of */ +/* the project. */ +/*----------------------------------------------------------------------------*/ + +#include "frc/shuffleboard/ShuffleboardWidget.h" + +using namespace frc; + +static constexpr char* widgetStrings[] = { +"Text View", +"Number Slider", +"Number Bar", +"Simple Dial", +"Graph", +"Boolean Box", +"Toggle Button", +"Toggle Switch", +"Voltage View", +"PDP", +"ComboBox Chooser", +"Split Button Chooser", +"Encoder", +"Speed Controller", +"Command", +"PID Command", +"PID Controller", +"Accelerometer", +"3-Axis Accelerometer", +"Gyro", +"Relay", +"Differential Drivebase", +"Mecanum Drivebase", +"Camera Stream", +}; + +const char* detail::GetStringForWidgetType(BuiltInWidgets type) { + return widgetStrings[static_cast(type)]; +} diff --git a/wpilibc/src/main/native/include/frc/shuffleboard/BuiltInLayouts.h b/wpilibc/src/main/native/include/frc/shuffleboard/BuiltInLayouts.h index 2ac74b37789..c958baafc51 100644 --- a/wpilibc/src/main/native/include/frc/shuffleboard/BuiltInLayouts.h +++ b/wpilibc/src/main/native/include/frc/shuffleboard/BuiltInLayouts.h @@ -19,7 +19,7 @@ namespace frc { * .GetLayout(BuiltinLayouts::kList, "My List"); * } */ -namespace BuiltInLayouts { +enum class BuiltInLayouts { /** * Groups components in a vertical list. New widgets added to the layout will * be placed at the bottom of the list.
      Custom properties: @@ -29,7 +29,7 @@ namespace BuiltInLayouts { * {@code ["TOP", "LEFT", "BOTTOM", "RIGHT", "HIDDEN"} *
      */ - static constexpr LayoutType kList{"List Layout"}; + kList, /** * Groups components in an n x m grid. Grid layouts default to @@ -46,7 +46,7 @@ namespace BuiltInLayouts { * * */ - static constexpr LayoutType kGrid{"Grid Layout"}; -} + kGrid +}; } // namespace frc diff --git a/wpilibc/src/main/native/include/frc/shuffleboard/BuiltInWidgets.h b/wpilibc/src/main/native/include/frc/shuffleboard/BuiltInWidgets.h index d95025b5da1..bdd201158b9 100644 --- a/wpilibc/src/main/native/include/frc/shuffleboard/BuiltInWidgets.h +++ b/wpilibc/src/main/native/include/frc/shuffleboard/BuiltInWidgets.h @@ -25,7 +25,7 @@ namespace frc { *

      Each value in this enum goes into detail on what data types that widget * can support, as well as the custom properties that widget uses. */ -namespace BuiltInWidgets { +enum class BuiltInWidgets { /** * Displays a value with a simple text field. *
      Supported types: @@ -36,7 +36,7 @@ namespace BuiltInWidgets { *

    *
    This widget has no custom properties. */ - static constexpr WidgetType kTextView{"Text View"}; + kTextView, /** * Displays a number with a controllable slider. *
    Supported types: @@ -53,7 +53,7 @@ namespace BuiltInWidgets { * slider by with the arrow keys * */ - static constexpr WidgetType kNumberSlider{"Number Slider"}; + kNumberSlider, /** * Displays a number with a view-only bar. *
    Supported types: @@ -70,7 +70,7 @@ namespace BuiltInWidgets { * of the bar * */ - static constexpr WidgetType kNumberBar{"Number Bar"}; + kNumberBar, /** * Displays a number with a view-only dial. Displayed values are rounded to * the nearest integer.
    Supported types:
    • Number
    • @@ -85,7 +85,7 @@ namespace BuiltInWidgets { * value as text * */ - static constexpr WidgetType kDial{"Simple Dial"}; + kDial, /** * Displays a number with a graph. NOTE: graphs can be taxing * on the computer running the dashboard. Keep the number of visible data @@ -102,7 +102,7 @@ namespace BuiltInWidgets { * How long, in seconds, should past data be visible for * */ - static constexpr WidgetType kGraph{"Graph"}; + kGraph, /** * Displays a boolean value as a large colored box. *
      Supported types: @@ -120,7 +120,7 @@ namespace BuiltInWidgets { * Can be specified as a string or a number * */ - static constexpr WidgetType kBooleanBox{"Boolean Box"}; + kBooleanBox, /** * Displays a boolean with a large interactive toggle button. *
      Supported types: @@ -129,7 +129,7 @@ namespace BuiltInWidgets { *
    *
    This widget has no custom properties. */ - static constexpr WidgetType kToggleButton{"Toggle Button"}; + kToggleButton, /** * Displays a boolean with a fixed-size toggle switch. *
    Supported types: @@ -138,7 +138,7 @@ namespace BuiltInWidgets { *
*
This widget has no custom properties. */ - static constexpr WidgetType kToggleSwitch{"Toggle Switch"}; + kToggleSwitch, /** * Displays an analog input or a raw number with a number bar. *
Supported types: @@ -161,7 +161,7 @@ namespace BuiltInWidgets { * bar * */ - static constexpr WidgetType kVoltageView{"Voltage View"}; + kVoltageView, /** * Displays a {@link edu.wpi.first.wpilibj.PowerDistributionPanel * PowerDistributionPanel}.
Supported types:
  • {@link @@ -174,7 +174,7 @@ namespace BuiltInWidgets { * Whether or not to display the voltage and current draw * */ - static constexpr WidgetType kPowerDistributionPanel{"PDP"}; + kPowerDistributionPanel, /** * Displays a {@link edu.wpi.first.wpilibj.smartdashboard.SendableChooser * SendableChooser} with a dropdown combo box with a list of options. @@ -184,7 +184,7 @@ namespace BuiltInWidgets { *
*
This widget has no custom properties. */ - static constexpr WidgetType kComboBoxChooser{"ComboBox Chooser"}; + kComboBoxChooser, /** * Displays a {@link edu.wpi.first.wpilibj.smartdashboard.SendableChooser * SendableChooser} with a toggle button for each available option. @@ -194,7 +194,7 @@ namespace BuiltInWidgets { * *
This widget has no custom properties. */ - static constexpr WidgetType kSplitButtonChooser{"Split Button Chooser"}; + kSplitButtonChooser, /** * Displays an {@link edu.wpi.first.wpilibj.Encoder} displaying its speed, * total travelled distance, and its distance per tick.
Supported types: @@ -203,7 +203,7 @@ namespace BuiltInWidgets { * *
This widget has no custom properties. */ - static constexpr WidgetType kEncoder{"Encoder"}; + kEncoder, /** * Displays a {@link edu.wpi.first.wpilibj.SpeedController SpeedController}. * The speed controller will be controllable from the dashboard when test mode @@ -227,7 +227,7 @@ namespace BuiltInWidgets { * One of {@code ["HORIZONTAL", "VERTICAL"]} * */ - static constexpr WidgetType kSpeedController{"Speed Controller"}; + kSpeedController, /** * Displays a command with a toggle button. Pressing the button will start the * command, and the button will automatically release when the command @@ -238,7 +238,7 @@ namespace BuiltInWidgets { * *
This widget has no custom properties. */ - static constexpr WidgetType kCommand{"Command"}; + kCommand, /** * Displays a PID command with a checkbox and an editor for the PIDF * constants. Selecting the checkbox will start the command, and the checkbox @@ -248,7 +248,7 @@ namespace BuiltInWidgets { * *
This widget has no custom properties. */ - static constexpr WidgetType kPIDCommand{"PID Command"}; + kPIDCommand, /** * Displays a PID controller with an editor for the PIDF constants and a * toggle switch for enabling and disabling the controller.
Supported @@ -256,7 +256,7 @@ namespace BuiltInWidgets { * *
This widget has no custom properties. */ - static constexpr WidgetType kPIDController{"PID Controller"}; + kPIDController, /** * Displays an accelerometer with a number bar displaying the magnitude of the * acceleration and text displaying the exact value.
Supported types:
    @@ -277,7 +277,7 @@ namespace BuiltInWidgets { * Show or hide the tick marks on the number bars * */ - static constexpr WidgetType kAccelerometer{"Accelerometer"}; + kAccelerometer, /** * Displays a 3-axis accelerometer with a number bar for each axis' * accleration.
    Supported types:
    • {@link @@ -297,7 +297,7 @@ namespace BuiltInWidgets { * Show or hide the tick marks on the number bars * */ - static constexpr WidgetType k3AxisAccelerometer{"3-Axis Accelerometer"}; + k3AxisAccelerometer, /** * Displays a gyro with a dial from 0 to 360 degrees. *
      Supported types: @@ -316,7 +316,7 @@ namespace BuiltInWidgets { * Show tick mark ringBooleantrue * */ - static constexpr WidgetType kGyro{"Gyro"}; + kGyro, /** * Displays a relay with toggle buttons for each supported mode (off, on, * forward, reverse).
      Supported types:
      • {@link @@ -324,7 +324,7 @@ namespace BuiltInWidgets { *
      *
      This widget has no custom properties. */ - static constexpr WidgetType kRelay{"Relay"}; + kRelay, /** * Displays a differential drive with a widget that displays the speed of each * side of the drivebase and a vector for the direction and rotation of the @@ -343,7 +343,7 @@ namespace BuiltInWidgets { * Show velocity vectorsBooleantrue * */ - static constexpr WidgetType kDifferentialDrive{"Differential Drivebase"}; + kDifferentialDrive, /** * Displays a mecanum drive with a widget that displays the speed of each * wheel, and vectors for the direction and rotation of the drivebase. The @@ -356,7 +356,7 @@ namespace BuiltInWidgets { * Show velocity vectorsBooleantrue * */ - static constexpr WidgetType kMecanumDrive{"Mecanum Drivebase"}; + kMecanumDrive, /** * Displays a camera stream. *
      Supported types: @@ -380,7 +380,7 @@ namespace BuiltInWidgets { * * */ - static constexpr WidgetType kCameraStream{"Camera Stream"}; -} + kCameraStream +}; } // namespace frc diff --git a/wpilibc/src/main/native/include/frc/shuffleboard/ShuffleboardContainer.h b/wpilibc/src/main/native/include/frc/shuffleboard/ShuffleboardContainer.h index e53bcfc3098..1a4da647abe 100644 --- a/wpilibc/src/main/native/include/frc/shuffleboard/ShuffleboardContainer.h +++ b/wpilibc/src/main/native/include/frc/shuffleboard/ShuffleboardContainer.h @@ -20,6 +20,7 @@ #include "frc/ErrorBase.h" #include "frc/WPIErrors.h" +#include "frc/shuffleboard/BuiltInLayouts.h" #include "frc/shuffleboard/LayoutType.h" #include "frc/shuffleboard/ShuffleboardComponentBase.h" #include "frc/shuffleboard/ShuffleboardValue.h" @@ -53,6 +54,17 @@ class ShuffleboardContainer : public virtual ShuffleboardValue, const std::vector>& GetComponents() const; + /** + * Gets the layout with the given type and title, creating it if it does not + * already exist at the time this method is called. + * + * @param title the title of the layout + * @param layoutType the type of the layout, eg "List" or "Grid" + * @return the layout + */ + ShuffleboardLayout& GetLayout(const wpi::Twine& title, + BuiltInLayouts type); + /** * Gets the layout with the given type and title, creating it if it does not * already exist at the time this method is called. diff --git a/wpilibc/src/main/native/include/frc/shuffleboard/ShuffleboardWidget.h b/wpilibc/src/main/native/include/frc/shuffleboard/ShuffleboardWidget.h index 9f9e0ef3b93..83f84dfb384 100644 --- a/wpilibc/src/main/native/include/frc/shuffleboard/ShuffleboardWidget.h +++ b/wpilibc/src/main/native/include/frc/shuffleboard/ShuffleboardWidget.h @@ -9,6 +9,7 @@ #include +#include "frc/shuffleboard/BuiltInWidgets.h" #include "frc/shuffleboard/ShuffleboardComponent.h" #include "frc/shuffleboard/WidgetType.h" @@ -16,6 +17,10 @@ namespace frc { class ShuffleboardContainer; +namespace detail { +const char* GetStringForWidgetType(BuiltInWidgets type); +} + /** * Abstract superclass for widgets. * @@ -38,6 +43,17 @@ class ShuffleboardWidget : public ShuffleboardComponent { * @return this widget object * @see BuiltInWidgets */ + Derived& WithWidget(BuiltInWidgets widgetType) { + return WithWidget(detail::GetStringForWidgetType(widgetType)); + } + + /** + * Sets the type of widget used to display the data. If not set, the default + * widget type will be used. + * + * @param widgetType the type of the widget used to display the data + * @return this widget object + */ Derived& WithWidget(const WidgetType& widgetType) { return WithWidget(widgetType.GetWidgetName()); } From 1a3a690440bc9f943f843a36451fe350af5777bc Mon Sep 17 00:00:00 2001 From: Thad House Date: Tue, 12 Feb 2019 16:50:49 -0800 Subject: [PATCH 17/18] Pedantic errors --- .../src/main/native/cpp/shuffleboard/ShuffleboardContainer.cpp | 2 +- wpilibc/src/main/native/cpp/shuffleboard/ShuffleboardWidget.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/wpilibc/src/main/native/cpp/shuffleboard/ShuffleboardContainer.cpp b/wpilibc/src/main/native/cpp/shuffleboard/ShuffleboardContainer.cpp index 41c02ae752b..c921d7d4f08 100644 --- a/wpilibc/src/main/native/cpp/shuffleboard/ShuffleboardContainer.cpp +++ b/wpilibc/src/main/native/cpp/shuffleboard/ShuffleboardContainer.cpp @@ -18,7 +18,7 @@ using namespace frc; -static constexpr char* layoutStrings[] = { +static constexpr const char* layoutStrings[] = { "List Layout", "Grid Layout" }; diff --git a/wpilibc/src/main/native/cpp/shuffleboard/ShuffleboardWidget.cpp b/wpilibc/src/main/native/cpp/shuffleboard/ShuffleboardWidget.cpp index 57096652b0c..1b24e9a164c 100644 --- a/wpilibc/src/main/native/cpp/shuffleboard/ShuffleboardWidget.cpp +++ b/wpilibc/src/main/native/cpp/shuffleboard/ShuffleboardWidget.cpp @@ -9,7 +9,7 @@ using namespace frc; -static constexpr char* widgetStrings[] = { +static constexpr const char* widgetStrings[] = { "Text View", "Number Slider", "Number Bar", From 6da267b508e6dc4ecdf39ef60a3e25d952d82973 Mon Sep 17 00:00:00 2001 From: Thad House Date: Tue, 12 Feb 2019 17:22:31 -0800 Subject: [PATCH 18/18] Formatting --- .../shuffleboard/ShuffleboardContainer.cpp | 5 +- .../cpp/shuffleboard/ShuffleboardWidget.cpp | 48 +++++++++---------- .../frc/shuffleboard/ShuffleboardContainer.h | 3 +- .../frc/shuffleboard/ShuffleboardWidget.h | 2 +- 4 files changed, 27 insertions(+), 31 deletions(-) diff --git a/wpilibc/src/main/native/cpp/shuffleboard/ShuffleboardContainer.cpp b/wpilibc/src/main/native/cpp/shuffleboard/ShuffleboardContainer.cpp index c921d7d4f08..f13116d1846 100644 --- a/wpilibc/src/main/native/cpp/shuffleboard/ShuffleboardContainer.cpp +++ b/wpilibc/src/main/native/cpp/shuffleboard/ShuffleboardContainer.cpp @@ -18,10 +18,7 @@ using namespace frc; -static constexpr const char* layoutStrings[] = { - "List Layout", - "Grid Layout" - }; +static constexpr const char* layoutStrings[] = {"List Layout", "Grid Layout"}; static constexpr const char* GetStringFromBuiltInLayout(BuiltInLayouts layout) { return layoutStrings[static_cast(layout)]; diff --git a/wpilibc/src/main/native/cpp/shuffleboard/ShuffleboardWidget.cpp b/wpilibc/src/main/native/cpp/shuffleboard/ShuffleboardWidget.cpp index 1b24e9a164c..4573516668b 100644 --- a/wpilibc/src/main/native/cpp/shuffleboard/ShuffleboardWidget.cpp +++ b/wpilibc/src/main/native/cpp/shuffleboard/ShuffleboardWidget.cpp @@ -10,30 +10,30 @@ using namespace frc; static constexpr const char* widgetStrings[] = { -"Text View", -"Number Slider", -"Number Bar", -"Simple Dial", -"Graph", -"Boolean Box", -"Toggle Button", -"Toggle Switch", -"Voltage View", -"PDP", -"ComboBox Chooser", -"Split Button Chooser", -"Encoder", -"Speed Controller", -"Command", -"PID Command", -"PID Controller", -"Accelerometer", -"3-Axis Accelerometer", -"Gyro", -"Relay", -"Differential Drivebase", -"Mecanum Drivebase", -"Camera Stream", + "Text View", + "Number Slider", + "Number Bar", + "Simple Dial", + "Graph", + "Boolean Box", + "Toggle Button", + "Toggle Switch", + "Voltage View", + "PDP", + "ComboBox Chooser", + "Split Button Chooser", + "Encoder", + "Speed Controller", + "Command", + "PID Command", + "PID Controller", + "Accelerometer", + "3-Axis Accelerometer", + "Gyro", + "Relay", + "Differential Drivebase", + "Mecanum Drivebase", + "Camera Stream", }; const char* detail::GetStringForWidgetType(BuiltInWidgets type) { diff --git a/wpilibc/src/main/native/include/frc/shuffleboard/ShuffleboardContainer.h b/wpilibc/src/main/native/include/frc/shuffleboard/ShuffleboardContainer.h index 1a4da647abe..ab0309953af 100644 --- a/wpilibc/src/main/native/include/frc/shuffleboard/ShuffleboardContainer.h +++ b/wpilibc/src/main/native/include/frc/shuffleboard/ShuffleboardContainer.h @@ -62,8 +62,7 @@ class ShuffleboardContainer : public virtual ShuffleboardValue, * @param layoutType the type of the layout, eg "List" or "Grid" * @return the layout */ - ShuffleboardLayout& GetLayout(const wpi::Twine& title, - BuiltInLayouts type); + ShuffleboardLayout& GetLayout(const wpi::Twine& title, BuiltInLayouts type); /** * Gets the layout with the given type and title, creating it if it does not diff --git a/wpilibc/src/main/native/include/frc/shuffleboard/ShuffleboardWidget.h b/wpilibc/src/main/native/include/frc/shuffleboard/ShuffleboardWidget.h index 83f84dfb384..3b1b0a8aea5 100644 --- a/wpilibc/src/main/native/include/frc/shuffleboard/ShuffleboardWidget.h +++ b/wpilibc/src/main/native/include/frc/shuffleboard/ShuffleboardWidget.h @@ -19,7 +19,7 @@ class ShuffleboardContainer; namespace detail { const char* GetStringForWidgetType(BuiltInWidgets type); -} +} // namespace detail /** * Abstract superclass for widgets.