Loading...
Searching...
No Matches
allocateBoxedValue.h
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"
13#include "pxr/exec/vdf/boxedContainer.h"
14#include "pxr/exec/vdf/vector.h"
15
19
20PXR_NAMESPACE_OPEN_SCOPE
21
22class TfToken;
23class VdfContext;
24
25// Allocate a new VdfVector as backing store for a boxed value.
26//
27VDF_API
28VdfVector *Vdf_AllocateBoxedValueVector(const VdfContext &, const TfToken &);
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//
33template < typename T, typename... Args>
34bool
35Vdf_AllocateBoxedValue(
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.
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
60PXR_NAMESPACE_CLOSE_SCOPE
61
62#endif
Low-level utilities for informing users of various internal and external diagnostic conditions.
Scoped (i.e.
Definition: mallocTag.h:249
static bool IsInitialized()
Return true if the tagging system is active.
Definition: mallocTag.h:188
Token for efficient comparison, assignment, and hashing of known strings.
Definition: token.h:71
This simple container stores multiple values that flow through the network as a single data flow elem...
A context is the parameter bundle passed to callbacks of computations.
Definition: context.h:40
This class is used to abstract away knowledge of the cache data used for each node.
Definition: vector.h:56
void Set(TYPE &&data)
Forwards data into the vector.
Definition: vector.h:162
Define preprocessor function name macros.
#define TF_FUNC_NAME()
Get the name of the current function as a std::string.
Definition: diagnostic.h:292