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 <boost/operators.hpp>
34 #include <iosfwd>
35 #include <string>
36 
37 PXR_NAMESPACE_OPEN_SCOPE
38 
48  public boost::totally_ordered<SdfAssetPath>
49 {
50 public:
54 
56  SDF_API SdfAssetPath();
57 
63  SDF_API explicit SdfAssetPath(const std::string &path);
64 
70  SDF_API
71  SdfAssetPath(const std::string &path, const std::string &resolvedPath);
72 
74 
77 
79  bool operator==(const SdfAssetPath &rhs) const {
80  return _assetPath == rhs._assetPath &&
81  _resolvedPath == rhs._resolvedPath;
82  }
83 
85  SDF_API bool operator<(const SdfAssetPath &rhs) const;
86 
88  size_t GetHash() const {
89  return TfHash::Combine(_assetPath, _resolvedPath);
90  }
91 
93  struct Hash
94  {
95  size_t operator()(const SdfAssetPath &ap) const {
96  return ap.GetHash();
97  }
98  };
99 
100  friend size_t hash_value(const SdfAssetPath &ap) { return ap.GetHash(); }
101 
103 
106 
108  const std::string &GetAssetPath() const & {
109  return _assetPath;
110  }
111 
113  std::string GetAssetPath() const && {
114  return std::move(_assetPath);
115  }
116 
122  const std::string &GetResolvedPath() const & {
123  return _resolvedPath;
124  }
125 
127  std::string GetResolvedPath() const && {
128  return std::move(_resolvedPath);
129  }
130 
132 
133 private:
134  friend inline void swap(SdfAssetPath &lhs, SdfAssetPath &rhs) {
135  lhs._assetPath.swap(rhs._assetPath);
136  lhs._resolvedPath.swap(rhs._resolvedPath);
137  }
138 
139  std::string _assetPath;
140  std::string _resolvedPath;
141 };
142 
145 
152 SDF_API std::ostream& operator<<(std::ostream& out, const SdfAssetPath& ap);
153 
155 
156 PXR_NAMESPACE_CLOSE_SCOPE
157 
158 #endif // PXR_USD_SDF_ASSET_PATH_H
SDF_API SdfAssetPath()
Construct an empty asset path.
std::string GetAssetPath() const &&
Overload for rvalues, move out the asset path.
Definition: assetPath.h:113
const std::string & GetResolvedPath() const &
Return the resolved asset path, if any.
Definition: assetPath.h:122
static size_t Combine(Args &&... args)
Produce a hash code by combining the hash codes of several objects.
Definition: hash.h:519
size_t GetHash() const
Hash function.
Definition: assetPath.h:88
bool operator==(const SdfAssetPath &rhs) const
Equality, including the resolved path.
Definition: assetPath.h:79
const std::string & GetAssetPath() const &
Return the asset path.
Definition: assetPath.h:108
std::string GetResolvedPath() const &&
Overload for rvalues, move out the asset path.
Definition: assetPath.h:127
Contains an asset path and an optional resolved path.
Definition: assetPath.h:47
SDF_API std::ostream & operator<<(std::ostream &out, const SdfAssetPath &ap)
Stream insertion operator for the string representation of this assetPath.
SDF_API bool operator<(const SdfAssetPath &rhs) const
Ordering first by asset path, then by resolved path.