WPILibC++
2018.4.1-20180925013224-1203-g32ec07e
|
The SendableChooser class is a useful tool for presenting a selection of options to the SmartDashboard. More...
#include <SendableChooser.h>
Public Member Functions | |
void | AddOption (wpi::StringRef name, T object) |
Adds the given object to the list of options. More... | |
void | SetDefaultOption (wpi::StringRef name, T object) |
Add the given object to the list of options and marks it as the default. More... | |
void | AddObject (wpi::StringRef name, T object) |
void | AddDefault (wpi::StringRef name, T object) |
auto | GetSelected () -> decltype(_unwrap_smart_ptr(m_choices[""])) |
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>). More... | |
void | InitSendable (SendableBuilder &builder) override |
Initializes this Sendable object. More... | |
![]() | |
SendableChooserBase (SendableChooserBase &&)=default | |
SendableChooserBase & | operator= (SendableChooserBase &&)=default |
![]() | |
SendableBase (bool addLiveWindow=true) | |
Creates an instance of the sensor base. More... | |
SendableBase (SendableBase &&rhs) | |
SendableBase & | operator= (SendableBase &&rhs) |
std::string | GetName () const final |
Gets the name of this Sendable object. More... | |
void | SetName (const wpi::Twine &name) final |
Sets the name of this Sendable object. More... | |
std::string | GetSubsystem () const final |
Gets the subsystem name of this Sendable object. More... | |
void | SetSubsystem (const wpi::Twine &subsystem) final |
Sets the subsystem name of this Sendable object. More... | |
![]() | |
Sendable (Sendable &&)=default | |
Sendable & | operator= (Sendable &&)=default |
void | SetName (const wpi::Twine &subsystem, const wpi::Twine &name) |
Sets both the subsystem name and device name of this Sendable object. More... | |
Additional Inherited Members | |
![]() | |
void | AddChild (std::shared_ptr< Sendable > child) |
Add a child component. More... | |
void | AddChild (void *child) |
Add a child component. More... | |
void | SetName (const wpi::Twine &moduleType, int channel) |
Sets the name of the sensor with a channel number. More... | |
void | SetName (const wpi::Twine &moduleType, int moduleNumber, int channel) |
Sets the name of the sensor with a module and channel number. More... | |
![]() | |
std::string | m_defaultChoice |
std::string | m_selected |
bool | m_haveSelected = false |
wpi::SmallVector < nt::NetworkTableEntry, 2 > | m_activeEntries |
wpi::mutex | m_mutex |
int | m_instance |
![]() | |
static constexpr const char * | kDefault = "default" |
static constexpr const char * | kOptions = "options" |
static constexpr const char * | kSelected = "selected" |
static constexpr const char * | kActive = "active" |
static constexpr const char * | kInstance = ".instance" |
static std::atomic_int | s_instances |
The SendableChooser class is a useful tool for presenting a selection of options to the SmartDashboard.
For instance, you may wish to be able to select between multiple autonomous modes. You can do this by putting every possible Command you want to run as an autonomous into a SendableChooser and then put it into the SmartDashboard to have a list of options appear on the laptop. Once autonomous starts, simply ask the SendableChooser what the selected value is.
T | The type of values to be stored |
void frc::SendableChooser< T >::AddOption | ( | wpi::StringRef | name, |
T | object | ||
) |
Adds the given object to the list of options.
On the SmartDashboard on the desktop, the object will appear as the given name.
name | the name of the option |
object | the option |
auto frc::SendableChooser< T >::GetSelected | ( | ) | -> decltype(_unwrap_smart_ptr(m_choices[""])) |
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.
|
overridevirtual |
void frc::SendableChooser< T >::SetDefaultOption | ( | 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.
name | the name of the option |
object | the option |