mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-20 00:51:42 +00:00
[ntcore] Pass pub/sub options as a unified PubSubOptions struct (#4794)
In Java, PubSubOption is still used for passing options, but this simplifies C++ use substantially, as it allows aggregate construction.
This commit is contained in:
@@ -130,8 +130,8 @@ void SendableBuilderImpl::AddPropertyImpl(Topic topic, Getter getter,
|
||||
};
|
||||
}
|
||||
if (setter) {
|
||||
prop->sub = topic.Subscribe(
|
||||
{}, {{nt::PubSubOption::ExcludePublisher(prop->pub.GetHandle())}});
|
||||
prop->sub =
|
||||
topic.Subscribe({}, {.excludePublisher = prop->pub.GetHandle()});
|
||||
prop->updateLocal = [=](auto& sub) {
|
||||
for (auto&& val : sub.ReadQueue()) {
|
||||
setter(val.value);
|
||||
@@ -224,9 +224,8 @@ void SendableBuilderImpl::AddRawProperty(
|
||||
};
|
||||
}
|
||||
if (setter) {
|
||||
prop->sub = topic.Subscribe(
|
||||
typeString, {},
|
||||
{{nt::PubSubOption::ExcludePublisher(prop->pub.GetHandle())}});
|
||||
prop->sub = topic.Subscribe(typeString, {},
|
||||
{.excludePublisher = prop->pub.GetHandle()});
|
||||
prop->updateLocal = [=](auto& sub) {
|
||||
for (auto&& val : sub.ReadQueue()) {
|
||||
setter(val.value);
|
||||
@@ -249,8 +248,8 @@ void SendableBuilderImpl::AddSmallPropertyImpl(Topic topic, Getter getter,
|
||||
};
|
||||
}
|
||||
if (setter) {
|
||||
prop->sub = topic.Subscribe(
|
||||
{}, {{nt::PubSubOption::ExcludePublisher(prop->pub.GetHandle())}});
|
||||
prop->sub =
|
||||
topic.Subscribe({}, {.excludePublisher = prop->pub.GetHandle()});
|
||||
prop->updateLocal = [=](auto& sub) {
|
||||
for (auto&& val : sub.ReadQueue()) {
|
||||
setter(val.value);
|
||||
@@ -328,9 +327,8 @@ void SendableBuilderImpl::AddSmallRawProperty(
|
||||
};
|
||||
}
|
||||
if (setter) {
|
||||
prop->sub = topic.Subscribe(
|
||||
typeString, {},
|
||||
{{nt::PubSubOption::ExcludePublisher(prop->pub.GetHandle())}});
|
||||
prop->sub = topic.Subscribe(typeString, {},
|
||||
{.excludePublisher = prop->pub.GetHandle()});
|
||||
prop->updateLocal = [=](auto& sub) {
|
||||
for (auto&& val : sub.ReadQueue()) {
|
||||
setter(val.value);
|
||||
|
||||
Reference in New Issue
Block a user