From 129294cf05e7e3d7e8bf7c6197e8649488e6007b Mon Sep 17 00:00:00 2001 From: Ryan Blue Date: Fri, 1 Nov 2024 03:47:00 -0400 Subject: [PATCH] shrink header by moving as much to cpp --- wpilibc/src/main/native/cpp/Alert.cpp | 35 ++++++++++++++++-- wpilibc/src/main/native/include/frc/Alert.h | 40 ++------------------- 2 files changed, 35 insertions(+), 40 deletions(-) diff --git a/wpilibc/src/main/native/cpp/Alert.cpp b/wpilibc/src/main/native/cpp/Alert.cpp index 79037ae1248..896990f8da9 100644 --- a/wpilibc/src/main/native/cpp/Alert.cpp +++ b/wpilibc/src/main/native/cpp/Alert.cpp @@ -4,23 +4,54 @@ #include "frc/Alert.h" -#include +#include -#include #include #include #include #include #include +#include #include +#include +#include #include #include "frc/Errors.h" +#include "frc/RobotController.h" #include "frc/smartdashboard/SmartDashboard.h" using namespace frc; +class Alert::PublishedAlert { + public: + PublishedAlert(uint64_t timestamp, std::string_view text) + : timestamp{timestamp}, text{text} {} + uint64_t timestamp; + std::string text; + auto operator<=>(const PublishedAlert&) const = default; +}; + +class Alert::SendableAlerts : public nt::NTSendable, + public wpi::SendableHelper { + public: + SendableAlerts(); + void InitSendable(nt::NTSendableBuilder& builder) override; + + /** + * Returns a reference to the set of active alerts for the given type. + * @param type the type + * @return reference to the set of active alerts for the type + */ + std::set& GetActiveAlertsStorage(AlertType type); + const std::set& GetActiveAlertsStorage(AlertType type) const; + + private: + std::vector GetStrings(AlertType type) const; + std::array, 3> m_alerts; +}; + // TODO: throw if matching (group, text, type) already constructed Alert::Alert(std::string_view text, AlertType type) : Alert("Alerts", text, type) {} diff --git a/wpilibc/src/main/native/include/frc/Alert.h b/wpilibc/src/main/native/include/frc/Alert.h index fda9bafdaad..24aa379b987 100644 --- a/wpilibc/src/main/native/include/frc/Alert.h +++ b/wpilibc/src/main/native/include/frc/Alert.h @@ -4,18 +4,8 @@ #pragma once -#include - -#include -#include #include #include -#include - -#include -#include -#include -#include namespace frc { @@ -131,34 +121,8 @@ class Alert { AlertType GetType() const { return m_type; } private: - class PublishedAlert { - public: - PublishedAlert(uint64_t timestamp, std::string_view text) - : timestamp{timestamp}, text{text} {} - uint64_t timestamp; - std::string text; - auto operator<=>(const PublishedAlert&) const = default; - }; - - class SendableAlerts : public nt::NTSendable, - public wpi::SendableHelper { - public: - SendableAlerts(); - void InitSendable(nt::NTSendableBuilder& builder) override; - - /** - * Returns a reference to the set of active alerts for the given type. - * @param type the type - * @return reference to the set of active alerts for the type - */ - std::set& GetActiveAlertsStorage(AlertType type); - const std::set& GetActiveAlertsStorage( - AlertType type) const; - - private: - std::vector GetStrings(AlertType type) const; - std::array, 3> m_alerts; - }; + class PublishedAlert; + class SendableAlerts; AlertType m_type; std::string m_text;