Loading...
Searching...
No Matches
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
11
12#include "pxr/pxr.h"
13
14#include "pxr/exec/vdf/mask.h"
15#include "pxr/exec/vdf/vector.h"
16
17PXR_NAMESPACE_OPEN_SCOPE
18
21template<typename TYPE>
23{
24public:
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
32 static_assert(sizeof(VdfTypedVector) == sizeof(VdfVector),
33 "VdfTypedVector must have same size as VdfVector");
35 }
36
38 VdfTypedVector(const TYPE &value) {
39 static_assert(sizeof(VdfTypedVector) == sizeof(VdfVector),
40 "VdfTypedVector must have same size as VdfVector");
41 _data.New<Vdf_VectorImplSingle<TYPE>>(value);
42 }
43
45 static VdfTypedVector CreateWithSize(size_t size) {
46 return VdfTypedVector(size, _WithSize);
47 }
48
49private:
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
68PXR_NAMESPACE_CLOSE_SCOPE
69
70#endif
71
void New(Args &&... args)
Creates an instance.
Implements Vdf_VectorData storage that holds a contiguous range of elements, which may be a subrange ...
Implements a Vdf_VectorData storage that is always empty.
Implements a Vdf_VectorData storage that is holds a single element.
A VdfTypedVector implements a VdfVector with a specific type.
Definition: typedVector.h:23
static VdfTypedVector CreateWithSize(size_t size)
Constructs a new vector with the specified size.
Definition: typedVector.h:45
VdfTypedVector()
Constructs an empty vector.
Definition: typedVector.h:31
VdfTypedVector(const TYPE &value)
Constructs a new vector and initializes it with a specific value.
Definition: typedVector.h:38
This class is used to abstract away knowledge of the cache data used for each node.
Definition: vector.h:56