1 #ifndef USD_NOTICE_FRAMEWORK_DISPATCHER_H
2 #define USD_NOTICE_FRAMEWORK_DISPATCHER_H
9 #include <pxr/base/tf/refBase.h>
10 #include <pxr/base/tf/refPtr.h>
11 #include <pxr/base/tf/type.h>
12 #include <pxr/base/tf/weakBase.h>
14 #include <pxr/usd/usd/common.h>
64 template <
class InputNotice,
class OutputNotice>
67 auto self = PXR_NS::TfCreateWeakPtr(
this);
68 auto cb = &Dispatcher::_OnReceiving<InputNotice, OutputNotice>;
70 PXR_NS::TfNotice::Register(
self, cb,
_broker->GetStage()));
81 template <
class InputNotice,
class OutputNotice>
92 std::vector<PXR_NS::TfNotice::Key>
_keys;
105 return "StageDispatcher";
148 return PXR_NS::TfCreateRefPtr(
new T(broker));
165 template <
class T,
class... Bases>
168 PXR_NS::TfType::Define<T, PXR_NS::TfType::Bases<Bases...> >()
Intermediate object between the Usd Stage and any clients that needs asynchronous handling and upstre...
Definition: broker.h:46
Templated factory class which creates a specific type of Dispatcher.
Definition: dispatcher.h:142
virtual PXR_NS::TfRefPtr< Dispatcher > New(const BrokerWeakPtr &broker) const override
Create a Dispatcher and return reference pointer.
Definition: dispatcher.h:145
Interface for building Dispatcher type.
Definition: dispatcher.h:127
virtual PXR_NS::TfRefPtr< Dispatcher > New(const BrokerWeakPtr &broker) const =0
Base constructor to create a Dispatcher.
Interface for objects emitting standalone notices triggered by incoming PXR_NS::TfNotice derived noti...
Definition: dispatcher.h:23
UNF_API Dispatcher(const BrokerWeakPtr &)
Create a dispatcher targeting a Broker.
virtual UNF_API ~Dispatcher()
Revoke all registered listeners on destruction.
Definition: dispatcher.h:26
void _OnReceiving(const InputNotice ¬ice)
Convenient templated method to emit a OutputNotice notice from an incoming InputNotice notice.
Definition: dispatcher.h:82
virtual UNF_API void Revoke()
Revoke all registered listeners.
BrokerWeakPtr _broker
Broker that the dispatcher is attached to.
Definition: dispatcher.h:89
virtual UNF_API void Register()=0
Register listeners to PXR_NS::TfNotice derived notices.
virtual UNF_API std::string GetIdentifier() const =0
Get unique string identifier.
void _Register()
Convenient templated method to register a listener for incoming InputNotice notice which emits a Outp...
Definition: dispatcher.h:65
std::vector< PXR_NS::TfNotice::Key > _keys
List of handle-objects used for registering listeners.
Definition: dispatcher.h:92
Default dispatcher which emits UnfNotice::StageNotice derived notices corresponding to each PXR_NS::U...
Definition: dispatcher.h:101
virtual void Register() override
Register listeners to each PXR_NS::UsdNotice::StageNotice derived notices.
virtual std::string GetIdentifier() const override
Get unique string identifier.
Definition: dispatcher.h:103
void DispatcherDefine()
Define a PXR_NS::TfType for a specific type of Dispatcher.
Definition: dispatcher.h:166