namespace ZB.MOM.WW.MxGateway.Worker.MxAccess;

/// <summary>
/// Metadata for an item handle registered in an MXAccess session.
/// </summary>
public sealed class RegisteredItemHandle
{
    /// <summary>
    /// Initializes a registered item handle with complete metadata.
    /// </summary>
    /// <param name="serverHandle">Handle returned by Register.</param>
    /// <param name="itemHandle">Handle returned by AddItem.</param>
    /// <param name="itemDefinition">Item definition (tag address).</param>
    /// <param name="itemContext">Item context string.</param>
    /// <param name="hasItemContext">Whether this item has an associated context.</param>
    public RegisteredItemHandle(
        int serverHandle,
        int itemHandle,
        string itemDefinition,
        string itemContext,
        bool hasItemContext)
    {
        ServerHandle = serverHandle;
        ItemHandle = itemHandle;
        ItemDefinition = itemDefinition;
        ItemContext = itemContext;
        HasItemContext = hasItemContext;
    }

    /// <summary>
    /// Gets the server handle that owns this item.
    /// </summary>
    public int ServerHandle { get; }

    /// <summary>
    /// Gets the item handle within the server.
    /// </summary>
    public int ItemHandle { get; }

    /// <summary>
    /// Gets the item definition (tag address).
    /// </summary>
    public string ItemDefinition { get; }

    /// <summary>
    /// Gets the item context.
    /// </summary>
    public string ItemContext { get; }

    /// <summary>
    /// Gets a value indicating whether this item has an associated context.
    /// </summary>
    public bool HasItemContext { get; }
}
