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 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_EXPRESSION_VARIABLES_SOURCE_H
25 #define PXR_USD_PCP_EXPRESSION_VARIABLES_SOURCE_H
26 
27 #include "pxr/pxr.h"
28 #include "pxr/usd/pcp/api.h"
29 
30 #include <memory>
31 
33 
34 class PcpCache;
36 
37 /// \class PcpExpressionVariablesSource
38 ///
39 /// Represents the layer stack associated with a set of expression variables.
40 /// This is typically a simple PcpLayerStackIdentifier.
42 {
43 public:
44  /// Create a PcpExpressionVariableSource representing the root layer stack
45  /// of a prim index.
46  PCP_API
48 
49  /// Create a PcpExpressionVariableSource representing the layer stack
50  /// identified by \p layerStackIdentifier. If \p layerStackIdentifier
51  /// is equal to \p rootLayerStackIdentifier, this is the same as
52  /// the default constructor.
53  PCP_API
55  const PcpLayerStackIdentifier& layerStackIdentifier,
56  const PcpLayerStackIdentifier& rootLayerStackIdentifier);
57 
58  PCP_API
60 
61  /// \name Comparison Operators
62  /// @{
63  PCP_API
64  bool operator==(const PcpExpressionVariablesSource& rhs) const;
65 
66  PCP_API
67  bool operator!=(const PcpExpressionVariablesSource& rhs) const;
68 
69  PCP_API
70  bool operator<(const PcpExpressionVariablesSource& rhs) const;
71  /// @}
72 
73  /// Return hash value for this object.
74  PCP_API
75  size_t GetHash() const;
76 
77  /// Return true if this object represents a prim index's root
78  /// layer stack, false otherwise. If this function returns true,
79  /// GetLayerStackIdentifier will return nullptr.
80  bool IsRootLayerStack() const
81  {
82  return !static_cast<bool>(_identifier);
83  }
84 
85  /// Return the identifier of the layer stack represented by this
86  /// object if it is not the root layer stack. Return nullptr if
87  /// this object represents the root layer stack (i.e., IsRootLayerStack
88  /// returns true).
90  {
91  return _identifier ? _identifier.get() : nullptr;
92  }
93 
94  /// Convenience function to return the identifier of the layer
95  /// stack represented by this object. If this object represents
96  /// the root layer stack, return \p rootLayerStackIdentifier,
97  /// otherwise return *GetLayerStackIdentifier().
98  PCP_API
100  const PcpLayerStackIdentifier& rootLayerStackIdentifier) const;
101 
102  /// \overload
103  /// Equivalent to ResolveLayerStackIdentifier(cache.GetLayerStackIdentifier())
104  PCP_API
106  const PcpCache& cache) const;
107 
108  // Avoid possibly returning a const-reference to a temporary.
110  PcpLayerStackIdentifier&&) const = delete;
112  PcpCache&&) const = delete;
113 
114 private:
115  // The identifier of the layer stack providing the associated
116  // expression variables. A null value indicates the root layer stack.
117  std::shared_ptr<PcpLayerStackIdentifier> _identifier;
118 };
119 
120 template <typename HashState>
121 void
123 {
124  h.Append(x.GetHash());
125 }
126 
128 
129 #endif
PCP_API bool operator==(const PcpExpressionVariablesSource &rhs) const
const PcpLayerStackIdentifier * GetLayerStackIdentifier() const
Definition: cache.h:93
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:1432
#define PXR_NAMESPACE_CLOSE_SCOPE
Definition: pxr.h:91
PCP_API bool operator<(const PcpExpressionVariablesSource &rhs) const
#define PCP_API
Definition: api.h:40