// Copyright Epic Games, Inc. All Rights Reserved. using System; using System.Collections.Generic; using EpicGames.Core; namespace EpicGames.Horde.Storage { /// /// Data for an individual node. Must be disposed after use. /// public class BlobData : IDisposable { /// /// Type of the blob /// public BlobType Type { get; } /// /// Raw data for the blob. Lifetime of this data is tied to the lifetime of the object; consumers must not retain references to it. /// public ReadOnlyMemory Data { get; } /// /// Handles to referenced blobs /// public IReadOnlyList Imports { get; } /// /// Constructor /// public BlobData(BlobType type, ReadOnlyMemory data, IReadOnlyList imports) { Type = type; Data = data; Imports = imports; } /// public void Dispose() { Dispose(true); GC.SuppressFinalize(this); } /// /// Overridable dispose method /// /// True if derived instances should dispose managed resources. False when called from a finalizer. protected virtual void Dispose(bool disposing) { } } /// /// Implementation of for instances. /// public class BlobDataWithOwner : BlobData { readonly IDisposable _owner; /// /// Constructor /// public BlobDataWithOwner(BlobType type, ReadOnlyMemory data, IReadOnlyList imports, IDisposable owner) : base(type, data, imports) { _owner = owner; } /// protected override void Dispose(bool disposing) { base.Dispose(disposing); if (disposing) { _owner.Dispose(); } } } }