HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
vectorDataTyped.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_VECTOR_DATA_TYPED_H
8 #define PXR_EXEC_VDF_VECTOR_DATA_TYPED_H
9 
10 #include "pxr/pxr.h"
11 
12 #include "pxr/exec/vdf/api.h"
15 
17 
18 template<typename TYPE> class Vdf_VectorImplEmpty;
19 template<typename TYPE> class Vdf_VectorImplSingle;
20 template<typename TYPE> class Vdf_VectorImplContiguous;
21 template<typename TYPE> class Vdf_VectorImplBoxed;
22 
23 // Vdf_VectorDataTypedBase is used as templated base class for
24 // Vdf_VectorDataTyped implementing methods that are the same for
25 // all types.
26 //
27 template<typename TYPE>
29 {
30 public:
31  const std::type_info &GetTypeInfo() const override final
32  {
33  return typeid(TYPE);
34  }
35 
36  void NewEmpty(size_t size, DataHolder *destData) const override final
37  {
38  destData->New< Vdf_VectorImplEmpty<TYPE> >(size);
39  }
40 
41  void NewSingle(DataHolder *destData) const override final
42  {
43  destData->New< Vdf_VectorImplSingle<TYPE> >();
44  }
45 
46  void NewSparse(
47  size_t size, size_t first, size_t last,
48  DataHolder *destData) const override final
49  {
50  destData->New< Vdf_VectorImplContiguous<TYPE> >(size, first, last);
51  }
52 
53  void NewDense(size_t size, DataHolder *destData) const override final
54  {
55  destData->New< Vdf_VectorImplContiguous<TYPE> >(size);
56  }
57 
58  size_t EstimateElementMemory() const override
59  {
60  // We estimate the size of the element based on the type only. Note
61  // that this is an approximation, as individual instances of TYPE may
62  // heap allocate memory.
63  return sizeof(TYPE);
64  }
65 };
66 
67 #if !defined(ARCH_OS_WINDOWS)
68 #define VDF_DECLARE_EXTERN_VECTOR_DATA_TYPED(type) \
69  extern template class VDF_API_TYPE Vdf_VectorDataTyped<type>;
71 #undef VDF_DECLARE_EXTERN_VECTOR_DATA_TYPED
72 #endif // !defined(ARCH_OS_WINDOWS)
73 
75 
76 #endif
GLint first
Definition: glcorearb.h:405
void NewSparse(size_t size, size_t first, size_t last, DataHolder *destData) const overridefinal
#define PXR_NAMESPACE_OPEN_SCOPE
Definition: pxr.h:73
void NewDense(size_t size, DataHolder *destData) const overridefinal
#define VDF_FOR_EACH_COMMON_TYPE(macro)
VDF_FOR_EACH_COMMON_TYPE expands macro for each common type.
Abstract base class for storing data in a VdfVector.
Definition: vectorData.h:26
size_t EstimateElementMemory() const override
const std::type_info & GetTypeInfo() const overridefinal
Implements a Vdf_VectorData storage that holds a boxed element.
__hostdev__ uint64_t last(uint32_t i) const
Definition: NanoVDB.h:5976
GLsizeiptr size
Definition: glcorearb.h:664
void NewSingle(DataHolder *destData) const overridefinal
#define VDF_API_TYPE
Definition: api.h:26
Implements a Vdf_VectorData storage that is always empty.
#define PXR_NAMESPACE_CLOSE_SCOPE
Definition: pxr.h:74
void NewEmpty(size_t size, DataHolder *destData) const overridefinal
#define VDF_DECLARE_EXTERN_VECTOR_DATA_TYPED(type)
Implements a Vdf_VectorData storage that is holds a single element.