HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
expressionVariablesDependencyData.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_DEPENDENCY_DATA_H
25 #define PXR_USD_PCP_EXPRESSION_VARIABLES_DEPENDENCY_DATA_H
26 
27 #include "pxr/pxr.h"
28 #include "pxr/usd/pcp/api.h"
31 
32 #include <memory>
33 #include <unordered_set>
34 #include <string>
35 
37 
39 
40 /// \class PcpExpressionVariablesDependencyData
41 ///
42 /// Captures the expression variables used by an associated prim index
43 /// during composition.
45 {
46 public:
47  PCP_API
49 
50  PCP_API
52  PcpExpressionVariablesDependencyData&&);
53 
54  PCP_API
56 
57  PCP_API
58  PcpExpressionVariablesDependencyData& operator=(
59  PcpExpressionVariablesDependencyData&&);
60 
61  /// Returns true if any dependencies have been recorded, false otherwise.
62  PCP_API
63  bool IsEmpty() const;
64 
65  /// Moves dependencies in \p data and appends it to the dependencies
66  /// in this object.
67  PCP_API
68  void AppendDependencyData(PcpExpressionVariablesDependencyData&& data);
69 
70  /// Adds dependencies on the expression variables in \p exprVarDependencies
71  /// from \p layerStack.
72  PCP_API
73  void AddDependencies(
74  const PcpLayerStackPtr& layerStack,
75  std::unordered_set<std::string>&& exprVarDependencies);
76 
77  /// Runs the given \p callback on all of the dependencies in this object.
78  /// \p callback must have the signature:
79  ///
80  /// void(const PcpLayerStack&, const std::unordered_set<std::string>&)
81  ///
82  /// The first argument is the layer stack associated with the expression
83  /// variables in the second argument.
84  template <class Callback>
85  void ForEachDependency(const Callback& callback) const
86  {
87  _ForEachFunctionRef fn(callback);
88  _ForEachDependency(fn);
89  }
90 
91  /// Returns the expression variable dependencies associated with
92  /// \p layerStack. If no such dependencies have been added, returns
93  /// nullptr.
94  PCP_API
95  const std::unordered_set<std::string>*
96  GetDependenciesForLayerStack(const PcpLayerStackPtr& layerStack) const;
97 
98 private:
99  using _ForEachFunctionRef = TfFunctionRef<void(
100  const PcpLayerStackPtr&, const std::unordered_set<std::string>&)>;
101 
102  PCP_API
103  void _ForEachDependency(const _ForEachFunctionRef& fn) const;
104 
105  class _Data;
106  const _Data* _GetData() const;
107  _Data& _GetWritableData();
108 
109  std::unique_ptr<_Data> _data;
110 };
111 
113 
114 #endif
void
Definition: png.h:1083
PCP_API const std::unordered_set< std::string > * GetDependenciesForLayerStack(const PcpLayerStackPtr &layerStack) const
PCP_API void AppendDependencyData(PcpExpressionVariablesDependencyData &&data)
PCP_API PcpExpressionVariablesDependencyData & operator=(PcpExpressionVariablesDependencyData &&)
void ForEachDependency(const Callback &callback) const
PCP_API void AddDependencies(const PcpLayerStackPtr &layerStack, std::unordered_set< std::string > &&exprVarDependencies)
PXR_NAMESPACE_CLOSE_SCOPE PXR_NAMESPACE_OPEN_SCOPE
Definition: path.h:1441
PCP_API bool IsEmpty() const
Returns true if any dependencies have been recorded, false otherwise.
#define PXR_NAMESPACE_CLOSE_SCOPE
Definition: pxr.h:91
PXR_NAMESPACE_OPEN_SCOPE TF_DECLARE_WEAK_PTRS(PcpLayerStack)
Definition: format.h:895
#define PCP_API
Definition: api.h:40