Loading...
Searching...
No Matches
assetPath.h
Go to the documentation of this file.
1//
2// Copyright 2016 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#ifndef PXR_USD_SDF_ASSET_PATH_H
25#define PXR_USD_SDF_ASSET_PATH_H
26
28
29#include "pxr/pxr.h"
30#include "pxr/usd/sdf/api.h"
31#include "pxr/base/tf/hash.h"
32
33#include <iosfwd>
34#include <string>
35
36PXR_NAMESPACE_OPEN_SCOPE
37
47{
48public:
52
54 SDF_API SdfAssetPath();
55
61 SDF_API explicit SdfAssetPath(const std::string &path);
62
68 SDF_API
69 SdfAssetPath(const std::string &path, const std::string &resolvedPath);
70
72
75
77 bool operator==(const SdfAssetPath &rhs) const {
78 return _assetPath == rhs._assetPath &&
79 _resolvedPath == rhs._resolvedPath;
80 }
81
84 bool operator!=(const SdfAssetPath& rhs) const {
85 return !(*this == rhs);
86 }
87
89 SDF_API bool operator<(const SdfAssetPath &rhs) const;
90
93 bool operator<=(const SdfAssetPath& rhs) const {
94 return !(rhs < *this);
95 }
96
99 bool operator>(const SdfAssetPath& rhs) const {
100 return rhs < *this;
101 }
102
105 bool operator>=(const SdfAssetPath& rhs) const {
106 return !(*this < rhs);
107 }
108
110 size_t GetHash() const {
111 return TfHash::Combine(_assetPath, _resolvedPath);
112 }
113
115 struct Hash
116 {
117 size_t operator()(const SdfAssetPath &ap) const {
118 return ap.GetHash();
119 }
120 };
121
122 friend size_t hash_value(const SdfAssetPath &ap) { return ap.GetHash(); }
123
125
128
130 const std::string &GetAssetPath() const & {
131 return _assetPath;
132 }
133
135 std::string GetAssetPath() const && {
136 return std::move(_assetPath);
137 }
138
144 const std::string &GetResolvedPath() const & {
145 return _resolvedPath;
146 }
147
149 std::string GetResolvedPath() const && {
150 return std::move(_resolvedPath);
151 }
152
154
155private:
156 friend inline void swap(SdfAssetPath &lhs, SdfAssetPath &rhs) {
157 lhs._assetPath.swap(rhs._assetPath);
158 lhs._resolvedPath.swap(rhs._resolvedPath);
159 }
160
161 std::string _assetPath;
162 std::string _resolvedPath;
163};
164
167
174SDF_API std::ostream& operator<<(std::ostream& out, const SdfAssetPath& ap);
175
177
178PXR_NAMESPACE_CLOSE_SCOPE
179
180#endif // PXR_USD_SDF_ASSET_PATH_H
Contains an asset path and an optional resolved path.
Definition: assetPath.h:47
std::string GetResolvedPath() const &&
Overload for rvalues, move out the asset path.
Definition: assetPath.h:149
SDF_API SdfAssetPath(const std::string &path)
Construct an asset path with path and no associated resolved path.
bool operator<=(const SdfAssetPath &rhs) const
Less than or equal operator.
Definition: assetPath.h:93
SDF_API SdfAssetPath(const std::string &path, const std::string &resolvedPath)
Construct an asset path with path and an associated resolvedPath.
bool operator>=(const SdfAssetPath &rhs) const
Greater than or equal operator.
Definition: assetPath.h:105
const std::string & GetResolvedPath() const &
Return the resolved asset path, if any.
Definition: assetPath.h:144
std::string GetAssetPath() const &&
Overload for rvalues, move out the asset path.
Definition: assetPath.h:135
SDF_API bool operator<(const SdfAssetPath &rhs) const
Ordering first by asset path, then by resolved path.
bool operator!=(const SdfAssetPath &rhs) const
Inequality operator.
Definition: assetPath.h:84
const std::string & GetAssetPath() const &
Return the asset path.
Definition: assetPath.h:130
size_t GetHash() const
Hash function.
Definition: assetPath.h:110
bool operator==(const SdfAssetPath &rhs) const
Equality, including the resolved path.
Definition: assetPath.h:77
bool operator>(const SdfAssetPath &rhs) const
Greater than operator.
Definition: assetPath.h:99
SDF_API SdfAssetPath()
Construct an empty asset path.
static size_t Combine(Args &&... args)
Produce a hash code by combining the hash codes of several objects.
Definition: hash.h:492
GF_API std::ostream & operator<<(std::ostream &, const GfBBox3d &)
Output a GfBBox3d using the format [(range) matrix zeroArea].