AddReferenceImageJobState.cs
5.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
using System;
using Unity.Jobs;
namespace UnityEngine.XR.ARSubsystems
{
/// <summary>
/// Represents the state of an asynchronous "add image job" scheduled by
/// <see cref="MutableRuntimeReferenceImageLibrary.ScheduleAddImageWithValidationJob"/>
/// </summary>
public readonly struct AddReferenceImageJobState : IEquatable<AddReferenceImageJobState>
{
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;
}
/// <summary>
/// The [JobHandle](xref:Unity.Jobs.JobHandle) associated with the add job.
/// </summary>
public JobHandle jobHandle { get; }
/// <summary>
/// Gets the job state as an <see cref="System.IntPtr"/>.
/// </summary>
/// <returns>Returns this <see cref="AddReferenceImageJobState"/> as an <see cref="System.IntPtr"/>.</returns>
public IntPtr AsIntPtr() => m_Handle;
/// <summary>
/// Casts this <see cref="AddReferenceImageJobState"/> to an <see cref="System.IntPtr"/>.
/// </summary>
/// <param name="state">The <see cref="AddReferenceImageJobState"/> to cast.</param>
/// <returns>Returns the <see cref="System.IntPtr"/> associated with this
/// <see cref="AddReferenceImageJobState"/>.</returns>
public static explicit operator IntPtr(AddReferenceImageJobState state) => state.m_Handle;
/// <summary>
/// (Read Only) The status of the add job.
/// </summary>
public AddReferenceImageJobStatus status =>
m_Library?.GetAddReferenceImageJobStatus(this) ?? AddReferenceImageJobStatus.None;
/// <summary>
/// Provides a string representation suitable for debug logging.
/// </summary>
/// <returns>A string representation of this <see cref="AddReferenceImageJobState"/>.</returns>
public override string ToString() => $"(handle: {m_Handle.ToString()}, {nameof(status)}: {status})";
/// <summary>
/// Generates a hash suitable for use with containers like `HashSet` and `Dictionary`.
/// </summary>
/// <returns>Returns a hash code for this <see cref="AddReferenceImageJobState"/>.</returns>
public override int GetHashCode() => HashCode.Combine(
m_Handle.GetHashCode(),
HashCode.ReferenceHash(m_Library));
/// <summary>
/// Tests for equality.
/// </summary>
/// <param name="obj">The `object` to compare against.</param>
/// <returns>Returns `true` if <paramref name="obj"/> is of type <see cref="AddReferenceImageJobState"/>
/// and is considered equal to this <see cref="AddReferenceImageJobState"/> using
/// <see cref="Equals(AddReferenceImageJobState)"/>. Returns `false` otherwise `false`.</returns>
public override bool Equals(object obj) => obj is AddReferenceImageJobState other && Equals(other);
/// <summary>
/// Tests for equality.
/// </summary>
/// <param name="other">The other <see cref="AddReferenceImageJobState"/> to compare against.</param>
/// <returns>Returns `true` if this <see cref="AddReferenceImageJobState"/> represents the same handle
/// as <paramref name="other"/>. Returns `false` otherwise.</returns>
public bool Equals(AddReferenceImageJobState other) =>
m_Handle == other.m_Handle &&
m_Library == other.m_Library;
/// <summary>
/// Tests for equality. Same as <see cref="Equals(AddReferenceImageJobState)"/>.
/// </summary>
/// <param name="lhs">The <see cref="AddReferenceImageJobState"/> to compare with <paramref name="rhs"/>.</param>
/// <param name="rhs">The <see cref="AddReferenceImageJobState"/> to compare with <paramref name="lhs"/>.</param>
/// <returns>Returns `true` if <paramref name="lhs"/> is equal to <paramref name="rhs"/>.
/// Returns `false` otherwise.</returns>
public static bool operator ==(AddReferenceImageJobState lhs, AddReferenceImageJobState rhs) => lhs.Equals(rhs);
/// <summary>
/// Tests for inequality. This is the negation of <see cref="Equals(AddReferenceImageJobState)"/>.
/// </summary>
/// <param name="lhs">The <see cref="AddReferenceImageJobState"/> to compare with <paramref name="rhs"/>.</param>
/// <param name="rhs">The <see cref="AddReferenceImageJobState"/> to compare with <paramref name="lhs"/>.</param>
/// <returns>Returns `true` if <paramref name="lhs"/> is not equal to <paramref name="rhs"/>.
/// Returns `false` otherwise.</returns>
public static bool operator !=(AddReferenceImageJobState lhs, AddReferenceImageJobState rhs) => !lhs.Equals(rhs);
}
}