HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
userProcessingFunc.h
Go to the documentation of this file.
1 //
2 // Copyright 2023 Pixar
3 //
4 // Licensed under the terms set forth in the LICENSE.txt file available at
5 // https://openusd.org/license.
6 //
7 
8 #ifndef PXR_USD_USD_UTILS_USER_PROCESSING_FUNC
9 #define PXR_USD_USD_UTILS_USER_PROCESSING_FUNC
10 
11 /// \file usdUtils/userProcessingFunc.h
12 
13 #include "pxr/usd/sdf/layer.h"
14 #include "pxr/usd/usdUtils/api.h"
15 
16 #include <functional>
17 #include <string>
18 #include <vector>
19 
21 
22 /// Class containing information from a processed dependency.
23 /// A UsdUtilsDependencyInfo object is passed into the user processing function
24 /// and contains relevant asset path and dependency information.
25 /// Additionally, a UsdUtilsDependencyInfo object is also returned from the
26 /// user processing function and communicates back to the asset localization
27 /// routine any changes that were made during processing.
29 public:
31  USDUTILS_API explicit UsdUtilsDependencyInfo(const std::string &assetPath)
32  : _assetPath(assetPath) {}
33 
35  const std::string &assetPath,
36  const std::vector<std::string> &dependencies)
37  : _assetPath(assetPath), _dependencies(dependencies) {}
38 
39  /// Returns the asset value path for the dependency.
40  /// When UsdUtilsDependencyInfo is returned as a parameter from a user
41  /// processing function, the localization system compares the value
42  /// with the value that was originally authored in the layer.
43  ///
44  /// If the values are the same, no special action is taken and processing
45  /// will continue as normal.
46  ///
47  /// If the returned value is an empty string, the system will ignore this
48  /// path as well as any dependencies associated with it.
49  ///
50  /// If the returned value differs from what what was originally
51  /// authored into the layer, the system will instead operate on the updated.
52  /// value. If the updated path can be opened as a layer, it will be
53  /// enqueued and searched for additional dependencies.
54  ///
55  /// Note: A coding error will be issued if a user processing function
56  /// attempts to modify an asset path contained in an existing package.
57  USDUTILS_API const std::string& GetAssetPath() const {
58  return _assetPath;
59  }
60 
61  /// Returns a list of dependencies related to the asset path.
62  /// Paths in this vector are specified relative to their containing layer.
63  /// When passed into the user processing function, if this array is
64  /// populated, then the asset path resolved to one or more values, such as
65  /// in the case of UDIM tiles or clip asset path template strings.
66  ///
67  /// When this structure is returned from a processing function, each path
68  /// contained within will in turn be processed by the system. Any path
69  /// that can be opened as a layer, will be enqueued and searched for
70  /// additional dependencies.
71  USDUTILS_API const std::vector<std::string>& GetDependencies() const {
72  return _dependencies;
73  }
74 
75  /// Equality: Asset path and dependencies are the same
76  bool operator==(const UsdUtilsDependencyInfo &rhs) const {
77  return _assetPath == rhs._assetPath &&
78  _dependencies == rhs._dependencies;
79  }
80 
81  /// Inequality operator
82  /// \sa UsdUtilsDependencyInfo::operator==(const UsdUtilsDependencyInfo&)
83  bool operator!=(const UsdUtilsDependencyInfo& rhs) const {
84  return !(*this == rhs);
85  }
86 
87 private:
88  std::string _assetPath;
89  std::vector<std::string> _dependencies;
90 };
91 
92 /// Signature for user supplied processing function.
93 /// \param layer The layer containing this dependency.
94 /// \param dependencyInfo contains asset path information for this dependency.
96  const SdfLayerHandle &layer,
97  const UsdUtilsDependencyInfo &dependencyInfo);
98 
100 
101 #endif // PXR_USD_USD_UTILS_USER_PROCESSING_FUNC
USDUTILS_API UsdUtilsDependencyInfo(const std::string &assetPath)
USDUTILS_API UsdUtilsDependencyInfo()=default
USDUTILS_API const std::string & GetAssetPath() const
USDUTILS_API const std::vector< std::string > & GetDependencies() const
GLenum GLuint GLint GLint layer
Definition: glcorearb.h:1299
bool operator==(const UsdUtilsDependencyInfo &rhs) const
Equality: Asset path and dependencies are the same.
PXR_NAMESPACE_CLOSE_SCOPE PXR_NAMESPACE_OPEN_SCOPE
Definition: path.h:1425
#define PXR_NAMESPACE_CLOSE_SCOPE
Definition: pxr.h:74
UsdUtilsDependencyInfo(const SdfLayerHandle &layer, const UsdUtilsDependencyInfo &dependencyInfo) UsdUtilsProcessingFunc
#define USDUTILS_API
Definition: api.h:23
USDUTILS_API UsdUtilsDependencyInfo(const std::string &assetPath, const std::vector< std::string > &dependencies)
bool operator!=(const UsdUtilsDependencyInfo &rhs) const