24#ifndef PXR_BASE_PLUG_INTERFACE_FACTORY_H
25#define PXR_BASE_PLUG_INTERFACE_FACTORY_H
30#include "pxr/base/tf/type.h"
32PXR_NAMESPACE_OPEN_SCOPE
35class 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) \
68TF_REGISTRY_FUNCTION(TfType) \
70 TfType::Define<Interface>() \
71 .SetFactory<Plug_InterfaceFactory::SingletonFactory< \
72 Interface, Implementation> >(); \
75PXR_NAMESPACE_CLOSE_SCOPE
Base class of all factory types.