mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-20 00:51:42 +00:00
[wpilibc] Return reference from GetInstance (#3247)
Improves consistency across all classes. Affects Preferences, LiveWindow, and CameraServer. Old commands Scheduler::GetInstance() was not updated as this is already deprecated.
This commit is contained in:
@@ -108,7 +108,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()");
|
||||
@@ -122,7 +122,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()");
|
||||
@@ -136,7 +136,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()");
|
||||
@@ -150,7 +150,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()");
|
||||
@@ -167,7 +167,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()");
|
||||
|
||||
@@ -17,9 +17,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() {
|
||||
@@ -143,3 +143,5 @@ Preferences::Preferences()
|
||||
NT_NOTIFY_NEW | NT_NOTIFY_IMMEDIATE);
|
||||
HAL_Report(HALUsageReporting::kResourceType_Preferences, 0);
|
||||
}
|
||||
|
||||
Preferences::~Preferences() = default;
|
||||
|
||||
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user