WPILibC++  unspecified
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Pages
SendableChooser.h
1 /*----------------------------------------------------------------------------*/
2 /* Copyright (c) FIRST 2011-2017. 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 <memory>
11 #include <string>
12 
13 #include "SmartDashboard/SendableChooserBase.h"
14 #include "llvm/StringMap.h"
15 #include "llvm/StringRef.h"
16 #include "tables/ITable.h"
17 
18 namespace frc {
19 
34 template <class T>
36  public:
37  virtual ~SendableChooser() = default;
38 
39  void AddObject(llvm::StringRef name, const T& object);
40  void AddDefault(llvm::StringRef name, const T& object);
41  T GetSelected();
42 
43  void InitTable(std::shared_ptr<ITable> subtable) override;
44 
45  private:
46  llvm::StringMap<T> m_choices;
47 };
48 
49 } // namespace frc
50 
51 #include "SendableChooser.inc"
This class is a non-template base class for SendableChooser.
Definition: SendableChooserBase.h:24
The SendableChooser class is a useful tool for presenting a selection of options to the SmartDashboar...
Definition: SendableChooser.h:35
void InitTable(std::shared_ptr< ITable > subtable) override
Initializes a table for this sendable object.
Definition: SendableChooser.inc:67
T GetSelected()
Returns the selected option.
Definition: SendableChooser.inc:57
void AddDefault(llvm::StringRef name, const T &object)
Add the given object to the list of options and marks it as the default.
Definition: SendableChooser.inc:43
void AddObject(llvm::StringRef name, const T &object)
Adds the given object to the list of options.
Definition: SendableChooser.inc:28