//
// 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
{
///
///
/// This class is responsible for creating instances of classes based on their name or hash and is mainly used
/// for deserialization of saved data.
///
///
/// C++:
/// Jolt/Core/Factory.h:13
///
/// class Factory
///
///
[InteropHandle]
public readonly partial struct Factory : IDisposable
{
public static Factory Create() => Jolt.PInvoke.Factory_Create();
///
///
/// Create an object
///
///
/// C++:
/// Jolt/Core/Factory.h:19
///
/// void * CreateObject(const char *inName)
///
///
public unsafe Ptr CreateObject(RefString8 name)
{
fixed (byte* name_fixed = name)
{
return Jolt.PInvoke.Factory_CreateObject(this, name_fixed);
}
}
///
///
/// Find type info for a specific class by name
///
///
/// C++:
/// Jolt/Core/Factory.h:22
///
/// const RTTI * Find(const char *inName)
///
///
///
///
/// The returned handle is borrowed from its owner; don't Dispose it.
///
///
public unsafe RTTI Find(RefString8 name)
{
fixed (byte* name_fixed = name)
{
return Jolt.PInvoke.Factory_Find(this, name_fixed);
}
}
///
///
/// Find type info for a specific class by hash
///
///
/// C++:
/// Jolt/Core/Factory.h:25
///
/// const RTTI * Find(uint32 inHash)
///
///
///
///
/// The returned handle is borrowed from its owner; don't Dispose it.
///
///
public RTTI Find(uint hash) => Jolt.PInvoke.Factory_Find_2(this, hash);
///
///
/// Register an object with the factory. Returns false on failure.
///
///
/// C++:
/// Jolt/Core/Factory.h:28
///
/// bool Register(const RTTI *inRTTI)
///
///
public bool Register(RTTI rtti) => Jolt.PInvoke.Factory_Register(this, rtti);
///
///
/// Register a list of objects with the factory. Returns false on failure.
///
///
/// C++:
/// Jolt/Core/Factory.h:31
///
/// bool Register(const RTTI **inRTTIs, uint inNumber)
///
///
///
///
/// rTTIs is a buffer of RTTI handles you allocate and size; the handles the call writes into it are
/// borrowed from their owner - don't Dispose them.
///
///
public unsafe bool Register(Ptr rTTIs, uint number) =>
Jolt.PInvoke.Factory_Register_2(this, rTTIs, number);
///
///
/// Unregisters all types
///
///
/// C++:
/// Jolt/Core/Factory.h:34
///
/// void Clear()
///
///
public void Clear() => Jolt.PInvoke.Factory_Clear(this);
///
///
/// Get all registered classes
///
///
/// C++:
/// Jolt/Core/Factory.h:37
///
/// Array<const RTTI *> GetAllClasses() const
///
///
///
///
/// Returns an owned native buffer - read it through AsSpan() and Dispose it when you are done with it. The
/// handles in it are borrowed from the object that owns them: don't Dispose them, and don't read them once
/// that owner is gone - the buffer keeps the pointers alive, not the objects.
///
///
public NativeArray GetAllClasses() => new NativeArray(Jolt.PInvoke.Factory_GetAllClasses(this));
///
///
/// Singleton factory instance
///
///
/// C++:
/// Jolt/Core/Factory.h:40
///
/// static Factory * sInstance
///
///
///
///
/// The returned handle is borrowed from its owner; don't Dispose it.
///
///
internal static Factory GetInstance() => Jolt.PInvoke.Factory_GetInstance();
///
///
/// Singleton factory instance
///
///
/// C++:
/// Jolt/Core/Factory.h:40
///
/// static Factory * sInstance
///
///
internal static void SetInstance(Factory value) => Jolt.PInvoke.Factory_SetInstance(value);
public void Dispose() => Jolt.PInvoke.Factory_Destroy(this);
}
}