HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
maskedOutputVector.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_VDF_MASKED_OUTPUT_VECTOR_H
8 #define PXR_EXEC_VDF_MASKED_OUTPUT_VECTOR_H
9 
10 /// \file
11 
12 #include "pxr/pxr.h"
13 
14 #include "pxr/exec/vdf/api.h"
16 #include "pxr/exec/vdf/types.h"
17 
18 #include "pxr/base/tf/hash.h"
19 
21 
22 class VdfNetwork;
23 
24 /// A vector of VdfMaskedOutputs.
25 ///
26 typedef std::vector<VdfMaskedOutput> VdfMaskedOutputVector;
27 
28 /// Hashing functor for VdfMaskedOutputVectors.
29 ///
31  size_t operator()(const VdfMaskedOutputVector& vector) const
32  {
33  size_t hash = TfHash::Combine(vector.size());
34 
35  // Instead of hashing on the complete request we just do it on the
36  // first three outputs (if any).
37  size_t num = std::min<size_t>(vector.size(), 3);
38 
39  for(size_t i = 0; i < num; ++i) {
40  hash = TfHash::Combine(hash, VdfMaskedOutput::Hash()(vector[i]));
41  }
42 
43  // Also add the last entry.
44  if (vector.size() > 3) {
45  hash = TfHash::Combine(
46  hash, VdfMaskedOutput::Hash()(vector.back()));
47  }
48 
49  return hash;
50  }
51 };
52 
53 /// Sorts and uniques the given vector.
54 ///
55 VDF_API
57 
58 /// Returns a pointer to the network if the vector is not empty. Otherwise
59 /// returns a nullptr. This method assumes that all outputs in the vector
60 /// come from the same network.
61 ///
62 VDF_API
64  const VdfMaskedOutputVector& vector);
65 
67 
68 #endif /* PXR_EXEC_VDF_MASKED_OUTPUT_VECTOR_H */
#define PXR_NAMESPACE_OPEN_SCOPE
Definition: pxr.h:73
#define VDF_API
Definition: api.h:25
std::vector< VdfMaskedOutput > VdfMaskedOutputVector
VDF_API void VdfSortAndUniqueMaskedOutputVector(VdfMaskedOutputVector *vector)
VDF_API const VdfNetwork * VdfGetMaskedOutputVectorNetwork(const VdfMaskedOutputVector &vector)
static size_t Combine(Args &&...args)
Produce a hash code by combining the hash codes of several objects.
Definition: hash.h:487
#define PXR_NAMESPACE_CLOSE_SCOPE
Definition: pxr.h:74
size_t operator()(const VdfMaskedOutputVector &vector) const
std::vector< VdfMaskedOutput > VdfMaskedOutputVector