blob: c541a21f6698273d1c6ea7c5cce22f4ae9655a1f [file] [log] [blame]
jerrymf1579332013-02-07 01:56:28 +00001/*----------------------------------------------------------------------------*/
2/* Copyright (c) FIRST 2011. 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 $(WIND_BASE)/WPILib. */
5/*----------------------------------------------------------------------------*/
6
7#ifndef __SENDABLE_CHOOSER_H__
8#define __SENDABLE_CHOOSER_H__
9
10#include "SmartDashboard/Sendable.h"
11#include "tables/ITable.h"
12#include <map>
13#include <string>
14
15/**
16 * The {@link SendableChooser} class is a useful tool for presenting a selection of options
17 * to the {@link SmartDashboard}.
18 *
19 * <p>For instance, you may wish to be able to select between multiple autonomous modes.
20 * You can do this by putting every possible {@link Command} you want to run as an autonomous into
21 * a {@link SendableChooser} and then put it into the {@link SmartDashboard} to have a list of options
22 * appear on the laptop. Once autonomous starts, simply ask the {@link SendableChooser} what the selected
23 * value is.</p>
24 *
25 * @see SmartDashboard
26 */
27class SendableChooser : public Sendable
28{
29public:
30 SendableChooser();
31 virtual ~SendableChooser() {};
32
33 void AddObject(const char *name, void *object);
34 void AddDefault(const char *name, void *object);
35 void *GetSelected();
36
37 virtual void InitTable(ITable* subtable);
38 virtual ITable* GetTable();
39 virtual std::string GetSmartDashboardType();
40
41private:
42 std::string m_defaultChoice;
43 std::map<std::string, void *> m_choices;
44 ITable *m_table;
45};
46
47#endif