All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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 SDF_ASSETPATH_H
25 #define SDF_ASSETPATH_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 
44  public boost::totally_ordered<SdfAssetPath>
45 {
46 public:
50 
52  SDF_API SdfAssetPath();
53 
55  SDF_API explicit SdfAssetPath(const std::string &path);
56 
58  SDF_API SdfAssetPath(const std::string &path, const std::string &resolvedPath);
59 
61 
64 
66  bool operator==(const SdfAssetPath &rhs) const {
67  return _assetPath == rhs._assetPath &&
68  _resolvedPath == rhs._resolvedPath;
69  }
70 
72  SDF_API bool operator<(const SdfAssetPath &rhs) const;
73 
75  size_t GetHash() const {
76  size_t hash = 0;
77  boost::hash_combine(hash, _assetPath);
78  boost::hash_combine(hash, _resolvedPath);
79  return hash;
80  }
81 
83  struct Hash
84  {
85  size_t operator()(const SdfAssetPath &ap) const {
86  return ap.GetHash();
87  }
88  };
89 
90  friend size_t hash_value(const SdfAssetPath &ap) { return ap.GetHash(); }
91 
93 
96 
98  const std::string &GetAssetPath() const {
99  return _assetPath;
100  }
101 
107  const std::string &GetResolvedPath() const {
108  return _resolvedPath;
109  }
110 
112 
113 private:
114  friend inline void swap(SdfAssetPath &lhs, SdfAssetPath &rhs) {
115  lhs._assetPath.swap(rhs._assetPath);
116  lhs._resolvedPath.swap(rhs._resolvedPath);
117  }
118 
119  std::string _assetPath;
120  std::string _resolvedPath;
121 };
122 
125 
132 SDF_API std::ostream& operator<<(std::ostream& out, const SdfAssetPath& ap);
133 
135 
136 PXR_NAMESPACE_CLOSE_SCOPE
137 
138 #endif // SDF_ASSETPATH_H
SDF_API SdfAssetPath()
Construct an empty asset path.
size_t GetHash() const
Hash function.
Definition: assetPath.h:75
const std::string & GetAssetPath() const
Return the asset path.
Definition: assetPath.h:98
const std::string & GetResolvedPath() const
Return the resolved asset path, if any.
Definition: assetPath.h:107
bool operator==(const SdfAssetPath &rhs) const
Equality, including the resolved path.
Definition: assetPath.h:66
GF_API std::ostream & operator<<(std::ostream &, const GfBBox3d &)
Output a GfBBox3d using the format [(range) matrix zeroArea].
Contains an asset path and an optional resolved path.
Definition: assetPath.h:43
SDF_API bool operator<(const SdfAssetPath &rhs) const
Ordering first by asset path, then by resolved path.