All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
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
20PXR_NAMESPACE_OPEN_SCOPE
21
32#ifdef doxygen
33#define AR_DEFINE_RESOLVER(ResolverClass, BaseClass1, ...)
34#else
35#define AR_DEFINE_RESOLVER(...) \
36TF_REGISTRY_FUNCTION(TfType) { \
37 Ar_DefineResolver<__VA_ARGS__>(); \
38}
39#endif // doxygen
40
41class Ar_ResolverFactoryBase
42 : public TfType::FactoryBase
43{
44public:
45 AR_API
46 virtual ~Ar_ResolverFactoryBase();
47
48 AR_API
49 virtual ArResolver* New() const = 0;
50};
51
52template <class T>
53class Ar_ResolverFactory
54 : public Ar_ResolverFactoryBase
55{
56public:
57 virtual ArResolver* New() const override
58 {
59 return new T;
60 }
61};
62
63template <class Resolver, class ...Bases>
64void Ar_DefineResolver()
65{
66 TfType::Define<Resolver, TfType::Bases<Bases...>>()
67 .template SetFactory<Ar_ResolverFactory<Resolver> >();
68}
69
70PXR_NAMESPACE_CLOSE_SCOPE
71
72#endif // PXR_USD_AR_DEFINE_RESOLVER_H
Interface for the asset resolution system.
Definition: resolver.h:43
Base class of all factory types.
Definition: type.h:56
static TfType const & Define()
Define a TfType with the given C++ type T and C++ base types B.
A type-list of C++ base types.
Definition: type.h:83