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"
32 
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 public:
51 
52  /// Construct with all empty pointers.
53  PCP_API
55 
56  /// Construct with given pointers. If all arguments are \c TfNullPtr
57  /// then the result is identical to the default constructed object.
58  PCP_API
60  const SdfLayerHandle& rootLayer,
61  const SdfLayerHandle& sessionLayer = TfNullPtr,
65 
66  // XXX: Allow assignment because there are clients using this
67  // as a member that themselves want to be assignable.
68  PCP_API
70 
71  // Validity.
72  PCP_API
73  explicit operator bool() const;
74 
75  // Comparison.
76  PCP_API
77  bool operator==(const This &rhs) const;
78  bool operator!=(const This &rhs) const
79  {
80  return !(rhs == *this);
81  }
82 
83  PCP_API
84  bool operator<(const This &rhs) const;
85  bool operator<=(const This& rhs) const
86  {
87  return !(rhs < *this);
88  }
89  bool operator>(const This& rhs) const
90  {
91  return rhs < *this;
92  }
93  bool operator>=(const This& rhs) const
94  {
95  return !(*this < rhs);
96  }
97 
98  // Hashing.
99  struct Hash {
100  size_t operator()(const This & x) const
101  {
102  return x.GetHash();
103  }
104  };
105  size_t GetHash() const
106  {
107  return _hash;
108  }
109 
110 public:
111  /// The root layer.
112  const SdfLayerHandle rootLayer;
113 
114  /// The session layer (optional).
115  const SdfLayerHandle sessionLayer;
116 
117  /// The path resolver context used for resolving asset paths. (optional)
119 
120  /// The source for expression variables that compose over the expression
121  /// variables in this layer stack. (optional)
123 
124 private:
125  size_t _ComputeHash() const;
126 
127 private:
128  const size_t _hash;
129 };
130 
131 template <typename HashState>
132 inline void
134 {
135  h.Append(x.GetHash());
136 }
137 
138 inline
139 size_t
141 {
142  return TfHash{}(x);
143 }
144 
145 PCP_API
146 std::ostream& operator<<(std::ostream&, const PcpLayerStackIdentifier&);
147 
148 /// Manipulator to cause the next PcpLayerStackIdentifier
149 /// written to the ostream to write the base name of
150 /// its layers, rather than the full identifier.
151 PCP_API
152 std::ostream& PcpIdentifierFormatBaseName(std::ostream&);
153 
154 /// Manipulator to cause the next PcpLayerStackIdentifier
155 /// written to the ostream to write the real path of
156 /// its layers, rather than the identifier.
157 PCP_API
158 std::ostream& PcpIdentifierFormatRealPath(std::ostream&);
159 
160 /// Manipulator to cause the next PcpLayerStackIdentifier
161 /// written to the ostream to write the identifier of
162 /// its layers. This is the default state; this manipulator is only to nullify
163 /// one of the above manipulators.
164 PCP_API
165 std::ostream& PcpIdentifierFormatIdentifier(std::ostream&);
166 
168 
169 #endif // PXR_USD_PCP_LAYER_STACK_IDENTIFIER_H
Definition: layer.h:94
PCP_API PcpLayerStackIdentifier()
Construct with all empty pointers.
TF_API const TfNullPtrType TfNullPtr
void TfHashAppend(HashState &h, const PcpLayerStackIdentifier &x)
PCP_API std::ostream & PcpIdentifierFormatRealPath(std::ostream &)
bool operator>(const This &rhs) const
size_t operator()(const This &x) const
const SdfLayerHandle rootLayer
The root layer.
Definition: hash.h:504
size_t hash_value(const PcpLayerStackIdentifier &x)
PCP_API std::ostream & operator<<(std::ostream &, const PcpLayerStackIdentifier &)
PCP_API bool operator==(const This &rhs) const
PcpLayerStackIdentifier This
PCP_API std::ostream & PcpIdentifierFormatIdentifier(std::ostream &)
GLint GLenum GLint x
Definition: glcorearb.h:409
const ArResolverContext pathResolverContext
The path resolver context used for resolving asset paths. (optional)
PXR_NAMESPACE_OPEN_SCOPE SDF_DECLARE_HANDLES(SdfLayer)
GLfloat GLfloat GLfloat GLfloat h
Definition: glcorearb.h:2002
const PcpExpressionVariablesSource expressionVariablesOverrideSource
PCP_API PcpLayerStackIdentifier & operator=(const PcpLayerStackIdentifier &)
PXR_NAMESPACE_CLOSE_SCOPE PXR_NAMESPACE_OPEN_SCOPE
Definition: path.h:1441
bool operator!=(const This &rhs) const
PCP_API std::ostream & PcpIdentifierFormatBaseName(std::ostream &)
const SdfLayerHandle sessionLayer
The session layer (optional).
#define PXR_NAMESPACE_CLOSE_SCOPE
Definition: pxr.h:91
PCP_API bool operator<(const This &rhs) const
bool operator<=(const This &rhs) const
bool operator>=(const This &rhs) const
#define PCP_API
Definition: api.h:40