direct.distributed.RelatedObjectMgr

from direct.distributed.RelatedObjectMgr import RelatedObjectMgr

RelatedObjectMgr module: contains the RelatedObjectMgr class

Inheritance diagram

Inheritance diagram of direct.distributed.RelatedObjectMgr

class RelatedObjectMgr(cr)[source]

Bases: DirectObject

This class manages a relationship between DistributedObjects that know about each other, and are expected to be generated together. Ideally, we should be able to guarantee the ordering of the generate calls, but there are certain cases in which the objects may not be generated in the correct order as defined by the toon.dc file.

To handle cases like these robustly, it is necessary for each object to deal with the possibility that its companion object has not yet been generated. This may mean deferring some operations until the expected companion object has been generated.

This class helps manage that process. To use it, an object should register its desire to be associated with the other object’s doId. When the other object is generated (or immediately, if the object already exists), the associated callback will be called. There is also a timeout callback in case the object never appears.

__init__(self, cr)[source]
abortAllRequests(self)[source]

Call this method to abruptly abort all pending requests, but leave the RelatedObjectMgr in a state for accepting more requests.

abortRequest(self, tuple)[source]

Aborts a previous request. The parameter is the return value from a previous call to requestObjects(). The pending request is removed from the queue and no further callbacks will be called.

See Also: requestObjects()

destroy(self)[source]
doLaterSequence = 1
notify = <direct.directnotify.Notifier.Notifier object>
requestObjects(self, doIdList, allCallback=None, eachCallback=None, timeout=None, timeoutCallback=None)[source]

Requests a callback to be called when the objects in the doIdList are generated. The allCallback will be called only when all the objects have been generated (and it receives a list of objects, in the order given in doIdList). The eachCallback is called as each object is generated, and receives only the object itself.

If the objects already exist, the appropriate callback is called immediately.

If all of the objects are not generated within the indicated timeout time, the timeoutCallback is called instead, with the original doIdList as the parameter. If the timeoutCallback is None, then allCallback is called on timeout, with the list of objects that have been generated so far, and None for objects that have not been generated.

If any element of doIdList is None or 0, it is ignored, and None is passed in its place in the object list passed to the callback.

The return value may be saved and passed to a future call to abortRequest(), in order to abort a pending request before the timeout expires.

Actually, you should be careful to call abortRequest() if you have made a call to requestObjects() that has not been resolved. To find examples, do a search for abortRequest() to find out how other code is using it. A common idiom is to store the result from requestObjects() and call abortRequest() if delete() or destroy() is called on the requesting object.

See Also: abortRequest()