2021-09-30 09:52:09 +00:00
|
|
|
// 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.
|
|
|
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
using System.Threading;
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
using osu.Game.IO.Archives;
|
|
|
|
using osu.Game.Overlays.Notifications;
|
|
|
|
|
2021-11-12 06:26:28 +00:00
|
|
|
#nullable enable
|
|
|
|
|
2021-09-30 09:52:09 +00:00
|
|
|
namespace osu.Game.Database
|
|
|
|
{
|
|
|
|
/// <summary>
|
2021-10-08 05:20:21 +00:00
|
|
|
/// A class which handles importing of associated models to the game store.
|
2021-09-30 09:52:09 +00:00
|
|
|
/// </summary>
|
|
|
|
/// <typeparam name="TModel">The model type.</typeparam>
|
2021-10-18 05:25:51 +00:00
|
|
|
public interface IModelImporter<TModel> : IPostNotifications, IPostImports<TModel>, ICanAcceptFiles
|
2021-09-30 09:52:09 +00:00
|
|
|
where TModel : class
|
|
|
|
{
|
2021-09-30 10:33:12 +00:00
|
|
|
Task<IEnumerable<ILive<TModel>>> Import(ProgressNotification notification, params ImportTask[] tasks);
|
2021-09-30 09:52:09 +00:00
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Import one <typeparamref name="TModel"/> from the filesystem and delete the file on success.
|
|
|
|
/// Note that this bypasses the UI flow and should only be used for special cases or testing.
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="task">The <see cref="ImportTask"/> containing data about the <typeparamref name="TModel"/> to import.</param>
|
|
|
|
/// <param name="lowPriority">Whether this is a low priority import.</param>
|
|
|
|
/// <param name="cancellationToken">An optional cancellation token.</param>
|
|
|
|
/// <returns>The imported model, if successful.</returns>
|
2021-11-12 06:26:28 +00:00
|
|
|
Task<ILive<TModel>?> Import(ImportTask task, bool lowPriority = false, CancellationToken cancellationToken = default);
|
2021-09-30 09:52:09 +00:00
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Silently import an item from an <see cref="ArchiveReader"/>.
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="archive">The archive to be imported.</param>
|
|
|
|
/// <param name="lowPriority">Whether this is a low priority import.</param>
|
|
|
|
/// <param name="cancellationToken">An optional cancellation token.</param>
|
2021-11-12 06:26:28 +00:00
|
|
|
Task<ILive<TModel>?> Import(ArchiveReader archive, bool lowPriority = false, CancellationToken cancellationToken = default);
|
2021-09-30 09:52:09 +00:00
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Silently import an item from a <typeparamref name="TModel"/>.
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="item">The model to be imported.</param>
|
|
|
|
/// <param name="archive">An optional archive to use for model population.</param>
|
|
|
|
/// <param name="lowPriority">Whether this is a low priority import.</param>
|
|
|
|
/// <param name="cancellationToken">An optional cancellation token.</param>
|
2021-11-12 06:26:28 +00:00
|
|
|
Task<ILive<TModel>?> Import(TModel item, ArchiveReader? archive = null, bool lowPriority = false, CancellationToken cancellationToken = default);
|
2021-09-30 09:52:09 +00:00
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// A user displayable name for the model type associated with this manager.
|
|
|
|
/// </summary>
|
|
|
|
string HumanisedModelName => $"{typeof(TModel).Name.Replace(@"Info", "").ToLower()}";
|
|
|
|
}
|
|
|
|
}
|