SW 중심대학 OSS GIT 서버 박건태, 이승준, 고기완, 이준호 새로운 배포
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

82 lines
4.2 KiB

4 years ago
  1. using System;
  2. using Unity.Collections;
  3. namespace UnityEngine.XR.ARKit
  4. {
  5. /// <summary>
  6. /// Represents the serialized form of an <see cref="ARCollaborationData"/>. Obtain with <see cref="ARCollaborationData.ToSerialized"/>.
  7. /// </summary>
  8. public struct SerializedARCollaborationData : IDisposable, IEquatable<SerializedARCollaborationData>
  9. {
  10. /// <summary>
  11. /// Whether the <see cref="SerializedARCollaborationData"/> has been created or not.
  12. /// </summary>
  13. public bool created => m_NSData.created;
  14. /// <summary>
  15. /// Get the raw bytes of the serialized <see cref="ARCollaborationData"/> as a <c>NativeSlice</c>.
  16. /// No copies are made; the <c>NativeSlice</c> is a "view" into the raw data.
  17. /// The <c>NativeSlice</c> is valid until this object is <see cref="Dispose"/>d.
  18. /// </summary>
  19. /// <exception cref="System.InvalidOperationException">Thrown if <see cref="created"/> is <c>false</c>.</exception>
  20. public unsafe NativeSlice<byte> bytes
  21. {
  22. get
  23. {
  24. if (!created)
  25. throw new InvalidOperationException("The SerializedARCollaborationData has not been created.");
  26. return m_NSData.ToNativeSlice();
  27. }
  28. }
  29. /// <summary>
  30. /// Disposes the native resource associated with this <see cref="SerializedARCollaborationData"/>.
  31. /// </summary>
  32. public void Dispose() => m_NSData.Dispose();
  33. /// <summary>
  34. /// Generates a hash code suitable for use in <c>HashSet</c> and <c>Dictionary</c>.
  35. /// </summary>
  36. /// <returns>A hash of the <see cref="SerializedARCollaborationData"/>.</returns>
  37. public override int GetHashCode() => m_NSData.GetHashCode();
  38. /// <summary>
  39. /// Compares for equality.
  40. /// </summary>
  41. /// <param name="obj">An <c>object</c> to compare against.</param>
  42. /// <returns><c>true</c> if <paramref name="obj"/> is an <see cref="SerializedARCollaborationData"/> and
  43. /// <see cref="Equals(SerializedARCollaborationData)"/> is also <c>true</c>. Otherwise, <c>false</c>.</returns>
  44. public override bool Equals(object obj) => (obj is SerializedARCollaborationData) && Equals((SerializedARCollaborationData)obj);
  45. /// <summary>
  46. /// Compares for equality.
  47. /// </summary>
  48. /// <param name="other">The other <see cref="SerializedARCollaborationData"/> to compare against.</param>
  49. /// <returns><c>true</c> if the <see cref="SerializedARCollaborationData"/> represents the same object.</returns>
  50. public bool Equals(SerializedARCollaborationData other) => m_NSData.Equals(other.m_NSData);
  51. /// <summary>
  52. /// Compares <paramref name="lhs"/> and <paramref name="rhs"/> for equality using <see cref="Equals(SerializedARCollaborationData)"/>.
  53. /// </summary>
  54. /// <param name="lhs">The left-hand-side <see cref="SerializedARCollaborationData"/> of the comparison.</param>
  55. /// <param name="rhs">The right-hand-side <see cref="SerializedARCollaborationData"/> of the comparison.</param>
  56. /// <returns><c>true</c> if <paramref name="lhs"/> compares equal to <paramref name="rhs"/>, <c>false</c> otherwise.</returns>
  57. public static bool operator ==(SerializedARCollaborationData lhs, SerializedARCollaborationData rhs) => lhs.Equals(rhs);
  58. /// <summary>
  59. /// Compares <paramref name="lhs"/> and <paramref name="rhs"/> for inequality using <see cref="Equals(SerializedARCollaborationData)"/>.
  60. /// </summary>
  61. /// <param name="lhs">The left-hand-side <see cref="SerializedARCollaborationData"/> of the comparison.</param>
  62. /// <param name="rhs">The right-hand-side <see cref="SerializedARCollaborationData"/> of the comparison.</param>
  63. /// <returns><c>false</c> if <paramref name="lhs"/> compares equal to <paramref name="rhs"/>, <c>true</c> otherwise.</returns>
  64. public static bool operator !=(SerializedARCollaborationData lhs, SerializedARCollaborationData rhs) => !lhs.Equals(rhs);
  65. internal SerializedARCollaborationData(NSData nsData)
  66. {
  67. m_NSData = nsData;
  68. }
  69. NSData m_NSData;
  70. }
  71. }