using System;
using Unity.Jobs;
namespace UnityEngine.XR.ARSubsystems
{
///
/// Represents the state of an asynchronous "add image job" scheduled by
/// .
///
public readonly struct AddReferenceImageJobState : IEquatable
{
readonly IntPtr m_Handle;
readonly MutableRuntimeReferenceImageLibrary m_Library;
internal AddReferenceImageJobState(IntPtr nativePtr, JobHandle jobHandle, MutableRuntimeReferenceImageLibrary library)
{
if (library == null)
throw new ArgumentNullException(nameof(library));
m_Handle = nativePtr;
m_Library = library;
this.jobHandle = jobHandle;
}
///
/// The [JobHandle](xref:Unity.Jobs.JobHandle) associated with the add job.
///
public JobHandle jobHandle { get; }
///
/// Gets the job state as an .
///
/// Returns this as an .
public IntPtr AsIntPtr() => m_Handle;
///
/// Casts this to an .
///
/// The to cast.
/// Returns the associated with this
/// .
public static explicit operator IntPtr(AddReferenceImageJobState state) => state.m_Handle;
///
/// (Read Only) The status of the add job.
///
public AddReferenceImageJobStatus status =>
m_Library?.GetAddReferenceImageJobStatus(this) ?? AddReferenceImageJobStatus.None;
///
/// Provides a string representation suitable for debug logging.
///
/// A string representation of this .
public override string ToString() => $"(handle: {m_Handle.ToString()}, {nameof(status)}: {status})";
///
/// Generates a hash suitable for use with containers like `HashSet` and `Dictionary`.
///
/// Returns a hash code for this .
public override int GetHashCode() => HashCodeUtil.Combine(
m_Handle.GetHashCode(),
HashCodeUtil.ReferenceHash(m_Library));
///
/// Tests for equality.
///
/// The `object` to compare against.
/// Returns `true` if is of type
/// and is considered equal to this using
/// . Returns `false` otherwise `false`.
public override bool Equals(object obj) => obj is AddReferenceImageJobState other && Equals(other);
///
/// Tests for equality.
///
/// The other to compare against.
/// Returns `true` if this represents the same handle
/// as . Returns `false` otherwise.
public bool Equals(AddReferenceImageJobState other) =>
m_Handle == other.m_Handle &&
m_Library == other.m_Library;
///
/// Tests for equality. Same as .
///
/// The to compare with .
/// The to compare with .
/// Returns `true` if is equal to .
/// Returns `false` otherwise.
public static bool operator ==(AddReferenceImageJobState lhs, AddReferenceImageJobState rhs) => lhs.Equals(rhs);
///
/// Tests for inequality. This is the negation of .
///
/// The to compare with .
/// The to compare with .
/// Returns `true` if is not equal to .
/// Returns `false` otherwise.
public static bool operator !=(AddReferenceImageJobState lhs, AddReferenceImageJobState rhs) => !lhs.Equals(rhs);
}
}