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 
32 #include <boost/functional/hash.hpp>
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  size_t hash = 0;
90  boost::hash_combine(hash, _assetPath);
91  boost::hash_combine(hash, _resolvedPath);
92  return hash;
93  }
94 
96  struct Hash
97  {
98  size_t operator()(const SdfAssetPath &ap) const {
99  return ap.GetHash();
100  }
101  };
102 
103  friend size_t hash_value(const SdfAssetPath &ap) { return ap.GetHash(); }
104 
106 
109 
111  const std::string &GetAssetPath() const {
112  return _assetPath;
113  }
114 
120  const std::string &GetResolvedPath() const {
121  return _resolvedPath;
122  }
123 
125 
126 private:
127  friend inline void swap(SdfAssetPath &lhs, SdfAssetPath &rhs) {
128  lhs._assetPath.swap(rhs._assetPath);
129  lhs._resolvedPath.swap(rhs._resolvedPath);
130  }
131 
132  std::string _assetPath;
133  std::string _resolvedPath;
134 };
135 
138 
145 SDF_API std::ostream& operator<<(std::ostream& out, const SdfAssetPath& ap);
146 
148 
149 PXR_NAMESPACE_CLOSE_SCOPE
150 
151 #endif // PXR_USD_SDF_ASSET_PATH_H
SDF_API SdfAssetPath()
Construct an empty asset path.
const std::string & GetResolvedPath() const
Return the resolved asset path, if any.
Definition: assetPath.h:120
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
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.
const std::string & GetAssetPath() const
Return the asset path.
Definition: assetPath.h:111
SDF_API bool operator<(const SdfAssetPath &rhs) const
Ordering first by asset path, then by resolved path.