Files
Denso/srcs/RobotNet10/RobotApp/Communication/CeresSharp/Native/SafeHandles/ProblemOptionsHandle.cs
2026-07-03 16:31:37 +07:00

34 lines
919 B
C#

using System;
using CeresSharp.Native;
namespace CeresSharp.Native.SafeHandles;
/// <summary>
/// Safe handle for Ceres ProblemOptions.
/// </summary>
internal sealed class ProblemOptionsHandle : BaseSafeHandle
{
private ProblemOptionsHandle() : base()
{
}
private ProblemOptionsHandle(IntPtr handle, bool ownsHandle) : base(handle, ownsHandle)
{
}
public static ProblemOptionsHandle Create()
{
var handle = CeresNative.ceres_wrapper_create_problem_options();
if (handle == IntPtr.Zero)
{
throw new Exceptions.CeresException(Exceptions.CeresErrorCode.OutOfMemory, "Failed to create problem options");
}
return new ProblemOptionsHandle(handle, true);
}
protected override void ReleaseNativeHandle(IntPtr handle)
{
CeresNative.ceres_wrapper_free_problem_options(handle);
}
}