A node in the topic tree. This contains a list of callables that are interested in the topic that this node is associated with, and contains a dictionary of subtopics, whose associated values are other _TopicTreeNodes. The topic of a node is not stored in the node, so that the tree can be implemented as a dictionary rather than a list, for ease of use (and, likely, performance).
Note that it uses _NodeCallback to encapsulate a callback for when a registered listener dies, possible thanks to WeakRef. Whenever this callback is called, the onDeadListener() function, passed in at construction time, is called (unless it is None).
__init__ | |
addCallable | Add a callable to list of callables for this topic node |
clearCallables | Abandon list of callables to caller. We no longer have |
createSubtopic | Create a child node for subtopic |
getCallables | Get callables associated with this topic node |
getNode | Return ref to node associated with subtopic |
getPathname | The complete node path to us, ie., the topic tuple that would lead to us |
hasCallable | Return true if callable in this node |
hasSubtopic | Return true only if topic string is one of subtopics of this node |
removeCallable | Remove weak callable from our node (and return True). |
sendMessage | Send a message to our callables |
A node in the topic tree. This contains a list of callables that are interested in the topic that this node is associated with, and contains a dictionary of subtopics, whose associated values are other _TopicTreeNodes. The topic of a node is not stored in the node, so that the tree can be implemented as a dictionary rather than a list, for ease of use (and, likely, performance).
Note that it uses _NodeCallback to encapsulate a callback for when a registered listener dies, possible thanks to WeakRef. Whenever this callback is called, the onDeadListener() function, passed in at construction time, is called (unless it is None).
Add a callable to list of callables for this topic node
Abandon list of callables to caller. We no longer have any callables after this method is called.
Create a child node for subtopic
Get callables associated with this topic node
Return ref to node associated with subtopic
The complete node path to us, ie., the topic tuple that would lead to us
Return true if callable in this node
Return true only if topic string is one of subtopics of this node
Remove weak callable from our node (and return True). Does nothing if not here (and returns False).
Send a message to our callables