[wpilibc] Revert "Return reference from GetInstance" (#3342)

This reverts commit a79faace1b.

This change will be superseded in a non-breaking way by changing to static functions and deprecating GetInstance() entirely.
This commit is contained in:
Peter Johnson
2021-05-09 18:16:07 -07:00
committed by GitHub
parent 3cc2da3328
commit 3fe8fc75aa
18 changed files with 63 additions and 67 deletions

View File

@@ -112,7 +112,7 @@ void IterativeRobotBase::LoopFunc() {
// Call DisabledInit() if we are now just entering disabled mode from
// either a different mode or from power-on.
if (m_lastMode != Mode::kDisabled) {
LiveWindow::GetInstance().SetEnabled(false);
LiveWindow::GetInstance()->SetEnabled(false);
Shuffleboard::DisableActuatorWidgets();
DisabledInit();
m_watchdog.AddEpoch("DisabledInit()");
@@ -126,7 +126,7 @@ void IterativeRobotBase::LoopFunc() {
// Call AutonomousInit() if we are now just entering autonomous mode from
// either a different mode or from power-on.
if (m_lastMode != Mode::kAutonomous) {
LiveWindow::GetInstance().SetEnabled(false);
LiveWindow::GetInstance()->SetEnabled(false);
Shuffleboard::DisableActuatorWidgets();
AutonomousInit();
m_watchdog.AddEpoch("AutonomousInit()");
@@ -140,7 +140,7 @@ void IterativeRobotBase::LoopFunc() {
// Call TeleopInit() if we are now just entering teleop mode from
// either a different mode or from power-on.
if (m_lastMode != Mode::kTeleop) {
LiveWindow::GetInstance().SetEnabled(false);
LiveWindow::GetInstance()->SetEnabled(false);
Shuffleboard::DisableActuatorWidgets();
TeleopInit();
m_watchdog.AddEpoch("TeleopInit()");
@@ -154,7 +154,7 @@ void IterativeRobotBase::LoopFunc() {
// Call TestInit() if we are now just entering test mode from
// either a different mode or from power-on.
if (m_lastMode != Mode::kTest) {
LiveWindow::GetInstance().SetEnabled(true);
LiveWindow::GetInstance()->SetEnabled(true);
Shuffleboard::EnableActuatorWidgets();
TestInit();
m_watchdog.AddEpoch("TestInit()");
@@ -171,7 +171,7 @@ void IterativeRobotBase::LoopFunc() {
SmartDashboard::UpdateValues();
m_watchdog.AddEpoch("SmartDashboard::UpdateValues()");
LiveWindow::GetInstance().UpdateValues();
LiveWindow::GetInstance()->UpdateValues();
m_watchdog.AddEpoch("LiveWindow::UpdateValues()");
Shuffleboard::Update();
m_watchdog.AddEpoch("Shuffleboard::Update()");

View File

@@ -15,9 +15,9 @@ using namespace frc;
// The Preferences table name
static wpi::StringRef kTableName{"Preferences"};
Preferences& Preferences::GetInstance() {
Preferences* Preferences::GetInstance() {
static Preferences instance;
return instance;
return &instance;
}
std::vector<std::string> Preferences::GetKeys() {
@@ -165,5 +165,3 @@ Preferences::Preferences()
NT_NOTIFY_NEW | NT_NOTIFY_IMMEDIATE);
HAL_Report(HALUsageReporting::kResourceType_Preferences, 0);
}
Preferences::~Preferences() = default;

View File

@@ -61,9 +61,9 @@ std::shared_ptr<LiveWindow::Impl::Component> LiveWindow::Impl::GetOrAdd(
return data;
}
LiveWindow& LiveWindow::GetInstance() {
LiveWindow* LiveWindow::GetInstance() {
static LiveWindow instance;
return instance;
return &instance;
}
void LiveWindow::EnableTelemetry(Sendable* sendable) {