[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:
Peter Johnson
2022-12-12 19:28:15 -08:00
committed by GitHub
parent f66a667321
commit a865f48e96
53 changed files with 695 additions and 623 deletions

View File

@@ -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);