24 #ifndef PXR_BASE_PLUG_INTERFACE_FACTORY_H
25 #define PXR_BASE_PLUG_INTERFACE_FACTORY_H
30 #include "pxr/base/tf/type.h"
32 PXR_NAMESPACE_OPEN_SCOPE
35 class Plug_InterfaceFactory {
39 virtual void* New() = 0;
42 template <
class Interface,
class Implementation>
43 struct SingletonFactory :
public Base {
47 static_assert(std::is_abstract<Interface>::value,
48 "Interface type must be abstract.");
49 static Implementation impl;
50 return static_cast<Interface*
>(&impl);
67 #define PLUG_REGISTER_INTERFACE_SINGLETON_TYPE(Interface, Implementation) \
68 TF_REGISTRY_FUNCTION(TfType) \
70 TfType::Define<Interface>() \
71 .SetFactory<Plug_InterfaceFactory::SingletonFactory< \
72 Interface, Implementation> >(); \
75 PXR_NAMESPACE_CLOSE_SCOPE
77 #endif // PXR_BASE_PLUG_INTERFACE_FACTORY_H
Base class of all factory types.