diff --git a/wpilibc/src/main/native/include/frc/smartdashboard/SendableChooser.h b/wpilibc/src/main/native/include/frc/smartdashboard/SendableChooser.h index b370fc0f4f..c55df67ee9 100644 --- a/wpilibc/src/main/native/include/frc/smartdashboard/SendableChooser.h +++ b/wpilibc/src/main/native/include/frc/smartdashboard/SendableChooser.h @@ -45,12 +45,31 @@ class SendableChooser : public SendableChooserBase { static std::weak_ptr _unwrap_smart_ptr(const std::shared_ptr& value); public: - ~SendableChooser() override = default; SendableChooser() = default; + ~SendableChooser() override = default; SendableChooser(SendableChooser&& rhs) = default; SendableChooser& operator=(SendableChooser&& rhs) = default; + /** + * Adds the given object to the list of options. + * + * On the SmartDashboard on the desktop, the object will appear as the given + * name. + * + * @param name the name of the option + * @param object the option + */ void AddOption(wpi::StringRef name, T object); + + /** + * Add the given object to the list of options and marks it as the default. + * + * Functionally, this is very close to AddOption() except that it will use + * this as the default option if none other is explicitly selected. + * + * @param name the name of the option + * @param object the option + */ void SetDefaultOption(wpi::StringRef name, T object); /** @@ -83,6 +102,17 @@ class SendableChooser : public SendableChooserBase { SetDefaultOption(name, object); } + /** + * Returns a copy of the selected option (a raw pointer U* if T = + * std::unique_ptr or a std::weak_ptr if T = std::shared_ptr). + * + * If there is none selected, it will return the default. If there is none + * selected and no default, then it will return a value-initialized instance. + * For integer types, this is 0. For container types like std::string, this is + * an empty string. + * + * @return The option selected + */ auto GetSelected() -> decltype(_unwrap_smart_ptr(m_choices[""])); void InitSendable(SendableBuilder& builder) override; diff --git a/wpilibc/src/main/native/include/frc/smartdashboard/SendableChooser.inc b/wpilibc/src/main/native/include/frc/smartdashboard/SendableChooser.inc index 57e28285fa..300c9022d4 100644 --- a/wpilibc/src/main/native/include/frc/smartdashboard/SendableChooser.inc +++ b/wpilibc/src/main/native/include/frc/smartdashboard/SendableChooser.inc @@ -17,46 +17,17 @@ namespace frc { -/** - * Adds the given object to the list of options. - * - * On the SmartDashboard on the desktop, the object will appear as the given - * name. - * - * @param name the name of the option - * @param object the option - */ template void SendableChooser::AddOption(wpi::StringRef name, T object) { m_choices[name] = std::move(object); } -/** - * Add the given object to the list of options and marks it as the default. - * - * Functionally, this is very close to AddOption() except that it will use this - * as the default option if none other is explicitly selected. - * - * @param name the name of the option - * @param object the option - */ template void SendableChooser::SetDefaultOption(wpi::StringRef name, T object) { m_defaultChoice = name; AddOption(name, std::move(object)); } -/** - * Returns a copy of the selected option (a raw pointer U* if T = - * std::unique_ptr or a std::weak_ptr if T = std::shared_ptr). - * - * If there is none selected, it will return the default. If there is none - * selected and no default, then it will return a value-initialized instance. - * For integer types, this is 0. For container types like std::string, this is - * an empty string. - * - * @return The option selected - */ template auto SendableChooser::GetSelected() -> decltype(_unwrap_smart_ptr(m_choices[""])) {