HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
typedVector.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_TYPED_VECTOR_H
8 #define PXR_EXEC_VDF_TYPED_VECTOR_H
9 
10 /// \file
11 
12 #include "pxr/pxr.h"
13 
14 #include "pxr/exec/vdf/mask.h"
15 #include "pxr/exec/vdf/vector.h"
16 
18 
19 /// A VdfTypedVector implements a VdfVector with a specific type.
20 ///
21 template<typename TYPE>
22 class VdfTypedVector : public VdfVector
23 {
24 public:
25  // Note the sole purpose of this type is to allow construction of
26  // VdfVectors holding TYPE. VdfVector is not polymorphic, this type
27  // should not hold any state at all. We rely that objects of this type
28  // can be sliced into VdfVectors with no adverse effect.
29 
30  /// Constructs an empty vector.
32  static_assert(sizeof(VdfTypedVector) == sizeof(VdfVector),
33  "VdfTypedVector must have same size as VdfVector");
35  }
36 
37  /// Constructs a new vector and initializes it with a specific value.
38  VdfTypedVector(const TYPE &value) {
39  static_assert(sizeof(VdfTypedVector) == sizeof(VdfVector),
40  "VdfTypedVector must have same size as VdfVector");
42  }
43 
44  /// Constructs a new vector with the specified size.
46  return VdfTypedVector(size, _WithSize);
47  }
48 
49 private:
50  enum _WithSizeTag { _WithSize };
51  VdfTypedVector(size_t size, _WithSizeTag) {
52  static_assert(sizeof(VdfTypedVector) == sizeof(VdfVector),
53  "VdfTypedVector must have same size as VdfVector");
54  switch (size) {
55  case 0:
57  break;
58  case 1:
60  break;
61  default:
63  break;
64  }
65  }
66 };
67 
69 
70 #endif
71 
#define PXR_NAMESPACE_OPEN_SCOPE
Definition: pxr.h:73
GLsizei const GLfloat * value
Definition: glcorearb.h:824
Vdf_VectorData::DataHolder _data
Definition: vector.h:727
static VdfTypedVector CreateWithSize(size_t size)
Constructs a new vector with the specified size.
Definition: typedVector.h:45
VdfTypedVector(const TYPE &value)
Constructs a new vector and initializes it with a specific value.
Definition: typedVector.h:38
GLsizeiptr size
Definition: glcorearb.h:664
Implements a Vdf_VectorData storage that is always empty.
VdfTypedVector()
Constructs an empty vector.
Definition: typedVector.h:31
#define PXR_NAMESPACE_CLOSE_SCOPE
Definition: pxr.h:74
Implements a Vdf_VectorData storage that is holds a single element.