Initial commit
This commit is contained in:
@@ -0,0 +1,34 @@
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
using CeresSharp.Native;
|
||||
|
||||
namespace CeresSharp.Native.SafeHandles;
|
||||
|
||||
/// <summary>
|
||||
/// Safe handle for Ceres SolverOptions.
|
||||
/// </summary>
|
||||
internal sealed class SolverOptionsHandle : BaseSafeHandle
|
||||
{
|
||||
private SolverOptionsHandle() : base()
|
||||
{
|
||||
}
|
||||
|
||||
private SolverOptionsHandle(IntPtr handle, bool ownsHandle) : base(handle, ownsHandle)
|
||||
{
|
||||
}
|
||||
|
||||
public static SolverOptionsHandle Create()
|
||||
{
|
||||
var handle = CeresNative.ceres_wrapper_create_solver_options();
|
||||
if (handle == IntPtr.Zero)
|
||||
{
|
||||
throw new Exceptions.CeresException(Exceptions.CeresErrorCode.OutOfMemory, "Failed to create solver options");
|
||||
}
|
||||
return new SolverOptionsHandle(handle, true);
|
||||
}
|
||||
|
||||
protected override void ReleaseNativeHandle(IntPtr handle)
|
||||
{
|
||||
CeresNative.ceres_wrapper_free_solver_options(handle);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user