// Copyright (c) 2010-2014 SharpDX - Alexandre Mutel
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
using System;
using System.Runtime.InteropServices;
namespace SharpDX.MediaFoundation
{
///
/// A Work Queue Identifier
///
/// ms703102
/// Work Queue Identifiers
/// Work Queue Identifiers
[StructLayout(LayoutKind.Sequential)]
public struct WorkQueueId : IEquatable
{
///
/// The default queue associated to the .
///
public static readonly WorkQueueId Standard = new WorkQueueId(WorkQueueType.Standard);
///
/// The identifier.
///
public readonly int Id;
///
/// Initializes a new instance of the struct.
///
/// The id.
public WorkQueueId(int id)
{
this.Id = id;
}
///
/// Initializes a new instance of the struct.
///
/// The id.
public WorkQueueId(WorkQueueType id)
{
this.Id = (int)id;
}
public bool Equals(WorkQueueId other)
{
return Id == other.Id;
}
public override bool Equals(object obj)
{
if (ReferenceEquals(null, obj))
{
return false;
}
return obj is WorkQueueId && Equals((WorkQueueId)obj);
}
public override int GetHashCode()
{
return Id;
}
public static bool operator ==(WorkQueueId left, WorkQueueId right)
{
return left.Equals(right);
}
public static bool operator !=(WorkQueueId left, WorkQueueId right)
{
return !left.Equals(right);
}
public override string ToString()
{
return string.Format("Id: {0} (Type: {1})", Id, (WorkQueueType)Id);
}
///
/// Performs an implicit conversion from to .
///
/// The id.
/// The result of the conversion.
public static implicit operator WorkQueueId(int id)
{
return new WorkQueueId(id);
}
///
/// Performs an implicit conversion from to .
///
/// The type.
/// The result of the conversion.
public static implicit operator WorkQueueId(WorkQueueType type)
{
return new WorkQueueId(type);
}
///
/// Performs an explicit conversion from to .
///
/// The work queue Id.
/// The result of the conversion.
public static explicit operator int(WorkQueueId workQueueId)
{
return workQueueId.Id;
}
///
/// Performs an explicit conversion from to .
///
/// The work queue Id.
/// The result of the conversion.
public static explicit operator WorkQueueType(WorkQueueId workQueueId)
{
return (WorkQueueType)workQueueId.Id;
}
}
}