Table Of Contents

Previous topic

_SingletonKey

Next topic

_TopicTreeRoot

This Page

phoenix_title _TopicTreeNode

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).


class_hierarchy Inheritance Diagram

Inheritance diagram for class _TopicTreeNode

Inheritance diagram of _TopicTreeNode


method_summary Methods Summary

__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

api Class API



class _TopicTreeNode

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).


Methods



__init__(self, topicPath, onDeadListenerWeakCB)


addCallable(self, callable)

Add a callable to list of callables for this topic node



clearCallables(self)

Abandon list of callables to caller. We no longer have any callables after this method is called.



createSubtopic(self, subtopic, topicPath)

Create a child node for subtopic



getCallables(self)

Get callables associated with this topic node



getNode(self, subtopic)

Return ref to node associated with subtopic



getPathname(self)

The complete node path to us, ie., the topic tuple that would lead to us



hasCallable(self, callable)

Return true if callable in this node



hasSubtopic(self, subtopic)

Return true only if topic string is one of subtopics of this node



removeCallable(self, callable)

Remove weak callable from our node (and return True). Does nothing if not here (and returns False).



sendMessage(self, message)

Send a message to our callables