This document is for a version of USD that is under development. See this page for the current release.
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
definePackageResolver.h
Go to the documentation of this file.
1//
2// Copyright 2018 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_PACKAGE_RESOLVER_H
8#define PXR_USD_AR_DEFINE_PACKAGE_RESOLVER_H
9
12
13#include "pxr/pxr.h"
14#include "pxr/usd/ar/api.h"
16
18#include "pxr/base/tf/type.h"
19
20PXR_NAMESPACE_OPEN_SCOPE
21
32#ifdef doxygen
33#define AR_DEFINE_PACKAGE_RESOLVER(PackageResolverClass, BaseClass1, ...)
34#else
35
36#define AR_DEFINE_PACKAGE_RESOLVER(...) \
37TF_REGISTRY_FUNCTION(TfType) { \
38 Ar_DefinePackageResolver<__VA_ARGS__>(); \
39}
40
41class Ar_PackageResolverFactoryBase
42 : public TfType::FactoryBase
43{
44public:
45 AR_API
46 virtual ~Ar_PackageResolverFactoryBase();
47
48 AR_API
49 virtual ArPackageResolver* New() const = 0;
50};
51
52template <class T>
53class Ar_PackageResolverFactory
54 : public Ar_PackageResolverFactoryBase
55{
56public:
57 virtual ArPackageResolver* New() const override
58 {
59 return new T;
60 }
61};
62
63template <class PackageResolver, class ...Bases>
64void Ar_DefinePackageResolver()
65{
66 TfType::Define<PackageResolver, TfType::Bases<Bases...>>()
67 .template SetFactory<Ar_PackageResolverFactory<PackageResolver>>();
68}
69
70#endif // doxygen
71
72PXR_NAMESPACE_CLOSE_SCOPE
73
74#endif // PXR_USD_AR_DEFINE_PACKAGE_RESOLVER_H
Interface for resolving assets within package assets.
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