WPILibC++  unspecified
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Pages
frc::SendableChooser< T > Class Template Reference

The SendableChooser class is a useful tool for presenting a selection of options to the SmartDashboard. More...

#include <SendableChooser.h>

Inheritance diagram for frc::SendableChooser< T >:
frc::SendableChooserBase frc::Sendable

Public Member Functions

void AddObject (llvm::StringRef name, T object)
 Adds the given object to the list of options. More...
 
void AddDefault (llvm::StringRef name, T object)
 Add the given object to the list of options and marks it as the default. More...
 
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 InitTable (std::shared_ptr< ITable > subtable) override
 Initializes a table for this sendable object. More...
 
- Public Member Functions inherited from frc::SendableChooserBase
std::shared_ptr< ITableGetTable () const override
 
std::string GetSmartDashboardType () const override
 

Additional Inherited Members

- Protected Attributes inherited from frc::SendableChooserBase
std::string m_defaultChoice
 
std::shared_ptr< ITablem_table
 
- Static Protected Attributes inherited from frc::SendableChooserBase
static const char * kDefault = "default"
 
static const char * kOptions = "options"
 
static const char * kSelected = "selected"
 

Detailed Description

template<class T>
class frc::SendableChooser< T >

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.

Template Parameters
TThe type of values to be stored
See Also
SmartDashboard

Member Function Documentation

template<class T >
void frc::SendableChooser< T >::AddDefault ( llvm::StringRef  name,
object 
)

Add the given object to the list of options and marks it as the default.

Functionally, this is very close to char *name, void *object) AddObject(...) except that it will use this as the default option if none other is explicitly selected.

Parameters
namethe name of the option
objectthe option
template<class T >
void frc::SendableChooser< T >::AddObject ( llvm::StringRef  name,
object 
)

Adds the given object to the list of options.

On the SmartDashboard on the desktop, the object will appear as the given name.

Parameters
namethe name of the option
objectthe option
template<class T >
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.

Returns
the option selected
template<class T >
void frc::SendableChooser< T >::InitTable ( std::shared_ptr< ITable subtable)
overridevirtual

Initializes a table for this sendable object.

Parameters
subtableThe table to put the values in.

Implements frc::Sendable.


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