Loading...
Searching...
No Matches
assetPath.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_SDF_ASSET_PATH_H
8#define PXR_USD_SDF_ASSET_PATH_H
9
11
12#include "pxr/pxr.h"
13#include "pxr/usd/sdf/api.h"
14#include "pxr/base/tf/hash.h"
15
16#include <iosfwd>
17#include <string>
18
19PXR_NAMESPACE_OPEN_SCOPE
20
21class SdfAssetPath;
22
37public:
38 SdfAssetPathParams& Authored(const std::string &authoredPath_) {
39 authoredPath = authoredPath_;
40 return *this;
41 }
42
43 SdfAssetPathParams& Evaluated(const std::string &evaluatedPath_) {
44 evaluatedPath = evaluatedPath_;
45 return *this;
46 }
47
48 SdfAssetPathParams& Resolved(const std::string &resolvedPath_) {
49 resolvedPath = resolvedPath_;
50 return *this;
51 }
52
53private:
54 friend class SdfAssetPath;
55
56 std::string authoredPath;
57 std::string evaluatedPath;
58 std::string resolvedPath;
59};
60
73{
74public:
78
80 SDF_API SdfAssetPath();
81
88 SDF_API explicit SdfAssetPath(const std::string &authoredPath);
89
96 SDF_API
97 SdfAssetPath(const std::string &authoredPath,
98 const std::string &resolvedPath);
99
105 SDF_API
107
109
112
114 bool operator==(const SdfAssetPath &rhs) const {
115 return _authoredPath == rhs._authoredPath &&
116 _evaluatedPath == rhs._evaluatedPath &&
117 _resolvedPath == rhs._resolvedPath;
118 }
119
122 bool operator!=(const SdfAssetPath& rhs) const {
123 return !(*this == rhs);
124 }
125
127 SDF_API bool operator<(const SdfAssetPath &rhs) const;
128
131 bool operator<=(const SdfAssetPath& rhs) const {
132 return !(rhs < *this);
133 }
134
137 bool operator>(const SdfAssetPath& rhs) const {
138 return rhs < *this;
139 }
140
143 bool operator>=(const SdfAssetPath& rhs) const {
144 return !(*this < rhs);
145 }
146
148 size_t GetHash() const {
149 return TfHash::Combine(_authoredPath, _evaluatedPath, _resolvedPath);
150 }
151
153 struct Hash
154 {
155 size_t operator()(const SdfAssetPath &ap) const {
156 return ap.GetHash();
157 }
158 };
159
160 friend size_t hash_value(const SdfAssetPath &ap) { return ap.GetHash(); }
161
163
166
169 const std::string &GetAuthoredPath() const & {
170 return _authoredPath;
171 }
172
174 std::string GetAuthoredPath() const && {
175 return std::move(_authoredPath);
176 }
177
186 const std::string &GetEvaluatedPath() const & {
187 return _evaluatedPath;
188 }
189
191 std::string GetEvaluatedPath() const && {
192 return std::move(_evaluatedPath);
193 }
194
199 const std::string &GetAssetPath() const & {
200 return _evaluatedPath.empty() ? _authoredPath : _evaluatedPath;
201 }
202
204 std::string GetAssetPath() const && {
205 return std::move(
206 _evaluatedPath.empty() ? _authoredPath : _evaluatedPath);
207 }
208
215 const std::string &GetResolvedPath() const & {
216 return _resolvedPath;
217 }
218
220 std::string GetResolvedPath() const && {
221 return std::move(_resolvedPath);
222 }
223
225
228
231 void SetAuthoredPath(const std::string &authoredPath) {
232 _authoredPath = authoredPath;
233 }
234
237 void SetEvaluatedPath(const std::string &evaluatedPath) {
238 _evaluatedPath = evaluatedPath;
239 }
240
242 void SetResolvedPath(const std::string &resolvedPath) {
243 _resolvedPath = resolvedPath;
244 }
245
247
248private:
249 friend inline void swap(SdfAssetPath &lhs, SdfAssetPath &rhs) {
250 lhs._authoredPath.swap(rhs._authoredPath);
251 lhs._evaluatedPath.swap(rhs._evaluatedPath);
252 lhs._resolvedPath.swap(rhs._resolvedPath);
253 }
254
256 std::string _authoredPath;
259 std::string _evaluatedPath;
261 std::string _resolvedPath;
262};
263
266
273SDF_API std::ostream& operator<<(std::ostream& out, const SdfAssetPath& ap);
274
276
277PXR_NAMESPACE_CLOSE_SCOPE
278
279#endif // PXR_USD_SDF_ASSET_PATH_H
Contains an asset path and optional evaluated and resolved paths.
Definition: assetPath.h:73
void SetAuthoredPath(const std::string &authoredPath)
Sets the authored path.
Definition: assetPath.h:231
void SetEvaluatedPath(const std::string &evaluatedPath)
Sets the evaluated path.
Definition: assetPath.h:237
std::string GetAuthoredPath() const &&
Overload for rvalues, move out the asset path.
Definition: assetPath.h:174
SDF_API SdfAssetPath(const std::string &authoredPath, const std::string &resolvedPath)
Construct an asset path with authoredPath and an associated resolvedPath.
std::string GetResolvedPath() const &&
Overload for rvalues, move out the asset path.
Definition: assetPath.h:220
bool operator<=(const SdfAssetPath &rhs) const
Less than or equal operator.
Definition: assetPath.h:131
bool operator>=(const SdfAssetPath &rhs) const
Greater than or equal operator.
Definition: assetPath.h:143
const std::string & GetEvaluatedPath() const &
Return the evaluated asset path, if any.
Definition: assetPath.h:186
const std::string & GetResolvedPath() const &
Return the resolved asset path, if any.
Definition: assetPath.h:215
SDF_API SdfAssetPath(const std::string &authoredPath)
Construct an asset path with authoredPath and no associated evaluated or resolved path.
std::string GetAssetPath() const &&
Overload for rvalues, move out the asset path.
Definition: assetPath.h:204
SDF_API bool operator<(const SdfAssetPath &rhs) const
Ordering first by asset path, resolved path, then by evaluated path.
bool operator!=(const SdfAssetPath &rhs) const
Inequality operator.
Definition: assetPath.h:122
const std::string & GetAssetPath() const &
Return the asset path.
Definition: assetPath.h:199
SDF_API SdfAssetPath(const SdfAssetPathParams &params)
Construct an asset path using a SdfAssetPathParams object.
void SetResolvedPath(const std::string &resolvedPath)
Sets the resolved path. This value is the result of asset resolution.
Definition: assetPath.h:242
size_t GetHash() const
Hash function.
Definition: assetPath.h:148
const std::string & GetAuthoredPath() const &
Returns the asset path as it was authored in the original layer.
Definition: assetPath.h:169
bool operator==(const SdfAssetPath &rhs) const
Equality, including the evaluated and resolved paths.
Definition: assetPath.h:114
std::string GetEvaluatedPath() const &&
Overload for rvalues, move out the evaluated path.
Definition: assetPath.h:191
bool operator>(const SdfAssetPath &rhs) const
Greater than operator.
Definition: assetPath.h:137
SDF_API SdfAssetPath()
Construct an empty asset path.
Helper class for explicitly setting values when creating a SdfAssetPath.
Definition: assetPath.h:36
static size_t Combine(Args &&... args)
Produce a hash code by combining the hash codes of several objects.
Definition: hash.h:487
GF_API std::ostream & operator<<(std::ostream &, const GfBBox3d &)
Output a GfBBox3d using the format [(range) matrix zeroArea].