|
The base class for objects used to notify interested parties (listeners) when events have occurred. More...
#include <notice.h>
Classes | |
class | Block |
Blocks sending of all notices in current thread. More... | |
class | Key |
Handle-object returned by TfNotice::Register() . More... | |
class | Probe |
Probe interface class which may be implemented and then registered via InsertProbe to introspect about notices as they are sent and delivered. More... | |
Public Types | |
typedef TfWeakPtr< Probe > | WeakProbePtr |
typedef std::vector< Key > | Keys |
A TfNotice::Key container. | |
Public Member Functions | |
TF_API size_t | Send () const |
Deliver the notice to interested listeners, returning the number of interested listeners. | |
template<typename SenderPtr > | |
size_t | Send (SenderPtr const &s) const |
Deliver the notice to interested listeners, returning the number of interested listeners. | |
TF_API size_t | SendWithWeakBase (const TfWeakBase *senderWeakBase, const void *senderUniqueId, const std::type_info &type) const |
Variant of Send() that takes a specific sender in the form of a TfWeakBase pointer and a typeid. | |
Static Public Member Functions | |
static TF_API void | InsertProbe (const WeakProbePtr &probe) |
Register a probe that will be invoked when notices are sent and delivered. | |
static TF_API void | RemoveProbe (const WeakProbePtr &probe) |
Remove a probe that was previously registered with InsertProbe . | |
template<class LPtr , class MethodPtr > | |
static TfNotice::Key | Register (LPtr const &listener, MethodPtr method) |
Register a listener as being interested in a TfNotice . | |
template<class LPtr , class MethodPtr , class SenderPtr > | |
static TfNotice::Key | Register (LPtr const &listener, MethodPtr method, SenderPtr const &sender) |
template<class LPtr , class MethodPtr > | |
static TfNotice::Key | Register (LPtr const &listener, MethodPtr method, const TfType ¬iceType, const TfAnyWeakPtr &sender) |
static TF_API bool | Revoke (TfNotice::Key &key) |
Revoke interest by a listener. | |
static TF_API void | Revoke (TfNotice::Keys *keys) |
Revoke interest by listeners. | |
The base class for objects used to notify interested parties (listeners) when events have occurred.
The TfNotice class also serves as a container for various dispatching routines such as Register() and Send().
See The TfNotice Notification System in the C++ API reference for a detailed description of the notification system.
Notices The following code provides examples of how to set up a Notice listener connection (represented in Python by the Listener class), including creating and sending notices, registering to receive notices, and breaking a listener connection.
For more on using notices in Python, see the Editor With Notices tutorial.
A TfNotice::Key
container.
Many listeners listen for several notices and must revoke interest for those several notices at once. These listeners can put all of the keys into a TfNotice::Keys
then call Revoke()
on it.
typedef TfWeakPtr<Probe> WeakProbePtr |
|
static |
|
inlinestatic |
Register a listener as being interested in a TfNotice
.
Registration of interest in a notice class N
automatically registers interest in all classes derived from N
. When a notice of appropriate type is received, the listening object's member-function method
is called with the notice.
Supports several forms of registration.
The listener being registered must be pointed to by a TfWeakPtrFacade
, like a TfWeakPtr or another TfWeakPtrFacade-based Handle. The sender being registered for (if any) must also be pointed to by a TfWeakPtrFacade
.
Note that the notification center only holds onto the listening object via a TfWeakPtr
. That is, it does not influence the lifetime of that object.
To reverse the registration, call Key::Revoke()
on the Key
object returned by this call.
|
inlinestatic |
|
inlinestatic |
|
static |
Remove a probe that was previously registered with InsertProbe
.
|
static |
Revoke interest by a listener.
This revokes interest by the listener for the particular notice type and call-back method for which this key was created.
Revoke
will return a bool value indicating whether or not the key was successfully revoked. Subsequent calls to Revoke
with the same key will return false.
|
static |
Revoke interest by listeners.
This revokes interest by the listeners for the particular notice types and call-back methods for which the keys were created. It then clears the keys container.
TF_API size_t Send | ( | ) | const |
Deliver the notice to interested listeners, returning the number of interested listeners.
For most clients it is recommended to use the Send(sender) version of Send() rather than this one. Clients that use this form of Send will prevent listeners from being able to register to receive notices based on the sender of the notice.
ONLY listeners that registered globally will get the notice.
Listeners are invoked synchronously and in arbitrary order. The value returned is the total number of times the notice was sent to listeners. Note that a listener is called in the thread in which Send()
is called and not necessarily in the thread that Register()
was called in.
size_t Send | ( | SenderPtr const & | s | ) | const |
Deliver the notice to interested listeners, returning the number of interested listeners.
This is the recommended form of Send. It takes the sender as an argument.
Listeners that registered for the given sender AND listeners that registered globally will get the notice.
Listeners are invoked synchronously and in arbitrary order. The value returned is the total number of times the notice was sent to listeners. Note that a listener is called in the thread in which Send()
is called and not necessarily in the thread that Register()
was called in.
TF_API size_t SendWithWeakBase | ( | const TfWeakBase * | senderWeakBase, |
const void * | senderUniqueId, | ||
const std::type_info & | type | ||
) | const |
Variant of Send() that takes a specific sender in the form of a TfWeakBase pointer and a typeid.
This version is used by senders who don't have static knowledge of sender's type, but have access to its weak base pointer and its typeid.