WPILibC++  unspecified
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Pages
SendableChooser.h
1 /*----------------------------------------------------------------------------*/
2 /* Copyright (c) FIRST 2011-2016. All Rights Reserved. */
3 /* Open Source Software - may be modified and shared by FRC teams. The code */
4 /* must be accompanied by the FIRST BSD license file in the root directory of */
5 /* the project. */
6 /*----------------------------------------------------------------------------*/
7 
8 #ifndef __SENDABLE_CHOOSER_H__
9 #define __SENDABLE_CHOOSER_H__
10 
11 #include "SmartDashboard/Sendable.h"
12 #include "tables/ITable.h"
13 #include <map>
14 #include <memory>
15 #include <string>
16 
34 class SendableChooser : public Sendable {
35  public:
36  virtual ~SendableChooser() = default;
37 
38  void AddObject(const std::string &name, void *object);
39  void AddDefault(const std::string &name, void *object);
40  void *GetSelected();
41 
42  virtual void InitTable(std::shared_ptr<ITable> subtable);
43  virtual std::shared_ptr<ITable> GetTable() const;
44  virtual std::string GetSmartDashboardType() const;
45 
46  private:
47  std::string m_defaultChoice;
48  std::map<std::string, void *> m_choices;
49  std::shared_ptr<ITable> m_table;
50 };
51 
52 #endif
void * GetSelected()
Returns the selected option.
Definition: SendableChooser.cpp:47
The SendableChooser class is a useful tool for presenting a selection of options to the SmartDashboar...
Definition: SendableChooser.h:34
virtual void InitTable(std::shared_ptr< ITable > subtable)
Initializes a table for this sendable object.
Definition: SendableChooser.cpp:55
Definition: Sendable.h:15
virtual std::shared_ptr< ITable > GetTable() const
Definition: SendableChooser.cpp:68
void AddDefault(const std::string &name, void *object)
Add the given object to the list of options and marks it as the default.
Definition: SendableChooser.cpp:36
virtual std::string GetSmartDashboardType() const
Definition: SendableChooser.cpp:70
void AddObject(const std::string &name, void *object)
Adds the given object to the list of options.
Definition: SendableChooser.cpp:23