inputValueBlock.h
Go to the documentation of this file.
1 //
2 // Copyright 2025 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_EXEC_EF_INPUT_VALUE_BLOCK_H
8 #define PXR_EXEC_EF_INPUT_VALUE_BLOCK_H
9 
11 
12 #include "pxr/pxr.h"
13 
14 #include "pxr/exec/ef/api.h"
15 
19 
20 #include <vector>
21 #include <utility>
22 
23 PXR_NAMESPACE_OPEN_SCOPE
24 
27 
36 {
37 
38 private:
39 
40  // The type representing the vector of (output, value) pairs.
41  typedef std::vector< std::pair<VdfMaskedOutput, VdfVector *> > _VectorType;
42 
43 public:
44 
47  EfInputValueBlock() = default;
48 
51  EF_API
53 
56  EfInputValueBlock(EfInputValueBlock &&rhs) = default;
57 
60  EF_API
62 
65  EF_API
67 
71 
77  template <typename T>
78  void AddOutputValuePair(const VdfMaskedOutput &output, const T &value)
79  {
80  _values.push_back(std::make_pair( output, new VdfTypedVector<T>()));
81  _values.back().second->Set(value);
82  }
83 
86  void AddOutputVectorPair(const VdfMaskedOutput &output,
87  const VdfVector &value)
88  {
89  _values.push_back(std::make_pair( output, new VdfVector(value) ) );
90  }
91 
99  EF_API
100  void Apply(VdfExecutorInterface *executor,
101  VdfMaskedOutputVector *invalidationRequest = NULL) const;
102 
108  EF_API
110  const VdfMaskedOutputVector &invalidationRequest) const;
111 
114  typedef _VectorType::const_iterator const_iterator;
115 
119  return _values.begin();
120  }
121 
124  const_iterator end() const {
125  return _values.end();
126  }
127 
130  size_t GetSize() const {
131  return _values.size();
132  }
133 
134 private:
135 
136  // Push invalidation on to the executor.
137  //
138  void _Invalidate(VdfExecutorInterface *executor,
139  const VdfMaskedOutputVector &invalidationRequest) const;
140 
141  // Sets the output values on the executor.
142  //
143  void _SetValues(VdfExecutorInterface *executor) const;
144 
145  // Clears the input value block.
146  //
147  void _Clear();
148 
149  // Appends the contents of \p to this object.
150  //
151  void _Append(const EfInputValueBlock &rhs);
152 
153 private:
154 
155  // The value pairs that make up this block.
156  _VectorType _values;
157 
158 };
159 
162 typedef std::vector< EfInputValueBlock > EfInputValueBlockVector;
163 
164 PXR_NAMESPACE_CLOSE_SCOPE
165 
166 #endif
void AddOutputValuePair(const VdfMaskedOutput &output, const T &value)
Adds an (output, value) pair to this block.
This class is used to abstract away knowledge of the cache data used for each node.
Definition: vector.h:58
size_t GetSize() const
Returns the number of outputs in this block.
EF_API void InvalidateAndApply(VdfExecutorInterface *executor, const VdfMaskedOutputVector &invalidationRequest) const
Pushes invalidation into the executor using the supplied invalidationRequest.
const_iterator begin() const
Returns a const_iterator to the beginning of the values vector.
A VdfTypedVector implements a VdfVector with a specific type.
Definition: typedVector.h:22
std::vector< EfInputValueBlock > EfInputValueBlockVector
A vector of EfInputValueBlocks.
Class to hold on to an externally owned output and a mask.
Definition: maskedOutput.h:31
An input value block is a vector of (output, value) pairs, each of which will be used to initialize a...
EF_API void Apply(VdfExecutorInterface *executor, VdfMaskedOutputVector *invalidationRequest=NULL) const
Applies the input value block to an executor, by setting the output values and pushing through invali...
const_iterator end() const
Returns a const_iterator to the end of the values vector.
void AddOutputVectorPair(const VdfMaskedOutput &output, const VdfVector &value)
Adds an (output, VdfVector) pair to this block.
EfInputValueBlock()=default
Constructs an empty input value block.
Abstract base class for classes that execute a VdfNetwork to compute a requested set of values.
_VectorType::const_iterator const_iterator
A const iterator into a block vector.
EF_API ~EfInputValueBlock()
Destructor.
EF_API EfInputValueBlock & operator=(const EfInputValueBlock &rhs)
Copy assignment operator.