//
// Generated by Brutal.Jolt.Generate; do not edit by hand.
#nullable enable
using System.Runtime.CompilerServices;
using Brutal.Interop;
using Brutal.Numerics;
namespace Brutal.JoltApi
{
///
///
/// Default implementation of the temp allocator that allocates a large block through malloc upfront
///
///
/// C++:
/// Jolt/Core/TempAllocator.h:34
///
/// class TempAllocatorImpl final : public TempAllocator
///
///
[InteropHandle]
public readonly partial struct TempAllocatorImpl : IDisposable
{
///
///
/// Constructs the allocator with a maximum allocatable size of inSize
///
///
/// C++:
/// Jolt/Core/TempAllocator.h:40
///
/// explicit TempAllocatorImpl(size_t inSize)
///
///
public static TempAllocatorImpl Create(nuint size) => Jolt.PInvoke.TempAllocatorImpl_Create(size);
///
///
/// See: TempAllocator
///
///
/// C++:
/// Jolt/Core/TempAllocator.h:59
///
/// virtual void * Allocate(uint inSize) override
///
///
public unsafe Ptr Allocate(uint size) => Jolt.PInvoke.TempAllocatorImpl_Allocate(this, size);
///
///
/// See: TempAllocator
///
///
/// C++:
/// Jolt/Core/TempAllocator.h:80
///
/// virtual void Free(void *inAddress, uint inSize) override
///
///
public unsafe void Free(Ptr address, uint size) => Jolt.PInvoke.TempAllocatorImpl_Free(this, address, size);
///
///
/// Check if no allocations have been made
///
///
/// C++:
/// Jolt/Core/TempAllocator.h:98
///
/// bool IsEmpty() const
///
///
public bool IsEmpty() => Jolt.PInvoke.TempAllocatorImpl_IsEmpty(this);
///
///
/// Get the total size of the fixed buffer
///
///
/// C++:
/// Jolt/Core/TempAllocator.h:104
///
/// size_t GetSize() const
///
///
public ByteSize GetSize() => (ByteSize)Jolt.PInvoke.TempAllocatorImpl_GetSize(this);
///
///
/// Get current usage in bytes of the buffer
///
///
/// C++:
/// Jolt/Core/TempAllocator.h:110
///
/// size_t GetUsage() const
///
///
public ByteSize GetUsage() => (ByteSize)Jolt.PInvoke.TempAllocatorImpl_GetUsage(this);
///
///
/// Check if an allocation of inSize can be made in this fixed buffer allocator
///
///
/// C++:
/// Jolt/Core/TempAllocator.h:116
///
/// bool CanAllocate(uint inSize) const
///
///
public bool CanAllocate(uint size) => Jolt.PInvoke.TempAllocatorImpl_CanAllocate(this, size);
///
///
/// Check if memory block at inAddress is owned by this allocator
///
///
/// C++:
/// Jolt/Core/TempAllocator.h:122
///
/// bool OwnsMemory(const void *inAddress) const
///
///
public unsafe bool OwnsMemory(Ptr address) => Jolt.PInvoke.TempAllocatorImpl_OwnsMemory(this, address);
public static implicit operator TempAllocator(TempAllocatorImpl value) =>
Unsafe.BitCast(value);
public void Dispose() => Jolt.PInvoke.TempAllocatorImpl_Destroy(this);
///
public unsafe Ptr Allocate(ByteSize size) => ((TempAllocator)this).Allocate(size);
///
public unsafe void Free(Ptr address, ByteSize size) => ((TempAllocator)this).Free(address, size);
}
}