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 terms set forth in the LICENSE.txt file available at
5 // https://openusd.org/license.
6 //
7 #ifndef PXR_USD_PCP_LAYER_STACK_IDENTIFIER_H
8 #define PXR_USD_PCP_LAYER_STACK_IDENTIFIER_H
9 
10 /// \file pcp/layerStackIdentifier.h
11 
12 #include "pxr/pxr.h"
13 #include "pxr/usd/pcp/api.h"
15 
18 
19 #include <iosfwd>
20 
22 
24 
25 /// \class PcpLayerStackIdentifier
26 ///
27 /// Arguments used to identify a layer stack.
28 ///
29 /// Objects of this type are immutable.
30 ///
32 public:
34 
35  /// Construct with all empty pointers.
36  PCP_API
38 
39  /// Construct with given pointers. If all arguments are \c TfNullPtr
40  /// then the result is identical to the default constructed object.
41  PCP_API
43  const SdfLayerHandle& rootLayer,
44  const SdfLayerHandle& sessionLayer = TfNullPtr,
48 
49  // XXX: Allow assignment because there are clients using this
50  // as a member that themselves want to be assignable.
51  PCP_API
53 
54  // Validity.
55  PCP_API
56  explicit operator bool() const;
57 
58  // Comparison.
59  PCP_API
60  bool operator==(const This &rhs) const;
61  bool operator!=(const This &rhs) const
62  {
63  return !(rhs == *this);
64  }
65 
66  PCP_API
67  bool operator<(const This &rhs) const;
68  bool operator<=(const This& rhs) const
69  {
70  return !(rhs < *this);
71  }
72  bool operator>(const This& rhs) const
73  {
74  return rhs < *this;
75  }
76  bool operator>=(const This& rhs) const
77  {
78  return !(*this < rhs);
79  }
80 
81  // Hashing.
82  struct Hash {
83  size_t operator()(const This & x) const
84  {
85  return x.GetHash();
86  }
87  };
88  size_t GetHash() const
89  {
90  return _hash;
91  }
92 
93 public:
94  /// The root layer.
95  const SdfLayerHandle rootLayer;
96 
97  /// The session layer (optional).
98  const SdfLayerHandle sessionLayer;
99 
100  /// The path resolver context used for resolving asset paths. (optional)
102 
103  /// The source for expression variables that compose over the expression
104  /// variables in this layer stack. (optional)
106 
107 private:
108  size_t _ComputeHash() const;
109 
110 private:
111  const size_t _hash;
112 };
113 
114 template <typename HashState>
115 inline void
117 {
118  h.Append(x.GetHash());
119 }
120 
121 inline
122 size_t
124 {
125  return TfHash{}(x);
126 }
127 
128 PCP_API
129 std::ostream& operator<<(std::ostream&, const PcpLayerStackIdentifier&);
130 
131 /// Manipulator to cause the next PcpLayerStackIdentifier
132 /// written to the ostream to write the base name of
133 /// its layers, rather than the full identifier.
134 PCP_API
135 std::ostream& PcpIdentifierFormatBaseName(std::ostream&);
136 
137 /// Manipulator to cause the next PcpLayerStackIdentifier
138 /// written to the ostream to write the real path of
139 /// its layers, rather than the identifier.
140 PCP_API
141 std::ostream& PcpIdentifierFormatRealPath(std::ostream&);
142 
143 /// Manipulator to cause the next PcpLayerStackIdentifier
144 /// written to the ostream to write the identifier of
145 /// its layers. This is the default state; this manipulator is only to nullify
146 /// one of the above manipulators.
147 PCP_API
148 std::ostream& PcpIdentifierFormatIdentifier(std::ostream&);
149 
151 
152 #endif // PXR_USD_PCP_LAYER_STACK_IDENTIFIER_H
Definition: layer.h:81
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
OutGridT const XformOp bool bool
size_t operator()(const This &x) const
const SdfLayerHandle rootLayer
The root layer.
Definition: hash.h:472
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:1425
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:74
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:23