SubZero Common
Common library components for an FRC CommandRobot
Loading...
Searching...
No Matches
subzero::ModifiableChooser< T > Class Template Reference

A SmartDashboard drop-down that can have its options dynamically change. More...

#include <ModifiableChooser.h>

+ Inheritance diagram for subzero::ModifiableChooser< T >:
+ Collaboration diagram for subzero::ModifiableChooser< T >:

Public Member Functions

 ModifiableChooser ()
 
 ~ModifiableChooser ()
 
void AddOption (std::string name, T object)
 Add a new option to the chooser.
 
void RemoveOption (std::string name)
 Removes the option and updates the default option accoringly.
 
void ClearOptions ()
 Clears all options.
 
void SetOptions (std::map< std::string, T > options)
 Populates options from an existing set.
 
void SetDefaultOption (std::string name, T object)
 Set the default option to return.
 
void SetOptions (std::map< std::string, T > options, std::string defaultName, T defaultObject)
 Set the options from an existing set along with a default.
 
GetSelected ()
 Get the selected option.
 
std::string GetSelectedKey ()
 Get the selected key rather than the value.
 
std::string GetNtSelected ()
 
void SetNtSelected (std::string val)
 
void OnChange (std::function< void(std::optional< T >)> listener)
 Register a callback that gets executed whenever the selection changes.
 
void InitSendable (wpi::SendableBuilder &builder) override
 

Detailed Description

template<typename T>
class subzero::ModifiableChooser< T >

A SmartDashboard drop-down that can have its options dynamically change.

Template Parameters
TThe underlying value to return for a selected option

Definition at line 29 of file ModifiableChooser.h.

Constructor & Destructor Documentation

◆ ModifiableChooser()

template<typename T >
subzero::ModifiableChooser< T >::ModifiableChooser ( )

◆ ~ModifiableChooser()

template<typename T >
subzero::ModifiableChooser< T >::~ModifiableChooser ( )

Member Function Documentation

◆ AddOption()

template<typename T >
void subzero::ModifiableChooser< T >::AddOption ( std::string name,
T object )

Add a new option to the chooser.

Parameters
nameName to display
objectValue that gets returned upon selection

◆ ClearOptions()

template<typename T >
void subzero::ModifiableChooser< T >::ClearOptions ( )

Clears all options.

◆ GetNtSelected()

template<typename T >
std::string subzero::ModifiableChooser< T >::GetNtSelected ( )

◆ GetSelected()

template<typename T >
T subzero::ModifiableChooser< T >::GetSelected ( )

Get the selected option.

Returns
T

◆ GetSelectedKey()

template<typename T >
std::string subzero::ModifiableChooser< T >::GetSelectedKey ( )

Get the selected key rather than the value.

Returns
std::string

◆ InitSendable()

template<typename T >
void subzero::ModifiableChooser< T >::InitSendable ( wpi::SendableBuilder & builder)
override

◆ OnChange()

template<typename T >
void subzero::ModifiableChooser< T >::OnChange ( std::function< void(std::optional< T >)> listener)

Register a callback that gets executed whenever the selection changes.

Parameters
listener

◆ RemoveOption()

template<typename T >
void subzero::ModifiableChooser< T >::RemoveOption ( std::string name)

Removes the option and updates the default option accoringly.

Parameters
name

◆ SetDefaultOption()

template<typename T >
void subzero::ModifiableChooser< T >::SetDefaultOption ( std::string name,
T object )

Set the default option to return.

Parameters
name
object

◆ SetNtSelected()

template<typename T >
void subzero::ModifiableChooser< T >::SetNtSelected ( std::string val)

◆ SetOptions() [1/2]

template<typename T >
void subzero::ModifiableChooser< T >::SetOptions ( std::map< std::string, T > options)

Populates options from an existing set.

Parameters
options

◆ SetOptions() [2/2]

template<typename T >
void subzero::ModifiableChooser< T >::SetOptions ( std::map< std::string, T > options,
std::string defaultName,
T defaultObject )

Set the options from an existing set along with a default.

Parameters
options
defaultName
defaultObject

The documentation for this class was generated from the following file: