[wpilibc] Move SendableChooser Doxygen comments to header (NFC) (#2911)

This commit is contained in:
Tyler Veness
2020-12-05 20:04:44 -08:00
committed by GitHub
parent b8c4f603db
commit a6cfcc6866
2 changed files with 31 additions and 30 deletions

View File

@@ -45,12 +45,31 @@ class SendableChooser : public SendableChooserBase {
static std::weak_ptr<U> _unwrap_smart_ptr(const std::shared_ptr<U>& 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<U> or a std::weak_ptr<U> if T = std::shared_ptr<U>).
*
* 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;

View File

@@ -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 <class T>
void SendableChooser<T>::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 <class T>
void SendableChooser<T>::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<U> or a std::weak_ptr<U> if T = std::shared_ptr<U>).
*
* 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 <class T>
auto SendableChooser<T>::GetSelected()
-> decltype(_unwrap_smart_ptr(m_choices[""])) {