2013-12-15 18:30:16 -05:00
|
|
|
/*----------------------------------------------------------------------------*/
|
2017-01-01 01:05:57 -07:00
|
|
|
/* Copyright (c) FIRST 2011-2017. All Rights Reserved. */
|
2013-12-15 18:30:16 -05:00
|
|
|
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
2016-01-02 03:02:34 -08:00
|
|
|
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
|
|
|
|
/* the project. */
|
2013-12-15 18:30:16 -05:00
|
|
|
/*----------------------------------------------------------------------------*/
|
|
|
|
|
|
|
|
|
|
#include "SmartDashboard/SmartDashboard.h"
|
|
|
|
|
|
2016-05-20 17:30:37 -07:00
|
|
|
#include "HLUsageReporting.h"
|
2013-12-15 18:30:16 -05:00
|
|
|
#include "SmartDashboard/NamedSendable.h"
|
|
|
|
|
#include "WPIErrors.h"
|
|
|
|
|
#include "networktables/NetworkTable.h"
|
|
|
|
|
|
2016-11-01 22:33:12 -07:00
|
|
|
using namespace frc;
|
|
|
|
|
|
2015-11-23 00:46:05 -08:00
|
|
|
std::shared_ptr<ITable> SmartDashboard::m_table;
|
2016-05-20 17:30:37 -07:00
|
|
|
std::map<std::shared_ptr<ITable>, Sendable*> SmartDashboard::m_tablesToData;
|
2013-12-15 18:30:16 -05:00
|
|
|
|
2015-06-25 15:07:55 -04:00
|
|
|
void SmartDashboard::init() {
|
2015-08-13 23:17:19 -07:00
|
|
|
m_table = NetworkTable::GetTable("SmartDashboard");
|
2013-12-15 18:30:16 -05:00
|
|
|
|
2015-06-25 15:07:55 -04:00
|
|
|
HLUsageReporting::ReportSmartDashboard();
|
2014-08-04 14:43:31 -04:00
|
|
|
}
|
2013-12-15 18:30:16 -05:00
|
|
|
|
2016-10-03 09:59:18 -07:00
|
|
|
/**
|
|
|
|
|
* Determines whether the given key is in this table.
|
|
|
|
|
*
|
|
|
|
|
* @param key the key to search for
|
|
|
|
|
* @return true if the table as a value assigned to the given key
|
|
|
|
|
*/
|
|
|
|
|
bool SmartDashboard::ContainsKey(llvm::StringRef key) {
|
|
|
|
|
return m_table->ContainsKey(key);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @param types bitmask of types; 0 is treated as a "don't care".
|
|
|
|
|
* @return keys currently in the table
|
|
|
|
|
*/
|
|
|
|
|
std::vector<std::string> SmartDashboard::GetKeys(int types) {
|
|
|
|
|
return m_table->GetKeys(types);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Makes a key's value persistent through program restarts.
|
|
|
|
|
*
|
|
|
|
|
* @param key the key to make persistent
|
|
|
|
|
*/
|
|
|
|
|
void SmartDashboard::SetPersistent(llvm::StringRef key) {
|
|
|
|
|
m_table->SetPersistent(key);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Stop making a key's value persistent through program restarts.
|
|
|
|
|
* The key cannot be null.
|
|
|
|
|
*
|
|
|
|
|
* @param key the key name
|
|
|
|
|
*/
|
|
|
|
|
void SmartDashboard::ClearPersistent(llvm::StringRef key) {
|
|
|
|
|
m_table->ClearPersistent(key);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Returns whether the value is persistent through program restarts.
|
|
|
|
|
* The key cannot be null.
|
|
|
|
|
*
|
|
|
|
|
* @param key the key name
|
|
|
|
|
*/
|
|
|
|
|
bool SmartDashboard::IsPersistent(llvm::StringRef key) {
|
|
|
|
|
return m_table->IsPersistent(key);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Sets flags on the specified key in this table. The key can
|
|
|
|
|
* not be null.
|
|
|
|
|
*
|
|
|
|
|
* @param key the key name
|
|
|
|
|
* @param flags the flags to set (bitmask)
|
|
|
|
|
*/
|
|
|
|
|
void SmartDashboard::SetFlags(llvm::StringRef key, unsigned int flags) {
|
|
|
|
|
m_table->SetFlags(key, flags);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Clears flags on the specified key in this table. The key can
|
|
|
|
|
* not be null.
|
|
|
|
|
*
|
|
|
|
|
* @param key the key name
|
|
|
|
|
* @param flags the flags to clear (bitmask)
|
|
|
|
|
*/
|
|
|
|
|
void SmartDashboard::ClearFlags(llvm::StringRef key, unsigned int flags) {
|
|
|
|
|
m_table->ClearFlags(key, flags);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Returns the flags for the specified key.
|
|
|
|
|
*
|
|
|
|
|
* @param key the key name
|
|
|
|
|
* @return the flags, or 0 if the key is not defined
|
|
|
|
|
*/
|
|
|
|
|
unsigned int SmartDashboard::GetFlags(llvm::StringRef key) {
|
|
|
|
|
return m_table->GetFlags(key);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Deletes the specified key in this table.
|
|
|
|
|
*
|
|
|
|
|
* @param key the key name
|
|
|
|
|
*/
|
|
|
|
|
void SmartDashboard::Delete(llvm::StringRef key) { m_table->Delete(key); }
|
|
|
|
|
|
2013-12-15 18:30:16 -05:00
|
|
|
/**
|
|
|
|
|
* Maps the specified key to the specified value in this table.
|
2016-05-20 17:30:37 -07:00
|
|
|
*
|
2015-06-25 15:07:55 -04:00
|
|
|
* The value can be retrieved by calling the get method with a key that is equal
|
|
|
|
|
* to the original key.
|
2016-05-20 17:30:37 -07:00
|
|
|
*
|
2013-12-15 18:30:16 -05:00
|
|
|
* @param keyName the key
|
2016-05-20 17:30:37 -07:00
|
|
|
* @param value the value
|
2013-12-15 18:30:16 -05:00
|
|
|
*/
|
2016-05-20 17:30:37 -07:00
|
|
|
void SmartDashboard::PutData(llvm::StringRef key, Sendable* data) {
|
2015-06-23 04:49:51 -07:00
|
|
|
if (data == nullptr) {
|
2015-06-25 15:07:55 -04:00
|
|
|
wpi_setGlobalWPIErrorWithContext(NullParameter, "value");
|
|
|
|
|
return;
|
|
|
|
|
}
|
2015-07-29 16:48:04 -04:00
|
|
|
std::shared_ptr<ITable> dataTable(m_table->GetSubTable(key));
|
2015-06-25 15:07:55 -04:00
|
|
|
dataTable->PutString("~TYPE~", data->GetSmartDashboardType());
|
|
|
|
|
data->InitTable(dataTable);
|
|
|
|
|
m_tablesToData[dataTable] = data;
|
2013-12-15 18:30:16 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2016-05-20 17:30:37 -07:00
|
|
|
* Maps the specified key (where the key is the name of the
|
|
|
|
|
* {@link SmartDashboardNamedData} to the specified value in this table.
|
|
|
|
|
*
|
2015-06-25 15:07:55 -04:00
|
|
|
* The value can be retrieved by calling the get method with a key that is equal
|
|
|
|
|
* to the original key.
|
2016-05-20 17:30:37 -07:00
|
|
|
*
|
2013-12-15 18:30:16 -05:00
|
|
|
* @param value the value
|
|
|
|
|
*/
|
2016-05-20 17:30:37 -07:00
|
|
|
void SmartDashboard::PutData(NamedSendable* value) {
|
2015-06-23 04:49:51 -07:00
|
|
|
if (value == nullptr) {
|
2015-06-25 15:07:55 -04:00
|
|
|
wpi_setGlobalWPIErrorWithContext(NullParameter, "value");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
PutData(value->GetName(), value);
|
2013-12-15 18:30:16 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Returns the value at the specified key.
|
2016-05-20 17:30:37 -07:00
|
|
|
*
|
2013-12-15 18:30:16 -05:00
|
|
|
* @param keyName the key
|
|
|
|
|
* @return the value
|
|
|
|
|
*/
|
2016-05-20 17:30:37 -07:00
|
|
|
Sendable* SmartDashboard::GetData(llvm::StringRef key) {
|
2015-07-29 16:48:04 -04:00
|
|
|
std::shared_ptr<ITable> subtable(m_table->GetSubTable(key));
|
2016-05-20 17:30:37 -07:00
|
|
|
Sendable* data = m_tablesToData[subtable];
|
2015-06-23 04:49:51 -07:00
|
|
|
if (data == nullptr) {
|
2015-08-13 23:17:19 -07:00
|
|
|
wpi_setGlobalWPIErrorWithContext(SmartDashboardMissingKey, key);
|
2015-06-23 04:49:51 -07:00
|
|
|
return nullptr;
|
2015-06-25 15:07:55 -04:00
|
|
|
}
|
|
|
|
|
return data;
|
2014-08-04 14:43:31 -04:00
|
|
|
}
|
2013-12-15 18:30:16 -05:00
|
|
|
|
|
|
|
|
/**
|
2015-06-25 15:07:55 -04:00
|
|
|
* Maps the specified key to the specified complex value (such as an array) in
|
|
|
|
|
* this table.
|
2016-05-20 17:30:37 -07:00
|
|
|
*
|
2015-06-25 15:07:55 -04:00
|
|
|
* The value can be retrieved by calling the RetrieveValue method with a key
|
|
|
|
|
* that is equal to the original key.
|
2016-05-20 17:30:37 -07:00
|
|
|
*
|
2013-12-15 18:30:16 -05:00
|
|
|
* @param keyName the key
|
2016-05-20 17:30:37 -07:00
|
|
|
* @param value the value
|
2016-10-03 09:59:18 -07:00
|
|
|
* @return False if the table key already exists with a different type
|
2013-12-15 18:30:16 -05:00
|
|
|
*/
|
2016-10-03 09:59:18 -07:00
|
|
|
bool SmartDashboard::PutValue(llvm::StringRef keyName,
|
2015-08-13 23:17:19 -07:00
|
|
|
std::shared_ptr<nt::Value> value) {
|
2016-10-03 09:59:18 -07:00
|
|
|
return m_table->PutValue(keyName, value);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Gets the current value in the table, setting it if it does not exist.
|
|
|
|
|
* @param key the key
|
|
|
|
|
* @param defaultValue the default value to set if key doesn't exist.
|
|
|
|
|
* @returns False if the table key exists with a different type
|
|
|
|
|
*/
|
|
|
|
|
bool SmartDashboard::SetDefaultValue(llvm::StringRef key,
|
|
|
|
|
std::shared_ptr<nt::Value> defaultValue) {
|
|
|
|
|
return m_table->SetDefaultValue(key, defaultValue);
|
2013-12-15 18:30:16 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2015-06-25 15:07:55 -04:00
|
|
|
* Retrieves the complex value (such as an array) in this table into the complex
|
2016-05-20 17:30:37 -07:00
|
|
|
* data object.
|
|
|
|
|
*
|
2013-12-15 18:30:16 -05:00
|
|
|
* @param keyName the key
|
2016-05-20 17:30:37 -07:00
|
|
|
* @param value the object to retrieve the value into
|
2013-12-15 18:30:16 -05:00
|
|
|
*/
|
2015-08-13 23:17:19 -07:00
|
|
|
std::shared_ptr<nt::Value> SmartDashboard::GetValue(llvm::StringRef keyName) {
|
|
|
|
|
return m_table->GetValue(keyName);
|
2013-12-15 18:30:16 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Maps the specified key to the specified value in this table.
|
2016-05-20 17:30:37 -07:00
|
|
|
*
|
2015-06-25 15:07:55 -04:00
|
|
|
* The value can be retrieved by calling the get method with a key that is equal
|
|
|
|
|
* to the original key.
|
2016-05-20 17:30:37 -07:00
|
|
|
*
|
2013-12-15 18:30:16 -05:00
|
|
|
* @param keyName the key
|
2016-05-20 17:30:37 -07:00
|
|
|
* @param value the value
|
2016-10-03 09:59:18 -07:00
|
|
|
* @return False if the table key already exists with a different type
|
2013-12-15 18:30:16 -05:00
|
|
|
*/
|
2016-10-03 09:59:18 -07:00
|
|
|
bool SmartDashboard::PutBoolean(llvm::StringRef keyName, bool value) {
|
|
|
|
|
return m_table->PutBoolean(keyName, value);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Gets the current value in the table, setting it if it does not exist.
|
|
|
|
|
* @param key the key
|
|
|
|
|
* @param defaultValue the default value to set if key doesn't exist.
|
|
|
|
|
* @returns False if the table key exists with a different type
|
|
|
|
|
*/
|
|
|
|
|
bool SmartDashboard::SetDefaultBoolean(llvm::StringRef key, bool defaultValue) {
|
|
|
|
|
return m_table->SetDefaultBoolean(key, defaultValue);
|
2013-12-15 18:30:16 -05:00
|
|
|
}
|
|
|
|
|
|
2014-10-15 17:03:04 -04:00
|
|
|
/**
|
2016-05-20 17:30:37 -07:00
|
|
|
* Returns the value at the specified key.
|
|
|
|
|
*
|
|
|
|
|
* If the key is not found, returns the default value.
|
|
|
|
|
*
|
2014-10-15 17:03:04 -04:00
|
|
|
* @param keyName the key
|
|
|
|
|
* @return the value
|
|
|
|
|
*/
|
2015-08-13 23:17:19 -07:00
|
|
|
bool SmartDashboard::GetBoolean(llvm::StringRef keyName, bool defaultValue) {
|
2015-06-25 15:07:55 -04:00
|
|
|
return m_table->GetBoolean(keyName, defaultValue);
|
2014-10-15 17:03:04 -04:00
|
|
|
}
|
|
|
|
|
|
2013-12-15 18:30:16 -05:00
|
|
|
/**
|
|
|
|
|
* Maps the specified key to the specified value in this table.
|
2016-05-20 17:30:37 -07:00
|
|
|
*
|
2015-06-25 15:07:55 -04:00
|
|
|
* The value can be retrieved by calling the get method with a key that is equal
|
|
|
|
|
* to the original key.
|
2016-05-20 17:30:37 -07:00
|
|
|
*
|
2013-12-15 18:30:16 -05:00
|
|
|
* @param keyName the key
|
2016-05-20 17:30:37 -07:00
|
|
|
* @param value the value
|
2016-10-03 09:59:18 -07:00
|
|
|
* @return False if the table key already exists with a different type
|
2013-12-15 18:30:16 -05:00
|
|
|
*/
|
2016-10-03 09:59:18 -07:00
|
|
|
bool SmartDashboard::PutNumber(llvm::StringRef keyName, double value) {
|
|
|
|
|
return m_table->PutNumber(keyName, value);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Gets the current value in the table, setting it if it does not exist.
|
|
|
|
|
* @param key the key
|
|
|
|
|
* @param defaultValue the default value to set if key doesn't exist.
|
|
|
|
|
* @returns False if the table key exists with a different type
|
|
|
|
|
*/
|
|
|
|
|
bool SmartDashboard::SetDefaultNumber(llvm::StringRef key,
|
|
|
|
|
double defaultValue) {
|
|
|
|
|
return m_table->SetDefaultNumber(key, defaultValue);
|
2013-12-15 18:30:16 -05:00
|
|
|
}
|
|
|
|
|
|
2014-10-15 17:03:04 -04:00
|
|
|
/**
|
2016-05-20 17:30:37 -07:00
|
|
|
* Returns the value at the specified key.
|
|
|
|
|
*
|
|
|
|
|
* If the key is not found, returns the default value.
|
|
|
|
|
*
|
2014-10-15 17:03:04 -04:00
|
|
|
* @param keyName the key
|
|
|
|
|
* @return the value
|
|
|
|
|
*/
|
2015-08-13 23:17:19 -07:00
|
|
|
double SmartDashboard::GetNumber(llvm::StringRef keyName, double defaultValue) {
|
2015-06-25 15:07:55 -04:00
|
|
|
return m_table->GetNumber(keyName, defaultValue);
|
2014-10-15 17:03:04 -04:00
|
|
|
}
|
|
|
|
|
|
2013-12-15 18:30:16 -05:00
|
|
|
/**
|
|
|
|
|
* Maps the specified key to the specified value in this table.
|
2016-05-20 17:30:37 -07:00
|
|
|
*
|
2015-06-25 15:07:55 -04:00
|
|
|
* The value can be retrieved by calling the get method with a key that is equal
|
|
|
|
|
* to the original key.
|
2016-05-20 17:30:37 -07:00
|
|
|
*
|
2013-12-15 18:30:16 -05:00
|
|
|
* @param keyName the key
|
2016-05-20 17:30:37 -07:00
|
|
|
* @param value the value
|
2016-10-03 09:59:18 -07:00
|
|
|
* @return False if the table key already exists with a different type
|
2013-12-15 18:30:16 -05:00
|
|
|
*/
|
2016-10-03 09:59:18 -07:00
|
|
|
bool SmartDashboard::PutString(llvm::StringRef keyName, llvm::StringRef value) {
|
|
|
|
|
return m_table->PutString(keyName, value);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Gets the current value in the table, setting it if it does not exist.
|
|
|
|
|
* @param key the key
|
|
|
|
|
* @param defaultValue the default value to set if key doesn't exist.
|
|
|
|
|
* @returns False if the table key exists with a different type
|
|
|
|
|
*/
|
|
|
|
|
bool SmartDashboard::SetDefaultString(llvm::StringRef key,
|
|
|
|
|
llvm::StringRef defaultValue) {
|
|
|
|
|
return m_table->SetDefaultString(key, defaultValue);
|
2013-12-15 18:30:16 -05:00
|
|
|
}
|
|
|
|
|
|
2014-10-15 17:03:04 -04:00
|
|
|
/**
|
2016-05-20 17:30:37 -07:00
|
|
|
* Returns the value at the specified key.
|
|
|
|
|
*
|
|
|
|
|
* If the key is not found, returns the default value.
|
|
|
|
|
*
|
2014-10-15 17:03:04 -04:00
|
|
|
* @param keyName the key
|
|
|
|
|
* @return the value
|
|
|
|
|
*/
|
2015-08-13 23:17:19 -07:00
|
|
|
std::string SmartDashboard::GetString(llvm::StringRef keyName,
|
|
|
|
|
llvm::StringRef defaultValue) {
|
2015-06-25 15:07:55 -04:00
|
|
|
return m_table->GetString(keyName, defaultValue);
|
2014-10-15 17:03:04 -04:00
|
|
|
}
|
2016-10-03 09:59:18 -07:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Put a boolean array in the table
|
|
|
|
|
* @param key the key to be assigned to
|
|
|
|
|
* @param value the value that will be assigned
|
|
|
|
|
* @return False if the table key already exists with a different type
|
|
|
|
|
*
|
|
|
|
|
* @note The array must be of int's rather than of bool's because
|
|
|
|
|
* std::vector<bool> is special-cased in C++. 0 is false, any
|
|
|
|
|
* non-zero value is true.
|
|
|
|
|
*/
|
|
|
|
|
bool SmartDashboard::PutBooleanArray(llvm::StringRef key,
|
|
|
|
|
llvm::ArrayRef<int> value) {
|
|
|
|
|
return m_table->PutBooleanArray(key, value);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Gets the current value in the table, setting it if it does not exist.
|
|
|
|
|
* @param key the key
|
|
|
|
|
* @param defaultValue the default value to set if key doesn't exist.
|
|
|
|
|
* @returns False if the table key exists with a different type
|
|
|
|
|
*/
|
|
|
|
|
bool SmartDashboard::SetDefaultBooleanArray(llvm::StringRef key,
|
|
|
|
|
llvm::ArrayRef<int> defaultValue) {
|
|
|
|
|
return m_table->SetDefaultBooleanArray(key, defaultValue);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Returns the boolean array the key maps to. If the key does not exist or is
|
|
|
|
|
* of different type, it will return the default value.
|
|
|
|
|
* @param key the key to look up
|
|
|
|
|
* @param defaultValue the value to be returned if no value is found
|
|
|
|
|
* @return the value associated with the given key or the given default value
|
|
|
|
|
* if there is no value associated with the key
|
|
|
|
|
*
|
|
|
|
|
* @note This makes a copy of the array. If the overhead of this is a
|
|
|
|
|
* concern, use GetValue() instead.
|
|
|
|
|
*
|
|
|
|
|
* @note The returned array is std::vector<int> instead of std::vector<bool>
|
|
|
|
|
* because std::vector<bool> is special-cased in C++. 0 is false, any
|
|
|
|
|
* non-zero value is true.
|
|
|
|
|
*/
|
|
|
|
|
std::vector<int> SmartDashboard::GetBooleanArray(
|
|
|
|
|
llvm::StringRef key, llvm::ArrayRef<int> defaultValue) {
|
|
|
|
|
return m_table->GetBooleanArray(key, defaultValue);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Put a number array in the table
|
|
|
|
|
* @param key the key to be assigned to
|
|
|
|
|
* @param value the value that will be assigned
|
|
|
|
|
* @return False if the table key already exists with a different type
|
|
|
|
|
*/
|
|
|
|
|
bool SmartDashboard::PutNumberArray(llvm::StringRef key,
|
|
|
|
|
llvm::ArrayRef<double> value) {
|
|
|
|
|
return m_table->PutNumberArray(key, value);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Gets the current value in the table, setting it if it does not exist.
|
|
|
|
|
* @param key the key
|
|
|
|
|
* @param defaultValue the default value to set if key doesn't exist.
|
|
|
|
|
* @returns False if the table key exists with a different type
|
|
|
|
|
*/
|
|
|
|
|
bool SmartDashboard::SetDefaultNumberArray(
|
|
|
|
|
llvm::StringRef key, llvm::ArrayRef<double> defaultValue) {
|
|
|
|
|
return m_table->SetDefaultNumberArray(key, defaultValue);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Returns the number array the key maps to. If the key does not exist or is
|
|
|
|
|
* of different type, it will return the default value.
|
|
|
|
|
* @param key the key to look up
|
|
|
|
|
* @param defaultValue the value to be returned if no value is found
|
|
|
|
|
* @return the value associated with the given key or the given default value
|
|
|
|
|
* if there is no value associated with the key
|
|
|
|
|
*
|
|
|
|
|
* @note This makes a copy of the array. If the overhead of this is a
|
|
|
|
|
* concern, use GetValue() instead.
|
|
|
|
|
*/
|
|
|
|
|
std::vector<double> SmartDashboard::GetNumberArray(
|
|
|
|
|
llvm::StringRef key, llvm::ArrayRef<double> defaultValue) {
|
|
|
|
|
return m_table->GetNumberArray(key, defaultValue);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Put a string array in the table
|
|
|
|
|
* @param key the key to be assigned to
|
|
|
|
|
* @param value the value that will be assigned
|
|
|
|
|
* @return False if the table key already exists with a different type
|
|
|
|
|
*/
|
|
|
|
|
bool SmartDashboard::PutStringArray(llvm::StringRef key,
|
|
|
|
|
llvm::ArrayRef<std::string> value) {
|
|
|
|
|
return m_table->PutStringArray(key, value);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Gets the current value in the table, setting it if it does not exist.
|
|
|
|
|
* @param key the key
|
|
|
|
|
* @param defaultValue the default value to set if key doesn't exist.
|
|
|
|
|
* @returns False if the table key exists with a different type
|
|
|
|
|
*/
|
|
|
|
|
bool SmartDashboard::SetDefaultStringArray(
|
|
|
|
|
llvm::StringRef key, llvm::ArrayRef<std::string> defaultValue) {
|
|
|
|
|
return m_table->SetDefaultStringArray(key, defaultValue);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Returns the string array the key maps to. If the key does not exist or is
|
|
|
|
|
* of different type, it will return the default value.
|
|
|
|
|
* @param key the key to look up
|
|
|
|
|
* @param defaultValue the value to be returned if no value is found
|
|
|
|
|
* @return the value associated with the given key or the given default value
|
|
|
|
|
* if there is no value associated with the key
|
|
|
|
|
*
|
|
|
|
|
* @note This makes a copy of the array. If the overhead of this is a
|
|
|
|
|
* concern, use GetValue() instead.
|
|
|
|
|
*/
|
|
|
|
|
std::vector<std::string> SmartDashboard::GetStringArray(
|
|
|
|
|
llvm::StringRef key, llvm::ArrayRef<std::string> defaultValue) {
|
|
|
|
|
return m_table->GetStringArray(key, defaultValue);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Put a raw value (byte array) in the table
|
|
|
|
|
* @param key the key to be assigned to
|
|
|
|
|
* @param value the value that will be assigned
|
|
|
|
|
* @return False if the table key already exists with a different type
|
|
|
|
|
*/
|
|
|
|
|
bool SmartDashboard::PutRaw(llvm::StringRef key, llvm::StringRef value) {
|
|
|
|
|
return m_table->PutRaw(key, value);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Gets the current value in the table, setting it if it does not exist.
|
|
|
|
|
* @param key the key
|
|
|
|
|
* @param defaultValue the default value to set if key doesn't exist.
|
|
|
|
|
* @returns False if the table key exists with a different type
|
|
|
|
|
*/
|
|
|
|
|
bool SmartDashboard::SetDefaultRaw(llvm::StringRef key,
|
|
|
|
|
llvm::StringRef defaultValue) {
|
|
|
|
|
return m_table->SetDefaultRaw(key, defaultValue);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Returns the raw value (byte array) the key maps to. If the key does not
|
|
|
|
|
* exist or is of different type, it will return the default value.
|
|
|
|
|
* @param key the key to look up
|
|
|
|
|
* @param defaultValue the value to be returned if no value is found
|
|
|
|
|
* @return the value associated with the given key or the given default value
|
|
|
|
|
* if there is no value associated with the key
|
|
|
|
|
*
|
|
|
|
|
* @note This makes a copy of the raw contents. If the overhead of this is a
|
|
|
|
|
* concern, use GetValue() instead.
|
|
|
|
|
*/
|
|
|
|
|
std::string SmartDashboard::GetRaw(llvm::StringRef key,
|
|
|
|
|
llvm::StringRef defaultValue) {
|
|
|
|
|
return m_table->GetRaw(key, defaultValue);
|
|
|
|
|
}
|