[wpilib] Deprecate getInstance() in favor of static functions (#3440)

Co-authored-by: Noam Zaks <imnoamzaks@gmail.com>
This commit is contained in:
Peter Johnson
2021-06-15 23:06:03 -07:00
committed by GitHub
parent 26ff9371d9
commit 362066a9b7
105 changed files with 1500 additions and 1539 deletions

View File

@@ -5,7 +5,8 @@
#pragma once
#include <functional>
#include <memory>
#include <wpi/deprecated.h>
namespace wpi {
class Sendable;
@@ -19,47 +20,58 @@ namespace frc {
*/
class LiveWindow {
public:
LiveWindow(const LiveWindow&) = delete;
LiveWindow& operator=(const LiveWindow&) = delete;
std::function<void()> enabled;
std::function<void()> disabled;
/**
* Get an instance of the LiveWindow main class.
*
* This is a singleton to guarantee that there is only a single instance
* regardless of how many times GetInstance is called.
* @deprecated Use the static methods unless guaranteeing LiveWindow is
* instantiated
*/
WPI_DEPRECATED("Use static methods")
static LiveWindow* GetInstance();
/**
* Set function to be called when LiveWindow is enabled.
*
* @param func function (or nullptr for none)
*/
static void SetEnabledCallback(std::function<void()> func);
/**
* Set function to be called when LiveWindow is disabled.
*
* @param func function (or nullptr for none)
*/
static void SetDisabledCallback(std::function<void()> func);
/**
* Enable telemetry for a single component.
*
* @param sendable component
*/
void EnableTelemetry(wpi::Sendable* component);
static void EnableTelemetry(wpi::Sendable* component);
/**
* Disable telemetry for a single component.
*
* @param sendable component
*/
void DisableTelemetry(wpi::Sendable* component);
static void DisableTelemetry(wpi::Sendable* component);
/**
* Disable ALL telemetry.
*/
void DisableAllTelemetry();
static void DisableAllTelemetry();
bool IsEnabled() const;
static bool IsEnabled();
/**
* Change the enabled status of LiveWindow.
*
* If it changes to enabled, start livewindow running otherwise stop it
*/
void SetEnabled(bool enabled);
static void SetEnabled(bool enabled);
/**
* Tell all the sensors to update (send) their values.
@@ -67,18 +79,15 @@ class LiveWindow {
* Actuators are handled through callbacks on their value changing from the
* SmartDashboard widgets.
*/
void UpdateValues();
static void UpdateValues();
private:
LiveWindow();
struct Impl;
std::unique_ptr<Impl> m_impl;
LiveWindow() = default;
/**
* Updates the entries, without using a mutex or lock.
*/
void UpdateValuesUnsafe();
static void UpdateValuesUnsafe();
};
} // namespace frc