[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:
Peter Johnson
2021-03-21 11:13:49 -07:00
committed by GitHub
parent 9550777b9d
commit a79faace1b
18 changed files with 67 additions and 64 deletions

View File

@@ -71,19 +71,19 @@ CommandScheduler::CommandScheduler()
HAL_Report(HALUsageReporting::kResourceType_Command,
HALUsageReporting::kCommand2_Scheduler);
frc::SendableRegistry::GetInstance().AddLW(this, "Scheduler");
auto scheduler = frc::LiveWindow::GetInstance();
scheduler->enabled = [this] {
this->Disable();
this->CancelAll();
auto& scheduler = frc::LiveWindow::GetInstance();
scheduler.enabled = [this] {
Disable();
CancelAll();
};
scheduler->disabled = [this] { this->Enable(); };
scheduler.disabled = [this] { Enable(); };
}
CommandScheduler::~CommandScheduler() {
frc::SendableRegistry::GetInstance().Remove(this);
auto scheduler = frc::LiveWindow::GetInstance();
scheduler->enabled = nullptr;
scheduler->disabled = nullptr;
auto& scheduler = frc::LiveWindow::GetInstance();
scheduler.enabled = nullptr;
scheduler.disabled = nullptr;
std::unique_ptr<Impl>().swap(m_impl);
}