// This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. // If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/. // Copyright (C) LibreHardwareMonitor and Contributors. // Partial Copyright (C) Michael Möller and Contributors. // All Rights Reserved. namespace LibreHardwareMonitor.Hardware; /// /// This structure describes a group-specific affinity. /// public readonly struct GroupAffinity { public static GroupAffinity Undefined = new(ushort.MaxValue, 0); /// /// Initializes a new instance of the struct. /// /// The group. /// The mask. public GroupAffinity(ushort group, ulong mask) { Group = group; Mask = mask; } /// /// Gets a single group affinity. /// /// The group. /// The index. /// . public static GroupAffinity Single(ushort group, int index) { return new GroupAffinity(group, 1UL << index); } /// /// Gets the group. /// public ushort Group { get; } /// /// Gets the mask. /// public ulong Mask { get; } /// /// Determines whether the specified is equal to this instance. /// /// The to compare with this instance. /// true if the specified is equal to this instance; otherwise, false. public override bool Equals(object o) { if (o == null || GetType() != o.GetType()) return false; GroupAffinity a = (GroupAffinity)o; return (Group == a.Group) && (Mask == a.Mask); } /// /// Returns a hash code for this instance. /// /// A hash code for this instance, suitable for use in hashing algorithms and data structures like a hash table. public override int GetHashCode() { return Group.GetHashCode() ^ Mask.GetHashCode(); } /// /// Implements the == operator. /// /// The a1. /// The a2. /// The result of the operator. public static bool operator ==(GroupAffinity a1, GroupAffinity a2) { return (a1.Group == a2.Group) && (a1.Mask == a2.Mask); } /// /// Implements the != operator. /// /// The a1. /// The a2. /// The result of the operator. public static bool operator !=(GroupAffinity a1, GroupAffinity a2) { return (a1.Group != a2.Group) || (a1.Mask != a2.Mask); } }