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 terms set forth in the LICENSE.txt file available at
5 // https://openusd.org/license.
6 //
7 #ifndef PXR_USD_PCP_EXPRESSION_VARIABLES_DEPENDENCY_DATA_H
8 #define PXR_USD_PCP_EXPRESSION_VARIABLES_DEPENDENCY_DATA_H
9 
10 #include "pxr/pxr.h"
11 #include "pxr/usd/pcp/api.h"
14 
15 #include <memory>
16 #include <unordered_set>
17 #include <string>
18 
20 
22 
23 /// \class PcpExpressionVariablesDependencyData
24 ///
25 /// Captures the expression variables used by an associated prim index
26 /// during composition.
28 {
29 public:
30  PCP_API
32 
33  PCP_API
35  PcpExpressionVariablesDependencyData&&);
36 
37  PCP_API
39 
40  PCP_API
41  PcpExpressionVariablesDependencyData& operator=(
42  PcpExpressionVariablesDependencyData&&);
43 
44  /// Returns true if any dependencies have been recorded, false otherwise.
45  PCP_API
46  bool IsEmpty() const;
47 
48  /// Moves dependencies in \p data and appends it to the dependencies
49  /// in this object.
50  PCP_API
51  void AppendDependencyData(PcpExpressionVariablesDependencyData&& data);
52 
53  /// Adds dependencies on the expression variables in \p exprVarDependencies
54  /// from \p layerStack.
55  PCP_API
56  void AddDependencies(
57  const PcpLayerStackPtr& layerStack,
58  std::unordered_set<std::string>&& exprVarDependencies);
59 
60  /// Runs the given \p callback on all of the dependencies in this object.
61  /// \p callback must have the signature:
62  ///
63  /// void(const PcpLayerStack&, const std::unordered_set<std::string>&)
64  ///
65  /// The first argument is the layer stack associated with the expression
66  /// variables in the second argument.
67  template <class Callback>
68  void ForEachDependency(const Callback& callback) const
69  {
70  _ForEachFunctionRef fn(callback);
71  _ForEachDependency(fn);
72  }
73 
74  /// Returns the expression variable dependencies associated with
75  /// \p layerStack. If no such dependencies have been added, returns
76  /// nullptr.
77  PCP_API
78  const std::unordered_set<std::string>*
79  GetDependenciesForLayerStack(const PcpLayerStackPtr& layerStack) const;
80 
81 private:
82  using _ForEachFunctionRef = TfFunctionRef<void(
83  const PcpLayerStackPtr&, const std::unordered_set<std::string>&)>;
84 
85  PCP_API
86  void _ForEachDependency(const _ForEachFunctionRef& fn) const;
87 
88  class _Data;
89  const _Data* _GetData() const;
90  _Data& _GetWritableData();
91 
92  std::unique_ptr<_Data> _data;
93 };
94 
96 
97 #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:1425
PCP_API bool IsEmpty() const
Returns true if any dependencies have been recorded, false otherwise.
#define PXR_NAMESPACE_CLOSE_SCOPE
Definition: pxr.h:74
PXR_NAMESPACE_OPEN_SCOPE TF_DECLARE_WEAK_PTRS(PcpLayerStack)
Definition: format.h:1821
#define PCP_API
Definition: api.h:23