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 #pragma once
9 
10 #include <map>
11 #include <memory>
12 #include <string>
13 
14 #include "SmartDashboard/Sendable.h"
15 #include "tables/ITable.h"
16 
17 namespace frc {
18 
32 class SendableChooser : public Sendable {
33  public:
34  virtual ~SendableChooser() = default;
35 
36  void AddObject(const std::string& name, void* object);
37  void AddDefault(const std::string& name, void* object);
38  void* GetSelected();
39 
40  void InitTable(std::shared_ptr<ITable> subtable) override;
41  std::shared_ptr<ITable> GetTable() const override;
42  std::string GetSmartDashboardType() const override;
43 
44  private:
45  std::string m_defaultChoice;
46  std::map<std::string, void*> m_choices;
47  std::shared_ptr<ITable> m_table;
48 };
49 
50 } // namespace frc
void AddObject(const std::string &name, void *object)
Adds the given object to the list of options.
Definition: SendableChooser.cpp:25
std::string GetSmartDashboardType() const override
Definition: SendableChooser.cpp:75
void InitTable(std::shared_ptr< ITable > subtable) override
Initializes a table for this sendable object.
Definition: SendableChooser.cpp:60
The SendableChooser class is a useful tool for presenting a selection of options to the SmartDashboar...
Definition: SendableChooser.h:32
std::shared_ptr< ITable > GetTable() const override
Definition: SendableChooser.cpp:73
Definition: Sendable.h:17
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:39
void * GetSelected()
Returns the selected option.
Definition: SendableChooser.cpp:52