![]() |
ezEngine Release 26.3
|
Manages complex multi-type instance data allocation with proper construction and destruction. More...
#include <InstanceDataAllocator.h>
Public Member Functions | |
| ezUInt32 | AddDesc (const ezInstanceDataDesc &desc) |
| Adds the given desc to internal list of data that needs to be allocated and returns the byte offset. | |
| void | ClearDescs () |
| Resets all internal state. | |
| void | Construct (ezByteBlobPtr blobPtr) const |
| Constructs the instance data objects, within the pre-allocated memory block. | |
| void | Destruct (ezByteBlobPtr blobPtr) const |
| Destructs the instance data objects. | |
| ezBlob | AllocateAndConstruct () const |
| Allocates memory and constructs the instance data objects inside it. The returned ezBlob must be stored somewhere. | |
| void | DestructAndDeallocate (ezBlob &ref_blob) const |
| Destructs and deallocates the instance data objects and the given memory block. | |
| ezUInt32 | GetTotalDataSize () const |
| The total size in bytes taken up by all instance data objects that were added. | |
Static Public Member Functions | |
| static EZ_ALWAYS_INLINE void * | GetInstanceData (const ezByteBlobPtr &blobPtr, ezUInt32 uiOffset) |
| Retrieves a void pointer to the instance data within the given blob at the given offset, or nullptr if the offset is invalid. | |
Manages complex multi-type instance data allocation with proper construction and destruction.
This allocator is designed for systems that need to allocate heterogeneous data structures in a single memory block, such as VM instances, state machines, or script execution contexts. It calculates proper alignments for mixed data types and handles construction/destruction automatically.
Typical workflow: