layerStackIdentifier.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_PCP_LAYER_STACK_IDENTIFIER_H
25 #define PXR_USD_PCP_LAYER_STACK_IDENTIFIER_H
26 
28 
29 #include "pxr/pxr.h"
30 #include "pxr/usd/pcp/api.h"
33 
34 #include <boost/operators.hpp>
35 
36 #include <iosfwd>
37 
38 PXR_NAMESPACE_OPEN_SCOPE
39 
40 SDF_DECLARE_HANDLES(SdfLayer);
41 
49  boost::totally_ordered<PcpLayerStackIdentifier> {
50 public:
52 
54  PCP_API
56 
59  PCP_API
60  PcpLayerStackIdentifier(const SdfLayerHandle& rootLayer_,
61  const SdfLayerHandle& sessionLayer_ = TfNullPtr,
62  const ArResolverContext& pathResolverContext_ =
64 
65  // XXX: Allow assignment because there are clients using this
66  // as a member that themselves want to be assignable.
67  PCP_API
69 
70  // Validity.
71 #if !defined(doxygen)
72  typedef const size_t This::*UnspecifiedBoolType;
73 #endif
74  PCP_API
75  operator UnspecifiedBoolType() const;
76 
77  // Comparison.
78  PCP_API
79  bool operator==(const This &rhs) const;
80  PCP_API
81  bool operator<(const This &rhs) const;
82 
83  // Hashing.
84  struct Hash {
85  size_t operator()(const This & x) const
86  {
87  return x.GetHash();
88  }
89  };
90  size_t GetHash() const
91  {
92  return _hash;
93  }
94 
95 public:
97  const SdfLayerHandle rootLayer;
98 
100  const SdfLayerHandle sessionLayer;
101 
104 
105 private:
106  size_t _ComputeHash() const;
107 
108 private:
109  const size_t _hash;
110 };
111 
112 
120  boost::totally_ordered<PcpLayerStackIdentifierStr> {
121 public:
123 
127  PCP_API
129  std::string const &rootLayerId = std::string(),
130  std::string const &sessionLayerId = std::string(),
131  ArResolverContext const &resolverContext = ArResolverContext());
132 
134  PCP_API
136 
137  // Validity.
138 #if !defined(doxygen)
139  typedef const size_t This::*UnspecifiedBoolType;
140 #endif
141  PCP_API
142  operator UnspecifiedBoolType() const;
143 
144  // Comparison.
145  PCP_API
146  bool operator==(const This &rhs) const;
147  PCP_API
148  bool operator<(const This &rhs) const;
149 
150  // Hashing.
151  struct Hash {
152  size_t operator()(const This & x) const
153  {
154  return x.GetHash();
155  }
156  };
157  size_t GetHash() const
158  {
159  return _hash;
160  }
161 
162 public:
164  std::string rootLayerId;
165 
167  std::string sessionLayerId;
168 
171 
172 private:
173  size_t _ComputeHash() const;
174 
175 private:
176  size_t _hash;
177 };
178 
179 template <typename HashState>
180 inline void
181 TfHashAppend(HashState& h, const PcpLayerStackIdentifier& x)
182 {
183  h.Append(x.GetHash());
184 }
185 
186 template <typename HashState>
187 inline void
188 TfHashAppend(HashState& h, const PcpLayerStackIdentifierStr& x)
189 {
190  h.Append(x.GetHash());
191 }
192 
193 inline
194 size_t
196 {
197  return TfHash{}(x);
198 }
199 
200 inline
201 size_t
203 {
204  return TfHash{}(x);
205 }
206 
207 PCP_API
208 std::ostream& operator<<(std::ostream&, const PcpLayerStackIdentifier&);
209 PCP_API
210 std::ostream& operator<<(std::ostream&, const PcpLayerStackIdentifierStr&);
211 
215 PCP_API
216 std::ostream& PcpIdentifierFormatBaseName(std::ostream&);
217 
221 PCP_API
222 std::ostream& PcpIdentifierFormatRealPath(std::ostream&);
223 
228 PCP_API
229 std::ostream& PcpIdentifierFormatIdentifier(std::ostream&);
230 
231 PXR_NAMESPACE_CLOSE_SCOPE
232 
233 #endif // PXR_USD_PCP_LAYER_STACK_IDENTIFIER_H
A scene description container that can combine with other such containers to form simple component as...
Definition: layer.h:94
PCP_API PcpLayerStackIdentifierStr(std::string const &rootLayerId=std::string(), std::string const &sessionLayerId=std::string(), ArResolverContext const &resolverContext=ArResolverContext())
Construct with given identifier strings and context.
const ArResolverContext pathResolverContext
The path resolver context used for resolving asset paths. (optional)
std::string rootLayerId
The root layer.
ArResolverContext pathResolverContext
The path resolver context used for resolving asset paths. (optional)
PCP_API std::ostream & PcpIdentifierFormatRealPath(std::ostream &)
Manipulator to cause the next PcpLayerStackIdentifier or PcpLayerStackIdentifierStr written to the os...
A user-extensible hashing mechanism for use with runtime hash tables.
Definition: hash.h:504
std::string sessionLayerId
The session layer (optional).
const SdfLayerHandle sessionLayer
The session layer (optional).
PCP_API std::ostream & PcpIdentifierFormatIdentifier(std::ostream &)
Manipulator to cause the next PcpLayerStackIdentifier or PcpLayerStackIdentifierStr written to the os...
A "string"-based version of PcpLayerStackIdentifier.
GF_API std::ostream & operator<<(std::ostream &, const GfBBox3d &)
Output a GfBBox3d using the format [(range) matrix zeroArea].
PCP_API PcpLayerStackIdentifier()
Construct with all empty pointers.
PCP_API std::ostream & PcpIdentifierFormatBaseName(std::ostream &)
Manipulator to cause the next PcpLayerStackIdentifier or PcpLayerStackIdentifierStr written to the os...
size_t hash_value(const half h)
Overload hash_value for half.
Definition: half.h:45
An asset resolver context allows clients to provide additional data to the resolver for use during re...
const SdfLayerHandle rootLayer
The root layer.
Arguments used to identify a layer stack.