All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
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
30{
31public:
35
37 SDF_API SdfAssetPath();
38
44 SDF_API explicit SdfAssetPath(const std::string &path);
45
51 SDF_API
52 SdfAssetPath(const std::string &path, const std::string &resolvedPath);
53
55
58
60 bool operator==(const SdfAssetPath &rhs) const {
61 return _assetPath == rhs._assetPath &&
62 _resolvedPath == rhs._resolvedPath;
63 }
64
67 bool operator!=(const SdfAssetPath& rhs) const {
68 return !(*this == rhs);
69 }
70
72 SDF_API bool operator<(const SdfAssetPath &rhs) const;
73
76 bool operator<=(const SdfAssetPath& rhs) const {
77 return !(rhs < *this);
78 }
79
82 bool operator>(const SdfAssetPath& rhs) const {
83 return rhs < *this;
84 }
85
88 bool operator>=(const SdfAssetPath& rhs) const {
89 return !(*this < rhs);
90 }
91
93 size_t GetHash() const {
94 return TfHash::Combine(_assetPath, _resolvedPath);
95 }
96
98 struct Hash
99 {
100 size_t operator()(const SdfAssetPath &ap) const {
101 return ap.GetHash();
102 }
103 };
104
105 friend size_t hash_value(const SdfAssetPath &ap) { return ap.GetHash(); }
106
108
111
113 const std::string &GetAssetPath() const & {
114 return _assetPath;
115 }
116
118 std::string GetAssetPath() const && {
119 return std::move(_assetPath);
120 }
121
127 const std::string &GetResolvedPath() const & {
128 return _resolvedPath;
129 }
130
132 std::string GetResolvedPath() const && {
133 return std::move(_resolvedPath);
134 }
135
137
138private:
139 friend inline void swap(SdfAssetPath &lhs, SdfAssetPath &rhs) {
140 lhs._assetPath.swap(rhs._assetPath);
141 lhs._resolvedPath.swap(rhs._resolvedPath);
142 }
143
144 std::string _assetPath;
145 std::string _resolvedPath;
146};
147
150
157SDF_API std::ostream& operator<<(std::ostream& out, const SdfAssetPath& ap);
158
160
161PXR_NAMESPACE_CLOSE_SCOPE
162
163#endif // PXR_USD_SDF_ASSET_PATH_H
Contains an asset path and an optional resolved path.
Definition: assetPath.h:30
std::string GetResolvedPath() const &&
Overload for rvalues, move out the asset path.
Definition: assetPath.h:132
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:76
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:88
const std::string & GetResolvedPath() const &
Return the resolved asset path, if any.
Definition: assetPath.h:127
std::string GetAssetPath() const &&
Overload for rvalues, move out the asset path.
Definition: assetPath.h:118
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:67
const std::string & GetAssetPath() const &
Return the asset path.
Definition: assetPath.h:113
size_t GetHash() const
Hash function.
Definition: assetPath.h:93
bool operator==(const SdfAssetPath &rhs) const
Equality, including the resolved path.
Definition: assetPath.h:60
bool operator>(const SdfAssetPath &rhs) const
Greater than operator.
Definition: assetPath.h:82
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:475
GF_API std::ostream & operator<<(std::ostream &, const GfBBox3d &)
Output a GfBBox3d using the format [(range) matrix zeroArea].