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 
180 inline
181 size_t
182 hash_value(const PcpLayerStackIdentifier& x)
183 {
184  return x.GetHash();
185 }
186 
187 inline
188 size_t
190 {
191  return x.GetHash();
192 }
193 
194 PCP_API
195 std::ostream& operator<<(std::ostream&, const PcpLayerStackIdentifier&);
196 PCP_API
197 std::ostream& operator<<(std::ostream&, const PcpLayerStackIdentifierStr&);
198 
202 PCP_API
203 std::ostream& PcpIdentifierFormatBaseName(std::ostream&);
204 
208 PCP_API
209 std::ostream& PcpIdentifierFormatRealPath(std::ostream&);
210 
215 PCP_API
216 std::ostream& PcpIdentifierFormatIdentifier(std::ostream&);
217 
218 PXR_NAMESPACE_CLOSE_SCOPE
219 
220 #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...
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.