2019-06-11 23:47:05 +05:30
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
2022-06-17 16:37:17 +09:00
#nullable disable
2019-06-11 22:42:57 +05:30
using System ;
2020-05-19 16:44:22 +09:00
using osu.Game.Online.API ;
2019-06-11 22:42:57 +05:30
namespace osu.Game.Database
{
2019-06-12 18:35:34 +05:30
/// <summary>
/// Represents a <see cref="IModelManager{TModel}"/> that can download new models from an external source.
/// </summary>
2021-11-05 17:37:05 +09:00
/// <typeparam name="T">The item's interface type.</typeparam>
public interface IModelDownloader < T > : IPostNotifications
where T : class
2019-06-11 22:42:57 +05:30
{
/// <summary>
2021-11-05 17:37:05 +09:00
/// Fired when a <typeparamref name="T"/> download begins.
2020-03-10 20:11:06 +09:00
/// This is NOT run on the update thread and should be scheduled.
2019-06-11 22:42:57 +05:30
/// </summary>
2021-11-06 22:31:49 +09:00
event Action < ArchiveDownloadRequest < T > > DownloadBegan ;
2019-06-11 22:42:57 +05:30
/// <summary>
2021-11-05 17:37:05 +09:00
/// Fired when a <typeparamref name="T"/> download is interrupted, either due to user cancellation or failure.
2020-03-10 20:11:06 +09:00
/// This is NOT run on the update thread and should be scheduled.
2019-06-11 22:42:57 +05:30
/// </summary>
2021-11-06 22:31:49 +09:00
event Action < ArchiveDownloadRequest < T > > DownloadFailed ;
2019-06-11 22:42:57 +05:30
/// <summary>
2021-11-05 17:37:05 +09:00
/// Begin a download for the requested <typeparamref name="T"/>.
2019-06-11 22:42:57 +05:30
/// </summary>
2021-11-05 17:37:05 +09:00
/// <param name="item">The <stypeparamref name="T"/> to be downloaded.</param>
2019-06-19 01:41:19 +09:00
/// <param name="minimiseDownloadSize">Whether this download should be optimised for slow connections. Generally means extras are not included in the download bundle..</param>
/// <returns>Whether the download was started.</returns>
2021-11-05 17:37:05 +09:00
bool Download ( T item , bool minimiseDownloadSize ) ;
2019-06-11 22:42:57 +05:30
/// <summary>
2021-11-05 17:37:05 +09:00
/// Gets an existing <typeparamref name="T"/> download request if it exists.
2019-06-11 22:42:57 +05:30
/// </summary>
2021-11-05 17:37:05 +09:00
/// <param name="item">The <typeparamref name="T"/> whose request is wanted.</param>
/// <returns>The <see cref="ArchiveDownloadRequest{T}"/> object if it exists, otherwise null.</returns>
ArchiveDownloadRequest < T > GetExistingDownload ( T item ) ;
2019-06-11 22:42:57 +05:30
}
}