mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-19 00:41:43 +00:00
[wpilibc] Shuffleboard SimpleWidget: Return pointer instead of reference (#4703)
Based on beta test feedback, returning a pointer is more intuitive, as typically the return value is late bound to an instance variable.
This commit is contained in:
@@ -83,7 +83,7 @@ SimpleWidget& ShuffleboardContainer::Add(std::string_view title,
|
||||
auto ptr = widget.get();
|
||||
m_components.emplace_back(std::move(widget));
|
||||
ptr->GetEntry(nt::GetStringFromType(defaultValue.type()))
|
||||
.SetDefault(defaultValue);
|
||||
->SetDefault(defaultValue);
|
||||
return *ptr;
|
||||
}
|
||||
|
||||
@@ -322,7 +322,7 @@ SimpleWidget& ShuffleboardContainer::AddPersistent(
|
||||
std::string_view title, const nt::Value& defaultValue) {
|
||||
auto& widget = Add(title, defaultValue);
|
||||
widget.GetEntry(nt::GetStringFromType(defaultValue.type()))
|
||||
.GetTopic()
|
||||
->GetTopic()
|
||||
.SetPersistent(true);
|
||||
return widget;
|
||||
}
|
||||
|
||||
@@ -14,19 +14,19 @@ SimpleWidget::SimpleWidget(ShuffleboardContainer& parent,
|
||||
std::string_view title)
|
||||
: ShuffleboardValue(title), ShuffleboardWidget(parent, title), m_entry() {}
|
||||
|
||||
nt::GenericEntry& SimpleWidget::GetEntry() {
|
||||
nt::GenericEntry* SimpleWidget::GetEntry() {
|
||||
if (!m_entry) {
|
||||
ForceGenerate();
|
||||
}
|
||||
return m_entry;
|
||||
return &m_entry;
|
||||
}
|
||||
|
||||
nt::GenericEntry& SimpleWidget::GetEntry(std::string_view typeString) {
|
||||
nt::GenericEntry* SimpleWidget::GetEntry(std::string_view typeString) {
|
||||
if (!m_entry) {
|
||||
m_typeString = typeString;
|
||||
ForceGenerate();
|
||||
}
|
||||
return m_entry;
|
||||
return &m_entry;
|
||||
}
|
||||
|
||||
void SimpleWidget::BuildInto(std::shared_ptr<nt::NetworkTable> parentTable,
|
||||
|
||||
Reference in New Issue
Block a user