HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
allocateBoxedValue.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_ALLOCATE_BOXED_VALUE_H
8 #define PXR_EXEC_VDF_ALLOCATE_BOXED_VALUE_H
9 
10 #include "pxr/pxr.h"
11 
12 #include "pxr/exec/vdf/api.h"
14 #include "pxr/exec/vdf/vector.h"
15 
17 #include "pxr/base/tf/diagnostic.h"
18 #include "pxr/base/tf/mallocTag.h"
19 
21 
22 class TfToken;
23 class VdfContext;
24 
25 // Allocate a new VdfVector as backing store for a boxed value.
26 //
27 VDF_API
29 
30 // Allocate a new VdfVector as backing store for a boxed value, then construct
31 // a boxed value inside that newly allocated VdfVector.
32 //
33 template < typename T, typename... Args>
34 bool
36  const VdfContext &context,
37  const TfToken &name,
38  Args&&... args)
39 {
40  // Allocate a new VdfVector for storing a boxed value. This function will
41  // return nullptr if the output is not requested, or if an error occurred.
42  // The function will emit a coding error in the latter case.
43  VdfVector *v = Vdf_AllocateBoxedValueVector(context, name);
44  if (!v) {
45  return false;
46  }
47 
48  // Keep track of how much memory we are allocating.
49  TfAutoMallocTag tag(
50  "Vdf", TfMallocTag::IsInitialized() ? TF_FUNC_NAME() : "");
51  TfAutoMallocTag typedTag("Vdf", __ARCH_PRETTY_FUNCTION__);
52 
53  // Store a new Vdf_BoxedContainer at the output.
54  v->Set(Vdf_BoxedContainer<T>(std::forward<Args>(args)...));
55 
56  // Success!
57  return true;
58 }
59 
61 
62 #endif
void Set(TYPE &&data)
Definition: vector.h:162
const GLdouble * v
Definition: glcorearb.h:837
#define PXR_NAMESPACE_OPEN_SCOPE
Definition: pxr.h:73
bool Vdf_AllocateBoxedValue(const VdfContext &context, const TfToken &name, Args &&...args)
#define VDF_API
Definition: api.h:25
Definition: token.h:70
#define __ARCH_PRETTY_FUNCTION__
Definition: functionLite.h:29
VDF_API VdfVector * Vdf_AllocateBoxedValueVector(const VdfContext &, const TfToken &)
GLuint const GLchar * name
Definition: glcorearb.h:786
#define PXR_NAMESPACE_CLOSE_SCOPE
Definition: pxr.h:74
**If you just want to fire and args
Definition: thread.h:618