HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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 
27 /// \file pcp/layerStackIdentifier.h
28 
29 #include "pxr/pxr.h"
30 #include "pxr/usd/pcp/api.h"
33 
34 #include <hboost/operators.hpp>
35 
36 #include <iosfwd>
37 
39 
41 
42 /// \class PcpLayerStackIdentifier
43 ///
44 /// Arguments used to identify a layer stack.
45 ///
46 /// Objects of this type are immutable.
47 ///
49  hboost::totally_ordered<PcpLayerStackIdentifier> {
50 public:
52 
53  /// Construct with all empty pointers.
54  PCP_API
56 
57  /// Construct with given pointers. If all arguments are \c TfNullPtr
58  /// then the result is identical to the default constructed object.
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:
96  /// The root layer.
97  const SdfLayerHandle rootLayer;
98 
99  /// The session layer (optional).
100  const SdfLayerHandle sessionLayer;
101 
102  /// The path resolver context used for resolving asset paths. (optional)
104 
105 private:
106  size_t _ComputeHash() const;
107 
108 private:
109  const size_t _hash;
110 };
111 
112 
113 /// \class PcpLayerStackIdentifierStr
114 ///
115 /// A "string"-based version of PcpLayerStackIdentifier. These are used in
116 /// places where they should be stable wrt layer lifetimes. This is done by
117 /// storing layer identifiers as strings rather than SdfLayerHandles.
118 ///
120  hboost::totally_ordered<PcpLayerStackIdentifierStr> {
121 public:
123 
124  /// Construct with given identifier strings and context. If all arguments
125  /// are empty strings and default-constructed ArResolverContext, then the
126  /// result is identical to the default constructed object.
127  PCP_API
131  ArResolverContext const &resolverContext = ArResolverContext());
132 
133  /// Allow implicit conversion from PcpLayerStackIdentifier
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:
163  /// The root layer.
165 
166  /// The session layer (optional).
168 
169  /// The path resolver context used for resolving asset paths. (optional)
171 
172 private:
173  size_t _ComputeHash() const;
174 
175 private:
176  size_t _hash;
177 };
178 
179 
180 inline
181 size_t
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 
199 /// Manipulator to cause the next PcpLayerStackIdentifier or
200 /// PcpLayerStackIdentifierStr written to the ostream to write the base name of
201 /// its layers, rather than the full identifier.
202 PCP_API
203 std::ostream& PcpIdentifierFormatBaseName(std::ostream&);
204 
205 /// Manipulator to cause the next PcpLayerStackIdentifier or
206 /// PcpLayerStackIdentifierStr written to the ostream to write the real path of
207 /// its layers, rather than the identifier.
208 PCP_API
209 std::ostream& PcpIdentifierFormatRealPath(std::ostream&);
210 
211 /// Manipulator to cause the next PcpLayerStackIdentifier or
212 /// PcpLayerStackIdentifierStr written to the ostream to write the identifier of
213 /// its layers. This is the default state; this manipulator is only to nullify
214 /// one of the above manipulators.
215 PCP_API
216 std::ostream& PcpIdentifierFormatIdentifier(std::ostream&);
217 
219 
220 #endif // PXR_USD_PCP_LAYER_STACK_IDENTIFIER_H
Definition: layer.h:93
PCP_API PcpLayerStackIdentifier()
Construct with all empty pointers.
ArResolverContext pathResolverContext
The path resolver context used for resolving asset paths. (optional)
PCP_API bool operator<(const This &rhs) const
PCP_API PcpLayerStackIdentifierStr(std::string const &rootLayerId=std::string(), std::string const &sessionLayerId=std::string(), ArResolverContext const &resolverContext=ArResolverContext())
TF_API const TfNullPtrType TfNullPtr
const size_t This::* UnspecifiedBoolType
PCP_API bool operator==(const This &rhs) const
PCP_API std::ostream & PcpIdentifierFormatRealPath(std::ostream &)
size_t operator()(const This &x) const
std::string sessionLayerId
The session layer (optional).
const SdfLayerHandle rootLayer
The root layer.
size_t hash_value(const PcpLayerStackIdentifier &x)
GLint GLint GLint GLint GLint x
Definition: glew.h:1252
PCP_API std::ostream & operator<<(std::ostream &, const PcpLayerStackIdentifier &)
const size_t This::* UnspecifiedBoolType
PCP_API bool operator==(const This &rhs) const
PcpLayerStackIdentifier This
size_t operator()(const This &x) const
PCP_API std::ostream & PcpIdentifierFormatIdentifier(std::ostream &)
const ArResolverContext pathResolverContext
The path resolver context used for resolving asset paths. (optional)
PXR_NAMESPACE_OPEN_SCOPE SDF_DECLARE_HANDLES(SdfLayer)
GLsizei const GLchar *const * string
Definition: glew.h:1844
PCP_API PcpLayerStackIdentifier & operator=(const PcpLayerStackIdentifier &)
PXR_NAMESPACE_CLOSE_SCOPE PXR_NAMESPACE_OPEN_SCOPE
Definition: path.h:1346
PCP_API std::ostream & PcpIdentifierFormatBaseName(std::ostream &)
PcpLayerStackIdentifierStr This
const SdfLayerHandle sessionLayer
The session layer (optional).
std::string rootLayerId
The root layer.
#define PXR_NAMESPACE_CLOSE_SCOPE
Definition: pxr.h:91
PCP_API bool operator<(const This &rhs) const
#define PCP_API
Definition: api.h:40