HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
expressionVariablesSource.h
Go to the documentation of this file.
1 //
2 // Copyright 2023 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_EXPRESSION_VARIABLES_SOURCE_H
8 #define PXR_USD_PCP_EXPRESSION_VARIABLES_SOURCE_H
9 
10 #include "pxr/pxr.h"
11 #include "pxr/usd/pcp/api.h"
12 
13 #include <memory>
14 
16 
17 class PcpCache;
19 
20 /// \class PcpExpressionVariablesSource
21 ///
22 /// Represents the layer stack associated with a set of expression variables.
23 /// This is typically a simple PcpLayerStackIdentifier.
25 {
26 public:
27  /// Create a PcpExpressionVariableSource representing the root layer stack
28  /// of a prim index.
29  PCP_API
31 
32  /// Create a PcpExpressionVariableSource representing the layer stack
33  /// identified by \p layerStackIdentifier. If \p layerStackIdentifier
34  /// is equal to \p rootLayerStackIdentifier, this is the same as
35  /// the default constructor.
36  PCP_API
38  const PcpLayerStackIdentifier& layerStackIdentifier,
39  const PcpLayerStackIdentifier& rootLayerStackIdentifier);
40 
41  PCP_API
43 
44  /// \name Comparison Operators
45  /// @{
46  PCP_API
47  bool operator==(const PcpExpressionVariablesSource& rhs) const;
48 
49  PCP_API
50  bool operator!=(const PcpExpressionVariablesSource& rhs) const;
51 
52  PCP_API
53  bool operator<(const PcpExpressionVariablesSource& rhs) const;
54  /// @}
55 
56  /// Return hash value for this object.
57  PCP_API
58  size_t GetHash() const;
59 
60  /// Return true if this object represents a prim index's root
61  /// layer stack, false otherwise. If this function returns true,
62  /// GetLayerStackIdentifier will return nullptr.
63  bool IsRootLayerStack() const
64  {
65  return !static_cast<bool>(_identifier);
66  }
67 
68  /// Return the identifier of the layer stack represented by this
69  /// object if it is not the root layer stack. Return nullptr if
70  /// this object represents the root layer stack (i.e., IsRootLayerStack
71  /// returns true).
73  {
74  return _identifier ? _identifier.get() : nullptr;
75  }
76 
77  /// Convenience function to return the identifier of the layer
78  /// stack represented by this object. If this object represents
79  /// the root layer stack, return \p rootLayerStackIdentifier,
80  /// otherwise return *GetLayerStackIdentifier().
81  PCP_API
83  const PcpLayerStackIdentifier& rootLayerStackIdentifier) const;
84 
85  /// \overload
86  /// Equivalent to ResolveLayerStackIdentifier(cache.GetLayerStackIdentifier())
87  PCP_API
89  const PcpCache& cache) const;
90 
91  // Avoid possibly returning a const-reference to a temporary.
93  PcpLayerStackIdentifier&&) const = delete;
95  PcpCache&&) const = delete;
96 
97 private:
98  // The identifier of the layer stack providing the associated
99  // expression variables. A null value indicates the root layer stack.
100  std::shared_ptr<PcpLayerStackIdentifier> _identifier;
101 };
102 
103 template <typename HashState>
104 void
106 {
107  h.Append(x.GetHash());
108 }
109 
111 
112 #endif
PCP_API bool operator==(const PcpExpressionVariablesSource &rhs) const
const PcpLayerStackIdentifier * GetLayerStackIdentifier() const
Definition: cache.h:76
void TfHashAppend(HashState &h, const PcpExpressionVariablesSource &x)
GLint GLenum GLint x
Definition: glcorearb.h:409
PCP_API const PcpLayerStackIdentifier & ResolveLayerStackIdentifier(const PcpLayerStackIdentifier &rootLayerStackIdentifier) const
GLfloat GLfloat GLfloat GLfloat h
Definition: glcorearb.h:2002
PCP_API bool operator!=(const PcpExpressionVariablesSource &rhs) const
PCP_API size_t GetHash() const
Return hash value for this object.
PXR_NAMESPACE_CLOSE_SCOPE PXR_NAMESPACE_OPEN_SCOPE
Definition: path.h:1425
#define PXR_NAMESPACE_CLOSE_SCOPE
Definition: pxr.h:74
PCP_API bool operator<(const PcpExpressionVariablesSource &rhs) const
#define PCP_API
Definition: api.h:23