Remove GetTable from wpilibc Sendable interface.

This allows nearly all m_table member variables to be removed.
This commit is contained in:
Peter Johnson
2017-09-02 00:35:30 -07:00
parent 040a8c6bcc
commit 0d4fde17e0
57 changed files with 87 additions and 259 deletions

View File

@@ -435,12 +435,11 @@ std::string Command::GetSmartDashboardType() const { return "Command"; }
void Command::InitTable(std::shared_ptr<nt::NetworkTable> subtable) {
if (m_runningListener != 0) m_runningEntry.RemoveListener(m_runningListener);
m_table = subtable;
if (m_table != nullptr) {
m_table->GetEntry(kName).SetString(GetName());
m_runningEntry = m_table->GetEntry(kRunning);
if (subtable) {
subtable->GetEntry(kName).SetString(GetName());
m_runningEntry = subtable->GetEntry(kRunning);
m_runningEntry.SetBoolean(IsRunning());
m_isParentedEntry = m_table->GetEntry(kIsParented);
m_isParentedEntry = subtable->GetEntry(kIsParented);
m_isParentedEntry.SetBoolean(m_parent != nullptr);
m_runningListener = m_runningEntry.AddListener(
@@ -455,5 +454,3 @@ void Command::InitTable(std::shared_ptr<nt::NetworkTable> subtable) {
NT_NOTIFY_NEW | NT_NOTIFY_UPDATE);
}
}
std::shared_ptr<nt::NetworkTable> Command::GetTable() const { return m_table; }

View File

@@ -218,7 +218,6 @@ void Scheduler::ResetAll() {
m_buttons.clear();
m_additions.clear();
m_commands.clear();
m_table = nullptr;
m_namesEntry = nt::NetworkTableEntry();
m_idsEntry = nt::NetworkTableEntry();
m_cancelEntry = nt::NetworkTableEntry();
@@ -229,7 +228,7 @@ void Scheduler::ResetAll() {
* SmartDashboard.
*/
void Scheduler::UpdateTable() {
if (m_table != nullptr) {
if (m_cancelEntry && m_namesEntry && m_idsEntry) {
// Get the list of possible commands to cancel
auto new_toCancel = m_cancelEntry.GetValue();
if (new_toCancel)
@@ -277,11 +276,10 @@ std::string Scheduler::GetType() const { return "Scheduler"; }
std::string Scheduler::GetSmartDashboardType() const { return "Scheduler"; }
void Scheduler::InitTable(std::shared_ptr<nt::NetworkTable> subTable) {
m_table = subTable;
if (m_table) {
m_namesEntry = m_table->GetEntry("Names");
m_idsEntry = m_table->GetEntry("Ids");
m_cancelEntry = m_table->GetEntry("Cancel");
if (subTable) {
m_namesEntry = subTable->GetEntry("Names");
m_idsEntry = subTable->GetEntry("Ids");
m_cancelEntry = subTable->GetEntry("Cancel");
m_namesEntry.SetStringArray(commands);
m_idsEntry.SetDoubleArray(ids);
m_cancelEntry.SetDoubleArray(toCancel);
@@ -291,7 +289,3 @@ void Scheduler::InitTable(std::shared_ptr<nt::NetworkTable> subTable) {
m_cancelEntry = nt::NetworkTableEntry();
}
}
std::shared_ptr<nt::NetworkTable> Scheduler::GetTable() const {
return m_table;
}

View File

@@ -64,7 +64,7 @@ void Subsystem::SetDefaultCommand(Command* command) {
m_defaultCommand = command;
}
if (m_table != nullptr) {
if (m_hasDefaultEntry && m_defaultEntry) {
if (m_defaultCommand != nullptr) {
m_hasDefaultEntry.SetBoolean(true);
m_defaultEntry.SetString(m_defaultCommand->GetName());
@@ -119,7 +119,7 @@ void Subsystem::Periodic() {}
*/
void Subsystem::ConfirmCommand() {
if (m_currentCommandChanged) {
if (m_table != nullptr) {
if (m_hasCommandEntry && m_commandEntry) {
if (m_currentCommand != nullptr) {
m_hasCommandEntry.SetBoolean(true);
m_commandEntry.SetString(m_currentCommand->GetName());
@@ -136,12 +136,11 @@ std::string Subsystem::GetName() const { return m_name; }
std::string Subsystem::GetSmartDashboardType() const { return "Subsystem"; }
void Subsystem::InitTable(std::shared_ptr<nt::NetworkTable> subtable) {
m_table = subtable;
if (m_table != nullptr) {
m_hasDefaultEntry = m_table->GetEntry("hasDefault");
m_defaultEntry = m_table->GetEntry("default");
m_hasCommandEntry = m_table->GetEntry("hasCommand");
m_commandEntry = m_table->GetEntry("command");
if (subtable != nullptr) {
m_hasDefaultEntry = subtable->GetEntry("hasDefault");
m_defaultEntry = subtable->GetEntry("default");
m_hasCommandEntry = subtable->GetEntry("hasCommand");
m_commandEntry = subtable->GetEntry("command");
if (m_defaultCommand != nullptr) {
m_hasDefaultEntry.SetBoolean(true);
@@ -157,7 +156,3 @@ void Subsystem::InitTable(std::shared_ptr<nt::NetworkTable> subtable) {
}
}
}
std::shared_ptr<nt::NetworkTable> Subsystem::GetTable() const {
return m_table;
}