1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295
|
.. wxPython Phoenix documentation
This file was generated by Phoenix's sphinx generator and associated
tools, do not edit by hand.
Copyright: (c) 2011-2018 by Total Control Software
License: wxWindows License
.. include:: headings.inc
.. currentmodule:: wx.lib.pubsub.core.topicobj
.. highlight:: python
.. _wx.lib.pubsub.core.topicobj.Topic:
==========================================================================================================================================
|phoenix_title| **wx.lib.pubsub.core.topicobj.Topic**
==========================================================================================================================================
Represent topics in pubsub. Contains information about a topic,
including topic's message data specification (MDS), the list of
subscribed listeners, docstring for the topic. It allows Python-like
access to subtopics (e.g. A.B is subtopic B of topic A).
|
|class_hierarchy| Class Hierarchy
=================================
.. raw:: html
<div id="toggleBlock" onclick="return toggleVisibility(this)" class="closed" style="cursor:pointer;">
<img id="toggleBlock-trigger" src="_static/images/closed.png"/>
Inheritance diagram for class <strong>Topic</strong>:
</div>
<div id="toggleBlock-summary" style="display:block;"></div>
<div id="toggleBlock-content" style="display:none;">
<p class="graphviz">
<center><img src="_static/images/inheritance/wx.lib.pubsub.core.topicobj.Topic_inheritance.png" alt="Inheritance diagram of Topic" usemap="#dummy" class="inheritance"/></center>
</div>
<script type="text/javascript">toggleVisibilityOnLoad(document.getElementById('toggleBlock'))</script>
<map id="dummy" name="dummy"> <area shape="rect" id="node1" href="wx.lib.pubsub.core.topicobj.Topic.html" title="wx.lib.pubsub.core.topicobj.Topic" alt="" coords="55,83,283,112"/> <area shape="rect" id="node2" href="wx.lib.pubsub.core.publishermixin.PublisherMixin.html" title="wx.lib.pubsub.core.publishermixin.PublisherMixin" alt="" coords="5,5,333,35"/> </map>
</p>
|
|super_classes| Known Superclasses
==================================
:class:`wx.lib.pubsub.core.publishermixin.PublisherMixin`
|
|method_summary| Methods Summary
================================
================================================================================ ================================================================================
:meth:`~wx.lib.pubsub.core.topicobj.Topic.__init__` Create a topic. Should only be called by TopicManager via its
:meth:`~wx.lib.pubsub.core.topicobj.Topic.filterMsgArgs` Get the MDS docstrings for each of the spedified kwargs.
:meth:`~wx.lib.pubsub.core.topicobj.Topic.getArgDescriptions` Get a map of keyword names to docstrings: documents each MDS element.
:meth:`~wx.lib.pubsub.core.topicobj.Topic.getArgs` Returns a pair (reqdArgs, optArgs) where reqdArgs is tuple
:meth:`~wx.lib.pubsub.core.topicobj.Topic.getDescription` Return the 'docstring' of topic
:meth:`~wx.lib.pubsub.core.topicobj.Topic.getListeners` Get a copy of list of listeners subscribed to this topic. Safe to iterate over while listeners
:meth:`~wx.lib.pubsub.core.topicobj.Topic.getListenersIter` Get an iterator over listeners subscribed to this topic. Do not use if listeners can be
:meth:`~wx.lib.pubsub.core.topicobj.Topic.getName` Return dotted form of full topic name
:meth:`~wx.lib.pubsub.core.topicobj.Topic.getNameTuple` Return tuple form of full topic name
:meth:`~wx.lib.pubsub.core.topicobj.Topic.getNodeName` Return the last part of the topic name (has no dots)
:meth:`~wx.lib.pubsub.core.topicobj.Topic.getNumListeners` Return number of listeners currently subscribed to topic. This is
:meth:`~wx.lib.pubsub.core.topicobj.Topic.getParent` Get Topic object that is parent of self (i.e. self is a subtopic
:meth:`~wx.lib.pubsub.core.topicobj.Topic.getSubtopic` Get the specified subtopic object. The relName can be a valid
:meth:`~wx.lib.pubsub.core.topicobj.Topic.getSubtopics` Get a list of Topic instances that are subtopics of self.
:meth:`~wx.lib.pubsub.core.topicobj.Topic.hasListener` Return true if listener is subscribed to this topic.
:meth:`~wx.lib.pubsub.core.topicobj.Topic.hasListeners` Return true if there are any listeners subscribed to
:meth:`~wx.lib.pubsub.core.topicobj.Topic.hasMDS` Return true if this topic has a message data specification (MDS).
:meth:`~wx.lib.pubsub.core.topicobj.Topic.hasSubtopic` Return true only if name is a subtopic of self. If name not
:meth:`~wx.lib.pubsub.core.topicobj.Topic.isAll` Returns true if this topic is the 'all topics' topic. All root
:meth:`~wx.lib.pubsub.core.topicobj.Topic.isRoot` Returns true if this is a "root" topic, false otherwise. A
:meth:`~wx.lib.pubsub.core.topicobj.Topic.isValid` Return ``True`` only if listener could be subscribed to this topic,
:meth:`~wx.lib.pubsub.core.topicobj.Topic.setArgDescriptions` Set the docstring for each MDS datum.
:meth:`~wx.lib.pubsub.core.topicobj.Topic.setDescription` Set the 'docstring' of topic
:meth:`~wx.lib.pubsub.core.topicobj.Topic.setMsgArgSpec` Specify the message data for topic messages.
:meth:`~wx.lib.pubsub.core.topicobj.Topic.subscribe` Subscribe listener to this topic. Returns a pair
:meth:`~wx.lib.pubsub.core.topicobj.Topic.unsubscribe` Unsubscribe the specified listener from this topic. Returns
:meth:`~wx.lib.pubsub.core.topicobj.Topic.unsubscribeAllListeners` Clears list of subscribed listeners. If filter is given, it must
:meth:`~wx.lib.pubsub.core.topicobj.Topic.validate` Checks whether listener could be subscribed to this topic
================================================================================ ================================================================================
|
|api| Class API
===============
.. class:: Topic(PublisherMixin)
Represent topics in pubsub. Contains information about a topic,
including topic's message data specification (MDS), the list of
subscribed listeners, docstring for the topic. It allows Python-like
access to subtopics (e.g. A.B is subtopic B of topic A).
.. method:: __init__(self, treeConfig, nameTuple, description, msgArgsInfo, parent=None)
Create a topic. Should only be called by TopicManager via its
getOrCreateTopic() method (which gets called in several places
in pubsub, such as sendMessage, subscribe, and newTopic).
:param treeConfig: topic tree configuration settings
:param nameTuple: topic name, in tuple format (no dots)
:param description: "docstring" for topic
:param ArgsInfo msgArgsInfo: object that defines MDS for topic
:param parent: parent of topic
:raises ValueError: invalid topic name
.. method:: filterMsgArgs(self, msgKwargs, check=False)
Get the MDS docstrings for each of the spedified kwargs.
.. method:: getArgDescriptions(self)
Get a map of keyword names to docstrings: documents each MDS element.
.. method:: getArgs(self)
Returns a pair (reqdArgs, optArgs) where reqdArgs is tuple
of names of required message arguments, optArgs is tuple
of names for optional arguments. If topic args not specified
yet, returns (None, None).
.. method:: getDescription(self)
Return the 'docstring' of topic
.. method:: getListeners(self)
Get a copy of list of listeners subscribed to this topic. Safe to iterate over while listeners
get un/subscribed from this topics (such as while sending a message).
.. method:: getListenersIter(self)
Get an iterator over listeners subscribed to this topic. Do not use if listeners can be
un/subscribed while iterating.
.. method:: getName(self)
Return dotted form of full topic name
.. method:: getNameTuple(self)
Return tuple form of full topic name
.. method:: getNodeName(self)
Return the last part of the topic name (has no dots)
.. method:: getNumListeners(self)
Return number of listeners currently subscribed to topic. This is
different from number of listeners that will get notified since more
general topics up the topic tree may have listeners.
.. method:: getParent(self)
Get Topic object that is parent of self (i.e. self is a subtopic
of parent). Return none if self is the "all topics" topic.
.. method:: getSubtopic(self, relName)
Get the specified subtopic object. The relName can be a valid
subtopic name, a dotted-name string, or a tuple.
.. method:: getSubtopics(self)
Get a list of Topic instances that are subtopics of self.
.. method:: hasListener(self, listener)
Return true if listener is subscribed to this topic.
.. method:: hasListeners(self)
Return true if there are any listeners subscribed to
this topic, false otherwise.
.. method:: hasMDS(self)
Return true if this topic has a message data specification (MDS).
.. method:: hasSubtopic(self, name=None)
Return true only if name is a subtopic of self. If name not
specified, return true only if self has at least one subtopic.
.. method:: isAll(self)
Returns true if this topic is the 'all topics' topic. All root
topics behave as though they are child of that topic.
.. method:: isRoot(self)
Returns true if this is a "root" topic, false otherwise. A
root topic is a topic whose name contains no dots and which
has pub.ALL_TOPICS as parent.
.. method:: isValid(self, listener)
Return ``True`` only if listener could be subscribed to this topic,
otherwise returns False. Note that method raises TopicDefnError
if self not hasMDS().
.. method:: setArgDescriptions(self, \*\*docs)
Set the docstring for each MDS datum.
.. method:: setDescription(self, desc)
Set the 'docstring' of topic
.. method:: setMsgArgSpec(self, argsDocs, required=())
Specify the message data for topic messages.
:param argsDocs: a dictionary of keyword names (message data name) and data 'docstring'; cannot be None
:param required: a list of those keyword names, appearing in argsDocs,
which are required (all others are assumed optional)
Can only be called if this info has not been already set at construction
or in a previous call.
:raise RuntimeError: if MDS already set at construction or previous call.
.. method:: subscribe(self, listener)
Subscribe listener to this topic. Returns a pair
(pub.Listener, success). The success is true only if listener
was not already subscribed and is now subscribed.
.. method:: unsubscribe(self, listener)
Unsubscribe the specified listener from this topic. Returns
the pub.Listener object associated with the listener that was
unsubscribed, or None if the specified listener was not
subscribed to this topic. Note that this method calls
``notifyUnsubscribe(listener, self)`` on all registered notification
handlers (see pub.addNotificationHandler).
.. method:: unsubscribeAllListeners(self, filter=None)
Clears list of subscribed listeners. If filter is given, it must
be a function that takes a listener and returns true if the listener
should be unsubscribed. Returns the list of Listener for listeners
that were unsubscribed.
.. method:: validate(self, listener)
Checks whether listener could be subscribed to this topic:
if yes, just returns; if not, raises ListenerMismatchError.
Note that method raises TopicDefnError if self not
hasMDS().
|