mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-26 01:51:41 +00:00
Major formatting changes (breaks diffs). No code changes.
The changes made in this commit do not affect any actual code,
they are purely aesthetic. I ran clang-format with google style
over all .h/.cpp files in wpilibc that weren't in wpilibC++Sim
or gtest, and the eclipse formatter over all of the Java files
using the Google eclipse formatting configuration.
Change-Id: I9627bca0bc103c398ecc1c5ba17467193291ae63
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) FIRST 2011. All Rights Reserved. */
|
||||
/* Copyright (c) FIRST 2011. All Rights Reserved.
|
||||
*/
|
||||
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
||||
/* must be accompanied by the FIRST BSD license file in $(WIND_BASE)/WPILib. */
|
||||
/*----------------------------------------------------------------------------*/
|
||||
@@ -13,66 +14,62 @@ static const char *kDefault = "default";
|
||||
static const char *kOptions = "options";
|
||||
static const char *kSelected = "selected";
|
||||
|
||||
SendableChooser::SendableChooser()
|
||||
{
|
||||
m_defaultChoice = "";
|
||||
}
|
||||
SendableChooser::SendableChooser() { m_defaultChoice = ""; }
|
||||
|
||||
/**
|
||||
* Adds the given object to the list of options. On the {@link SmartDashboard} on the desktop,
|
||||
* Adds the given object to the list of options. On the {@link SmartDashboard}
|
||||
* on the desktop,
|
||||
* the object will appear as the given name.
|
||||
* @param name the name of the option
|
||||
* @param object the option
|
||||
*/
|
||||
void SendableChooser::AddObject(const char *name, void *object)
|
||||
{
|
||||
m_choices[name] = object;
|
||||
void SendableChooser::AddObject(const char *name, void *object) {
|
||||
m_choices[name] = object;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add the given object to the list of options and marks it as the default.
|
||||
* Functionally, this is very close to {@link SendableChooser#AddObject(const char *name, void *object) AddObject(...)}
|
||||
* except that it will use this as the default option if none other is explicitly selected.
|
||||
* Functionally, this is very close to {@link SendableChooser#AddObject(const
|
||||
* char *name, void *object) AddObject(...)}
|
||||
* except that it will use this as the default option if none other is
|
||||
* explicitly selected.
|
||||
* @param name the name of the option
|
||||
* @param object the option
|
||||
*/
|
||||
void SendableChooser::AddDefault(const char *name, void *object)
|
||||
{
|
||||
m_defaultChoice = name;
|
||||
AddObject(name, object);
|
||||
void SendableChooser::AddDefault(const char *name, void *object) {
|
||||
m_defaultChoice = name;
|
||||
AddObject(name, object);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the selected option. If there is none selected, it will return the default. If there is none selected
|
||||
* Returns the selected option. If there is none selected, it will return the
|
||||
* default. If there is none selected
|
||||
* and no default, then it will return {@code NULL}.
|
||||
* @return the option selected
|
||||
*/
|
||||
void *SendableChooser::GetSelected()
|
||||
{
|
||||
std::string selected = m_table->GetString(kSelected, m_defaultChoice);
|
||||
if (selected == "")
|
||||
return NULL;
|
||||
else
|
||||
return m_choices[selected];
|
||||
void *SendableChooser::GetSelected() {
|
||||
std::string selected = m_table->GetString(kSelected, m_defaultChoice);
|
||||
if (selected == "")
|
||||
return NULL;
|
||||
else
|
||||
return m_choices[selected];
|
||||
}
|
||||
|
||||
void SendableChooser::InitTable(ITable* subtable) {
|
||||
StringArray keys;
|
||||
m_table = subtable;
|
||||
if (m_table != NULL) {
|
||||
std::map<std::string, void *>::iterator iter;
|
||||
for (iter = m_choices.begin(); iter != m_choices.end(); iter++) {
|
||||
keys.add(iter->first);
|
||||
}
|
||||
m_table->PutValue(kOptions, keys);
|
||||
m_table->PutString(kDefault, m_defaultChoice);
|
||||
}
|
||||
void SendableChooser::InitTable(ITable *subtable) {
|
||||
StringArray keys;
|
||||
m_table = subtable;
|
||||
if (m_table != NULL) {
|
||||
std::map<std::string, void *>::iterator iter;
|
||||
for (iter = m_choices.begin(); iter != m_choices.end(); iter++) {
|
||||
keys.add(iter->first);
|
||||
}
|
||||
m_table->PutValue(kOptions, keys);
|
||||
m_table->PutString(kDefault, m_defaultChoice);
|
||||
}
|
||||
}
|
||||
|
||||
ITable* SendableChooser::GetTable() const {
|
||||
return m_table;
|
||||
}
|
||||
ITable *SendableChooser::GetTable() const { return m_table; }
|
||||
|
||||
std::string SendableChooser::GetSmartDashboardType() const {
|
||||
return "String Chooser";
|
||||
return "String Chooser";
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user