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 Apache License, Version 2.0 (the "Apache License")
5 // with the following modification; you may not use this file except in
6 // compliance with the Apache License and the following modification to it:
7 // Section 6. Trademarks. is deleted and replaced with:
8 //
9 // 6. Trademarks. This License does not grant permission to use the trade
10 // names, trademarks, service marks, or product names of the Licensor
11 // and its affiliates, except as required to comply with Section 4(c) of
12 // the License and to reproduce the content of the NOTICE file.
13 //
14 // You may obtain a copy of the Apache License at
15 //
16 // http://www.apache.org/licenses/LICENSE-2.0
17 //
18 // Unless required by applicable law or agreed to in writing, software
19 // distributed under the Apache License with the above modification is
20 // distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
21 // KIND, either express or implied. See the Apache License for the specific
22 // language governing permissions and limitations under the Apache License.
23 //
24 
25 #ifndef PXR_USD_USD_UTILS_USER_PROCESSING_FUNC
26 #define PXR_USD_USD_UTILS_USER_PROCESSING_FUNC
27 
28 /// \file usdUtils/userProcessingFunc.h
29 
30 #include "pxr/usd/sdf/layer.h"
31 #include "pxr/usd/usdUtils/api.h"
32 
33 #include <functional>
34 #include <string>
35 #include <vector>
36 
38 
39 /// Class containing information from a processed dependency.
40 /// A UsdUtilsDependencyInfo object is passed into the user processing function
41 /// and contains relevant asset path and dependency information.
42 /// Additionally, a UsdUtilsDependencyInfo object is also returned from the
43 /// user processing function and communicates back to the asset localization
44 /// routine any changes that were made during processing.
46 public:
48  USDUTILS_API explicit UsdUtilsDependencyInfo(const std::string &assetPath)
49  : _assetPath(assetPath) {}
50 
52  const std::string &assetPath,
53  const std::vector<std::string> &dependencies)
54  : _assetPath(assetPath), _dependencies(dependencies) {}
55 
56  /// Returns the asset value path for the dependency.
57  /// When UsdUtilsDependencyInfo is returned as a parameter from a user
58  /// processing function, the localization system compares the value
59  /// with the value that was originally authored in the layer.
60  ///
61  /// If the values are the same, no special action is taken and processing
62  /// will continue as normal.
63  ///
64  /// If the returned value is an empty string, the system will ignore this
65  /// path as well as any dependencies associated with it.
66  ///
67  /// If the returned value differs from what what was originally
68  /// authored into the layer, the system will instead operate on the updated.
69  /// value. If the updated path can be opened as a layer, it will be
70  /// enqueued and searched for additional dependencies.
72  return _assetPath;
73  }
74 
75  /// Returns a list of dependencies related to the asset path.
76  /// Paths in this vector are specified relative to their containing layer.
77  /// When passed into the user processing function, if this array is
78  /// populated, then the asset path resolved to one or more values, such as
79  /// in the case of UDIM tiles or clip asset path template strings.
80  ///
81  /// When this structure is returned from a processing function, each path
82  /// contained within will in turn be processed by the system. Any path
83  /// that can be opened as a layer, will be enqueued and searched for
84  /// additional dependencies.
85  USDUTILS_API const std::vector<std::string>& GetDependencies() const {
86  return _dependencies;
87  }
88 
89  /// Equality: Asset path and dependencies are the same
90  bool operator==(const UsdUtilsDependencyInfo &rhs) const {
91  return _assetPath == rhs._assetPath &&
92  _dependencies == rhs._dependencies;
93  }
94 
95  /// Inequality operator
96  /// \sa UsdUtilsDependencyInfo::operator==(const UsdUtilsDependencyInfo&)
97  bool operator!=(const UsdUtilsDependencyInfo& rhs) const {
98  return !(*this == rhs);
99  }
100 
101 private:
102  std::string _assetPath;
103  std::vector<std::string> _dependencies;
104 };
105 
106 /// Signature for user supplied processing function.
107 /// \param layer The layer containing this dependency.
108 /// \param dependencyInfo contains asset path information for this dependency.
110  const SdfLayerHandle &layer,
111  const UsdUtilsDependencyInfo &dependencyInfo);
112 
114 
115 #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
GLsizei const GLchar *const * string
Definition: glcorearb.h:814
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:1432
#define PXR_NAMESPACE_CLOSE_SCOPE
Definition: pxr.h:91
UsdUtilsDependencyInfo(const SdfLayerHandle &layer, const UsdUtilsDependencyInfo &dependencyInfo) UsdUtilsProcessingFunc
#define USDUTILS_API
Definition: api.h:40
USDUTILS_API UsdUtilsDependencyInfo(const std::string &assetPath, const std::vector< std::string > &dependencies)
bool operator!=(const UsdUtilsDependencyInfo &rhs) const