Skip to content

Commit 0c11be7

Browse files
added topics property to SystemState (fixes #374)
1 parent 7fc56b8 commit 0c11be7

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

src/roswire/proxy/state.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,18 +22,30 @@ class SystemState:
2222
A mapping from topics to the names of subscribers to that topic.
2323
services: Mapping[str, Collection[str]]
2424
A mapping from services to the names of providers of that service.
25+
nodes: AbstractSet[str]
26+
The names of all known nodes running on the system.
27+
topics: AbstractSet[str]
28+
The names of all known topics on the system with at least one
29+
publisher or one subscriber.
2530
"""
2631
publishers: Mapping[str, Collection[str]]
2732
subscribers: Mapping[str, Collection[str]]
2833
services: Mapping[str, Collection[str]]
2934
nodes: AbstractSet[str] = attr.ib(init=False, repr=False)
35+
topics: AbstractSet[str] = attr.ib(init=False, repr=False)
3036

3137
def __attrs_post_init__(self) -> None:
3238
nodes: Set[str] = set()
3339
nodes = nodes.union(*self.publishers.values())
3440
nodes = nodes.union(*self.subscribers.values())
3541
nodes = nodes.union(*self.services.values())
42+
43+
topics: Set[str] = set()
44+
topics = topics.union(self.publishers)
45+
topics = topics.union(self.subscribers)
46+
3647
object.__setattr__(self, 'nodes', frozenset(nodes))
48+
object.__setattr__(self, 'topics', frozenset(topics))
3749

3850

3951
@attr.s(frozen=True, auto_attribs=True)

0 commit comments

Comments
 (0)