using System;
using System.Runtime.InteropServices;
using NvAPIWrapper.Native.Interfaces;
namespace NvAPIWrapper.Native.DRS.Structures
{
///
/// DRSProfileHandle is a reference to a DRS profile.
///
[StructLayout(LayoutKind.Sequential)]
public struct DRSProfileHandle : IHandle, IEquatable
{
internal readonly IntPtr _MemoryAddress;
private DRSProfileHandle(IntPtr memoryAddress)
{
_MemoryAddress = memoryAddress;
}
///
public bool Equals(DRSProfileHandle other)
{
return _MemoryAddress.Equals(other._MemoryAddress);
}
///
public override bool Equals(object obj)
{
if (ReferenceEquals(null, obj))
{
return false;
}
return obj is DRSProfileHandle handle && Equals(handle);
}
///
public override int GetHashCode()
{
return _MemoryAddress.GetHashCode();
}
///
public override string ToString()
{
return $"DRSProfileHandle #{MemoryAddress.ToInt64()}";
}
///
public IntPtr MemoryAddress
{
get => _MemoryAddress;
}
///
public bool IsNull
{
get => _MemoryAddress == IntPtr.Zero;
}
///
/// Checks for equality between two objects of same type
///
/// The first object
/// The second object
/// true, if both objects are equal, otherwise false
public static bool operator ==(DRSProfileHandle left, DRSProfileHandle right)
{
return left.Equals(right);
}
///
/// Checks for inequality between two objects of same type
///
/// The first object
/// The second object
/// true, if both objects are not equal, otherwise false
public static bool operator !=(DRSProfileHandle left, DRSProfileHandle right)
{
return !left.Equals(right);
}
///
/// Gets default DRSProfileHandle with a null pointer
///
public static DRSProfileHandle DefaultHandle
{
get => default(DRSProfileHandle);
}
///
/// Gets the default global profile handle
///
public static DRSProfileHandle DefaultGlobalProfileHandle
{
get => new DRSProfileHandle(new IntPtr(-1));
}
}
}