YAMS
Yet Another Mechanism System
Loading...
Searching...
No Matches
SmartMotorControllerCommandRegistry.hpp
Go to the documentation of this file.
1// Copyright (c) 2026 Yet Another Software Suite
2// SPDX-License-Identifier: LGPL-3.0-or-later
3
4#pragma once
5
6#include <functional>
7#include <string>
8#include <unordered_map>
9#include <vector>
10#include <wpi/commands2/CommandPtr.hpp>
11#include <wpi/commands2/SubsystemBase.hpp>
12
13namespace yams::motorcontrollers {
14
25 public:
36 static void AddCommand(const std::string& cmdName, wpi::cmd::SubsystemBase* subsystem,
37 std::function<void()> callback);
38
47 static void AddCommand(const std::string& cmdName, wpi::cmd::SubsystemBase* subsystem,
48 std::function<void()> callback, std::function<void()> onEnd);
49
57 static wpi::cmd::Command* GetCommand(const std::string& cmdName,
58 wpi::cmd::SubsystemBase* subsystem);
59
67 static bool CommandExists(const std::string& cmdName, wpi::cmd::SubsystemBase* subsystem);
68
79 static void RemoveCommands(wpi::cmd::SubsystemBase* subsystem);
80
88 static void Clear();
89
90 private:
91 static std::unordered_map<std::string, wpi::cmd::CommandPtr> s_commands;
92 static std::unordered_map<std::string, std::vector<std::function<void()>>> s_callbacks;
93 static std::unordered_map<std::string, std::vector<std::function<void()>>> s_endCallbacks;
94 static std::unordered_map<std::string, wpi::cmd::SubsystemBase*> s_owners;
95
96 static std::string MakeKey(const std::string& cmdName, wpi::cmd::SubsystemBase* subsystem);
97 static void PublishToNT(const std::string& cmdName, wpi::cmd::SubsystemBase* subsystem);
98};
99
100} // namespace yams::motorcontrollers
Definition SmartMotorControllerCommandRegistry.hpp:24
static void RemoveCommands(wpi::cmd::SubsystemBase *subsystem)
static wpi::cmd::Command * GetCommand(const std::string &cmdName, wpi::cmd::SubsystemBase *subsystem)
static void AddCommand(const std::string &cmdName, wpi::cmd::SubsystemBase *subsystem, std::function< void()> callback, std::function< void()> onEnd)
static bool CommandExists(const std::string &cmdName, wpi::cmd::SubsystemBase *subsystem)
static void AddCommand(const std::string &cmdName, wpi::cmd::SubsystemBase *subsystem, std::function< void()> callback)
Definition SimSensorConfig.hpp:15