mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-19 00:41:43 +00:00
Add braces to C++ single-line loops and conditionals (NFC) (#2973)
This makes code easier to read and more consistent between C++ and Java. Also update clang-format settings to always add a line break (even if no braces are used).
This commit is contained in:
@@ -20,14 +20,20 @@ std::shared_ptr<nt::NetworkTable> SendableBuilderImpl::GetTable() {
|
||||
return m_table;
|
||||
}
|
||||
|
||||
bool SendableBuilderImpl::HasTable() const { return m_table != nullptr; }
|
||||
bool SendableBuilderImpl::HasTable() const {
|
||||
return m_table != nullptr;
|
||||
}
|
||||
|
||||
bool SendableBuilderImpl::IsActuator() const { return m_actuator; }
|
||||
bool SendableBuilderImpl::IsActuator() const {
|
||||
return m_actuator;
|
||||
}
|
||||
|
||||
void SendableBuilderImpl::UpdateTable() {
|
||||
uint64_t time = nt::Now();
|
||||
for (auto& property : m_properties) {
|
||||
if (property.update) property.update(property.entry, time);
|
||||
if (property.update) {
|
||||
property.update(property.entry, time);
|
||||
}
|
||||
}
|
||||
for (auto& updateTable : m_updateTables) {
|
||||
updateTable();
|
||||
@@ -35,26 +41,40 @@ void SendableBuilderImpl::UpdateTable() {
|
||||
}
|
||||
|
||||
void SendableBuilderImpl::StartListeners() {
|
||||
for (auto& property : m_properties) property.StartListener();
|
||||
if (m_controllableEntry) m_controllableEntry.SetBoolean(true);
|
||||
for (auto& property : m_properties) {
|
||||
property.StartListener();
|
||||
}
|
||||
if (m_controllableEntry) {
|
||||
m_controllableEntry.SetBoolean(true);
|
||||
}
|
||||
}
|
||||
|
||||
void SendableBuilderImpl::StopListeners() {
|
||||
for (auto& property : m_properties) property.StopListener();
|
||||
if (m_controllableEntry) m_controllableEntry.SetBoolean(false);
|
||||
for (auto& property : m_properties) {
|
||||
property.StopListener();
|
||||
}
|
||||
if (m_controllableEntry) {
|
||||
m_controllableEntry.SetBoolean(false);
|
||||
}
|
||||
}
|
||||
|
||||
void SendableBuilderImpl::StartLiveWindowMode() {
|
||||
if (m_safeState) m_safeState();
|
||||
if (m_safeState) {
|
||||
m_safeState();
|
||||
}
|
||||
StartListeners();
|
||||
}
|
||||
|
||||
void SendableBuilderImpl::StopLiveWindowMode() {
|
||||
StopListeners();
|
||||
if (m_safeState) m_safeState();
|
||||
if (m_safeState) {
|
||||
m_safeState();
|
||||
}
|
||||
}
|
||||
|
||||
void SendableBuilderImpl::ClearProperties() { m_properties.clear(); }
|
||||
void SendableBuilderImpl::ClearProperties() {
|
||||
m_properties.clear();
|
||||
}
|
||||
|
||||
void SendableBuilderImpl::SetSmartDashboardType(const wpi::Twine& type) {
|
||||
m_table->GetEntry(".type").SetString(type);
|
||||
@@ -92,7 +112,9 @@ void SendableBuilderImpl::AddBooleanProperty(const wpi::Twine& key,
|
||||
[=](nt::NetworkTableEntry entry) -> NT_EntryListener {
|
||||
return entry.AddListener(
|
||||
[=](const nt::EntryNotification& event) {
|
||||
if (!event.value->IsBoolean()) return;
|
||||
if (!event.value->IsBoolean()) {
|
||||
return;
|
||||
}
|
||||
SmartDashboard::PostListenerTask(
|
||||
[=] { setter(event.value->GetBoolean()); });
|
||||
},
|
||||
@@ -116,7 +138,9 @@ void SendableBuilderImpl::AddDoubleProperty(
|
||||
[=](nt::NetworkTableEntry entry) -> NT_EntryListener {
|
||||
return entry.AddListener(
|
||||
[=](const nt::EntryNotification& event) {
|
||||
if (!event.value->IsDouble()) return;
|
||||
if (!event.value->IsDouble()) {
|
||||
return;
|
||||
}
|
||||
SmartDashboard::PostListenerTask(
|
||||
[=] { setter(event.value->GetDouble()); });
|
||||
},
|
||||
@@ -140,7 +164,9 @@ void SendableBuilderImpl::AddStringProperty(
|
||||
[=](nt::NetworkTableEntry entry) -> NT_EntryListener {
|
||||
return entry.AddListener(
|
||||
[=](const nt::EntryNotification& event) {
|
||||
if (!event.value->IsString()) return;
|
||||
if (!event.value->IsString()) {
|
||||
return;
|
||||
}
|
||||
SmartDashboard::PostListenerTask(
|
||||
[=] { setter(event.value->GetString()); });
|
||||
},
|
||||
@@ -164,7 +190,9 @@ void SendableBuilderImpl::AddBooleanArrayProperty(
|
||||
[=](nt::NetworkTableEntry entry) -> NT_EntryListener {
|
||||
return entry.AddListener(
|
||||
[=](const nt::EntryNotification& event) {
|
||||
if (!event.value->IsBooleanArray()) return;
|
||||
if (!event.value->IsBooleanArray()) {
|
||||
return;
|
||||
}
|
||||
SmartDashboard::PostListenerTask(
|
||||
[=] { setter(event.value->GetBooleanArray()); });
|
||||
},
|
||||
@@ -188,7 +216,9 @@ void SendableBuilderImpl::AddDoubleArrayProperty(
|
||||
[=](nt::NetworkTableEntry entry) -> NT_EntryListener {
|
||||
return entry.AddListener(
|
||||
[=](const nt::EntryNotification& event) {
|
||||
if (!event.value->IsDoubleArray()) return;
|
||||
if (!event.value->IsDoubleArray()) {
|
||||
return;
|
||||
}
|
||||
SmartDashboard::PostListenerTask(
|
||||
[=] { setter(event.value->GetDoubleArray()); });
|
||||
},
|
||||
@@ -212,7 +242,9 @@ void SendableBuilderImpl::AddStringArrayProperty(
|
||||
[=](nt::NetworkTableEntry entry) -> NT_EntryListener {
|
||||
return entry.AddListener(
|
||||
[=](const nt::EntryNotification& event) {
|
||||
if (!event.value->IsStringArray()) return;
|
||||
if (!event.value->IsStringArray()) {
|
||||
return;
|
||||
}
|
||||
SmartDashboard::PostListenerTask(
|
||||
[=] { setter(event.value->GetStringArray()); });
|
||||
},
|
||||
@@ -236,7 +268,9 @@ void SendableBuilderImpl::AddRawProperty(
|
||||
[=](nt::NetworkTableEntry entry) -> NT_EntryListener {
|
||||
return entry.AddListener(
|
||||
[=](const nt::EntryNotification& event) {
|
||||
if (!event.value->IsRaw()) return;
|
||||
if (!event.value->IsRaw()) {
|
||||
return;
|
||||
}
|
||||
SmartDashboard::PostListenerTask(
|
||||
[=] { setter(event.value->GetRaw()); });
|
||||
},
|
||||
@@ -284,7 +318,9 @@ void SendableBuilderImpl::AddSmallStringProperty(
|
||||
[=](nt::NetworkTableEntry entry) -> NT_EntryListener {
|
||||
return entry.AddListener(
|
||||
[=](const nt::EntryNotification& event) {
|
||||
if (!event.value->IsString()) return;
|
||||
if (!event.value->IsString()) {
|
||||
return;
|
||||
}
|
||||
SmartDashboard::PostListenerTask(
|
||||
[=] { setter(event.value->GetString()); });
|
||||
},
|
||||
@@ -310,7 +346,9 @@ void SendableBuilderImpl::AddSmallBooleanArrayProperty(
|
||||
[=](nt::NetworkTableEntry entry) -> NT_EntryListener {
|
||||
return entry.AddListener(
|
||||
[=](const nt::EntryNotification& event) {
|
||||
if (!event.value->IsBooleanArray()) return;
|
||||
if (!event.value->IsBooleanArray()) {
|
||||
return;
|
||||
}
|
||||
SmartDashboard::PostListenerTask(
|
||||
[=] { setter(event.value->GetBooleanArray()); });
|
||||
},
|
||||
@@ -337,7 +375,9 @@ void SendableBuilderImpl::AddSmallDoubleArrayProperty(
|
||||
[=](nt::NetworkTableEntry entry) -> NT_EntryListener {
|
||||
return entry.AddListener(
|
||||
[=](const nt::EntryNotification& event) {
|
||||
if (!event.value->IsDoubleArray()) return;
|
||||
if (!event.value->IsDoubleArray()) {
|
||||
return;
|
||||
}
|
||||
SmartDashboard::PostListenerTask(
|
||||
[=] { setter(event.value->GetDoubleArray()); });
|
||||
},
|
||||
@@ -365,7 +405,9 @@ void SendableBuilderImpl::AddSmallStringArrayProperty(
|
||||
[=](nt::NetworkTableEntry entry) -> NT_EntryListener {
|
||||
return entry.AddListener(
|
||||
[=](const nt::EntryNotification& event) {
|
||||
if (!event.value->IsStringArray()) return;
|
||||
if (!event.value->IsStringArray()) {
|
||||
return;
|
||||
}
|
||||
SmartDashboard::PostListenerTask(
|
||||
[=] { setter(event.value->GetStringArray()); });
|
||||
},
|
||||
@@ -391,7 +433,9 @@ void SendableBuilderImpl::AddSmallRawProperty(
|
||||
[=](nt::NetworkTableEntry entry) -> NT_EntryListener {
|
||||
return entry.AddListener(
|
||||
[=](const nt::EntryNotification& event) {
|
||||
if (!event.value->IsRaw()) return;
|
||||
if (!event.value->IsRaw()) {
|
||||
return;
|
||||
}
|
||||
SmartDashboard::PostListenerTask(
|
||||
[=] { setter(event.value->GetRaw()); });
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user