From 0c11be703e97e45d32be6063dd377ca970b534e8 Mon Sep 17 00:00:00 2001 From: ChrisTimperley Date: Tue, 23 Jun 2020 17:26:33 -0400 Subject: [PATCH] added topics property to SystemState (fixes #374) --- src/roswire/proxy/state.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/roswire/proxy/state.py b/src/roswire/proxy/state.py index c915e1c5..a7b19f58 100644 --- a/src/roswire/proxy/state.py +++ b/src/roswire/proxy/state.py @@ -22,18 +22,30 @@ class SystemState: A mapping from topics to the names of subscribers to that topic. services: Mapping[str, Collection[str]] A mapping from services to the names of providers of that service. + nodes: AbstractSet[str] + The names of all known nodes running on the system. + topics: AbstractSet[str] + The names of all known topics on the system with at least one + publisher or one subscriber. """ publishers: Mapping[str, Collection[str]] subscribers: Mapping[str, Collection[str]] services: Mapping[str, Collection[str]] nodes: AbstractSet[str] = attr.ib(init=False, repr=False) + topics: AbstractSet[str] = attr.ib(init=False, repr=False) def __attrs_post_init__(self) -> None: nodes: Set[str] = set() nodes = nodes.union(*self.publishers.values()) nodes = nodes.union(*self.subscribers.values()) nodes = nodes.union(*self.services.values()) + + topics: Set[str] = set() + topics = topics.union(self.publishers) + topics = topics.union(self.subscribers) + object.__setattr__(self, 'nodes', frozenset(nodes)) + object.__setattr__(self, 'topics', frozenset(topics)) @attr.s(frozen=True, auto_attribs=True)