[commands] Allow unsetting a subsystem's default command (#4621)

This commit is contained in:
Colin Wong
2022-11-28 16:03:14 -06:00
committed by GitHub
parent 2b2aa8eef7
commit ec124bb662
3 changed files with 38 additions and 0 deletions

View File

@@ -258,6 +258,11 @@ void CommandScheduler::Run() {
}
void CommandScheduler::RegisterSubsystem(Subsystem* subsystem) {
if (m_impl->subsystems.find(subsystem) != m_impl->subsystems.end()) {
std::puts("Tried to register an already-registered subsystem");
return;
}
m_impl->subsystems[subsystem] = nullptr;
}
@@ -306,6 +311,10 @@ void CommandScheduler::SetDefaultCommand(Subsystem* subsystem,
SetDefaultCommandImpl(subsystem, std::move(defaultCommand).Unwrap());
}
void CommandScheduler::RemoveDefaultCommand(Subsystem* subsystem) {
m_impl->subsystems[subsystem] = nullptr;
}
Command* CommandScheduler::GetDefaultCommand(const Subsystem* subsystem) const {
auto&& find = m_impl->subsystems.find(subsystem);
if (find != m_impl->subsystems.end()) {