defineResolver.h
Go to the documentation of this file.
1 //
2 // Copyright 2016 Pixar
3 //
4 // Licensed under the terms set forth in the LICENSE.txt file available at
5 // https://openusd.org/license.
6 //
7 #ifndef PXR_USD_AR_DEFINE_RESOLVER_H
8 #define PXR_USD_AR_DEFINE_RESOLVER_H
9 
12 
13 #include "pxr/pxr.h"
14 #include "pxr/usd/ar/api.h"
15 #include "pxr/usd/ar/resolver.h"
16 
18 #include "pxr/base/tf/type.h"
19 
20 PXR_NAMESPACE_OPEN_SCOPE
21 
32 #ifdef doxygen
33 #define AR_DEFINE_RESOLVER(ResolverClass, BaseClass1, ...)
34 #else
35 #define AR_DEFINE_RESOLVER(...) \
36 TF_REGISTRY_FUNCTION(TfType) { \
37  Ar_DefineResolver<__VA_ARGS__>(); \
38 }
39 #endif // doxygen
40 
41 class Ar_ResolverFactoryBase
42  : public TfType::FactoryBase
43 {
44 public:
45  AR_API
46  virtual ~Ar_ResolverFactoryBase();
47 
48  AR_API
49  virtual ArResolver* New() const = 0;
50 };
51 
52 template <class T>
53 class Ar_ResolverFactory
54  : public Ar_ResolverFactoryBase
55 {
56 public:
57  virtual ArResolver* New() const override
58  {
59  return new T;
60  }
61 };
62 
63 template <class Resolver, class ...Bases>
64 void Ar_DefineResolver()
65 {
66  TfType::Define<Resolver, TfType::Bases<Bases...>>()
67  .template SetFactory<Ar_ResolverFactory<Resolver> >();
68 }
69 
70 PXR_NAMESPACE_CLOSE_SCOPE
71 
72 #endif // PXR_USD_AR_DEFINE_RESOLVER_H
Base class of all factory types.
Definition: type.h:56
A type-list of C++ base types.
Definition: type.h:83
static TfType const & Define()
Define a TfType with the given C++ type T and C++ base types B.
Definition: type_Impl.h:61
Interface for the asset resolution system.
Definition: resolver.h:42