mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-25 01:41:43 +00:00
[ntcore] Add subscriber option to exclude single publisher
This enables limited self-exclusion for entries seeing their own changes or similarly with a pub/sub pair.
This commit is contained in:
@@ -96,6 +96,8 @@ enum NT_PubSubOptionType {
|
||||
NT_PUBSUB_POLLSTORAGE, /* polling storage for subscription */
|
||||
NT_PUBSUB_KEEPDUPLICATES, /* preserve duplicate values */
|
||||
NT_PUBSUB_LOCALREMOTE, /* local, remote, or any value changes */
|
||||
NT_PUBSUB_EXCLUDEPUB, /* exclude value changes made by given publisher */
|
||||
NT_PUBSUB_EXCLUDESELF, /* exclude value changes made by entry publisher */
|
||||
};
|
||||
|
||||
/** Event notification flags. */
|
||||
@@ -290,7 +292,7 @@ struct NT_PubSubOption {
|
||||
* Option value. 1 (true) or 0 (false) for immediate and logging options,
|
||||
* time between updates, in milliseconds, for periodic option. For
|
||||
* local/remote option, 1=local only, 2=remote only, 0 or 3=both local and
|
||||
* remote.
|
||||
* remote. For exclude publisher, publisher handle.
|
||||
*/
|
||||
unsigned int value;
|
||||
};
|
||||
|
||||
@@ -358,6 +358,28 @@ class PubSubOption {
|
||||
return PubSubOption{NT_PUBSUB_LOCALREMOTE, 0u};
|
||||
}
|
||||
|
||||
/**
|
||||
* Don't queue value updates for the given publisher. Only has an effect on
|
||||
* subscriptions. Only one exclusion may be set.
|
||||
*
|
||||
* @param publisher publisher handle
|
||||
* @return option
|
||||
*/
|
||||
static constexpr PubSubOption ExcludePublisher(NT_Publisher publisher) {
|
||||
return PubSubOption{NT_PUBSUB_EXCLUDEPUB, publisher};
|
||||
}
|
||||
|
||||
/**
|
||||
* Don't queue value updates for the internal publisher for an entry. Only has
|
||||
* an effect on entries.
|
||||
*
|
||||
* @param enabled True to enable, false to disable
|
||||
* @return option
|
||||
*/
|
||||
static constexpr PubSubOption ExcludeSelf(bool enabled) {
|
||||
return PubSubOption{NT_PUBSUB_EXCLUDESELF, enabled ? 1u : 0u};
|
||||
}
|
||||
|
||||
NT_PubSubOptionType type;
|
||||
unsigned int value;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user