diff --git a/pathplannerlib/src/main/native/cpp/pathplanner/lib/auto/NamedCommands.cpp b/pathplannerlib/src/main/native/cpp/pathplanner/lib/auto/NamedCommands.cpp index c1630e8c..f329875e 100644 --- a/pathplannerlib/src/main/native/cpp/pathplanner/lib/auto/NamedCommands.cpp +++ b/pathplannerlib/src/main/native/cpp/pathplanner/lib/auto/NamedCommands.cpp @@ -5,15 +5,6 @@ using namespace pathplanner; std::unordered_map> NamedCommands::namedCommands; -void NamedCommands::registerCommand(std::string name, - std::shared_ptr command) { - NamedCommands::namedCommands.emplace(name, command); -} - -bool NamedCommands::hasCommand(std::string name) { - return NamedCommands::namedCommands.contains(name); -} - frc2::CommandPtr NamedCommands::getCommand(std::string name) { if (NamedCommands::hasCommand(name)) { return CommandUtil::wrappedEventCommand( diff --git a/pathplannerlib/src/main/native/include/pathplanner/lib/auto/NamedCommands.h b/pathplannerlib/src/main/native/include/pathplanner/lib/auto/NamedCommands.h index 693578ed..a171909d 100644 --- a/pathplannerlib/src/main/native/include/pathplanner/lib/auto/NamedCommands.h +++ b/pathplannerlib/src/main/native/include/pathplanner/lib/auto/NamedCommands.h @@ -14,8 +14,17 @@ class NamedCommands { * @param name the name of the command * @param command shared pointer to the command to register */ - static void registerCommand(std::string name, - std::shared_ptr command); + static inline void registerCommand(std::string name, + std::shared_ptr command) { + NamedCommands::namedCommands.emplace(name, command); + } + + static inline void registerCommand(std::string name, + frc2::CommandPtr &&command) { + registerCommand(name, + std::shared_ptr < frc2::Command + > (std::move(command).Unwrap())); + } /** * Returns whether a command with the given name has been registered. @@ -23,7 +32,9 @@ class NamedCommands { * @param name the name of the command to check * @return true if a command with the given name has been registered, false otherwise */ - static bool hasCommand(std::string name); + static inline bool hasCommand(std::string name) { + return NamedCommands::namedCommands.contains(name); + } /** * Returns the command with the given name.