Usd Notice Framework  0.7.0
unf::Broker Class Reference

Intermediate object between the Usd Stage and any clients that needs asynchronous handling and upstream filtering of notices. More...

#include <broker.h>

Inheritance diagram for unf::Broker:
PXR_NS::TfRefBase PXR_NS::TfWeakBase

Public Member Functions

UNF_API Broker (const Broker &)=delete
 Remove default copy constructor.
 
UNF_API Brokeroperator= (const Broker &)=delete
 Remove default assignment operator.
 
UNF_API const PXR_NS::UsdStageWeakPtr GetStage () const
 Return Usd Stage associated with the broker.
 
UNF_API bool IsInTransaction ()
 Indicate whether a notice transaction has been started. More...
 
UNF_API void BeginTransaction (CapturePredicate predicate=CapturePredicate::Default())
 Start a notice transaction. More...
 
UNF_API void BeginTransaction (const CapturePredicateFunc &)
 Start a notice transaction with a capture predicate function. More...
 
UNF_API void EndTransaction ()
 Stop a notice transaction. More...
 
template<class UnfNotice , class... Args>
void Send (Args &&... args)
 Create and send a UnfNotice::StageNotice notice via the broker. More...
 
UNF_API void Send (const UnfNotice::StageNoticeRefPtr &)
 Send a UnfNotice::StageNotice notice via the broker. More...
 
UNF_API DispatcherPtrGetDispatcher (std::string identifier)
 Return dispatcher reference associated with identifier.
 
template<class T >
void AddDispatcher ()
 Create and register a new dispatcher. More...
 
UNF_API void Reset ()
 Un-register broker. More...
 

Static Public Member Functions

static UNF_API BrokerPtr Create (const PXR_NS::UsdStageWeakPtr &stage)
 Create a broker from a Usd Stage. More...
 
static UNF_API void ResetAll ()
 Un-register all brokers.
 

Detailed Description

Intermediate object between the Usd Stage and any clients that needs asynchronous handling and upstream filtering of notices.

Member Function Documentation

◆ Create()

static UNF_API BrokerPtr unf::Broker::Create ( const PXR_NS::UsdStageWeakPtr stage)
static

Create a broker from a Usd Stage.

If a broker has already been created from this stage, it will be returned. Otherwise, a new one will be created and returned.

◆ IsInTransaction()

UNF_API bool unf::Broker::IsInTransaction ( )

Indicate whether a notice transaction has been started.

See also
BeginTransaction

◆ BeginTransaction() [1/2]

UNF_API void unf::Broker::BeginTransaction ( CapturePredicate  predicate = CapturePredicate::Default())

Start a notice transaction.

Notices derived from UnfNotice::StageNotice will be held during the transaction and emitted at the end.

By default, all UnfNotice::StageNotice notices will be captured during the entire scope of the transaction. A CapturePredicate can be passed to influence which notices are captured. Notices that are not captured will not be emitted.

Warning
Each transaction started must be closed with EndTransaction. It is preferrable to use NoticeTransaction over this API to safely manage transactions.
See also
EndTransaction
NoticeTransaction

◆ BeginTransaction() [2/2]

UNF_API void unf::Broker::BeginTransaction ( const CapturePredicateFunc )

Start a notice transaction with a capture predicate function.

The following example will filter out all 'Foo' notices emitted during the transaction.

broker->BeginTransaction([&](const unf::UnfNotice::StageNotice& n) {
return (n.GetTypeId() != typeid(Foo).name());
});
Base class for standalone PXR_NS::UsdStage notices.
Definition: notice.h:47
virtual UNF_API std::string GetTypeId() const
Interface method for returing unique type identifier.
Definition: notice.h:84
Warning
Each transaction started must be closed with EndTransaction. It is preferrable to use NoticeTransaction over this API to safely manage transactions.
See also
EndTransaction
NoticeTransaction

◆ EndTransaction()

UNF_API void unf::Broker::EndTransaction ( )

Stop a notice transaction.

This will trigger the emission of all captured UnfNotice::StageNotice notices. Each notice type will be consolidated before emission if applicable.

Warning
It is preferrable to use NoticeTransaction over this API to safely manage transactions.
See also
BeginTransaction
NoticeTransaction

◆ Send() [1/2]

template<class UnfNotice , class... Args>
void unf::Broker::Send ( Args &&...  args)

Create and send a UnfNotice::StageNotice notice via the broker.

Note
The associated stage will be used as sender.

◆ Send() [2/2]

UNF_API void unf::Broker::Send ( const UnfNotice::StageNoticeRefPtr )

Send a UnfNotice::StageNotice notice via the broker.

Note
The associated stage will be used as sender.

◆ AddDispatcher()

template<class T >
void unf::Broker::AddDispatcher

Create and register a new dispatcher.

This will call the Dispatcher::Register method.

◆ Reset()

UNF_API void unf::Broker::Reset ( )

Un-register broker.

Warning
The broker is not safe to use after this call.

The documentation for this class was generated from the following file: